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

Python relpath.relpath函数代码示例

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

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



在下文中一共展示了relpath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: projectFileGenerator

def projectFileGenerator(project_info):
    directory = project_info.info("PROJECT_PATH")
    project_data = {}
    enabled_modules = []
    for module, information in project_info.info("MODULES").items():
        if information["enabled"]:
            enabled_modules.append(module)
    project_data["ENABLED_MODULES"] = enabled_modules
    if project_info.info("PRESET"):
        # For presets save again the BERTOS_PATH into project file
        project_data["PRESET"] = True
        project_data["BERTOS_PATH"] = relpath.relpath(project_info.info("BERTOS_PATH"), directory)
    elif project_info.edit:
        # If in editing mode the BERTOS_PATH is maintained
        project_data["BERTOS_PATH"] = relpath.relpath(project_info.info("BERTOS_PATH"), directory)
    else:
        # Use the local BeRTOS version instead of the original one
        # project_data["BERTOS_PATH"] = project_info.info("BERTOS_PATH")
        project_data["BERTOS_PATH"] = "."
    project_data["PROJECT_NAME"] = project_info.info("PROJECT_NAME", os.path.basename(directory))
    project_src_relpath = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), directory)
    project_data["PROJECT_SRC_PATH"] = project_src_relpath
    project_data["TOOLCHAIN"] = project_info.info("TOOLCHAIN")
    project_data["CPU_NAME"] = project_info.info("CPU_NAME")
    project_data["SELECTED_FREQ"] = project_info.info("SELECTED_FREQ")
    project_data["OUTPUT"] = project_info.info("OUTPUT")
    project_data["WIZARD_VERSION"] = WIZARD_VERSION
    project_data["PRESET"] = project_info.info("PRESET")
    project_data["PROJECT_HW_PATH"] = relpath.relpath(project_info.info("PROJECT_HW_PATH"), directory)
    return pickle.dumps(project_data)
开发者ID:mtarek,项目名称:BeRTOS,代码行数:30,代码来源:bertos_utils.py


示例2: readTestFunctions

    def readTestFunctions(self):
        """For each TestFile we are running tests in, load the list of
        test functions in that file"""
        #XXX TODO - error handling if a test is specified that does not exist

        sys.stderr.write("Finding tests...\n")

        def get_job(test_file):
            def get_tests():
                def callback(rv, signal, proc, killed):
                    test_file.updateTestLists(rv)
                    if test_file.compile_failed:
                        self.uncompiled_files.append(test_file)
                    else:
                        self.compiled_files.append(test_file)
                return test_file.getTests(self.engine), callback, None
            return get_tests

        test_finder = JobRunner(self.num_processes, timeout=30)
        
        for path, test_file in self.tests.iteritems():
            self.all_files.append(relpath(path, test_path))
            test_finder.queue([get_job(test_file)])

        test_finder.run()
开发者ID:Ms2ger,项目名称:presto-testo,代码行数:25,代码来源:opjsunit.py


示例3: get_lecture_date_folder

 def get_lecture_date_folder(self):
     folder_path = self._get_lecture_date_folder()
     #print('folder_path = %s' % folder_path)
     rp = relpath.relpath(folder_path, base=semester_root)
     self.dest_dir_box.SetValue(rp)
     self.check_for_existing_lecture_folder()
     return folder_path
开发者ID:ryanGT,项目名称:wxpython_guis,代码行数:7,代码来源:old_lecture_prep_copy_gui.py


示例4: importInShell

    def importInShell(self):
        modDir, modFile = os.path.split(self.assertLocalFile())
        modName = os.path.splitext(modFile)[0]
        if self.app:
            execDir = os.path.dirname(self.app.assertLocalFile())
            if execDir != modDir:
                p, m = os.path.split(relpath.relpath(execDir, self.assertLocalFile()))
                p = p.replace('/', '.')
                p = p.replace('\\', '.')
                pckName = p
                impExecStr = 'from %s import %s'%(pckName, modName)
            else:
                impExecStr = 'import %s'%modName

        else:
            execDir = modDir
            impExecStr = 'import %s'%modName

        shell = self.editor.shell
        if execDir not in sys.path:
            sys.path.append(execDir)
            shell.pushLine("print '## Appended to sys.path'")
        else:
            info = ''

        shell.pushLine(impExecStr, impExecStr)
        if shell.lastResult != 'stderr':
            return _('Import of %s successfull')%modName, 'Info'
        else:
            return _('Import of %s failed')%modName, 'Error'
开发者ID:tinkertonyo,项目名称:boa-constructor,代码行数:30,代码来源:PythonEditorModels.py


示例5: pathRelativeToModel

def pathRelativeToModel(path, model):
    from relpath import relpath
    mbd = getModelBaseDir(model)
    if mbd:
        return relpath(mbd, path)
    else:
        return path
开发者ID:tinkertonyo,项目名称:boa-constructor,代码行数:7,代码来源:Utils.py


示例6: __init__

    def __init__(self, abspath, basepath, rel_link_paths, level=1, \
                 index_name='index.html', subclass=None, title=None,
                 myskips=[]):
        self.abspath = abspath
        rest, self.name = os.path.split(self.abspath)
        self.basepath = basepath
        if subclass is None:
           subclass = subfolder
        self.relpath = relpath.relpath(abspath, basepath)
        self.rel_link_paths = rel_link_paths
        self.mylinks = [item for item in self.rel_link_paths \
                        if item.find(self.relpath+os.sep) == 0]

        subfolder_abstract.__init__(self, index_name=index_name, \
                                    title=title, subclass=subclass, \
                                    myskips=myskips, level=level)
        self.topnavlinks = [relpath.relpath(item, self.relpath) for item in self.toplinks]#used for sidebar navigation in Krauss blog
开发者ID:ryanGT,项目名称:report_generation,代码行数:17,代码来源:website_index_maker.py


示例7: h

 def h( x ):
     import relpath
     if not x.startswith( "/" ):
         return x
     
     p = relpath.relpath( os.getcwd(), x )
     #print p
     return p
开发者ID:Tallefer,项目名称:scons-for-symbian,代码行数:8,代码来源:cpp.py


示例8: on_browse

 def on_browse(self, event=None):
     course_dir = self.get_course_dir()
     folder_path = wx_utils.my_dir_dialog(parent=None,\
                                          start_dir=course_dir,\
                                          msg="Choose root directory", \
                                          )
     if folder_path:
         rp = relpath.relpath(folder_path, base=course_dir)
         self.root_folder_box.SetValue(rp)
开发者ID:ryanGT,项目名称:wxpython_guis,代码行数:9,代码来源:course_prep_gui.py


示例9: createFileSoftLink

 def createFileSoftLink(self, name, target):
     if os.path.exists(name) or os.path.islink(name):
         os.remove(name)
     if os.path.exists(target):
         # Create soft link with absolute path
         t_relpath = relpath.relpath(os.path.dirname(name), os.path.dirname(target), '/')
         t = t_relpath + "/" + os.path.basename(target)
         os.system("ln -s %s %s" %(t, name))
     return
开发者ID:LuckJC,项目名称:pro-mk,代码行数:9,代码来源:nonndk.py


示例10: on_browse_dest

 def on_browse_dest(self, event=None):
     lectures_dir = self.get_lectures_dir()
     folder_path = wx_utils.my_dir_dialog(parent=None, \
                                          start_dir=lectures_dir, \
                                          msg="Choose destination directory", \
                                          )
     if folder_path:
         rp = relpath.relpath(folder_path, base=semester_root)
         self.dest_dir_box.SetValue(rp)
开发者ID:ryanGT,项目名称:wxpython_guis,代码行数:9,代码来源:old_lecture_prep_copy_gui.py


示例11: saveAs

    def saveAs(self, filename):
        for mod in self.modules.keys():
            self.modules[mod][2] = self.convertToUnixPath(\
              relpath.relpath(os.path.dirname(filename),
              self.normaliseModuleRelativeToApp(self.modules[mod][2])))

        self.writeModules()

        ClassModel.saveAs(self, filename)

        self.notify()
开发者ID:tinkertonyo,项目名称:boa-constructor,代码行数:11,代码来源:PythonEditorModels.py


示例12: userMkGenerator

def userMkGenerator(project_info):
    makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_user.mk"), "r").read()
    destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + "_user.mk")
    # Deadly performances loss was here :(
    mk_data = {}
    mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH"))
    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
    mk_data["$main"] = "/".join(["$(%s_SRC_PATH)" %project_info.info("PROJECT_NAME"), "main.c"])
    for key in mk_data:
        makefile = makefile.replace(key, mk_data[key])
    open(destination, "w").write(makefile)
开发者ID:mtarek,项目名称:BeRTOS,代码行数:11,代码来源:bertos_utils.py


示例13: on_browse_source

 def on_browse_source(self, event=None):
     course_dir = self.get_course_dir()
     folder_path = wx_utils.my_dir_dialog(parent=None, \
                                          start_dir=course_dir, \
                                          msg="Choose source directory", \
                                          )
     if folder_path:
         rp = relpath.relpath(folder_path, base=semester_root)
         self.source_dir_box.SetValue(rp)
         self.list_source_dir()
         self.set_lecture_number()
开发者ID:ryanGT,项目名称:wxpython_guis,代码行数:11,代码来源:old_lecture_prep_copy_gui.py


示例14: __init__

 def __init__(self, path):
     if not os.path.exists(path):
         print "Test file %s not found"%path
         sys.exit(1)
     self.path = path
     self.compile_failed = None
     self.get_tests_output = None
     self.tests_to_run = []
     self.crashed = False #Did the current file crash (fast mode only)
     self.relative_path = relpath(path, test_path)
     self.run_tests_individually = False
     self.read_options()
开发者ID:Ms2ger,项目名称:presto-testo,代码行数:12,代码来源:opjsunit.py


示例15: makefileGenerator

def makefileGenerator(project_info):
    """
    Generate the Makefile for the current project.
    """
    makefile = open(os.path.join(const.DATA_DIR, "mktemplates/Makefile"), "r").read()
    destination = os.path.join(project_info.maindir, "Makefile")
    # TODO write a general function that works for both the mk file and the Makefile
    mk_data = {}
    mk_data["$pname"] = project_info.info("PROJECT_NAME")
    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
    for key in mk_data:
        makefile = makefile.replace(key, mk_data[key])
    open(destination, "w").write(makefile)
开发者ID:mtarek,项目名称:BeRTOS,代码行数:13,代码来源:bertos_utils.py


示例16: addModule

    def addModule(self, filename, descr, source=None):
        name, ext = os.path.splitext(os.path.basename(filename))
        if self.modules.has_key(name):
            raise Exception(_('Module name exists in application'))
        if self.savedAs:
            relative = relpath.relpath(os.path.dirname(self.filename), filename)
        else:
            relative = filename
        self.modules[name] = [0, descr, self.convertToUnixPath(relative)]

        self.idModel(name, source)

        self.writeModules()
开发者ID:tinkertonyo,项目名称:boa-constructor,代码行数:13,代码来源:PythonEditorModels.py


示例17: mkGenerator

def mkGenerator(project_info):
    """
    Generates the mk file for the current project.
    """
    makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read()
    prjdir = os.path.abspath(project_info.prjdir)
    destination = os.path.join(prjdir, os.path.basename(prjdir) + ".mk")
    mk_data = {}
    mk_data["$pname"] = project_info.info("PROJECT_NAME")
    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
    mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ")
    cpu_mk_parameters = []
    for key, value in project_info.info("CPU_INFOS").items():
        if key.startswith(const.MK_PARAM_ID):
            cpu_mk_parameters.append("%s = %s" %(key.replace("MK", mk_data["$pname"]), value))
    mk_data["$cpuparameters"] = "\n".join(cpu_mk_parameters)
    mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$cppasrc"], mk_data["$cxxsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info)
    mk_data["$prefix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].rsplit("gcc", 1)[0])
    mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].rsplit("gcc", 1)[1])
    mk_data["$hwpath"] = relpath.relpath(project_info.info("PROJECT_HW_PATH"), project_info.info("PROJECT_PATH"))
    for key in mk_data:
        makefile = makefile.replace(key, mk_data[key])
    open(destination, "w").write(makefile)
开发者ID:mtarek,项目名称:BeRTOS,代码行数:23,代码来源:bertos_utils.py


示例18: add_header_search_path

	def add_header_search_path(self, configuration):
		project_path = os.path.dirname(os.path.abspath(self.xcodeprojpath()))
		build_path = os.path.join(os.path.join(os.path.join(os.path.dirname(Paths.src_dir), 'Build'), 'Products'), 'three20')
		rel_path = relpath(project_path, build_path)

		did_add_build_setting = self.add_build_setting(configuration, 'HEADER_SEARCH_PATHS', '"'+rel_path+'"')
		if not did_add_build_setting:
			return did_add_build_setting
		
		# Version 46 is Xcode 4's file format.
		try:
			primary_version = int(self._xcode_version.split('.')[0])
		except ValueError, e:
			primary_version = 0
开发者ID:000fan000,项目名称:nimbus,代码行数:14,代码来源:pbxproj.py


示例19: get_all_tests

def get_all_tests():
    tests = set()
    for dirpath, dirnames, filenames in os.walk(base_path):
        if ".svn" in dirpath or "tools" in dirpath:
            continue

        for fn in filenames:
            if os.path.splitext(fn)[1] != ".js" or fn[0] in ("#", "."):
                continue

            if fn not in ("mjsunit.js", "harness.js"):
                full_path = os.path.join(dirpath, fn)
                tests.add(relpath.relpath(full_path, base_path))

    return tests
开发者ID:Ms2ger,项目名称:presto-testo,代码行数:15,代码来源:harness.py


示例20: gen_nav

 def gen_nav(self, firstdays_dict):
    navlist = []
    self.dict_to_rst()
    for month in months:
       if firstdays_dict.has_key(month):
          month_link = firstdays_dict[month]
          month_rel_link = relpath.relpath(month_link, self.relpath)
          month_rel_link = month_rel_link.replace('\\','/')
          navlist.append(link_dec(month_rel_link, month))
          navlist.append('')
          if month == self.name:
             navlist.append('')
             navlist.extend(self.rst_links)
             navlist.append('')
    self.navlist = rst_to_html_list(navlist)
    return self.navlist
开发者ID:ryanGT,项目名称:report_generation,代码行数:16,代码来源:website_index_maker.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python remi.start函数代码示例发布时间:2022-05-26
下一篇:
Python logger.logVV函数代码示例发布时间: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