ProjectPyramid/Project.py

changeset 142
77e872c9c300
parent 140
a891fb543d28
child 143
4ef44e854b39
equal deleted inserted replaced
141:95615a2a9277 142:77e872c9c300
542 return 542 return
543 543
544 try: 544 try:
545 with open(fname, "w", encoding="utf-8") as f: 545 with open(fname, "w", encoding="utf-8") as f:
546 f.write(template) 546 f.write(template)
547 except IOError as e: 547 except OSError as e:
548 E5MessageBox.critical( 548 E5MessageBox.critical(
549 self.__ui, 549 self.__ui,
550 self.tr("New Form"), 550 self.tr("New Form"),
551 self.tr("<p>The new form file <b>{0}</b> could" 551 self.tr("<p>The new form file <b>{0}</b> could"
552 " not be created.<br/> Problem: {1}</p>") 552 " not be created.<br/> Problem: {1}</p>")
631 fullCmds = self.__getExecutablePaths(cmd) 631 fullCmds = self.__getExecutablePaths(cmd)
632 for fullCmd in fullCmds: 632 for fullCmd in fullCmds:
633 try: 633 try:
634 with open(fullCmd, 'r', encoding='utf-8') as f: 634 with open(fullCmd, 'r', encoding='utf-8') as f:
635 l0 = f.readline() 635 l0 = f.readline()
636 except (IOError, OSError): 636 except OSError:
637 l0 = "" 637 l0 = ""
638 if self.__isSuitableForVariant(variant, l0): 638 if self.__isSuitableForVariant(variant, l0):
639 variants.append(variant) 639 variants.append(variant)
640 break 640 break
641 641
819 for line in lines: 819 for line in lines:
820 if line.startswith("__requires__"): 820 if line.startswith("__requires__"):
821 ## sample: __requires__ = 'pyramid==1.4' 821 ## sample: __requires__ = 'pyramid==1.4'
822 vers = line.strip().split()[-1][1:-1].split("==")[1] 822 vers = line.strip().split()[-1][1:-1].split("==")[1]
823 self.__pyramidVersion = vers 823 self.__pyramidVersion = vers
824 except (IOError, OSError): 824 except OSError:
825 self.__pyramidVersion = "" 825 self.__pyramidVersion = ""
826 826
827 return self.__pyramidVersion 827 return self.__pyramidVersion
828 828
829 def getPyramidVersion(self): 829 def getPyramidVersion(self):
1422 @param filename name of the file used for extraction (string) 1422 @param filename name of the file used for extraction (string)
1423 @return extracted locale (string) or None 1423 @return extracted locale (string) or None
1424 """ 1424 """
1425 if self.__e5project.getTranslationPattern(): 1425 if self.__e5project.getTranslationPattern():
1426 # On Windows, path typically contains backslashes. This leads 1426 # On Windows, path typically contains backslashes. This leads
1427 # to an invalid seach pattern '...\(' because the opening bracked 1427 # to an invalid search pattern '...\(' because the opening bracket
1428 # will be escaped. 1428 # will be escaped.
1429 pattern = self.__e5project.getTranslationPattern() 1429 pattern = self.__e5project.getTranslationPattern()
1430 pattern = os.path.normpath(pattern) 1430 pattern = os.path.normpath(pattern)
1431 pattern = pattern.replace("%language%", "(.*?)") 1431 pattern = pattern.replace("%language%", "(.*?)")
1432 pattern = pattern.replace('\\', '\\\\') 1432 pattern = pattern.replace('\\', '\\\\')

eric ide

mercurial