diff options
| author | Simeon Simeonov | 2018-10-17 14:34:13 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2018-10-17 14:34:13 +0200 |
| commit | d0588352dacbb62084605ce67b863b9f12f90920 (patch) | |
| tree | 2dd490417460b238e2a082e240078b1a07c37cd4 | |
| parent | 22fb4125b4904f266467d48e88d5e5951ebd6eec (diff) | |
Add -a / --all
| -rwxr-xr-x | pygitchecker.py | 29 |
1 files 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): | |||
| 104 | return git_files_list | 104 | return git_files_list |
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | def fetch_all_files(abspath): | ||
| 108 | """ | ||
| 109 | Fetches all .py-files | ||
| 110 | """ | ||
| 111 | all_files_list = list() | ||
| 112 | for root, dirs, files in os.walk(abspath): | ||
| 113 | for f in files: | ||
| 114 | if os.path.splitext(f)[1].lower() == '.py': | ||
| 115 | all_files_list.append(os.path.join(abspath, root, f)) | ||
| 116 | return all_files_list | ||
| 117 | |||
| 118 | |||
| 107 | if __name__ == '__main__': | 119 | if __name__ == '__main__': |
| 108 | parser = argparse.ArgumentParser( | 120 | parser = argparse.ArgumentParser( |
| 109 | description='The following options are available') | 121 | description='The following options are available') |
| @@ -114,6 +126,12 @@ if __name__ == '__main__': | |||
| 114 | type=str, | 126 | type=str, |
| 115 | help='Git repo path (default: cwd)') | 127 | help='Git repo path (default: cwd)') |
| 116 | parser.add_argument( | 128 | parser.add_argument( |
| 129 | '-a', '--all', | ||
| 130 | action='store_true', | ||
| 131 | dest='all_files', | ||
| 132 | default=False, | ||
| 133 | help='Check all .py files (not only the ones that are modified)') | ||
| 134 | parser.add_argument( | ||
| 117 | '-f', '--full', | 135 | '-f', '--full', |
| 118 | action='store_true', | 136 | action='store_true', |
| 119 | dest='full_search', | 137 | dest='full_search', |
| @@ -161,10 +179,13 @@ if __name__ == '__main__': | |||
| 161 | modifications_exist(repo_path, args), | 179 | modifications_exist(repo_path, args), |
| 162 | args) | 180 | args) |
| 163 | sys.exit(0) | 181 | sys.exit(0) |
| 164 | git_files = fetch_git_files(args) | 182 | if args.all_files: |
| 165 | if not git_files: | 183 | selected_files = fetch_all_files(abs_repo_path) |
| 166 | print('No modifications') | 184 | else: |
| 185 | selected_files = fetch_git_files(args) | ||
| 186 | if not selected_files: | ||
| 187 | print('No files selected') | ||
| 167 | sys.exit(0) | 188 | sys.exit(0) |
| 168 | report = flake8_legacy.get_style_guide().check_files(git_files) | 189 | report = flake8_legacy.get_style_guide().check_files(selected_files) |
| 169 | if report.total_errors: | 190 | if report.total_errors: |
| 170 | print('Total errors: {errors}'.format(errors=report.total_errors)) | 191 | print('Total errors: {errors}'.format(errors=report.total_errors)) |
