def run(args): if not args: args = [ '.' ] work = set() arg_filenames = [] for arg in args: if os.path.isdir(arg): for dirpath, dirnames, filenames in os.walk(arg): work.update( os.path.join(dirpath, f) for f in fnmatch.filter(filenames, '*.py') ) else: arg_filenames.append(arg) work.update(fnmatch.filter(arg_filenames, '*.py')) for filename in work: try: old_style = python_code_parsing.find_old_style_classes( python_source_filename=filename) except Exception, e: import traceback print filename print traceback.format_exc() continue if old_style: print 'In file %s:' % filename print old_style print
def exercise_old_style_classes(): from libtbx.python_code_parsing import find_old_style_classes, old_style_class old_style = find_old_style_classes(old_style_class_test_case_1) assert old_style.names == set(('foo',)) old_style = find_old_style_classes(old_style_class_test_case_2) assert old_style.names == set() old_style = find_old_style_classes(old_style_class_test_case_3) assert old_style.names == set(('bar',)) old_style = find_old_style_classes(old_style_class_test_case_4) assert set(old_style) == set((old_style_class(name='foo', lineno=4), old_style_class(name='bar', lineno=1))) old_style = find_old_style_classes(old_style_class_test_case_5) assert old_style.names == set(('foo',))