--- a/svghmi/i18n.py Wed Mar 31 08:25:18 2021 +0200
+++ b/svghmi/i18n.py Wed Mar 31 09:08:15 2021 +0200
@@ -68,11 +68,15 @@
with open(fname, 'w') as POT_file:
+def GetPoFiles(dirpath): + po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")] def ReadTranslations(dirpath):
""" Read all PO files from a directory and return a list of (langcode, translation_dict) tuples """
- po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")]
+ po_files = GetPoFiles(dirpath) for po_fname in po_files:
--- a/svghmi/svghmi.py Wed Mar 31 08:25:18 2021 +0200
+++ b/svghmi/svghmi.py Wed Mar 31 09:08:15 2021 +0200
@@ -28,7 +28,8 @@
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
from XSLTransform import XSLTransform
from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\
- MatchTranslations, TranslationToEtree, open_pofile
+ MatchTranslations, TranslationToEtree, open_pofile,\ from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES
from svghmi.ui import SVGHMI_UI
from svghmi.fonts import GetFontTypeAndFamilyName, GetCSSFontFaceFromFontFile
@@ -400,13 +401,17 @@
- def GetFonts(self, _context):
+ def GetFontsFiles(self): project_path = self.CTNPath()
fontdir = os.path.join(project_path, "fonts")
+ if os.path.isdir(fontdir): + return [os.path.join(fontdir,f) for f in sorted(os.listdir(fontdir))] + def GetFonts(self, _context): - for f in sorted(os.listdir(fontdir)):
- fontfile = os.path.join(fontdir,f)
+ for fontfile in self.GetFontsFiles(): if os.path.isfile(fontfile):
css_parts.append(GetCSSFontFaceFromFontFile(fontfile))
@@ -446,13 +451,18 @@
hmi_tree_root._hash(hasher)
- with open(svgfile, 'rb') as afile:
- buf = afile.read(65536)
+ filestocheck = [svgfile] + \ + GetPoFiles(self.CTNPath()) + \ + for filetocheck in filestocheck: + with open(filetocheck, 'rb') as afile: + buf = afile.read(65536) digest = hasher.hexdigest()
if os.path.exists(hash_path):