summaryrefslogtreecommitdiff
path: root/rapid/generatename.py
diff options
context:
space:
mode:
authorJulien Valroff <julien@kirya.net>2012-01-08 07:54:46 +0100
committerJulien Valroff <julien@kirya.net>2012-01-08 07:54:46 +0100
commit05e7b52a1f94a40996f2619ad9db8bbdb1518497 (patch)
treef63dbaaf571e59a139ddf3de2a3103965e8093aa /rapid/generatename.py
parentda2cce92a7eed706d04d6cbe778fd1bf32f18eeb (diff)
Imported Upstream version 0.4.3upstream/0.4.3
Diffstat (limited to 'rapid/generatename.py')
-rw-r--r--rapid/generatename.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/rapid/generatename.py b/rapid/generatename.py
index 1c95478..99d7287 100644
--- a/rapid/generatename.py
+++ b/rapid/generatename.py
@@ -112,6 +112,39 @@ class PhotoName:
logger.error("Both file modification time and metadata date & time are invalid for file %s", self.rpd_file.full_file_name)
return ''
+ def _get_thm_extension(self):
+ """
+ Generates THM extension with correct capitalization, if needed
+ """
+ if self.rpd_file.thm_full_name:
+ thm_extension = os.path.splitext(self.rpd_file.thm_full_name)[1]
+ if self.L2 == UPPERCASE:
+ thm_extension = thm_extension.upper()
+ elif self.L2 == LOWERCASE:
+ thm_extension = thm_extension.lower()
+ self.rpd_file.thm_extension = thm_extension
+ else:
+ self.rpd_file.thm_extension = None
+
+ def _get_xmp_extension(self, extension):
+ """
+ Generates XMP extension with correct capitalization, if needed.
+ """
+ if self.rpd_file.temp_xmp_full_name:
+ if self.L2 == UPPERCASE:
+ self.rpd_file.xmp_extension = '.XMP'
+ elif self.L2 == LOWERCASE:
+ self.rpd_file.xmp_extension = '.xmp'
+ else:
+ # mimic capitalization of extension
+ if extension.isupper():
+ self.rpd_file.xmp_extension = '.XMP'
+ else:
+ self.rpd_file.xmp_extension = '.xmp'
+ else:
+ self.rpd_file.xmp_extension = None
+
+
def _get_filename_component(self):
"""
Returns portion of new file / subfolder name based on the file name
@@ -121,9 +154,13 @@ class PhotoName:
if self.L1 == NAME_EXTENSION:
filename = self.rpd_file.name
+ self._get_thm_extension()
+ self._get_xmp_extension(extension)
elif self.L1 == NAME:
filename = name
elif self.L1 == EXTENSION:
+ self._get_thm_extension()
+ self._get_xmp_extension(extension)
if extension:
if not self.strip_initial_period_from_extension:
# keep the period / dot of the extension, so the user does not
@@ -196,7 +233,10 @@ class PhotoName:
padding = LIST_SHUTTER_COUNT_L2.index(self.L2) + 3
formatter = '%0' + str(padding) + "i"
v = formatter % v
-
+ elif self.L1 == FILE_NUMBER:
+ v = self.rpd_file.metadata.file_number()
+ if v and self.L2 == FILE_NUMBER_FOLDER:
+ v = v[:3]
elif self.L1 == OWNER_NAME:
v = self.rpd_file.metadata.owner_name()
elif self.L1 == ARTIST: