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


Python utils._make_path_relative函数代码示例

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


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

示例1: PrepareUA

def PrepareUA(project, RTT_ROOT, BSP_ROOT):
    with open('rtua.py', 'w') as ua:
        # ua.write('import os\n')
        # ua.write('import sys\n')
        ua.write('\n')
        
        print RTT_ROOT
        
        CPPPATH = []
        CPPDEFINES = []

        for group in project:
            # get each include path
            if group.has_key('CPPPATH') and group['CPPPATH']:
                CPPPATH += group['CPPPATH']

            # get each group's definitions
            if group.has_key('CPPDEFINES') and group['CPPDEFINES']:
                CPPDEFINES += group['CPPDEFINES']

        if len(CPPPATH):
            # use absolute path 
            for i in range(len(CPPPATH)):
                CPPPATH[i] = os.path.abspath(CPPPATH[i])

            # remove repeat path
            paths = [i for i in set(CPPPATH)]
            CPPPATH = []
            for path in paths:
                if PrefixPath(RTT_ROOT, path):
                    CPPPATH += ['RTT_ROOT + "/%s",' % _make_path_relative(RTT_ROOT, path).replace('\\', '/')]
                
                elif PrefixPath(BSP_ROOT, path):
                    CPPPATH += ['BSP_ROOT + "/%s",' % _make_path_relative(BSP_ROOT, path).replace('\\', '/')]
                else:
                    CPPPATH += ['"%s",' % path.replace('\\', '/')]

            CPPPATH.sort()
            ua.write('def GetCPPPATH(BSP_ROOT, RTT_ROOT):\n')
            ua.write('\tCPPPATH=[\n')
            for path in CPPPATH:
                ua.write('\t\t%s\n' % path)
            ua.write('\t]\n\n')
            ua.write('\treturn CPPPATH\n\n')
        else:
            ua.write('def GetCPPPATH(BSP_ROOT, RTT_ROOT):\n')
            ua.write('\tCPPPATH=[]\n\n')
            ua.write('\treturn CPPPATH\n\n')

        if len(CPPDEFINES):
            CPPDEFINES = [i for i in set(CPPDEFINES)]

            ua.write('def GetCPPDEFINES():\n')
            ua.write('\tCPPDEFINES=%s\n' % str(CPPDEFINES))
            ua.write('\treturn CPPDEFINES\n\n')

        else:
            ua.write('def GetCPPDEFINES():\n')
            ua.write('\tCPPDEFINES=""\n\n')
            ua.write('\treturn CPPDEFINES\n\n')
开发者ID:nongxiaoming,项目名称:MiniQuadcopter,代码行数:60,代码来源:ua.py

示例2: MDK4AddGroup

def MDK4AddGroup(ProjectFiles, parent, name, files, project_path):
    # don't add an empty group 
    if len(files) == 0:
        return

    group = SubElement(parent, 'Group')
    group_name = SubElement(group, 'GroupName')
    group_name.text = name

    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        basename = os.path.basename(path)
        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)
        
        files = SubElement(group, 'Files')
        file = SubElement(files, 'File')
        file_name = SubElement(file, 'FileName')
        name = os.path.basename(path)
        if ProjectFiles.count(name):
            name = basename + '_' + name
        ProjectFiles.append(name)
        file_name.text = name.decode(fs_encoding)
        file_type = SubElement(file, 'FileType')
        file_type.text = '%d' % _get_filetype(name)
        file_path = SubElement(file, 'FilePath')
        
        file_path.text = path.decode(fs_encoding)
开发者ID:cclant,项目名称:rt-thread,代码行数:31,代码来源:keil.py

示例3: MDK5AddGroupForFN

def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
    group = SubElement(parent, 'Group')
    group_name = SubElement(group, 'GroupName')
    group_name.text = name

    name = os.path.basename(filename)
    path = os.path.dirname (filename)

    basename = os.path.basename(path)
    path = _make_path_relative(project_path, path)
    path = os.path.join(path, name)
    files = SubElement(group, 'Files')
    file = SubElement(files, 'File')
    file_name = SubElement(file, 'FileName')
    name = os.path.basename(path)

    if name.find('.cpp') != -1:
        obj_name = name.replace('.cpp', '.o')
    elif name.find('.c') != -1:
        obj_name = name.replace('.c', '.o')
    elif name.find('.s') != -1:
        obj_name = name.replace('.s', '.o')
    elif name.find('.S') != -1:
        obj_name = name.replace('.s', '.o')

    if ProjectFiles.count(obj_name):
        name = basename + '_' + name
    ProjectFiles.append(obj_name)
    file_name.text = name.decode(fs_encoding)
    file_type = SubElement(file, 'FileType')
    file_type.text = '%d' % _get_filetype(name)
    file_path = SubElement(file, 'FilePath')

    file_path.text = path.decode(fs_encoding)
开发者ID:Magicoe,项目名称:LPC54110_Audio,代码行数:34,代码来源:keil.py

示例4: VS_add_ItemGroup

def VS_add_ItemGroup(parent, file_type, files, project_path):
    from building import Rtt_Root
    RTT_ROOT = os.path.normpath(Rtt_Root)

    file_dict = {'C':"ClCompile", 'H':'ClInclude'}
    item_tag = file_dict[file_type]

    ItemGroup = SubElement(parent, 'ItemGroup')
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        objpath = path.lower()
        if len(project_path) >= len(RTT_ROOT) :
            if objpath.startswith(project_path.lower()) :
                objpath = ''.join('bsp'+objpath[len(project_path):])
            else :
                objpath = ''.join('kernel'+objpath[len(RTT_ROOT):])
        else :
            if objpath.startswith(RTT_ROOT.lower()) :
                objpath = ''.join('kernel'+objpath[len(RTT_ROOT):])
            else :
                objpath = ''.join('bsp'+objpath[len(project_path):])
        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(ItemGroup, item_tag)
        File.set('Include', path.decode(fs_encoding))
        if file_type == 'C' :
            ObjName = SubElement(File, 'ObjectFileName')
            ObjName.text = ''.join('$(IntDir)'+objpath+'\\')
开发者ID:onelife,项目名称:rt-thread,代码行数:32,代码来源:vs2012.py

示例5: IARProject

def IARProject(target, script):
    project_path = os.path.dirname(os.path.abspath(target))

    tree = etree.parse('template.ewp')
    root = tree.getroot()

    out = file(target, 'wb')

    CPPPATH = []
    CPPDEFINES = []
    LINKFLAGS = ''
    CCFLAGS = ''
    
    # add group
    for group in script:
        IARAddGroup(root, group['name'], group['src'], project_path)

        # get each include path
        if group.has_key('CPPPATH') and group['CPPPATH']:
            CPPPATH += group['CPPPATH']
        
        # get each group's definitions
        if group.has_key('CPPDEFINES') and group['CPPDEFINES']:
            CPPDEFINES += group['CPPDEFINES']
        
        # get each group's link flags
        if group.has_key('LINKFLAGS') and group['LINKFLAGS']:
            LINKFLAGS += group['LINKFLAGS']
    
    # make relative path 
    paths = set()
    for path in CPPPATH:
        inc = _make_path_relative(project_path, os.path.normpath(path))
        paths.add(inc) #.replace('\\', '/')
    
    # setting options
    options = tree.findall('configuration/settings/data/option')
    for option in options:
        # print option.text
        name = option.find('name')
        
        if name.text == 'CCIncludePath2' or name.text == 'newCCIncludePaths':
            for path in paths:
                state = SubElement(option, 'state')
                if os.path.isabs(path):
                    state.text = path
                else:
                    state.text = '$PROJ_DIR$\\' + path

        if name.text == 'CCDefines':
            for define in CPPDEFINES:
                state = SubElement(option, 'state')
                state.text = define
    
    xml_indent(root)
    out.write(etree.tostring(root, encoding='utf-8'))
    out.close()
    
    IARWorkspace(target)
开发者ID:AdrianHuang,项目名称:rt-thread-for-vmm,代码行数:59,代码来源:iar.py

示例6: VS_AddHeadFilesGroup

def VS_AddHeadFilesGroup(program, elem, project_path):
    building.source_ext = []
    building.source_ext = ["h"]
    for item in program:
        building.walk_children(item)
    building.source_list.sort()
    # print building.source_list

    for f in building.source_list:
        path = _make_path_relative(project_path, f)
        File = SubElement(elem, "File")
        File.set("RelativePath", path.decode(fs_encoding))
开发者ID:yygg,项目名称:rt-thread,代码行数:12,代码来源:vs.py

示例7: CB_AddHeadFiles

def CB_AddHeadFiles(program, elem, project_path):
    building.source_ext = []
    building.source_ext = ["h"]
    for item in program:
        building.walk_children(item)    
    building.source_list.sort()
    # print building.source_list
    
    for f in building.source_list:
        path = _make_path_relative(project_path, f)
        Unit = SubElement(elem, 'Unit')
        Unit.set('filename', path.decode(fs_encoding))
开发者ID:634351070,项目名称:rt-thread,代码行数:12,代码来源:codeblocks.py

示例8: CB_AddCFiles

def CB_AddCFiles(ProjectFiles, parent, gname, files, project_path):
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        Unit = SubElement(parent, 'Unit')
        Unit.set('filename', path.decode(fs_encoding))
        Option = SubElement(Unit, 'Option')
        Option.set('compilerVar', "CC")
开发者ID:634351070,项目名称:rt-thread,代码行数:13,代码来源:codeblocks.py

示例9: VS2012_AddGroup

def VS2012_AddGroup(parent, group_name, files, project_path):
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        ClCompile = SubElement(parent, 'ClCompile')
        ClCompile.set('Include', path.decode(fs_encoding))

        Filter = SubElement(ClCompile, 'Filter')
        Filter.text='Source Files\\'+group_name
开发者ID:BernardXiong,项目名称:stk3700,代码行数:14,代码来源:vs2012.py

示例10: VS_AddGroup

def VS_AddGroup(ProjectFiles, parent, name, files, project_path):
    Filter = SubElement(parent, "Filter")
    Filter.set("Name", name)  # set group name to group

    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(Filter, "File")
        File.set("RelativePath", path.decode(fs_encoding))
开发者ID:yygg,项目名称:rt-thread,代码行数:14,代码来源:vs.py

示例11: VS_add_ItemGroup

def VS_add_ItemGroup(parent, file_type, files, project_path):
    file_dict = {'C':"ClCompile", 'H':'ClInclude'}
    item_tag = file_dict[file_type]

    ItemGroup = SubElement(parent, 'ItemGroup')
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(ItemGroup, item_tag)
        File.set('Include', path.decode(fs_encoding))
开发者ID:BernardXiong,项目名称:stk3700,代码行数:15,代码来源:vs2012.py

示例12: VS_AddGroup

def VS_AddGroup(ProjectFiles, parent, name, files, libs, project_path):
    Filter = SubElement(parent, 'Filter')
    Filter.set('Name', name) #set group name to group

    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(Filter, 'File')
        File.set('RelativePath', path.decode(fs_encoding))

    for lib in libs:
        name = os.path.basename(lib)
        path = os.path.dirname(lib)

        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(Filter, 'File')
        File.set('RelativePath', path.decode(fs_encoding))
开发者ID:gastonfeng,项目名称:rt-thread,代码行数:24,代码来源:vs.py

示例13: IARAddGroup

def IARAddGroup(parent, name, files, project_path):
    group = SubElement(parent, 'group')
    group_name = SubElement(group, 'name')
    group_name.text = name
    
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)
    
        basename = os.path.basename(path)
        path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)
        
        file = SubElement(group, 'file')
        file_name = SubElement(file, 'name')
        file_name.text = ('$PROJ_DIR$\\' + path).decode(fs_encoding)
开发者ID:ADTL,项目名称:realtouch-stm32f4,代码行数:17,代码来源:iar.py

示例14: VS_add_ItemGroup

def VS_add_ItemGroup(parent, file_type, files, project_path):
    file_dict = {'C':"ClCompile", 'H':'ClInclude'}
    item_tag = file_dict[file_type]

    ItemGroup = SubElement(parent, 'ItemGroup')
    for f in files:
        fn = f.rfile()
        name = fn.name
        path = os.path.dirname(fn.abspath)

        objpath = path = _make_path_relative(project_path, path)
        path = os.path.join(path, name)

        File = SubElement(ItemGroup, item_tag)
        File.set('Include', path.decode(fs_encoding))
        if file_type == 'C' :
            ObjName = SubElement(File, 'ObjectFileName')
            ObjName.text = ''.join('$(IntDir)'+objpath+'\\')
开发者ID:mbgrote,项目名称:rt-thread,代码行数:18,代码来源:vs2012.py

示例15: VS_add_HeadFiles

def VS_add_HeadFiles(program, elem, project_path):
    building.source_ext = []
    building.source_ext = ["h"]
    for item in program:
        building.walk_children(item)    
    building.source_list.sort()
    # print building.source_list
    ItemGroup = SubElement(elem, 'ItemGroup')

    filter_h_ItemGroup = SubElement(filter_project, 'ItemGroup')
    for f in building.source_list:
        path = _make_path_relative(project_path, f)
        File = SubElement(ItemGroup, 'ClInclude')
        File.set('Include', path.decode(fs_encoding))

        # add project.vcxproj.filter
        ClInclude = SubElement(filter_h_ItemGroup, 'ClInclude')
        ClInclude.set('Include', path.decode(fs_encoding))
        Filter = SubElement(ClInclude, 'Filter')
        Filter.text='Header Files'
开发者ID:BernardXiong,项目名称:stk3700,代码行数:20,代码来源:vs2012.py


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