aboutsummaryrefslogtreecommitdiffstats
path: root/typarichive.py
diff options
context:
space:
mode:
authorTeddy Wing2018-06-28 02:50:16 +0200
committerTeddy Wing2018-06-28 02:50:16 +0200
commitc66a8d90b916872d5670d2b845de7e7b3d1aca7b (patch)
tree9ceb8d97c801aaa0b64c28a970fc31a1b730ba7b /typarichive.py
parentb39ace1adedf3515a3f84f4ea93a5c1bcf511624 (diff)
downloadglyphs-typarichive-c66a8d90b916872d5670d2b845de7e7b3d1aca7b.tar.bz2
Don't recalculate timeHEADmaster
Only ever get the time once. Otherwise, we could imagine an unlikely situation where the new file would get created at 59 seconds and the family name would be updated at 00 seconds, causing the two timestamps to differ by a minute. Now the two timestamps will always be the same.
Diffstat (limited to 'typarichive.py')
-rw-r--r--typarichive.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/typarichive.py b/typarichive.py
index 7a48701..80d5cbf 100644
--- a/typarichive.py
+++ b/typarichive.py
@@ -26,21 +26,21 @@ import re
import shutil
-def new_font_name(filename):
- time_string = datetime.now().strftime('%Y%m%d%H%M')
-
+def new_font_name(filename, time_string):
return re.sub(r'\d{12}', time_string, filename)
font = Glyphs.font
filepath = font.filepath
+time_string = datetime.now().strftime('%Y%m%d%H%M')
font_directory = path.dirname(filepath)
archive_directory = path.join(font_directory, '_archive')
new_font_path = path.join(
font_directory,
new_font_name(
- path.basename(filepath)))
+ path.basename(filepath),
+ time_string))
shutil.copy2(filepath, new_font_path)
@@ -49,4 +49,6 @@ shutil.move(filepath, archive_directory)
font.close()
Glyphs.open(new_font_path)
-Glyphs.font.familyName = new_font_name(Glyphs.font.familyName)
+Glyphs.font.familyName = new_font_name(
+ Glyphs.font.familyName,
+ time_string)