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

Python util.normpath函数代码示例

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

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



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

示例1: pathto

 def pathto(self, f, cwd=None):
     if cwd is None:
         cwd = self.getcwd()
     path = util.pathto(self._root, cwd, f)
     if self._slash:
         return util.normpath(path)
     return path
开发者ID:rybesh,项目名称:mysite-lib,代码行数:7,代码来源:dirstate.py


示例2: __init__

    def __init__(self, root, is_type_editor):
        """
        Args:
            root: path of project root folder
            is_type_editor: bool. see class docstring                
        """
        self.path = util.normpath(os.path.abspath(root))
        self.is_type_editor = is_type_editor        
        self._auto_create_clazz_folder = True
        
        # Must be the first
        self.event_manager = EventManager()        
        self.type_manager = TypeManager()        
        self.fs_manager = FileSystemManager(self, os.path.join(self.path, const.PROJECT_FOLDER_DATA))
        # should after fs_manager
        self.object_manager = ObjectManager(self)
        # should after object_manager
        self.ref_manager = RefManager()        
        
        # self._langauges = ('en', )
        self._default_language = 'en'
        self._translations = {}
        self._verifier = None
        self._loading_errors = AttrVerifyLogger()

        self.tags = set()
        
        self._next_ids = {}  # {clazz_name: next_id}
        self._loaded = False
        self._editor_project = None
开发者ID:TimothyZhang,项目名称:structer,代码行数:30,代码来源:project.py


示例3: tidyprefix

def tidyprefix(dest, kind, prefix):
    '''choose prefix to use for names in archive.  make sure prefix is
    safe for consumers.'''

    if prefix:
        prefix = util.normpath(prefix)
    else:
        if not isinstance(dest, str):
            raise ValueError('dest must be string if no prefix')
        prefix = os.path.basename(dest)
        lower = prefix.lower()
        for sfx in exts.get(kind, []):
            if lower.endswith(sfx):
                prefix = prefix[:-len(sfx)]
                break
    lpfx = os.path.normpath(util.localpath(prefix))
    prefix = util.pconvert(lpfx)
    if not prefix.endswith('/'):
        prefix += '/'
    # Drop the leading '.' path component if present, so Windows can read the
    # zip files (issue4634)
    if prefix.startswith('./'):
        prefix = prefix[2:]
    if prefix.startswith('../') or os.path.isabs(lpfx) or '/../' in prefix:
        raise util.Abort(_('archive prefix contains illegal components'))
    return prefix
开发者ID:pierfort123,项目名称:mercurial,代码行数:26,代码来源:archival.py


示例4: lint_file

    def lint_file(path, kind):
        def import_script(import_path):
            # The user can specify paths using backslashes (such as when
            # linting Windows scripts on a posix environment.
            import_path = import_path.replace('\\', os.sep)
            import_path = os.path.join(os.path.dirname(path), import_path)
            return lint_file(import_path, 'js')
        def _lint_error(*args):
            return lint_error(normpath, *args)

        normpath = util.normpath(path)
        if normpath in lint_cache:
            return lint_cache[normpath]
        print normpath
        contents = util.readfile(path)
        lint_cache[normpath] = _Script()

        script_parts = []
        if kind == 'js':
            script_parts.append((None, contents))
        elif kind == 'html':
            for script in _findhtmlscripts(contents):
                if script['type'] == 'external':
                    other = import_script(script['src'])
                    lint_cache[normpath].importscript(other)
                elif script['type'] == 'inline':
                    script_parts.append((script['pos'], script['contents']))
                else:
                    assert False, 'Invalid internal script type %s' % \
                                  script['type']
        else:
            assert False, 'Unsupported file kind: %s' % kind

        _lint_script_parts(script_parts, lint_cache[normpath], _lint_error, conf, import_script)
        return lint_cache[normpath]
开发者ID:christian-oudard,项目名称:jsl,代码行数:35,代码来源:lint.py


示例5: doTextEdit

    def doTextEdit(self, url, setCursor=False):
        """Process a textedit link and either highlight
           the corresponding source code or set the 
           cursor to it.
        """
        t = textedit.link(url)
        # Only process textedit links
        if not t:
            return False
        filename = util.normpath(t.filename)
        doc = self.document(filename, setCursor)
        if doc:
            cursor = QTextCursor(doc)
            b = doc.findBlockByNumber(t.line - 1)
            p = b.position() + t.column
            cursor.setPosition(p)
            cursors = pointandclick.positions(cursor)
            # Do highlighting if the document is active
            if cursors and doc == self.mainwindow().currentDocument():
                import viewhighlighter

                view = self.mainwindow().currentView()
                viewhighlighter.highlighter(view).highlight(self._highlightFormat, cursors, 2, 0)
            # set the cursor and bring the document to front
            if setCursor:
                mainwindow = self.mainwindow()
                mainwindow.setTextCursor(cursor)
                import widgets.blink

                widgets.blink.Blinker.blink_cursor(mainwindow.currentView())
                self.mainwindow().setCurrentDocument(doc)
                mainwindow.activateWindow()
                mainwindow.currentView().setFocus()
        return True
开发者ID:wbsoft,项目名称:frescobaldi,代码行数:34,代码来源:view.py


示例6: _generate_dependencies

	def _generate_dependencies(self, solution):
		includes = []
		for p in solution.projects:
			abs_project_file = p.project_file
			abs_gyp_file, _ = os.path.splitext(abs_project_file)
			relative_path_to_sln = util.normpath(os.path.relpath(abs_gyp_file, solution.solution_dir))
			includes.append(relative_path_to_sln + ".gyp:" + p.name)
		return includes
开发者ID:kbinani,项目名称:sln2gyp,代码行数:8,代码来源:generator.py


示例7: _generate_proj_include_dirs

	def _generate_proj_include_dirs(self, project, configurations):
		include_dirs = project.compile_options.get_common_value_for_configurations(configurations, 'AdditionalIncludeDirectories')
		if include_dirs != None:
			if len(include_dirs) > 0:
				result = []
				for d in include_dirs:
					result.append(util.normpath(d))
				return result
		return None
开发者ID:kbinani,项目名称:sln2gyp,代码行数:9,代码来源:generator.py


示例8: _normalize

def _normalize(names, default, root, cwd):
    pats = []
    for kind, name in [_patsplit(p, default) for p in names]:
        if kind in ('glob', 'relpath'):
            name = util.canonpath(root, cwd, name)
        elif kind in ('relglob', 'path'):
            name = util.normpath(name)

        pats.append((kind, name))
    return pats
开发者ID:Frostman,项目名称:intellij-community,代码行数:10,代码来源:match.py


示例9: open

def open(ui, url_, data=None):
    u = util.url(url_)
    if u.scheme:
        u.scheme = u.scheme.lower()
        url_, authinfo = u.authinfo()
    else:
        path = util.normpath(os.path.abspath(url_))
        url_ = 'file://' + urllib.pathname2url(path)
        authinfo = None
    return opener(ui, authinfo).open(url_, data)
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:10,代码来源:url.py


示例10: open

def open(ui, url, data=None):
    scheme = None
    m = scheme_re.search(url)
    if m:
        scheme = m.group(1).lower()
    if not scheme:
        path = util.normpath(os.path.abspath(url))
        url = 'file://' + urllib.pathname2url(path)
        authinfo = None
    else:
        url, authinfo = getauthinfo(url)
    return opener(ui, authinfo).open(url, data)
开发者ID:Frostman,项目名称:intellij-community,代码行数:12,代码来源:url.py


示例11: _generate_proj_dependencies

	def _generate_proj_dependencies(self, solution, project):
		dependencies = []
		for dep_guid in project.dependencies:
			for p in solution.projects:
				if p.guid == project.guid:
					continue
				if p.guid == dep_guid:
					dep_proj_path = p.project_file
					dep_gyp_name, ext = os.path.splitext(dep_proj_path)
					dep_gyp_path = dep_gyp_name + '.gyp'
					rel_gyp_path = util.normpath(os.path.relpath(dep_gyp_path, project.project_dir))
					dependencies.append(rel_gyp_path + ":" + p.name)
		return dependencies
开发者ID:kbinani,项目名称:sln2gyp,代码行数:13,代码来源:generator.py


示例12: dragElement

 def dragElement(self, url):
     t = textedit.link(url)
     # Only process textedit links
     if not t:
         return False
     filename = util.normpath(t.filename)
     doc = self.document(filename, True)
     if doc:
         cursor = QTextCursor(doc)
         b = doc.findBlockByNumber(t.line - 1)
         p = b.position() + t.column
         cursor.setPosition(p)
     self.emitCursor(cursor)
开发者ID:wbsoft,项目名称:frescobaldi,代码行数:13,代码来源:view.py


示例13: cursor

    def cursor(self, link, load=False):
        """Returns the destination of a link as a QTextCursor of the destination document.

        If load (defaulting to False) is True, the document is loaded if it is not yet loaded.
        Returns None if the url was not valid or the document could not be loaded.

        """
        import popplerqt5
        if not isinstance(link, popplerqt5.Poppler.LinkBrowse) or not link.url():
            return
        t = textedit.link(link.url())
        if t:
            filename = util.normpath(t.filename)
            return super(Links, self).cursor(filename, t.line, t.column, load)
开发者ID:brownian,项目名称:frescobaldi,代码行数:14,代码来源:pointandclick.py


示例14: slotJobOutput

 def slotJobOutput(self, message, type):
     """Called whenever the job has output.
     
     The output is checked for error messages that contain
     a filename:line:column expression.
     
     """
     if type == job.STDERR:
         enc = sys.getfilesystemencoding()
         for m in message_re.finditer(message.encode('latin1')):
             url = m.group(1).decode(enc)
             filename = m.group(2).decode(enc)
             filename = util.normpath(filename)
             line, column = int(m.group(3)), int(m.group(4) or 0)
             self._refs[url] = Reference(filename, line, column)
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:15,代码来源:errors.py


示例15: loadpath

def loadpath(path, module_name):
    module_name = module_name.replace('.', '_')
    path = util.normpath(util.expandpath(path))
    if os.path.isdir(path):
        # module/__init__.py style
        d, f = os.path.split(path)
        fd, fpath, desc = imp.find_module(f, [d])
        return imp.load_module(module_name, fd, fpath, desc)
    else:
        try:
            return imp.load_source(module_name, path)
        except IOError, exc:
            if not exc.filename:
                exc.filename = path # python does not fill this
            raise
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:15,代码来源:extensions.py


示例16: readfilename

def readfilename(match):
    """Returns the filename from the match object resulting from textedit_match."""
    fname = match.group(1)
    lat1 = fname.encode('latin1')
    try:
        lat1 = percentcoding.decode(lat1)
    except ValueError:
        pass
    try:
        fname = lat1.decode(sys.getfilesystemencoding())
    except UnicodeError:
        pass
    # normalize path (although this might change a path if it contains
    # symlinks followed by '/../' !
    fname = util.normpath(fname)
    return fname
开发者ID:willingc,项目名称:frescobaldi,代码行数:16,代码来源:pointandclick.py


示例17: links

def links(document):
    try:
        return _cache[document]
    except KeyError:
        l = _cache[document] = Links()
        with l:
            import popplerqt5
            with qpopplerview.lock(document):
                for num in range(document.numPages()):
                    page = document.page(num)
                    for link in page.links():
                        if isinstance(link, popplerqt5.Poppler.LinkBrowse):
                            t = textedit.link(link.url())
                            if t:
                                filename = util.normpath(t.filename)
                                l.add_link(filename, t.line, t.column, (num, link.linkArea()))
        return l
开发者ID:brownian,项目名称:frescobaldi,代码行数:17,代码来源:pointandclick.py


示例18: _normalize

def _normalize(names, default, root, cwd, auditor):
    pats = []
    for kind, name in [_patsplit(p, default) for p in names]:
        if kind in ('glob', 'relpath'):
            name = util.canonpath(root, cwd, name, auditor)
        elif kind in ('relglob', 'path'):
            name = util.normpath(name)
        elif kind in ('listfile', 'listfile0'):
            delimiter = kind == 'listfile0' and '\0' or '\n'
            try:
                files = open(name, 'r').read().split(delimiter)
                files = [f for f in files if f]
            except EnvironmentError:
                raise util.Abort(_("unable to read file list (%s)") % name)
            pats += _normalize(files, default, root, cwd, auditor)
            continue

        pats.append((kind, name))
    return pats
开发者ID:MezzLabs,项目名称:mercurial,代码行数:19,代码来源:match.py


示例19: add_manage_subparser

def add_manage_subparser(subparsers):
  p = subparsers.add_parser('manage',
      help=('copy a file to the dotpary directory, replace the original '
          'with a link, and add the new file to the repo (if possible)'))

  add_debug_argument(p)

  p.add_argument(
    'path',
    type=lambda p: util.normpath(p, absolute=True),
    help='the path to the source file to manage'
  )

  p.add_argument(
    '-f', '--force',
    action='store_true',
    help='overwrite any existing files in the dotparty directory'
  )

  p.set_defaults(command=dotparty.manage)
开发者ID:jasontbradshaw,项目名称:dotparty,代码行数:20,代码来源:arguments.py


示例20: load_config

def load_config(user_path=constants.USER_CONFIG_PATH,
    default_path=constants.DEFAULT_CONFIG_PATH):
  '''Load the default dotparty config file, then overlay the user's on top.'''

  # make sure we can load our default config file
  assert os.path.exists(default_path)

  # load the default config
  default_config = {}
  with open(default_path) as f:
    default_config = json.load(f)

  # load the user's config if one exists
  user_config = {}
  if os.path.exists(user_path):
    with open(user_path) as f:
      user_config = json.load(f)

  # build a config of the default values custom-merged with the user's
  config = {}
  config.update(default_config)
  config.update(user_config)

  # use the user's ignored values in addition to, not instead of, ours. we need
  # this because we always need to ignore our own files, and it's cleaner to do
  # so through the normal ignore channel than to write custom checks everywhere.
  if 'ignore' in user_config:
    config['ignore'] = frozenset(default_config['ignore'] + user_config['ignore'])

  # expand globs in the ignored list and root them in the dotparty directory
  config['ignore'] = frozenset(
      util.expand_globs(config['ignore'], root=constants.REPO_DIR))

  # normalize the destination directory
  config['destination'] = util.normpath(config['destination'])

  # TODO: handle packages

  return config
开发者ID:jasontbradshaw,项目名称:dotparty,代码行数:39,代码来源:config.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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