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


Python path.normpath方法代码示例

本文整理汇总了Python中os.path.normpath方法的典型用法代码示例。如果您正苦于以下问题:Python path.normpath方法的具体用法?Python path.normpath怎么用?Python path.normpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os.path的用法示例。


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

示例1: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def __init__(self, senna_path, operations, encoding='utf-8'):
        self._encoding = encoding
        self._path = path.normpath(senna_path) + sep 
        
        # Verifies the existence of the executable on the self._path first    
        #senna_binary_file_1 = self.executable(self._path)
        exe_file_1 = self.executable(self._path)
        if not path.isfile(exe_file_1):
            # Check for the system environment 
            if 'SENNA' in environ:
                #self._path = path.join(environ['SENNA'],'')  
                self._path = path.normpath(environ['SENNA']) + sep 
                exe_file_2 = self.executable(self._path)
                if not path.isfile(exe_file_2):
                    raise OSError("Senna executable expected at %s or %s but not found" % (exe_file_1,exe_file_2))
        
        self.operations = operations 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:19,代码来源:senna.py

示例2: get_appname_from_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def get_appname_from_path(absolute_path):
    absolute_path = op.normpath(absolute_path)
    parts = absolute_path.split(os.path.sep)
    parts.reverse()
    for key in ("apps", "slave-apps", "master-apps"):
        try:
            idx = parts.index(key)
        except ValueError:
            continue
        else:
            try:
                if parts[idx + 1] == "etc":
                    return parts[idx - 1]
            except IndexError:
                pass
            continue
    #return None
    return "-" 
开发者ID:remg427,项目名称:misp42splunk,代码行数:20,代码来源:util.py

示例3: _move

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def _move(self, path):
        if path == self.path:
            return

        files = self.get_marked() or self.get_selected()

        if not isabs(path):
            path = join(self.path, path)
        if not isdir(path):
            sublime.error_message('Not a valid directory: {}'.format(path))
            return

        # Move all items into the target directory.  If the target directory was also selected,
        # ignore it.
        files = self.get_marked() or self.get_selected()
        path = normpath(path)
        for filename in files:
            fqn = normpath(join(self.path, filename))
            if fqn != path:
                shutil.move(fqn, path)
        self.view.run_command('dired_refresh') 
开发者ID:kublaios,项目名称:dired,代码行数:23,代码来源:dired.py

示例4: config_win

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def config_win():

    try:
        import winreg as reg
        key = reg.CreateKey(reg.HKEY_CURRENT_USER, 'SOFTWARE\\Classes\\nzblnk')
        reg.SetValue(key, '', reg.REG_SZ, 'URL:nzblnk')
        reg.SetValueEx(key, 'URL Protocol', 0, reg.REG_SZ, '')
        reg.CloseKey(key)

        key = reg.CreateKey(reg.HKEY_CURRENT_USER, 'SOFTWARE\\Classes\\nzblnk\\shell\\open\\command')
        reg.SetValue(key, '', reg.REG_SZ, '"{0}" "%1"'.format(op.normpath(os.path.abspath(sys.executable))))
        reg.CloseKey(key)

    except (OSError, ImportError):
        print(Col.FAIL + ' FAILED to setup registry link for NZBLNK scheme!' + Col.OFF)
        sleep(wait_time)
        sys.exit(2) 
开发者ID:nzblnk,项目名称:nzb-monkey,代码行数:19,代码来源:nzblnkconfig.py

示例5: vcs_colorized

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def vcs_colorized(self, changed_items):
        '''called on main thread'''
        if not self.view.settings().has('dired_index'):
            return  # view was closed
        modified, untracked = [], []
        files_regions = dict((f, r) for f, r in zip(self.get_all(), self.view.split_by_newlines(Region(0, self.view.size()))))
        colorblind = self.view.settings().get('vcs_color_blind', False)
        offset = 1 if not colorblind else 0
        for fn in changed_items.keys():
            full_fn = normpath(fn)
            r = files_regions.get(full_fn, 0)
            if r:
                icon   = self._get_name_point(r) - 2
                r      = Region(icon, icon + offset)
                status = changed_items[fn]
                if status == 'M':
                    modified.append(r)
                elif status == '?':
                    untracked.append(r)
        if colorblind:
            self.view.add_regions('M', modified, 'item.colorblind.dired', '', MARK_OPTIONS | sublime.DRAW_EMPTY_AS_OVERWRITE)
            self.view.add_regions('?', untracked, 'item.colorblind.dired', '', MARK_OPTIONS | sublime.DRAW_EMPTY)
        else:
            self.view.add_regions('M', modified, 'item.modified.dired', '', MARK_OPTIONS)
            self.view.add_regions('?', untracked, 'item.untracked.dired', '', MARK_OPTIONS) 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:27,代码来源:dired_misc.py

示例6: handle_template

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:27,代码来源:templates.py

示例7: get_source_files

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def get_source_files(src_dir):
    mkdata = parse_makefile_data(join(src_dir, "Makefile"))

    for include in mkdata['includes']:
        _mkdata = parse_makefile_data(normpath(join(src_dir, include)))
        for key, value in _mkdata.iteritems():
            for v in value:
                if v not in mkdata[key]:
                    mkdata[key].append(v)

    sources = []
    lib_root = env.subst("$PLATFORMFW_DIR")
    for obj_file in mkdata['objs']:
        src_file = obj_file[:-1] + "c"
        for search_path in mkdata['vpath']:
            src_path = normpath(join(src_dir, search_path, src_file))
            if isfile(src_path):
                sources.append(join("$BUILD_DIR", "FrameworkLibOpenCM3",
                                    src_path.replace(lib_root + sep, "")))
                break
    return sources 
开发者ID:bq,项目名称:web2board,代码行数:23,代码来源:libopencm3.py

示例8: fix_scheme_in_settings

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def fix_scheme_in_settings(settings_file,current_scheme, new_scheme, regenerate=False):
  """Change the color scheme in the given Settings to a background-corrected one"""
  from os.path import join, normpath, isfile

  settings = load_settings(settings_file)
  settings_scheme = settings.get("color_scheme")
  if current_scheme == settings_scheme:
    new_scheme_path =  join(packages_path(), normpath(new_scheme[len("Packages/"):]))
    if isfile(new_scheme_path) and not regenerate:
      settings.set("color_scheme", new_scheme)
    else:
      generate_scheme_fix(current_scheme, new_scheme_path)
      settings.set("color_scheme", new_scheme)
    save_settings(settings_file)
    return True
  return False 
开发者ID:ggordan,项目名称:GutterColor,代码行数:18,代码来源:gutter_color.py

示例9: preauthChild

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def preauthChild(self, path):
        """
        Use me if C{path} might have slashes in it, but you know they're safe.

        @param path: A relative path (ie, a path not starting with C{"/"})
            which will be interpreted as a child or descendant of this path.
        @type path: L{bytes} or L{unicode}

        @return: The child path.
        @rtype: L{FilePath} with a mode equal to the type of C{path}.
        """
        ourPath = self._getPathAsSameTypeAs(path)

        newpath = abspath(joinpath(ourPath, normpath(path)))
        if not newpath.startswith(ourPath):
            raise InsecurePath("%s is not a child of %s" %
                               (newpath, ourPath))
        return self.clonePath(newpath) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:filepath.py

示例10: update_state

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def update_state(self):
        workdir = ut.truepath(self.workdir_row.edit.text())
        dbname = self.dbname_row.edit.text()
        current_choice = normpath(join(workdir, dbname))
        workdir_exists = ut.checkpath(workdir, verbose=False)
        print('workdir_exists = %r' % (workdir_exists,))
        if workdir_exists:
            if ut.checkpath(current_choice, verbose=False):
                self.current_row.edit.setColorFG((0, 0, 255))
                self.create_but.setText('Open existing database')
            else:
                self.current_row.edit.setColorFG(None)
                self.create_but.setText('Create in workdir')
            self.create_but.setEnabled(True)
        else:
            self.current_row.edit.setColorFG((255, 0, 0))
            self.create_but.setText('Create in workdir')
            self.create_but.setEnabled(False)
        self.current_row.edit.setText(current_choice) 
开发者ID:Erotemic,项目名称:ibeis,代码行数:21,代码来源:guiback.py

示例11: data_sample_pre_save

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def data_sample_pre_save(sender, instance, **kwargs):
    destination_path = path.join(getattr(settings, 'MEDIA_ROOT'), 'datasamples/{0}'.format(instance.pk))
    src_path = normpath(instance.path)

    if path.exists(destination_path):
        raise FileExistsError(f'File exists: {destination_path}')

    # try to make an hard link to keep a free copy of the data
    # if not possible, keep the real path location
    try:
        shutil.copytree(src_path, destination_path, copy_function=link)
    except Exception:
        logger.exception(f'error happened while copying data from {src_path} to {destination_path}')
        shutil.rmtree(destination_path, ignore_errors=True)
        logger.info(f'directory {destination_path} deleted')
    else:
        # override path for getting our hardlink
        instance.path = destination_path 
开发者ID:SubstraFoundation,项目名称:substra-backend,代码行数:20,代码来源:pre_save.py

示例12: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def __init__(self, url):
        super(Song, self).__init__()
        self.__dict__ = self
        for key in TAG_KEYS:
            if key in ['tracknumber', 'discnumber']:
                self[key] = 0
            elif key in ['title', 'artist', 'album']:
                self[key] = "unknown"

        from os.path import abspath, realpath, normpath
        self['url'] = normpath(realpath(abspath(url)))
        self['folder'] = os.path.dirname(self['url'])

        if self.isExisted():
            try:
                self.getTags()
            except Exception, e:
                logger.error(e) 
开发者ID:dragondjf,项目名称:QMusic,代码行数:20,代码来源:song.py

示例13: main

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def main():
    import sys

    # Possibly temp. addons path
    from os.path import join, dirname, normpath
    sys.path.append(normpath(join(dirname(__file__),
                                  "..", "..", "addons", "modules")))
    sys.path.append(join(utils.user_resource('SCRIPTS'),
                         "addons", "modules"))

    # fake module to allow:
    #   from bpy.types import Panel
    sys.modules.update({
        "bpy.app": app,
        "bpy.app.handlers": app.handlers,
        "bpy.app.translations": app.translations,
        "bpy.types": types,
    })

    # Initializes Python classes.
    # (good place to run a profiler or trace).
    utils.load_scripts() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:__init__.py

示例14: is_subdir

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def is_subdir(path, directory):
    """
    Returns true if *path* in a subdirectory of *directory*.
    Both paths must be absolute.

    :arg path: An absolute path.
    :type path: string or bytes
    """
    from os.path import normpath, normcase, sep
    path = normpath(normcase(path))
    directory = normpath(normcase(directory))
    if len(path) > len(directory):
        sep = sep.encode('ascii') if isinstance(directory, bytes) else sep
        if path.startswith(directory.rstrip(sep) + sep):
            return True
    return False 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:path.py

示例15: reduce_dirs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import normpath [as 别名]
def reduce_dirs(dirs):
    """
    Given a sequence of directories, remove duplicates and
    any directories nested in one of the other paths.
    (Useful for recursive path searching).

    :arg dirs: Sequence of directory paths.
    :type dirs: sequence
    :return: A unique list of paths.
    :rtype: list
    """
    dirs = list({_os.path.normpath(_os.path.abspath(d)) for d in dirs})
    dirs.sort(key=lambda d: len(d))
    for i in range(len(dirs) - 1, -1, -1):
        for j in range(i):
            print(i, j)
            if len(dirs[i]) == len(dirs[j]):
                break
            elif is_subdir(dirs[i], dirs[j]):
                del dirs[i]
                break
    return dirs 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:path.py


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