Simplify a bit the typing annotations of ./mat2
This commit is contained in:
parent
180ea24e5a
commit
29057d6cdf
11
mat2
11
mat2
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import List, Union, Set
|
|
||||||
import sys
|
import sys
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import argparse
|
import argparse
|
||||||
@ -36,7 +35,7 @@ def __check_file(filename: str, mode: int = os.R_OK) -> bool:
|
|||||||
__print_without_chars("[-] %s is not a regular file." % filename)
|
__print_without_chars("[-] %s is not a regular file." % filename)
|
||||||
return False
|
return False
|
||||||
elif not os.access(filename, mode):
|
elif not os.access(filename, mode):
|
||||||
mode_str = [] # type: List[str]
|
mode_str = [] # type: list[str]
|
||||||
if mode & os.R_OK:
|
if mode & os.R_OK:
|
||||||
mode_str += 'readable'
|
mode_str += 'readable'
|
||||||
if mode & os.W_OK:
|
if mode & os.W_OK:
|
||||||
@ -152,10 +151,10 @@ def clean_meta(filename: str, is_lightweight: bool, inplace: bool, sandbox: bool
|
|||||||
|
|
||||||
def show_parsers():
|
def show_parsers():
|
||||||
print('[+] Supported formats:')
|
print('[+] Supported formats:')
|
||||||
formats = set() # Set[str]
|
formats = set() # set[str]
|
||||||
for parser in parser_factory._get_parsers(): # type: ignore
|
for parser in parser_factory._get_parsers(): # type: ignore
|
||||||
for mtype in parser.mimetypes:
|
for mtype in parser.mimetypes:
|
||||||
extensions = set() # Set[str]
|
extensions = set() # set[str]
|
||||||
for extension in mimetypes.guess_all_extensions(mtype):
|
for extension in mimetypes.guess_all_extensions(mtype):
|
||||||
if extension not in UNSUPPORTED_EXTENSIONS:
|
if extension not in UNSUPPORTED_EXTENSIONS:
|
||||||
extensions.add(extension)
|
extensions.add(extension)
|
||||||
@ -167,8 +166,8 @@ def show_parsers():
|
|||||||
__print_without_chars('\n'.join(sorted(formats)))
|
__print_without_chars('\n'.join(sorted(formats)))
|
||||||
|
|
||||||
|
|
||||||
def __get_files_recursively(files: List[str]) -> List[str]:
|
def __get_files_recursively(files: list[str]) -> list[str]:
|
||||||
ret = set() # type: Set[str]
|
ret = set() # type: set[str]
|
||||||
for f in files:
|
for f in files:
|
||||||
if os.path.isdir(f):
|
if os.path.isdir(f):
|
||||||
for path, _, _files in os.walk(f):
|
for path, _, _files in os.walk(f):
|
||||||
|
Loading…
Reference in New Issue
Block a user