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

Python posixpath.normpath函数代码示例

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

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



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

示例1: _converter

    def _converter(self, url):
        if url.startswith(('#', 'data:')):
            return url
        elif url.startswith(SCHEMES):
            return self.add_suffix(url)
        full_url = posixpath.normpath('/'.join([str(self.directory_name),
                                                url]))

        # custom
        partial_url = full_url[len(self.url) + 1:]
        if not os.path.isfile(
                os.path.join(
                    django_settings.STATIC_ROOT, partial_url)):
            dir_name = '/'.join((
                self.url,
                os.path.dirname(self.path)[len('/'.join([
                    django_settings.PIMPMYTHEME_FOLDER_NAME,
                    django_settings.SETTINGS_MODULE.split('.')[0]])) + 1:]))
            full_url = posixpath.normpath('/'.join([str(dir_name), url]))
        # end custom

        if self.has_scheme:
            full_url = "%s%s" % (self.protocol, full_url)
        full_url = self.add_suffix(full_url)
        return self.post_process_url(full_url)
开发者ID:novafloss,项目名称:django-pimpmytheme,代码行数:25,代码来源:filters.py


示例2: open_how_to

def open_how_to():
    failed_list = []
    bash = ''
    if (get_os_name() == "Windows"):
      bash = 'bash ';

    for lang in languages:     
        path = _base_path + lang['lang']
        how_to_list = glob.glob((path + '//' + "HowTo*"))
        for how_to in how_to_list:
            print "*" * 70
            build_sh = posixpath.normpath("%s/build.sh" % how_to)
            build_sh = build_sh.replace("\\", "/")
            run_sh = posixpath.normpath("%s/run.sh" % how_to)
            run_sh = run_sh.replace("\\", "/")
            print " - Building %s" % build_sh #os.path.basename(how_to)
            if subprocess.call("%s./%s" % (bash, build_sh)) == 0:
                print "     - Build succeeded"
                # print " - Running %s " % run_sh #os.path.basename(how_to)
                # print "     - ", "%s./%s" % (bash, run_sh)
                # subprocess.call("%s./%s" % (bash, run_sh))
            else:
                print "     - Build failed."
                print "     - Removing %s" %how_to
                failed_list.append((os.path.basename(how_to), lang['lang']))
                shutil.rmtree(how_to)
    print '*' * 70
    print ' - Failed builds:'
    for name, lang in failed_list:
        print '     - %s : %s' %(lang, name)
    print '*' * 70
开发者ID:Aloz1,项目名称:swingame,代码行数:31,代码来源:test_how_tos.py


示例3: compile_templates

def compile_templates(root, output, minify, input_encoding='utf-8', watch=True):
    """Compile all templates in root or root's subfolders."""
    root = posixpath.normpath(root)
    root_len = len(root)
    output = posixpath.normpath(output)
    for dirpath, dirnames, filenames in os.walk(root):
        dirpath = posixpath.normpath(dirpath)
        if posixpath.basename(dirpath).startswith('.'): continue
        filenames = [f for f in filenames if not f.startswith('.') and not f.endswith('~') and not f.endswith('.py') and not f.endswith('.pyc')]
        outdir = posixpath.join(output , dirpath[root_len:])
        if not posixpath.exists(outdir):
            os.makedirs(outdir)
        if not posixpath.exists(posixpath.join(outdir, '__init__.py')):
            out = open(posixpath.join(outdir, '__init__.py'), 'w')
            out.close()
        for f in filenames:
            path = posixpath.join(dirpath, f).replace('\\','/')
            outfile = posixpath.join(outdir, f.replace('.','_')+'.py')
            filemtime = os.stat(path)[stat.ST_MTIME]
            if not exists(outfile) or os.stat(outfile)[stat.ST_MTIME] < filemtime:
                uri = path[root_len+1:]
                print 'compiling', uri
                text = file(path).read()
                if minify:
                    text = minify_js_in_html(uri, text)
                t = mako.template.Template(text=text, filename=path, uri=uri, input_encoding=input_encoding)
                out = open(outfile, 'w')
                out.write( t.code)
                out.close()
        if watch:
            watch_folder_for_changes(dirpath, minify)
开发者ID:dound,项目名称:CraigNotes,代码行数:31,代码来源:manage.py


示例4: normalizeUrl

 def normalizeUrl(self, url, base=None):
     if url and not (url.startswith('http://') or os.path.isabs(url)):
         if base is not None and not base.startswith('http:') and '%' in url:
             url = unquote(url)
         if base:
             if base.startswith("http://"):
                 prot, sep, path = base.partition("://")
                 normedPath = prot + sep + posixpath.normpath(os.path.dirname(path) + "/" + url)
             else:
                 if '%' in base:
                     base = unquote(base)
                 normedPath = os.path.normpath(os.path.join(os.path.dirname(base),url))
         else:
             normedPath = url
         if normedPath.startswith("file://"): normedPath = normedPath[7:]
         elif normedPath.startswith("file:\\"): normedPath = normedPath[6:]
         
         # no base, not normalized, must be relative to current working directory
         if base is None and not os.path.isabs(url): 
             normedPath = os.path.abspath(normedPath)
     else:
         normedPath = url
     
     if normedPath:
         if normedPath.startswith('http://'):
             pathpart = normedPath[7:].replace('\\','/')
             endingSep = '/' if pathpart[-1] == '/' else ''  # normpath drops ending directory separator
             return "http://" + posixpath.normpath(pathpart) + endingSep
         normedPath = os.path.normpath(normedPath)
         if normedPath.startswith(self.cacheDir):
             normedPath = self.cacheFilepathToUrl(normedPath)
     return normedPath
开发者ID:fukkun,项目名称:Arelle,代码行数:32,代码来源:WebCache.py


示例5: remove_backslashes_and_dotdots

def remove_backslashes_and_dotdots(directory):
    """
    Walk a directory and rename the files if their names contain backslashes.
    Return a list of errors if any.
    """
    if on_linux:
        directory = path_to_bytes(directory)
    errors = []
    for top, _, files in os.walk(directory):
        for filename in files:
            if not (WIN_PATH_SEP in filename or DOTDOT in filename):
                continue
            try:
                new_path = fileutils.as_posixpath(filename)
                new_path = new_path.strip(POSIX_PATH_SEP)
                new_path = posixpath.normpath(new_path)
                new_path = new_path.replace(DOTDOT, POSIX_PATH_SEP)
                new_path = new_path.strip(POSIX_PATH_SEP)
                new_path = posixpath.normpath(new_path)
                segments = new_path.split(POSIX_PATH_SEP)
                directory = os.path.join(top, *segments[:-1])
                fileutils.create_dir(directory)
                shutil.move(os.path.join(top, filename), os.path.join(top, *segments))
            except Exception:
                errors.append(os.path.join(top, filename))
    return errors
开发者ID:ocabrisses,项目名称:scancode-toolkit,代码行数:26,代码来源:__init__.py


示例6: update_config_file

def update_config_file(dryrun=False):
    for site, site_config in config.sites.items():
        redis_processes = [
            (x, site_config.processes[x]) for x in site_config.processes if site_config.processes[x]["type"] == "redis"
        ]
        template_path = site_config["redis"]["template"]
        print redis_processes
        for process_name, process in redis_processes:
            working_directoy = posixpath.normpath(posixpath.join(env.path, "..", "data", "redis", process_name))
            log_directory = posixpath.normpath(posixpath.join(env.path, "..", "log", "redis"))
            run("mkdir -p " + working_directoy)
            run("mkdir -p " + log_directory)
            context_dict = site_config
            context_dict.update(
                {
                    "site": site,
                    "working_directory": working_directoy,
                    "log_directory": log_directory,
                    "process_name": process_name,
                    "socket": process["socket"],
                }
            )
            path = posixpath.abspath(
                posixpath.join(site_config["deployment"]["path"], "..", "config", process_name + ".conf")
            )
            output = render_template(template_path, context_dict)
            if dryrun:
                print path + ":"
                print output
            else:
                put(StringIO.StringIO(output), path)
开发者ID:justzx2011,项目名称:dploi-fabric,代码行数:31,代码来源:redis.py


示例7: __make_urls

 def __make_urls(self, repoline):
     """The same as above, but only for one line"""
     match = re.match(r"(?P<repo_type>deb|deb-src)\s+(?P<base_url>[\S]+?)/?\s+((?P<simple_repo>[\S]*?/)|(?P<repo>\S*?[^/\s])(?:\s+(?P<sections>[^/]+?)))\s*$", repoline)
     if not match:
         raise AptRepoException("Unable to parse: %s" % repoline)
    
     url_bins = []
     url_srcs = []
     repo_type = match.group("repo_type")
     if match.group("simple_repo"):
         if repo_type == "deb":
             __path = posixpath.normpath(posixpath.join("./" + match.group("simple_repo"), "Packages"))
             url_bins = [ (posixpath.join(match.group("base_url"), __path), match.group("simple_repo"), '') ]
         elif repo_type == "deb-src":
             __path = posixpath.normpath(posixpath.join("./" + match.group("simple_repo"), "Sources"))
             url_srcs = [ (posixpath.join(match.group("base_url"), __path), match.group("simple_repo"), '' ) ]
         else:
             raise AptRepoException("Unknown repository type: %s" % repo_type)
     else:
         if repo_type == "deb":
             for item in re.split("\s+", match.group("sections")):
                 for arch in self._arch:
                     url_bins.append( (posixpath.join(match.group("base_url"), "dists", match.group("repo"), item, "binary-%s/Packages" % arch), match.group("repo"), item))
         elif repo_type == "deb-src":
             for item in match.group("sections").split():
                 url_srcs.append( (posixpath.join(match.group("base_url"), "dists", match.group("repo"), item, "source/Sources"), match.group("repo"), item))
         else:
             raise AptRepoException("Unknown repository type: %s" % repo_type)
     return (match.group("base_url"), url_srcs, url_bins)
开发者ID:excid3,项目名称:python-minideblib,代码行数:29,代码来源:AptRepoClient.py


示例8: download_hash_list

def download_hash_list(config, config_filename, server):
    """
	Downloads file with indexes of file found in remote vault and return this list
	@param config: configparser object
	@param server: easywebdav object
	"""
    config.read(config_filename)
    save_loc = "."
    rem_list = config.get("RemoteFolders", "list_dir")
    # the file should given this code be called checksums.txt, @todo: smarter
    # remote = always posix
    remote_checksumfile = posixpath.normpath(posixpath.join(rem_list, "checksums.txt"))
    local_checksumfile = path.join(save_loc, "checksums.txt")
    # local can be 'nt' or 'posix', let's normalise stuff
    if myos == "nt":
        local_checksumfile = ntpath.normpath(local_checksumfile)
    elif myos == "posix":
        local_checksumfile = posixpath.normpath(local_checksumfile)
    server.download(remote_checksumfile, local_checksumfile)
    # curr_file = open(path.join(save_loc,'hashlist.txt'))
    with open(local_checksumfile, "r") as curr_file:
        download_list = curr_file.readlines()
        if DEBUG:
            print(download_list)
    download_list = [i.split() for i in download_list if not i[0] == "#"]  # remove comments from list and split string
    md5_list = [i for i in download_list if "md" in i[0]]
    sha256_list = [i for i in download_list if "sha" in i[0]]
    return download_list, md5_list, sha256_list
开发者ID:UtrechtUniversity,项目名称:Labdata_cleanup,代码行数:28,代码来源:clean_data.py


示例9: handle

	def handle(self):
		self.data = self.request.recv(1024).strip()
		request_list = self.data.split()
		path=posixpath.normpath(request_list[1])
		path=path[1:];
		if path == '':
			path = 'index.html'
		if os.path.isdir(path):
			path = path + '/index.html'
		path=posixpath.normpath(path)
		print path
		if  os.access(path, os.R_OK) is False:
			self.request.sendall("HTTP/1.1 404 NOT FOUND\r\n")
			self.send_header('Date', self.date_time_string())
			self.send_header('Content-Type',"text/plain; charset=UTF-8")
			self.send_header('Connection','closed')
			self.end_header()
			self.request.sendall(DEFAULT_ERROR_MESSAGE)
		if os.access(path, os.R_OK) is True:
			name,extend = os.path.splitext(path)
			try:
				with open(path,'r') as f:
					buffer = f.read()
					self.request.sendall("HTTP/1.1 200 OK\r\n")
					self.send_header('Date', self.date_time_string())
					self.send_header('Content-Type',"text/%s"%(extend[1:]))
					self.send_header('Connection','closed')
					self.end_header()
					self.request.sendall(buffer)
			except IOError as e:
				print "I/O error({0}): {1}".format(e.errno, e.strerror)
		print("Got a request of: %s\n" % self.data)
开发者ID:dyf102,项目名称:CMPUT404-assignment-webserver,代码行数:32,代码来源:server.py


示例10: locate_imported_file

    def locate_imported_file(self, source_dir, import_path):
        """ Locate the imported file in the source directory.
            Return the path to the imported file relative to STATIC_ROOT

        :param source_dir: source directory
        :type source_dir: str
        :param import_path: path to the imported file
        :type import_path: str
        :returns: str

        """
        if not import_path.endswith(self.EXTENSION):
            import_path += self.EXTENSION
        path = posixpath.normpath(posixpath.join(source_dir, import_path))

        try:
            self.get_full_source_path(path)
            return path
        except ValueError:
            pass

        filename = posixpath.basename(import_path)
        if filename[0] != "_":
            path = posixpath.normpath(posixpath.join(
                source_dir,
                posixpath.dirname(import_path),
                "_" + filename,
            ))

        try:
            self.get_full_source_path(path)
            return path
        except ValueError:
            pass
开发者ID:artas90,项目名称:django-static-precompiler,代码行数:34,代码来源:scss.py


示例11: update_config_file

def update_config_file(dryrun=False):
    for site, site_config in config.sites.items():
        redis_processes = [(x, site_config.processes[x]) for x in site_config.processes if site_config.processes[x]["type"] == "redis"]
        template_path = site_config['redis']['template']
        print redis_processes
        for process_name, process in redis_processes:
            working_directoy = posixpath.normpath(posixpath.join(env.path, '..', 'data', 'redis', process_name))
            log_directory = posixpath.normpath(posixpath.join(site_config['deployment']['logdir'], 'log', 'redis'))
            run('mkdir -p ' + working_directoy)
            run('mkdir -p ' + log_directory)
            context_dict = site_config
            context_dict.update({
                'site': site,
                'working_directory': working_directoy,
                'log_directory': log_directory,
                'process_name': process_name,
                'socket': process['socket'],
            })
            path = posixpath.abspath(posixpath.join(site_config['deployment']['path'], '..', 'config', process_name + '.conf'))
            output = render_template(template_path, context_dict)
            if dryrun:
                print path + ":"
                print output
            else:
                put(StringIO.StringIO(output), path)
开发者ID:baiyunping333,项目名称:dploi-fabric,代码行数:25,代码来源:redis.py


示例12: execute

    def execute(self):
        productionLocation = self.productionDetails[indexer.INDEX_PRODUCTION_LOCATION]
        fileLocation = self.fileDetails[indexer.INDEX_FILE_LOCATION]
        fileLocation = os.path.join(productionLocation, fileLocation)
        subDirs = fileLocation.replace(self.sourceDirectory, self.targetDirectory, 1)
        fileLocationDir = os.path.dirname(subDirs)
        absRefLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], subDirs)))
        
        absNewLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], self.referenceFileDetails[indexer.INDEX_FILE_LOCATION])))
        newpath = "//"+_relpath(absNewLoc, fileLocationDir)
        handle = blendfile.openBlendFile(fileLocation, 'r+b')
        for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
            
            relPath = libraryblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absNewLoc:
                libraryblock.Set("name", newpath)

        for imageblock in handle.FindBlendFileBlocksWithCode("IM"):
            
            relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
            absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
            normPath = os.path.normpath(absPath)
            if normPath==absNewLoc:
                imageblock.Set("name", newpath)
            
        handle.close()
开发者ID:JenevanStudios,项目名称:blender-aid,代码行数:28,代码来源:servicerefactor.py


示例13: translate_path

    def translate_path(self, path):
        """Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        """
        try:
            path = posixpath.normpath(urllib.unquote(path))
            words = path.split('/')
            words = filter(None, words)
            path = os.getcwd()
            for word in words:
                drive, word = os.path.splitdrive(word)
                head, word = os.path.split(word)
                if word in (os.curdir, os.pardir): continue
                path = os.path.join(path, word)
            return path
        except Exception, e:
           self.send_error(403, e)
           path = posixpath.normpath(urllib.unquote(path))
           words = path.split('/')
           words = filter(None, words)
           path = os.getcwd()
           for word in words:
               drive, word = os.path.splitdrive(word)
               head, word = os.path.split(word)
               if word in (os.curdir, os.pardir): continue
               path = os.path.join(path, word)
           return path.encode("utf-8")
开发者ID:AmarKalabic,项目名称:Xplorer,代码行数:31,代码来源:main.py


示例14: __call__

    def __call__(self, req):
        #if os.path.normpath("/" + req.path_info) == "/":
        #    return(base.ec2_md_print(base.VERSIONS + ["latest"]))

        path = req.path_info
        if path == "" or path[0] != "/":
            path = posixpath.normpath("/" + path)
        else:
            path = posixpath.normpath(path)

        path_tokens = path.split('/')[1:]

        if path_tokens[0] not in ("ip", "help"):
            if path_tokens[0] == "":
                # request for /
                #path_tokens = ["ip"]
                #TODO
                raise webob.exc.HTTPNotFound()
        elif path_tokens[0] == u'ip' and path_tokens[1]:
            data = self.check_ipv4(path_tokens[1])
        else:
            #TODO
            raise webob.exc.HTTPNotFound()

        return Response(json.dumps(data), content_type='application/json')
开发者ID:brk0v,项目名称:nova-viper,代码行数:25,代码来源:handler.py


示例15: _abssource

def _abssource(repo, push=False, abort=True):
    """return pull/push path of repo - either based on parent repo .hgsub info
    or on the top repo config. Abort or return None if no source found."""
    if hasattr(repo, '_subparent'):
        source = repo._subsource
        if source.startswith('/') or '://' in source:
            return source
        parent = _abssource(repo._subparent, push, abort=False)
        if parent:
            if '://' in parent:
                if parent[-1] == '/':
                    parent = parent[:-1]
                r = urlparse.urlparse(parent + '/' + source)
                r = urlparse.urlunparse((r[0], r[1],
                                         posixpath.normpath(r[2]),
                                         r[3], r[4], r[5]))
                return r
            else: # plain file system path
                return posixpath.normpath(os.path.join(parent, repo._subsource))
    else: # recursion reached top repo
        if hasattr(repo, '_subtoppath'):
            return repo._subtoppath
        if push and repo.ui.config('paths', 'default-push'):
            return repo.ui.config('paths', 'default-push')
        if repo.ui.config('paths', 'default'):
            return repo.ui.config('paths', 'default')
    if abort:
        raise util.Abort(_("default path for subrepository %s not found") %
            reporelpath(repo))
开发者ID:helloandre,项目名称:cr48,代码行数:29,代码来源:subrepo.py


示例16: report_path

 def report_path(self, path):
     new_path = path.replace(PathConstants.PACKAGE_BINARY, "${PROJECT_BUILD_DIR}")
     new_path = new_path.replace(PathConstants.CATKIN_DEVEL, "${CATKIN_DEVEL_PREFIX}")
     new_path = new_path.replace(PathConstants.CATKIN_INSTALL, "${CATKIN_INSTALL_PREFIX}")
     if new_path.startswith(PathConstants.PACKAGE_SOURCE):
         return posixpath.normpath(path[len(PathConstants.PACKAGE_SOURCE) + 1:])
     return posixpath.normpath(new_path)
开发者ID:fkie,项目名称:catkin_lint,代码行数:7,代码来源:linter.py


示例17: lookup

    def lookup(self, path):
        if path == "" or path[0] != "/":
            path = posixpath.normpath("/" + path)
        else:
            path = posixpath.normpath(path)

        # fix up requests, prepending /ec2 to anything that does not match
        path_tokens = path.split('/')[1:]
        if path_tokens[0] not in ("ec2", "openstack"):
            if path_tokens[0] == "":
                # request for /
                path_tokens = ["ec2"]
            else:
                path_tokens = ["ec2"] + path_tokens
            path = "/" + "/".join(path_tokens)

        # all values of 'path' input starts with '/' and have no trailing /

        # specifically handle the top level request
        if len(path_tokens) == 1:
            if path_tokens[0] == "openstack":
                versions = OPENSTACK_VERSIONS + ["latest"]
            else:
                versions = VERSIONS + ["latest"]
            return versions

        try:
            if path_tokens[0] == "openstack":
                data = self.get_openstack_item(path_tokens[1:])
            else:
                data = self.get_ec2_item(path_tokens[1:])
        except (InvalidMetadataVersion, KeyError):
            raise InvalidMetadataPath(path)

        return data
开发者ID:digantasahoo,项目名称:nova,代码行数:35,代码来源:base.py


示例18: normalizeUrl

 def normalizeUrl(self, url, base=None):
     if url and not (isHttpUrl(url) or os.path.isabs(url)):
         if base is not None and not isHttpUrl(base) and u'%' in url:
             url = unquote(url)
         if base:
             if isHttpUrl(base):
                 scheme, sep, path = base.partition(u"://")
                 normedPath = scheme + sep + posixpath.normpath(os.path.dirname(path) + u"/" + url)
             else:
                 if u'%' in base:
                     base = unquote(base)
                 normedPath = os.path.normpath(os.path.join(os.path.dirname(base),url))
         else: # includes base == '' (for forcing relative path)
             normedPath = url
         if normedPath.startswith(u"file://"): normedPath = normedPath[7:]
         elif normedPath.startswith(u"file:\\"): normedPath = normedPath[6:]
         
         # no base, not normalized, must be relative to current working directory
         if base is None and not os.path.isabs(url): 
             normedPath = os.path.abspath(normedPath)
     else:
         normedPath = url
     
     if normedPath:
         if isHttpUrl(normedPath):
             scheme, sep, pathpart = normedPath.partition(u"://")
             pathpart = pathpart.replace(u'\\',u'/')
             endingSep = u'/' if pathpart[-1] == u'/' else u''  # normpath drops ending directory separator
             return scheme + u"://" + posixpath.normpath(pathpart) + endingSep
         normedPath = os.path.normpath(normedPath)
         if normedPath.startswith(self.cacheDir):
             normedPath = self.cacheFilepathToUrl(normedPath)
     return normedPath
开发者ID:sternshus,项目名称:not_arelle2.7,代码行数:33,代码来源:WebCache.py


示例19: rewrite_file

def rewrite_file(filename):
    with open(filename) as f:
        old_file = f.read().splitlines()

    new_file = []
    deferred_imports = {}
    lineiter = iter(old_file)
    for line in lineiter:
        # rewrite from imports
        match = _from_import_re.search(line)
        if match is not None:
            fromlist = line[match.end():]
            new_file.extend(rewrite_from_imports(fromlist,
                                                 match.group(1),
                                                 lineiter))
            continue
        # rewrite attribute access to 'werkzeug'
        def _handle_match(match):
            attr = match.group(2)
            mod = find_module(attr)
            if mod == 'werkzeug':
                return match.group(0)
            deferred_imports.setdefault(mod, []).append(attr)
            return attr
        new_file.append(_direct_usage.sub(_handle_match, line))
    if deferred_imports:
        inject_imports(new_file, deferred_imports)

    for line in difflib.unified_diff(old_file, new_file,
                     posixpath.normpath(posixpath.join('a', filename)),
                     posixpath.normpath(posixpath.join('b', filename)),
                     lineterm=''):
        print line
开发者ID:0x19,项目名称:werkzeug,代码行数:33,代码来源:werkzeug-import-rewrite.py


示例20: get_template

    def get_template(self, uri, module=None):
        """Return a :class:`.Template` object corresponding to the given
        URL.

        Note the "relativeto" argument is not supported here at the moment.

        """

        try:
            if self.filesystem_checks:
                return self._check(uri, self._collection[uri])
            else:
                return self._collection[uri]
        except KeyError:

            if uri[0] == "/" and os.path.isfile(uri):
                return self._load(uri, uri)

            # Case 1: Used with Template.forModule
            if module != None and hasattr(module, "_dir"):
                srcfile = posixpath.normpath(posixpath.join(module._dir, uri))
                if os.path.isfile(srcfile):
                    return self._load(srcfile, srcfile)

            # Case 2: We look through the dirs in the TemplateLookup
            u = re.sub(r"^\/+", "", uri)
            for dir in self.directories:
                srcfile = posixpath.normpath(posixpath.join(dir, u))
                if os.path.isfile(srcfile):
                    return self._load(srcfile, uri)
            else:
                # We did not find anything, so we raise an exception
                raise exceptions.TopLevelLookupException("Can't locate template for uri {0!r}".format(uri))
开发者ID:hennogous,项目名称:indico,代码行数:33,代码来源:TemplateExec.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python posixpath.pjoin函数代码示例发布时间:2022-05-25
下一篇:
Python posixpath.lexists函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap