removing trailing spaces

This commit is contained in:
iperov 2019-03-19 23:53:27 +04:00
parent fa4e579b95
commit a3df04999c
61 changed files with 2110 additions and 2103 deletions

View file

@ -5,8 +5,8 @@ image_extensions = [".jpg", ".jpeg", ".png", ".tif", ".tiff"]
def get_image_paths(dir_path, image_extensions=image_extensions):
dir_path = Path (dir_path)
result = []
result = []
if dir_path.exists():
for x in list(scandir(str(dir_path))):
if any([x.name.lower().endswith(ext) for ext in image_extensions]):
@ -14,25 +14,25 @@ def get_image_paths(dir_path, image_extensions=image_extensions):
return result
def get_image_unique_filestem_paths(dir_path, verbose_print_func=None):
result = get_image_paths(dir_path)
result_dup = set()
result = get_image_paths(dir_path)
result_dup = set()
for f in result[:]:
f_stem = Path(f).stem
if f_stem in result_dup:
if f_stem in result_dup:
result.remove(f)
if verbose_print_func is not None:
verbose_print_func ("Duplicate filenames are not allowed, skipping: %s" % Path(f).name )
continue
verbose_print_func ("Duplicate filenames are not allowed, skipping: %s" % Path(f).name )
continue
result_dup.add(f_stem)
return result
def get_all_dir_names_startswith (dir_path, startswith):
dir_path = Path (dir_path)
startswith = startswith.lower()
result = []
result = []
if dir_path.exists():
for x in list(scandir(str(dir_path))):
if x.name.lower().startswith(startswith):
@ -42,7 +42,7 @@ def get_all_dir_names_startswith (dir_path, startswith):
def get_first_file_by_stem (dir_path, stem, exts=None):
dir_path = Path (dir_path)
stem = stem.lower()
if dir_path.exists():
for x in list(scandir(str(dir_path))):
if not x.is_file():
@ -50,5 +50,5 @@ def get_first_file_by_stem (dir_path, stem, exts=None):
xp = Path(x.path)
if xp.stem.lower() == stem and (exts is None or xp.suffix.lower() in exts):
return xp
return None
return None