diff options
Diffstat (limited to 'pygitchecker.py')
| -rwxr-xr-x | pygitchecker.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/pygitchecker.py b/pygitchecker.py index 719cac3..8dea428 100755 --- a/pygitchecker.py +++ b/pygitchecker.py | |||
| @@ -106,6 +106,18 @@ def fetch_git_files(args): | |||
| 106 | return git_files_list | 106 | return git_files_list |
| 107 | 107 | ||
| 108 | 108 | ||
| 109 | def fetch_all_files(abspath): | ||
| 110 | """ | ||
| 111 | Fetches all .py-files | ||
| 112 | """ | ||
| 113 | all_files_list = list() | ||
| 114 | for root, dirs, files in os.walk(abspath): | ||
| 115 | for f in files: | ||
| 116 | if os.path.splitext(f)[1].lower() == '.py': | ||
| 117 | all_files_list.append(os.path.join(abspath, root, f)) | ||
| 118 | return all_files_list | ||
| 119 | |||
| 120 | |||
| 109 | if __name__ == '__main__': | 121 | if __name__ == '__main__': |
| 110 | parser = argparse.ArgumentParser( | 122 | parser = argparse.ArgumentParser( |
| 111 | description='The following options are available') | 123 | description='The following options are available') |
| @@ -116,6 +128,12 @@ if __name__ == '__main__': | |||
| 116 | type=str, | 128 | type=str, |
| 117 | help='Git repo path (default: cwd)') | 129 | help='Git repo path (default: cwd)') |
| 118 | parser.add_argument( | 130 | parser.add_argument( |
| 131 | '-a', '--all', | ||
| 132 | action='store_true', | ||
| 133 | dest='all_files', | ||
| 134 | default=False, | ||
| 135 | help='Check all .py files (not only the ones that are modified)') | ||
| 136 | parser.add_argument( | ||
| 119 | '-f', '--full', | 137 | '-f', '--full', |
| 120 | action='store_true', | 138 | action='store_true', |
| 121 | dest='full_search', | 139 | dest='full_search', |
| @@ -163,10 +181,13 @@ if __name__ == '__main__': | |||
| 163 | modifications_exist(repo_path, args), | 181 | modifications_exist(repo_path, args), |
| 164 | args) | 182 | args) |
| 165 | sys.exit(0) | 183 | sys.exit(0) |
| 166 | git_files = fetch_git_files(args) | 184 | if args.all_files: |
| 167 | if not git_files: | 185 | selected_files = fetch_all_files(abs_repo_path) |
| 168 | print('No modifications') | 186 | else: |
| 187 | selected_files = fetch_git_files(args) | ||
| 188 | if not selected_files: | ||
| 189 | print('No files selected') | ||
| 169 | sys.exit(0) | 190 | sys.exit(0) |
| 170 | report = flake8_legacy.get_style_guide().check_files(git_files) | 191 | report = flake8_legacy.get_style_guide().check_files(selected_files) |
| 171 | if report.total_errors: | 192 | if report.total_errors: |
| 172 | print('Total errors: {errors}'.format(errors=report.total_errors)) | 193 | print('Total errors: {errors}'.format(errors=report.total_errors)) |
