From d0588352dacbb62084605ce67b863b9f12f90920 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 17 Oct 2018 14:34:13 +0200 Subject: Add -a / --all --- pygitchecker.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pygitchecker.py b/pygitchecker.py index 200627e..aa1cee8 100755 --- a/pygitchecker.py +++ b/pygitchecker.py @@ -104,6 +104,18 @@ def fetch_git_files(args): return git_files_list +def fetch_all_files(abspath): + """ + Fetches all .py-files + """ + all_files_list = list() + for root, dirs, files in os.walk(abspath): + for f in files: + if os.path.splitext(f)[1].lower() == '.py': + all_files_list.append(os.path.join(abspath, root, f)) + return all_files_list + + if __name__ == '__main__': parser = argparse.ArgumentParser( description='The following options are available') @@ -113,6 +125,12 @@ if __name__ == '__main__': default=os.getcwd(), type=str, help='Git repo path (default: cwd)') + parser.add_argument( + '-a', '--all', + action='store_true', + dest='all_files', + default=False, + help='Check all .py files (not only the ones that are modified)') parser.add_argument( '-f', '--full', action='store_true', @@ -161,10 +179,13 @@ if __name__ == '__main__': modifications_exist(repo_path, args), args) sys.exit(0) - git_files = fetch_git_files(args) - if not git_files: - print('No modifications') + if args.all_files: + selected_files = fetch_all_files(abs_repo_path) + else: + selected_files = fetch_git_files(args) + if not selected_files: + print('No files selected') sys.exit(0) - report = flake8_legacy.get_style_guide().check_files(git_files) + report = flake8_legacy.get_style_guide().check_files(selected_files) if report.total_errors: print('Total errors: {errors}'.format(errors=report.total_errors)) -- cgit v1.3