本文整理汇总了Python中misc.filetool.root函数的典型用法代码示例。如果您正苦于以下问题:Python root函数的具体用法?Python root怎么用?Python root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了root函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadTemplate
def loadTemplate(bootCode):
if bootCode:
loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader-build.tmpl.js")
else:
loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader-source.tmpl.js")
template = filetool.read(loaderFile)
return template
示例2: getData
def getData():
data = os.path.join(filetool.root(), os.pardir, "data", "icon", "qooxdoo.dat")
lines = filetool.read(data).split("\n")
result = {}
for line in lines:
if line == "" or line.startswith(" ") or line.startswith("#"):
continue
if ":" in line:
alternative = line[line.index(":")+1:].split(",")
key = line[:line.index(":")]
else:
alternative = []
key = line
if key in result:
console.error("Duplicate key found: %s" % key)
sys.exit(1)
result[key] = alternative
# convert to array
arr = []
keys = result.keys()
keys.sort()
for key in keys:
tmp = []
tmp.append(key)
tmp.extend(result[key])
arr.append(tmp)
return arr
示例3: getLocalizationData
def getLocalizationData(self, locales):
self._console.debug("Generating localization data...")
self._console.indent()
data = {}
root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
newlocales = locales
for locale in locales:
if len(locale) > 2 and locale[2] == "_":
topLevelLocale = locale[0:2]
if not topLevelLocale in locales:
self._console.warn("Base locale %s not specified, trying to add it." % topLevelLocale)
newlocales[:0] = [topLevelLocale]
for entry in newlocales:
if entry == "C":
locale = "en"
else:
locale = entry
locFile = os.path.join(root, "%s.xml" % locale)
cacheId = "locale-%s-%s" % (root, locale)
locDat = self._cache.read(cacheId, locFile)
if locDat == None:
self._console.debug("Processing locale: %s" % locale)
locDat = cldr.parseCldrFile(locFile)
self._cache.write(cacheId, locDat)
data[entry] = locDat
self._console.outdent()
return data
示例4: runMigration
def runMigration(jobconf, libs):
if not jobconf.get('migrate-files', False):
return
console = Context.console
console.info("Please heed the warnings from the configuration file parsing")
console.info("Migrating Javascript source code to most recent qooxdoo version...")
console.indent()
migSettings = jobconf.get('migrate-files')
shellCmd = ShellCmd()
migratorCmd = os.path.join(os.path.dirname(filetool.root()), "bin", "migrator.py")
libPaths = []
for lib in libs:
lib._init_from_manifest() # Lib()'s aren't initialized yet
libPaths.append(os.path.join(lib.path, lib.classPath))
mig_opts = []
if migSettings.get('from-version', False):
mig_opts.extend(["--from-version", migSettings.get('from-version')])
if migSettings.get('migrate-html'):
mig_opts.append("--migrate-html")
mig_opts.extend(["--class-path", ",".join(libPaths)])
shcmd = " ".join(textutil.quoteCommandArgs([sys.executable, migratorCmd] + mig_opts))
console.debug("Invoking migrator as: '%s'" % shcmd)
shellCmd.execute(shcmd)
console.outdent()
示例5: loaderTemplate
def loaderTemplate(script, compConf):
templatePath = compConf.get("paths/loader-template", None)
if not templatePath:
# use default template
templatePath = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader.tmpl.js")
templateCont = filetool.read(templatePath)
return templateCont, templatePath
示例6: getLocalizationData
def getLocalizationData(self, locales):
self._console.debug("Generating localization data...")
self._console.indent()
data = {}
root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
for entry in locales:
if entry == "C":
locale = "en"
else:
locale = entry
locFile = os.path.join(root, "%s.xml" % locale)
cacheId = "locale-%s" % locale
locDat = self._cache.read(cacheId, locFile)
if locDat == None:
self._console.debug("Processing locale: %s" % locale)
locDat = cldr.parseCldrFile(locFile)
self._cache.write(cacheId, locDat)
data[entry] = locDat
self._console.outdent()
return data
示例7: _checkToolsNewer_1
def _checkToolsNewer_1(self, path, checkFile, context):
if not os.path.isfile(checkFile):
return True
checkFileMTime = os.stat(checkFile).st_mtime
# find youngst tool file
_, toolCheckMTime = filetool.findYoungest(os.path.dirname(filetool.root()))
# compare
if checkFileMTime < toolCheckMTime:
return True
else:
return False
示例8: getLocalizationData
def getLocalizationData(self, locales):
self._console.debug("Generating localization data...")
self._console.indent()
data = {}
root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
for entry in locales:
if entry == "C":
locale = "en"
else:
locale = entry
self._console.debug("Processing locale: %s" % locale)
data[entry] = cldr.parseCldrFile(os.path.join(root, "%s.xml" % locale))
self._console.outdent()
return data
示例9: getLocalizationData
def getLocalizationData(self, classList, targetLocales, ):
self._console.debug("Generating localization data...")
data = {}
# check need for cldr data in this classlist
need_cldr = False
for clazz in classList:
if clazz.getHints('cldr'):
need_cldr = True
break
# early return
if not need_cldr:
return data
# else collect cldr data
self._console.indent()
root = os.path.join(filetool.root(), os.pardir, "data", "cldr", "main")
newlocales = targetLocales
for locale in targetLocales:
if len(locale) > 2 and locale[2] == "_":
topLevelLocale = locale[0:2]
if not topLevelLocale in targetLocales:
self._console.warn("Base locale %s not specified, trying to add it." % topLevelLocale)
newlocales[:0] = [topLevelLocale]
for entry in newlocales:
if entry == "C":
locale = "en"
else:
locale = entry
locFile = os.path.join(root, "%s.xml" % locale)
cacheId = "locale-%s-%s" % (root, locale)
locDat, _ = self._cache.read(cacheId, locFile)
if locDat == None:
self._console.debug("Processing locale: %s" % locale)
locDat = cldr.parseCldrFile(locFile)
self._cache.write(cacheId, locDat)
data[entry] = locDat
self._console.outdent()
return data