equal
deleted
inserted
replaced
26 from runtime.typemapping import DebugTypesSize |
26 from runtime.typemapping import DebugTypesSize |
27 import targets |
27 import targets |
28 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
28 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
29 from XSLTransform import XSLTransform |
29 from XSLTransform import XSLTransform |
30 from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\ |
30 from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\ |
31 MatchTranslations, TranslationToEtree, open_pofile |
31 MatchTranslations, TranslationToEtree, open_pofile,\ |
|
32 GetPoFiles |
32 from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES |
33 from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES |
33 from svghmi.ui import SVGHMI_UI |
34 from svghmi.ui import SVGHMI_UI |
34 from svghmi.fonts import GetFontTypeAndFamilyName, GetCSSFontFaceFromFontFile |
35 from svghmi.fonts import GetFontTypeAndFamilyName, GetCSSFontFaceFromFontFile |
35 |
36 |
36 |
37 |
398 |
399 |
399 self.ProgressEnd("i18n") |
400 self.ProgressEnd("i18n") |
400 |
401 |
401 return ret |
402 return ret |
402 |
403 |
403 def GetFonts(self, _context): |
404 def GetFontsFiles(self): |
404 project_path = self.CTNPath() |
405 project_path = self.CTNPath() |
405 fontdir = os.path.join(project_path, "fonts") |
406 fontdir = os.path.join(project_path, "fonts") |
|
407 if os.path.isdir(fontdir): |
|
408 return [os.path.join(fontdir,f) for f in sorted(os.listdir(fontdir))] |
|
409 return [] |
|
410 |
|
411 def GetFonts(self, _context): |
406 css_parts = [] |
412 css_parts = [] |
407 |
413 |
408 for f in sorted(os.listdir(fontdir)): |
414 for fontfile in self.GetFontsFiles(): |
409 fontfile = os.path.join(fontdir,f) |
|
410 if os.path.isfile(fontfile): |
415 if os.path.isfile(fontfile): |
411 css_parts.append(GetCSSFontFaceFromFontFile(fontfile)) |
416 css_parts.append(GetCSSFontFaceFromFontFile(fontfile)) |
412 |
417 |
413 return "".join(css_parts) |
418 return "".join(css_parts) |
414 |
419 |
444 |
449 |
445 if os.path.exists(svgfile): |
450 if os.path.exists(svgfile): |
446 |
451 |
447 hasher = hashlib.md5() |
452 hasher = hashlib.md5() |
448 hmi_tree_root._hash(hasher) |
453 hmi_tree_root._hash(hasher) |
449 with open(svgfile, 'rb') as afile: |
454 filestocheck = [svgfile] + \ |
450 while True: |
455 GetPoFiles(self.CTNPath()) + \ |
451 buf = afile.read(65536) |
456 self.GetFontsFiles() |
452 if len(buf) > 0: |
457 |
453 hasher.update(buf) |
458 for filetocheck in filestocheck: |
454 else: |
459 with open(filetocheck, 'rb') as afile: |
455 break |
460 while True: |
|
461 buf = afile.read(65536) |
|
462 if len(buf) > 0: |
|
463 hasher.update(buf) |
|
464 else: |
|
465 break |
456 digest = hasher.hexdigest() |
466 digest = hasher.hexdigest() |
457 |
467 |
458 if os.path.exists(hash_path): |
468 if os.path.exists(hash_path): |
459 with open(hash_path, 'rb') as digest_file: |
469 with open(hash_path, 'rb') as digest_file: |
460 last_digest = digest_file.read() |
470 last_digest = digest_file.read() |