当前位置: 首页>>代码示例>>Python>>正文


Python relpath.relpath函数代码示例

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


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


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