本文整理汇总了Python中exe.engine.path.Path.touch方法的典型用法代码示例。如果您正苦于以下问题:Python Path.touch方法的具体用法?Python Path.touch怎么用?Python Path.touch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.touch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeXulPO
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import touch [as 别名]
def makeXulPO(applicationDirectoryPath, applicationDomain=None, verbose=0):
"""Searches through xul files and appends to messages.pot"""
if verbose:
print "Importing xul templates..."
path = Path(applicationDirectoryPath)
messages = pot2dict('exe/locale/messages.pot')
messageCommentTemplate = '\n#: %s:%s\nmsgid "'
seq = len(messages)
skipPaths = (
applicationDirectoryPath/'exe/webui/firefox',
)
for fn in path.walkfiles():
if fn.ext.lower() == '.xul':
for skipPath in skipPaths:
if fn.startswith(skipPath):
print 'IGNORING', fn
break
else:
if verbose:
print "template: ", fn
reader = Sax2.Reader()
doc = reader.fromStream(file(fn, 'rb'))
xul2dict(doc, messages, seq, fn.relpath())
pot = Path('exe/locale/messages.pot')
if pot.exists():
pot.remove()
pot.touch()
dict2pot(messages, 'exe/locale/messages.pot')
示例2: makePO
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import touch [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()
messages_pot = Path('exe/locale/messages.pot')
# Use xgettext to make the base messages.pot (with header, etc.)
if messages_pot.exists():
messages_pot.remove()
messages_pot.touch()
cmd = 'xgettext -kx_ -s -j --no-wrap --output=exe/locale/messages.pot --from-code=utf8 exe/engine/package.py'
if verbose: print cmd
os.system(cmd)
if not os.path.exists('app.fil'):
raise IOError(2,'No module file: app.fil')
# Steps:
# Use xgettext to parse all application modules
# The following switches are used:
#
# -s : sort output by string content (easier to use when we need to merge several .po files)
# --files-from=app.fil : The list of files is taken from the file: app.fil
# --output= : specifies the name of the output file (using a .pot extension)
cmd = 'xgettext -kx_ -s -j --no-wrap --output=exe/locale/messages.pot --from-code=utf8 %s'
if verbose: print cmd
for fn in open('app.fil'):
print 'Extracting from', fn,
os.system(cmd % fn[:-1])
makeXulPO(applicationDirectoryPath, applicationDomain, verbose)
# Merge new pot with .po files
localeDirs = Path('exe/locale')
for filename in localeDirs.walkfiles('*_*.po'):
cmd = "msgmerge -U --no-wrap %s exe/locale/messages.pot" % filename
if verbose: print cmd
os.system(cmd)