Run black on all Python scripts!
This commit is contained in:
parent
fb6cfce656
commit
cd9cbcaa28
30 changed files with 1027 additions and 704 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -9,16 +9,16 @@ import PIL.ExifTags
|
|||
import PIL.Image
|
||||
import progressbar
|
||||
|
||||
EXTENSION_PATTERN = re.compile(r'\.JPE?G', re.I)
|
||||
COMMON_PATTERN = re.compile(r'(IMG|DSC[NF]?|100|P10|f|t)_?\d+', re.I)
|
||||
EXIF_TAG_NAME = 'DateTimeOriginal'
|
||||
EXIF_TAG_ID = list(PIL.ExifTags.TAGS.keys())[list(
|
||||
PIL.ExifTags.TAGS.values()).index(EXIF_TAG_NAME)]
|
||||
EXIF_DATE_FORMAT = '%Y:%m:%d %H:%M:%S'
|
||||
EXTENSION_PATTERN = re.compile(r"\.JPE?G", re.I)
|
||||
COMMON_PATTERN = re.compile(r"(IMG|DSC[NF]?|100|P10|f|t)_?\d+", re.I)
|
||||
EXIF_TAG_NAME = "DateTimeOriginal"
|
||||
EXIF_TAG_ID = list(PIL.ExifTags.TAGS.keys())[
|
||||
list(PIL.ExifTags.TAGS.values()).index(EXIF_TAG_NAME)
|
||||
]
|
||||
EXIF_DATE_FORMAT = "%Y:%m:%d %H:%M:%S"
|
||||
|
||||
|
||||
def get_pictures(directory: str = ".", skip_renamed: bool = True) \
|
||||
-> typing.Generator:
|
||||
def get_pictures(directory: str = ".", skip_renamed: bool = True) -> typing.Generator:
|
||||
for root, _, files in os.walk(directory):
|
||||
for filename in files:
|
||||
filename_trunk, extension = os.path.splitext(filename)
|
||||
|
@ -44,9 +44,9 @@ def main() -> None:
|
|||
if exif_data and EXIF_TAG_ID in exif_data:
|
||||
date_raw = exif_data[EXIF_TAG_ID]
|
||||
date = datetime.datetime.strptime(date_raw, EXIF_DATE_FORMAT)
|
||||
new_name = date.isoformat().replace(':', '-') + '.jpg' # For NTFS
|
||||
new_name = date.isoformat().replace(":", "-") + ".jpg" # For NTFS
|
||||
print(full_path, new_name)
|
||||
os.rename(full_path, new_name) # TODO FOLDER
|
||||
os.rename(full_path, new_name) # TODO FOLDER
|
||||
img.close()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue