script to report deprecated functions of text and their age in days.
This commit is contained in:
@@ -99,14 +99,18 @@ test:
|
|||||||
|
|
||||||
# run pep8 check check on scripts we distribute.
|
# run pep8 check check on scripts we distribute.
|
||||||
test_pep8:
|
test_pep8:
|
||||||
python source/tests/pep8.py > test_pep8.log 2>&1
|
python3 source/tests/pep8.py > test_pep8.log 2>&1
|
||||||
@echo "written: test_pep8.log"
|
@echo "written: test_pep8.log"
|
||||||
|
|
||||||
# run some checks on our cmakefiles.
|
# run some checks on our cmakefiles.
|
||||||
test_cmake:
|
test_cmake:
|
||||||
python build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
|
python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
|
||||||
@echo "written: test_cmake_consistency.log"
|
@echo "written: test_cmake_consistency.log"
|
||||||
|
|
||||||
|
# run deprecation tests, see if we have anything to remove.
|
||||||
|
test_deprecated:
|
||||||
|
python3 source/tests/check_deprecated.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make -C $(BUILD_DIR) clean
|
make -C $(BUILD_DIR) clean
|
||||||
|
|
||||||
|
@@ -114,7 +114,7 @@ static PyObject *Buffer_to_list_recursive(Buffer *self)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* deprecate */
|
/* *DEPRECATED* 2011/7/17 bgl.Buffer.list */
|
||||||
static PyObject *Buffer_list(Buffer *self, void *UNUSED(arg))
|
static PyObject *Buffer_list(Buffer *self, void *UNUSED(arg))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Warning: 'Buffer.list' deprecated, use '[:]' instead\n");
|
fprintf(stderr, "Warning: 'Buffer.list' deprecated, use '[:]' instead\n");
|
||||||
|
@@ -4548,7 +4548,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= {
|
|||||||
NULL, /* printfunc tp_print; */
|
NULL, /* printfunc tp_print; */
|
||||||
NULL, /* getattrfunc tp_getattr; */
|
NULL, /* getattrfunc tp_getattr; */
|
||||||
NULL, /* setattrfunc tp_setattr; */
|
NULL, /* setattrfunc tp_setattr; */
|
||||||
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
|
NULL, /* tp_compare */ /* deprecated in python 3.0! */
|
||||||
NULL, /* tp_repr */
|
NULL, /* tp_repr */
|
||||||
|
|
||||||
/* Method suites for standard classes */
|
/* Method suites for standard classes */
|
||||||
|
144
source/tests/check_deprecated.py
Normal file
144
source/tests/check_deprecated.py
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
# <pep8 compliant>
|
||||||
|
|
||||||
|
import os
|
||||||
|
from os.path import splitext
|
||||||
|
|
||||||
|
DEPRECATE_DAYS = 120
|
||||||
|
|
||||||
|
SKIP_DIRS = ("extern",
|
||||||
|
"scons",
|
||||||
|
os.path.join("source", "tests"), # not this dir
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_c_header(filename):
|
||||||
|
ext = splitext(filename)[1]
|
||||||
|
return (ext in (".h", ".hpp", ".hxx"))
|
||||||
|
|
||||||
|
|
||||||
|
def is_c(filename):
|
||||||
|
ext = splitext(filename)[1]
|
||||||
|
return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
|
||||||
|
|
||||||
|
|
||||||
|
def is_c_any(filename):
|
||||||
|
return is_c(filename) or is_c_header(filename)
|
||||||
|
|
||||||
|
def is_py(filename):
|
||||||
|
ext = splitext(filename)[1]
|
||||||
|
return (ext == ".py")
|
||||||
|
|
||||||
|
def is_source_any(filename):
|
||||||
|
return is_c_any(filename) or is_py(filename)
|
||||||
|
|
||||||
|
def source_list(path, filename_check=None):
|
||||||
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
|
|
||||||
|
# skip '.svn'
|
||||||
|
if dirpath.startswith("."):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for filename in filenames:
|
||||||
|
if filename_check is None or filename_check(filename):
|
||||||
|
yield os.path.join(dirpath, filename)
|
||||||
|
|
||||||
|
|
||||||
|
def deprecations():
|
||||||
|
"""
|
||||||
|
Searches out source code for lines like
|
||||||
|
|
||||||
|
/* *DEPRECATED* 2011/7/17 bgl.Buffer.list info text */
|
||||||
|
|
||||||
|
Or...
|
||||||
|
|
||||||
|
# *DEPRECATED* 2010/12/22 some.py.func more info */
|
||||||
|
|
||||||
|
"""
|
||||||
|
import datetime
|
||||||
|
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))
|
||||||
|
|
||||||
|
SKIP_DIRS_ABS = [os.path.join(SOURCE_DIR, p) for p in SKIP_DIRS]
|
||||||
|
|
||||||
|
deprecations_ls = []
|
||||||
|
|
||||||
|
scan_tot = 0
|
||||||
|
|
||||||
|
print("scanning in %r for '*DEPRECATED* YYYY/MM/DD info'" % SOURCE_DIR)
|
||||||
|
|
||||||
|
for fn in source_list(SOURCE_DIR, is_source_any):
|
||||||
|
# print(fn)
|
||||||
|
skip = False
|
||||||
|
for p in SKIP_DIRS_ABS:
|
||||||
|
if fn.startswith(p):
|
||||||
|
skip = True
|
||||||
|
break
|
||||||
|
if skip:
|
||||||
|
continue
|
||||||
|
|
||||||
|
file = open(fn, 'r', encoding="utf8")
|
||||||
|
for i, l in enumerate(file):
|
||||||
|
# logic for deprecation warnings
|
||||||
|
if '*DEPRECATED*' in l:
|
||||||
|
try:
|
||||||
|
l = l.strip()
|
||||||
|
data = l.split('*DEPRECATED*', 1)[-1].strip().strip()
|
||||||
|
data = [w.strip() for w in data.split('/', 2)]
|
||||||
|
data[-1], info = data[-1].split(' ', 1)
|
||||||
|
info = info.split("*/", 1)[0]
|
||||||
|
if len(data) != 3:
|
||||||
|
print(" poorly formatting line:\n"
|
||||||
|
" %r:%d\n"
|
||||||
|
" %s"%
|
||||||
|
(fn, i + 1, l)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
data = datetime.datetime(*tuple([int(w) for w in data]))
|
||||||
|
|
||||||
|
deprecations_ls.append((data, (fn, i + 1), info))
|
||||||
|
except:
|
||||||
|
print("Error file - %r:%d" % (fn, i + 1))
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
scan_tot += 1
|
||||||
|
|
||||||
|
print(" scanned %d files" % scan_tot)
|
||||||
|
|
||||||
|
return deprecations_ls
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import datetime
|
||||||
|
now = datetime.datetime.now()\
|
||||||
|
|
||||||
|
deps = deprecations()
|
||||||
|
|
||||||
|
print("\nAll deprecations...")
|
||||||
|
for data, fileinfo, info in deps:
|
||||||
|
days_old = (now - data).days
|
||||||
|
if days_old > DEPRECATE_DAYS:
|
||||||
|
info = "*** REMOVE! *** " + info
|
||||||
|
print(" %r, days-old(%.2d), %s:%d - %s" % (data, days_old, fileinfo[0], fileinfo[1], info))
|
||||||
|
if deps:
|
||||||
|
print("\ndone!")
|
||||||
|
else:
|
||||||
|
print("\nnone found!")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Reference in New Issue
Block a user