diff options
| author | jvoisin | 2018-05-16 22:36:59 +0200 |
|---|---|---|
| committer | jvoisin | 2018-05-16 22:36:59 +0200 |
| commit | fa7d18784ca18c5c70bbb36cde9d5915843456c3 (patch) | |
| tree | 3c7b36ea63ecf05ba6fc777c4f3a3a74fa60a450 /main.py | |
| parent | 0354c3b7e3a455cce130b6226926436a21128641 (diff) | |
Do a pylint pass
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 20 |
1 files changed, 10 insertions, 10 deletions
| @@ -12,7 +12,7 @@ from src import parser_factory, unsupported_extensions | |||
| 12 | 12 | ||
| 13 | __version__ = '0.1.0' | 13 | __version__ = '0.1.0' |
| 14 | 14 | ||
| 15 | def __check_file(filename:str, mode:int = os.R_OK) -> bool: | 15 | def __check_file(filename: str, mode: int = os.R_OK) -> bool: |
| 16 | if not os.path.isfile(filename): | 16 | if not os.path.isfile(filename): |
| 17 | print("[-] %s is not a regular file." % filename) | 17 | print("[-] %s is not a regular file." % filename) |
| 18 | return False | 18 | return False |
| @@ -26,9 +26,9 @@ def create_arg_parser(): | |||
| 26 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') | 26 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') |
| 27 | parser.add_argument('files', nargs='*') | 27 | parser.add_argument('files', nargs='*') |
| 28 | parser.add_argument('-v', '--version', action='version', | 28 | parser.add_argument('-v', '--version', action='version', |
| 29 | version='MAT2 %s' % __version__) | 29 | version='MAT2 %s' % __version__) |
| 30 | parser.add_argument('-l', '--list', action='store_true', | 30 | parser.add_argument('-l', '--list', action='store_true', |
| 31 | help='list all supported fileformats') | 31 | help='list all supported fileformats') |
| 32 | 32 | ||
| 33 | info = parser.add_mutually_exclusive_group() | 33 | info = parser.add_mutually_exclusive_group() |
| 34 | info.add_argument('-c', '--check', action='store_true', | 34 | info.add_argument('-c', '--check', action='store_true', |
| @@ -40,7 +40,7 @@ def create_arg_parser(): | |||
| 40 | return parser | 40 | return parser |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | def show_meta(filename:str): | 43 | def show_meta(filename: str): |
| 44 | if not __check_file(filename): | 44 | if not __check_file(filename): |
| 45 | return | 45 | return |
| 46 | 46 | ||
| @@ -48,18 +48,18 @@ def show_meta(filename:str): | |||
| 48 | if p is None: | 48 | if p is None: |
| 49 | print("[-] %s's format (%s) is not supported" % (filename, mtype)) | 49 | print("[-] %s's format (%s) is not supported" % (filename, mtype)) |
| 50 | return | 50 | return |
| 51 | |||
| 51 | print("[+] Metadata for %s:" % filename) | 52 | print("[+] Metadata for %s:" % filename) |
| 52 | for k,v in p.get_meta().items(): | 53 | for k, v in p.get_meta().items(): |
| 53 | try: # FIXME this is ugly. | 54 | try: # FIXME this is ugly. |
| 54 | print(" %s: %s" % (k, v)) | 55 | print(" %s: %s" % (k, v)) |
| 55 | except UnicodeEncodeError: | 56 | except UnicodeEncodeError: |
| 56 | print(" %s: harmful content" % k) | 57 | print(" %s: harmful content" % k) |
| 57 | 58 | ||
| 58 | 59 | def clean_meta(params: Tuple[str, bool]) -> bool: | |
| 59 | def clean_meta(params:Tuple[str, bool]) -> bool: | ||
| 60 | filename, is_lightweigth = params | 60 | filename, is_lightweigth = params |
| 61 | if not __check_file(filename, os.R_OK|os.W_OK): | 61 | if not __check_file(filename, os.R_OK|os.W_OK): |
| 62 | return | 62 | return False |
| 63 | 63 | ||
| 64 | p, mtype = parser_factory.get_parser(filename) | 64 | p, mtype = parser_factory.get_parser(filename) |
| 65 | if p is None: | 65 | if p is None: |
| @@ -102,12 +102,12 @@ def main(): | |||
| 102 | if not args.list: | 102 | if not args.list: |
| 103 | return arg_parser.print_help() | 103 | return arg_parser.print_help() |
| 104 | show_parsers() | 104 | show_parsers() |
| 105 | return | 105 | return 0 |
| 106 | 106 | ||
| 107 | elif args.show: | 107 | elif args.show: |
| 108 | for f in __get_files_recursively(args.files): | 108 | for f in __get_files_recursively(args.files): |
| 109 | show_meta(f) | 109 | show_meta(f) |
| 110 | return | 110 | return 0 |
| 111 | 111 | ||
| 112 | else: | 112 | else: |
| 113 | p = multiprocessing.Pool() | 113 | p = multiprocessing.Pool() |
