本文整理汇总了Python中exe.engine.path.Path.glob方法的典型用法代码示例。如果您正苦于以下问题:Python Path.glob方法的具体用法?Python Path.glob怎么用?Python Path.glob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.glob方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeMO
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import glob [as 别名]
def makeMO(applicationDirectoryPath, targetDir=None, applicationDomain=None, verbose=0, forceEnglish=0):
"""Compile the Portable Object files into the Machine Object stored in the right location.
makeMO converts all translated language-specific PO files located inside
the application directory into the binary .MO files stored inside the
LC_MESSAGES sub-directory for the found locale files.
makeMO searches for all files that have a name of the form 'app_xx.po'
inside the application directory specified by the first argument. The
'app' is the application domain name (that can be specified by the
applicationDomain argument or is taken from the directory name). The 'xx'
corresponds to one of the ISO 639 two-letter language codes.
makeMo stores the resulting files inside a sub-directory of `targetDir`
called xx/LC_MESSAGES where 'xx' corresponds to the 2-letter language
code.
"""
if targetDir is None:
targetDir = "exe/locale"
if verbose:
print "Target directory for .mo files is: %s" % targetDir
targetDir = Path(targetDir)
if applicationDomain is None:
applicationName = fileBaseOf(applicationDirectoryPath, withPath=0)
else:
applicationName = applicationDomain
currentDir = os.getcwd()
os.chdir(applicationDirectoryPath)
for filename in targetDir.glob("*_*.po"):
langCode = filename.split("_", 1)[1].split(".", 1)[0]
mo_targetDir = Path("%s/%s/LC_MESSAGES" % (targetDir, langCode))
if not mo_targetDir.exists():
mo_targetDir.makedirs()
cmd = "msgfmt --output-file=%s.mo %s" % (mo_targetDir / applicationName, filename)
if verbose:
print cmd
os.system(cmd)
os.chdir(currentDir)
示例2: makePO
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import glob [as 别名]
def makePO(applicationDirectoryPath, applicationDomain=None, verbose=1):
"""Build the Portable Object Template file for the application.
makePO builds the .pot file for the application stored inside
a specified directory by running xgettext for all application source
files. It finds the name of all files by looking for a file called 'app.fil'.
If this file does not exists, makePo raises an IOError exception.
By default the application domain (the application
name) is the same as the directory name but it can be overridden by the
'applicationDomain' argument.
makePO always creates a new file called messages.pot. If it finds files
of the form app_xx.po where 'app' is the application name and 'xx' is one
of the ISO 639 two-letter language codes, makePO resynchronizes those
files with the latest extracted strings (now contained in messages.pot).
This process updates all line location number in the language-specific
.po files and may also create new entries for translation (or comment out
some). The .po file is not changed, instead a new file is created with
the .new extension appended to the name of the .po file.
By default the function does not display what it is doing. Set the
verbose argument to 1 to force it to print its commands.
"""
if applicationDomain is None:
applicationName = fileBaseOf(applicationDirectoryPath, withPath=0)
else:
applicationName = applicationDomain
currentDir = os.getcwd()
os.chdir(applicationDirectoryPath)
if not os.path.exists("app.fil"):
raise IOError(2, "No module file: app.fil")
cmd = "xgettext -kx_ -s --no-wrap --files-from=app.fil " "--output=messages.pot --from-code=utf8"
if verbose:
print cmd
os.system(cmd)
os.chdir(currentDir)
makeXulPO(applicationDirectoryPath, applicationDomain, verbose)
localeDirs = Path("exe/locale")
for filename in localeDirs.glob("*_*.po"):
cmd = "msgmerge -U --no-wrap %s messages.pot" % filename
if verbose:
print cmd
os.system(cmd)