Commits

Andy Mikhailenko committed 6792b33

sort_files: fix bugs, add warnings, extend fields

Comments (0)

Files changed (1)

 DATE_FIELDS = (
     'Date/Time Original',
     'Create Date',
+    'Creation Date',
     'Media Create Date',
     'Track Create Date',
     'File Modification Date/Time',
     if not output:
         raise RuntimeError('EXIF: {0}: no meta data found'.format(file_path))
 
-    lines = (x for x in output.decode().split('\n') if x.strip())
-    triples = (x.strip().partition(':') for x in lines)
+    lines = output.decode(errors='replace').split('\n')
+    triples = (x.strip().partition(':') for x in lines if x.strip())
     pairs = ((k.strip(), v.strip()) for k,sep,v in triples)
 
     return OrderedDict(sorted(pairs, key=lambda t: t[0]))
 
     """
     if verbose:
-        print
+        print()
         print(name)
     assert '/' not in name, 'filename must not contain path information'
     src = os.path.join(src_dir, name)
 
+    if name.startswith('.'):
+        print(t.red('WARNING: including hidden file {0}'.format(src)))
+
     # извлекаем дату
     try:
         dt = get_file_datetime(src)
     if verbose:
         print('  trying', src, '->', dest)
 
-    assert os.path.abspath(src) != os.path.abspath(dest)
+    if os.path.abspath(src) == os.path.abspath(dest):
+        print(t.red('  ERROR: source equals destination for {0}'.format(src)))
+        return ERROR
 
     # make sure the file does not exist there
     if os.path.exists(dest):