本文整理汇总了Python中misc.Path.rel_from_to方法的典型用法代码示例。如果您正苦于以下问题:Python Path.rel_from_to方法的具体用法?Python Path.rel_from_to怎么用?Python Path.rel_from_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Path
的用法示例。
在下文中一共展示了Path.rel_from_to方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: determineRelPathToSdk
# 需要导入模块: from misc import Path [as 别名]
# 或者: from misc.Path import rel_from_to [as 别名]
def determineRelPathToSdk(appDir, framework_dir, options):
relPath = ''
if sys.platform == 'cygwin':
if re.match( r'^\.{1,2}\/', appDir):
relPath = Path.rel_from_to(normalizePath(appDir), framework_dir)
elif re.match( r'^/cygdrive\b', appDir):
relPath = Path.rel_from_to(appDir, framework_dir)
else:
relPath = Path.rel_from_to(normalizePath(appDir), normalizePath(framework_dir))
else:
relPath = Path.rel_from_to(normalizePath(appDir), normalizePath(framework_dir))
relPath = re.sub(r'\\', "/", relPath)
if relPath[-1] == "/":
relPath = relPath[:-1]
if not os.path.isdir(os.path.join(appDir, relPath)):
console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
sys.exit(1)
if options.type == "contribution":
#relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", QOOXDOO_VERSION)
#relPath = re.sub(r'\\', "/", relPath)
pass
return relPath
示例2: patchSkeleton
# 需要导入模块: from misc import Path [as 别名]
# 或者: from misc.Path import rel_from_to [as 别名]
def patchSkeleton(dir, framework_dir, options):
absPath = normalizePath(framework_dir)
if absPath[-1] == "/":
absPath = absPath[:-1]
if sys.platform == 'cygwin':
if re.match( r'^\.{1,2}\/', dir ):
relPath = Path.rel_from_to(normalizePath(dir), framework_dir)
elif re.match( r'^/cygdrive\b', dir):
relPath = Path.rel_from_to(dir, framework_dir)
else:
relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
else:
relPath = os.path.relpath(framework_dir, dir)
#relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
relPath = re.sub(r'\\', "/", relPath)
if relPath[-1] == "/":
relPath = relPath[:-1]
if not os.path.isdir(os.path.join(dir, relPath)):
console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
sys.exit(1)
if options.type == "contribution":
relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", QOOXDOO_VERSION)
relPath = re.sub(r'\\', "/", relPath)
for root, dirs, files in os.walk(dir):
for file in files:
split = file.split(".")
if len(split) >= 3 and split[-2] == "tmpl":
outFile = os.path.join(root, ".".join(split[:-2] + split[-1:]))
inFile = os.path.join(root, file)
console.log("Patching file '%s'" % outFile)
#config = MyTemplate(open(inFile).read())
config = Template(open(inFile).read())
out = open(outFile, "w")
out.write(
config.substitute({
"Name": options.name,
"Namespace": options.namespace,
"NamespacePath" : (options.namespace).replace('.', '/'),
"REL_QOOXDOO_PATH": relPath,
"ABS_QOOXDOO_PATH": absPath,
"QOOXDOO_VERSION": QOOXDOO_VERSION,
"Cache" : options.cache,
}).encode('utf-8')
)
out.close()
os.remove(inFile)
for root, dirs, files in os.walk(dir):
for file in [file for file in files if file.endswith(".py")]:
os.chmod(os.path.join(root, file), (stat.S_IRWXU
|stat.S_IRGRP |stat.S_IXGRP
|stat.S_IROTH |stat.S_IXOTH)) # 0755
示例3: patchSkeleton
# 需要导入模块: from misc import Path [as 别名]
# 或者: from misc.Path import rel_from_to [as 别名]
def patchSkeleton(dir, framework_dir, options):
absPath = normalizePath(framework_dir)
if absPath[-1] == "/":
absPath = absPath[:-1]
if sys.platform == 'cygwin':
if re.match( r'^\.{1,2}\/', dir ):
relPath = Path.rel_from_to(normalizePath(dir), framework_dir)
elif re.match( r'^/cygdrive\b', dir):
relPath = Path.rel_from_to(dir, framework_dir)
else:
relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
else:
relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
relPath = re.sub(r'\\', "/", relPath)
if relPath[-1] == "/":
relPath = relPath[:-1]
if not os.path.isdir(os.path.join(dir, relPath)):
console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
sys.exit(1)
if options.type == "contribution":
# TODO: in a final release the following "trunk" would need to be changed
# to an actual version number like "0.8.3"
relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", "0.8.3")
relPath = re.sub(r'\\', "/", relPath)
for root, dirs, files in os.walk(dir):
for file in files:
split = file.split(".")
if len(split) >= 3 and split[1] == "tmpl":
outFile = os.path.join(root, split[0] + "." + ".".join(split[2:]))
inFile = os.path.join(root, file)
console.log("Patching file '%s'" % outFile)
config = Template(open(inFile).read())
out = open(outFile, "w")
out.write(
config.substitute({
"Name": options.name,
"Namespace": options.namespace,
"REL_QOOXDOO_PATH": relPath,
"ABS_QOOXDOO_PATH": absPath,
"QOOXDOO_VERSION": "0.8.3",
"Cache" : options.cache,
}).encode('utf-8')
)
out.close()
os.remove(inFile)
for root, dirs, files in os.walk(dir):
for file in [file for file in files if file.endswith(".py")]:
os.chmod(os.path.join(root, file), (stat.S_IRWXU
|stat.S_IRGRP |stat.S_IXGRP
|stat.S_IROTH |stat.S_IXOTH)) # 0755
示例4: patchSkeleton
# 需要导入模块: from misc import Path [as 别名]
# 或者: from misc.Path import rel_from_to [as 别名]
def patchSkeleton(dir, name, namespace):
absPath = normalizePath(FRAMEWORK_DIR)
if absPath[-1] == "/":
absPath = absPath[:-1]
if sys.platform == 'cygwin':
if re.match( r'^\.{1,2}\/', dir ):
relPath = Path.rel_from_to(normalizePath(dir), FRAMEWORK_DIR)
elif re.match( r'^/cygdrive\b', dir):
relPath = Path.rel_from_to(dir, FRAMEWORK_DIR)
else:
relPath = Path.rel_from_to(normalizePath(dir), normalizePath(FRAMEWORK_DIR))
else:
relPath = Path.rel_from_to(normalizePath(dir), normalizePath(FRAMEWORK_DIR))
relPath = re.sub(r'\\', "/", relPath)
if relPath[-1] == "/":
relPath = relPath[:-1]
if not os.path.isdir(os.path.join(dir, relPath)):
console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
sys.exit(1)
for root, dirs, files in os.walk(dir):
for file in files:
split = file.split(".")
if len(split) >= 3 and split[1] == "tmpl":
outFile = os.path.join(root, split[0] + "." + ".".join(split[2:]))
inFile = os.path.join(root, file)
console.log("Patching file '%s'" % outFile)
config = Template(open(inFile).read())
out = open(outFile, "w")
out.write(
config.substitute({
"Name": name,
"Namespace": namespace,
"REL_QOOXDOO_PATH": relPath,
"ABS_QOOXDOO_PATH": absPath,
"QOOXDOO_VERSION": "0.8.1"
})
)
out.close()
os.remove(inFile)
for root, dirs, files in os.walk(dir):
for file in [file for file in files if file.endswith(".py")]:
os.chmod(os.path.join(root, file), 0755)
示例5: _computeResourceUri
# 需要导入模块: from misc import Path [as 别名]
# 或者: from misc.Path import rel_from_to [as 别名]
def _computeResourceUri(self, lib, resourcePath, rType="class", appRoot=None):
if 'uri' in lib:
libBaseUri = Uri(lib['uri'])
elif appRoot:
libBaseUri = Uri(Path.rel_from_to(self._config.absPath(appRoot), lib['path']))
else:
raise RuntimeError, "Need either lib['uri'] or appRoot, to calculate final URI"
#libBaseUri = Uri(libBaseUri.toUri())
if rType in lib:
libInternalPath = OsPath(lib[rType])
else:
raise RuntimeError, "No such resource type: \"%s\"" % rType
# process the second part of the target uri
uri = libInternalPath.join(resourcePath)
uri = Uri(uri.toUri())
libBaseUri.ensureTrailingSlash()
uri = libBaseUri.join(uri)
# strip dangling "/", e.g. when we have no resourcePath
uri.ensureNoTrailingSlash()
return uri