本文整理汇总了Python中utils.path_join函数的典型用法代码示例。如果您正苦于以下问题:Python path_join函数的具体用法?Python path_join怎么用?Python path_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_join函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract
def extract(self, ex_path, version):
if os.path.exists(ex_path):
utils.rmtree(ex_path, ignore_errors=True)
path = self.save_file_path(version)
file = self.extract_class(path,
*self.extract_args)
# currently, python's extracting mechanism for zipfile doesn't
# copy file permissions, resulting in a binary that
# that doesn't work. Copied from a patch here:
# http://bugs.python.org/file34873/issue15795_cleaned.patch
if path.endswith('.zip'):
members = file.namelist()
for zipinfo in members:
minfo = file.getinfo(zipinfo)
target = file.extract(zipinfo, ex_path)
mode = minfo.external_attr >> 16 & 0x1FF
os.chmod(target, mode)
else:
file.extractall(ex_path)
if path.endswith('.tar.gz'):
dir_name = utils.path_join(ex_path, os.path.basename(path).replace('.tar.gz',''))
else:
dir_name = utils.path_join(ex_path, os.path.basename(path).replace('.zip',''))
if os.path.exists(dir_name):
for p in os.listdir(dir_name):
abs_file = utils.path_join(dir_name, p)
utils.move(abs_file, ex_path)
utils.rmtree(dir_name, ignore_errors=True)
示例2: make_desktop_file
def make_desktop_file(self, nw_path, export_dest):
icon_set = self.get_setting('icon')
icon_path = utils.path_join(self.project_dir(), icon_set.value)
if os.path.exists(icon_path) and icon_set.value:
utils.copy(icon_path, export_dest)
icon_path = utils.path_join(export_dest, os.path.basename(icon_path))
else:
icon_path = ''
name = self.project_name()
pdir = self.project_dir()
version = self.get_setting('version')
desc = self.get_setting('description')
dfile_path = utils.path_join(export_dest, u'{}.desktop'.format(name))
file_str = (
u'[Desktop Entry]\n'
u'Version={}\n'
u'Name={}\n'
u'Comment={}\n'
u'Exec={}\n'
u'Icon={}\n'
u'Terminal=false\n'
u'Type=Application\n'
u'Categories=Utility;Application;\n'
)
file_str = file_str.format(version.value,
name,
desc.value,
nw_path,
icon_path)
with codecs.open(dfile_path, 'w+', encoding='utf-8') as f:
f.write(file_str)
os.chmod(dfile_path, 0755)
示例3: _remove_acl
def _remove_acl():
"""Ansi Common Lisp 1~2 is a lisp book."""
path = path_join(TEXT_DIR, 'acl1.txt.txt')
os.remove(path)
path = path_join(TEXT_DIR, 'acl2.txt.txt')
os.remove(path)
示例4: test__get_dst
def test__get_dst():
url = 'http://paulgraham.com/vb.html'
dirname = os.path.dirname(os.path.realpath(__file__))
dirname = os.path.dirname(dirname)
DATA_DIR = path_join(dirname, 'data')
RAW_HTML_DIR = path_join(DATA_DIR, 'raw_html')
assert download._get_dst(url) == path_join(RAW_HTML_DIR, get_basename(url))
示例5: compile_post
def compile_post(self):
if self.host_os == utils.WIN:
runtimeDir = utils.path_join(self.dir_source, "vb25-patch", "non-gpl", self.build_arch)
files = []
if self.vc2013:
files.extend([
"msvcp120.dll",
"msvcr120.dll",
"vcomp120.dll",
])
else:
files.append("vcomp90.dll")
for f in files:
shutil.copy(utils.path_join(runtimeDir, f), self.dir_install_path)
示例6: main
def main():
dst = path_join(DATA_DIR, 'PG')
shutil.make_archive(dst, 'zip', HTML_DIR)
base_cmd = '/usr/bin/ebook-convert {src}.zip {dst} --max-toc-links 999999 --toc-threshold 1 --title "Paul Graham Essay" --author-sort "Paul Graham" --authors "Paul Graham"'
s = Shell(base_cmd.format(src=dst, dst=dst + '.mobi'))
s.communicate()
示例7: _seperate_one
def _seperate_one(self, _file):
time = self._get_time(_file)
folder = self._get_time_folder(time)
fd_path = path_join([self.mv_path, folder, ''])
if not path_exists(fd_path):
create_folder(fd_path)
print _file, fd_path
print copy(_file, fd_path)
示例8: compile
def compile(self):
compileCmd = [sys.executable]
compileCmd.append("scons/scons.py")
if not self.build_clean:
compileCmd.append("--implicit-deps-unchanged")
compileCmd.append("--max-drift=1")
if self.use_env_msvc:
compileCmd.append(r'env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%"')
if self.vc2013:
compileCmd.append(r'MSVS_VERSION=12.0')
cleanCmd = [sys.executable]
cleanCmd.append("scons/scons.py")
cleanCmd.append("clean")
if not self.mode_test:
os.chdir(self.dir_blender)
if self.build_clean:
sys.stdout.write("Calling: %s\n" % (" ".join(cleanCmd)))
subprocess.call(cleanCmd)
sys.stdout.write("Calling: %s\n" % (" ".join(compileCmd)))
res = subprocess.call(compileCmd)
if not res == 0:
sys.stderr.write("There was an error during the compilation!\n")
sys.exit(1)
if self.host_os == utils.WIN:
runtimeDir = utils.path_join(self.dir_source, "vb25-patch", "non-gpl", self.build_arch)
files = []
if self.vc2013:
files.extend([
"msvcp120.dll",
"msvcr120.dll",
"vcomp120.dll",
])
else:
files.append("vcomp90.dll")
for f in files:
shutil.copy(utils.path_join(runtimeDir, f), self.dir_install_path)
示例9: init_paths
def init_paths(self):
if self.generate_package:
if not self.mode_test:
utils.path_create(self.dir_release)
self.dir_build = utils.path_slashify(self.dir_build)
self.dir_source = utils.path_slashify(self.dir_source)
self.dir_install_path = utils.path_slashify(self.dir_install_path)
self.dir_blender = utils.path_join(self.dir_source, "blender")
self.dir_blender_svn = utils.path_join(self.dir_source, "blender-git")
self.user_config = utils.path_join(self.dir_blender, "user-config.py")
if self.user_user_config:
self.user_user_config = utils.pathExpand(self.user_user_config)
if self.build_clean:
if os.path.exists(self.dir_build):
shutil.rmtree(self.dir_build)
示例10: update
def update(self):
self.revision, self.commits = utils.get_svn_revision(self.dir_blender)
self.version = utils.get_blender_version(self.dir_blender)
if self.build_release:
self.dir_install_name = utils.GetInstallDirName(self)
else:
self.dir_install_name = self.project
self.dir_install_path = utils.path_join(self.dir_install, self.dir_install_name)
示例11: replace_icon_in_exe
def replace_icon_in_exe(self, exe_path):
icon_setting = self.get_setting('icon')
exe_icon_setting = self.get_setting('exe_icon')
icon_path = (exe_icon_setting.value
if exe_icon_setting.value
else icon_setting.value)
if icon_path:
p = PEFile(exe_path)
p.replace_icon(utils.path_join(self.project_dir(), icon_path))
p.write(exe_path)
p = None
示例12: get_file_information_from_url
def get_file_information_from_url(self):
if hasattr(self, 'url'):
self.file_name = self.url.split(u'/')[-1]
self.full_file_path = utils.path_join(self.save_path, self.file_name)
self.file_ext = os.path.splitext(self.file_name)[1]
if self.file_ext == '.zip':
self.extract_class = ZipFile
self.extract_args = ()
elif self.file_ext == '.gz':
self.extract_class = TarFile.open
self.extract_args = ('r:gz',)
示例13: docs
def docs(self):
if self.generate_docs:
api_dir = utils.path_join(self.dir_install_path, "api")
sys.stdout.write("Generating API documentation: %s\n" % (api_dir))
if self.host_os != utils.LNX:
sys.stdout.write("API documentation generation is not supported on this platform.\n")
else:
if not self.mode_test:
sphinx_doc_gen = "doc/python_api/sphinx_doc_gen.py"
# Create API directory
os.system("mkdir -p %s" % api_dir)
# Generate API docs
os.chdir(self.dir_blender)
os.system("%s -b -P %s" % (utils.path_join(self.dir_install_path, "blender"), sphinx_doc_gen))
os.system("sphinx-build doc/python_api/sphinx-in %s" % api_dir)
示例14: get_file_information_from_url
def get_file_information_from_url(self):
"""Extract the file information from the setting url"""
if hasattr(self, 'url'):
self.file_name = self.url.split('/')[-1]
self.full_file_path = utils.path_join(self.save_path, self.file_name)
self.file_ext = os.path.splitext(self.file_name)[1]
if self.file_ext == '.zip':
self.extract_class = zipfile.ZipFile
self.extract_args = ()
elif self.file_ext == '.gz':
self.extract_class = tarfile.TarFile.open
self.extract_args = ('r:gz',)
示例15: test_download_nwjs
def test_download_nwjs(command_base):
command_base.get_setting('nw_version').value = '0.19.0'
command_base.get_setting('windows-x64').value = True
command_base.init()
command_base.get_files_to_download()
command_base.download_file_with_error_handling()
base, _ = os.path.split(__file__)
assert os.path.exists(utils.path_join(base, 'test_data', 'files',
'downloads',
'nwjs-v0.19.0-win-x64.zip'))