• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.path_join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.path_join函数的典型用法代码示例。如果您正苦于以下问题:Python path_join函数的具体用法?Python path_join怎么用?Python path_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了path_join函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:thugetry,项目名称:Web2Executable,代码行数:32,代码来源:command_line.py


示例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)
开发者ID:thugetry,项目名称:Web2Executable,代码行数:33,代码来源:command_line.py


示例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)
开发者ID:carcdrcons,项目名称:paul-graham-essays-to-mobi,代码行数:7,代码来源:parse_text.py


示例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))
开发者ID:carcdrcons,项目名称:paul-graham-essays-to-mobi,代码行数:7,代码来源:test_download.py


示例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)
开发者ID:zsnake1209,项目名称:vb25-patch,代码行数:14,代码来源:builder.py


示例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()
开发者ID:carcdrcons,项目名称:paul-graham-essays-to-mobi,代码行数:7,代码来源:make_mobi.py


示例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)
开发者ID:kevin89126,项目名称:picture_manager,代码行数:8,代码来源:pic.py


示例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)
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:44,代码来源:builder.py


示例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)
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:19,代码来源:builder.py


示例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)
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:10,代码来源:builder.py


示例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
开发者ID:thugetry,项目名称:Web2Executable,代码行数:11,代码来源:command_line.py


示例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',)
开发者ID:thugetry,项目名称:Web2Executable,代码行数:11,代码来源:command_line.py


示例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)
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:20,代码来源:builder.py


示例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',)
开发者ID:jyapayne,项目名称:Web2Executable,代码行数:12,代码来源:util_classes.py


示例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'))
开发者ID:jyapayne,项目名称:Web2Executable,代码行数:13,代码来源:test_command_line.py


示例16: create_icns_for_app

    def create_icns_for_app(self, icns_path):
        icon_setting = self.get_setting('icon')
        mac_app_icon_setting = self.get_setting('mac_icon')
        icon_path = (mac_app_icon_setting.value
                     if mac_app_icon_setting.value
                     else icon_setting.value)

        if icon_path:
            icon_path = utils.path_join(self.project_dir(), icon_path)
            if not icon_path.endswith('.icns'):
                save_icns(icon_path, icns_path)
            else:
                utils.copy(icon_path, icns_path)
开发者ID:thugetry,项目名称:Web2Executable,代码行数:13,代码来源:command_line.py


示例17: put_client_binary_files

 def put_client_binary_files(self, filenames, total_size):   
     # Filenames are relative to the data_dir.
     self.ui.set_progress_range(total_size)
     self.ui.set_progress_update_interval(total_size/50)
     for filename in filenames:
         self.request_connection()
         self.con.putrequest("PUT",
             self.url("/client_binary_file?session_token=%s&filename=%s" \
             % (self.server_info["session_token"],
             urllib.quote(filename.encode("utf-8"), ""))))
         full_path = path_join(self.database.data_dir(), filename)
         file_size = path_getsize(full_path)
         self.con.putheader("content-length", file_size)
         self.con.endheaders()
         for buffer in self.stream_binary_file(full_path, progress_bar=False):
             self.con.send(buffer)
             self.ui.increase_progress(len(buffer))
         self._check_response_for_errors(self.con.getresponse())
     self.ui.set_progress_value(total_size)
开发者ID:tbabej,项目名称:mnemosyne,代码行数:19,代码来源:client.py


示例18: load_package_json

 def load_package_json(self, json_path=None):
     self.logger.info('Loading package.json')
     if json_path is not None:
         p_json = [json_path]
     else:
         p_json = glob.glob(utils.path_join(self.project_dir(),
                                         'package.json'))
     setting_list = []
     if p_json:
         json_str = ''
         try:
             with codecs.open(p_json[0], 'r', encoding='utf-8') as f:
                 json_str = f.read()
         except IOError:
             return setting_list
         try:
             setting_list = self.load_from_json(json_str)
         except ValueError as e:  # Json file is invalid
             self.logger.warning('Warning: Json file invalid.')
             self.progress_text = u'{}\n'.format(e)
     return setting_list
开发者ID:thugetry,项目名称:Web2Executable,代码行数:21,代码来源:command_line.py


示例19: exporter

	def exporter(self):
		"""
		  Add script and modules
		"""
		scriptsPath = utils.path_join(self.dir_install, self.dir_install_name, self.version, "scripts")
		if self.host_os == utils.MAC:
			scriptsPath = utils.path_join(self.dir_install, self.dir_install_name, "blender.app", "Contents", "Resources", self.version, "scripts")

		addonsPath  = utils.path_join(scriptsPath, "addons")
		startupPath = utils.path_join(scriptsPath, "startup")

		clonePath = addonsPath if self.vb30 else startupPath

		sys.stdout.write("Adding exporter...\n")
		sys.stdout.write("  in: %s\n" % clonePath)

		if not self.mode_test:
			if not os.path.exists(clonePath):
				sys.stderr.write("Something went wrong! Can't add Python modules and exporter!\n")
				sys.exit(3)

			if self.vb30:
				os.chdir(clonePath)
				exporterPath = utils.path_join(clonePath, "vb30")
				if os.path.exists(exporterPath):
					utils.remove_directory(exporterPath)
				os.system("git clone --recursive https://github.com/bdancer/vb30.git")

			else:
				os.chdir(clonePath)
				exporterPath = utils.path_join(clonePath, "vb25")
				if os.path.exists(exporterPath):
					utils.remove_directory(exporterPath)

				os.system("git clone --recursive https://github.com/bdancer/vb25.git")

			if self.use_exp_branch not in {'master'}:
				os.chdir(exporterPath)
				os.system("git remote update")
				os.system("git checkout -b {branch} origin/{branch}".format(branch=self.use_exp_branch))

			os.chdir(exporterPath)
			os.system("git submodule update --init --recursive")
			os.system("git submodule foreach git checkout master")
			os.system("git submodule foreach git pull --rebase origin master")
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:45,代码来源:builder.py


示例20: patch

	def patch(self):
		patch_dir = utils.path_join(self.dir_source, "vb25-patch")

		if self.use_blender_hash:
			patchBin      = utils.find_patch()
			patchFilepath = os.path.join(tempfile.gettempdir(), "vray_for_blender.patch")

			os.chdir(self.dir_blender)

			os.system("git checkout %s" % self.use_github_branch) # Checkout exporter branch
			os.system("git diff master > %s" % patchFilepath)     # Generate diff with master
			os.system("git fetch --tags")                         # Hash could be tag also
			os.system("git checkout %s" % self.use_blender_hash)  # Checkout needed revision
			os.system("git checkout -b vray_for_blender")         # Create some branch for patching
			os.system("patch -Np1 -i %s" % patchFilepath)         # Apply patch

			os.remove(patchFilepath)

		# Add datafiles: splash, default scene etc
		if self.add_datafiles:
			sys.stdout.write("Adding datafiles...\n")

			datafiles_path = utils.path_join(self.dir_blender, "release", "datafiles")

			if not self.mode_test:
				# Change splash
				for splash_filename in ["splash.png", "splash_2x.png"]:
					splash_path_src = utils.path_join(patch_dir, "datafiles", splash_filename)
					splash_path_dst = utils.path_join(datafiles_path, splash_filename)

					shutil.copyfile(splash_path_src, splash_path_dst)

				# Change icons
				for subdir in ["blender_icons16", "blender_icons32"]:
					icons_path_src = utils.path_join(patch_dir, "datafiles", subdir)
					icons_path_dst = utils.path_join(datafiles_path, subdir)

					shutil.rmtree(icons_path_dst)
					shutil.copytree(icons_path_src, icons_path_dst)
开发者ID:israelavlis,项目名称:vb25-patch,代码行数:39,代码来源:builder.py



注:本文中的utils.path_join函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.path_prefix函数代码示例发布时间:2022-05-26
下一篇:
Python utils.patch_auth函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap