本文整理汇总了Python中util.normpath函数的典型用法代码示例。如果您正苦于以下问题:Python normpath函数的具体用法?Python normpath怎么用?Python normpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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]
示例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
示例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
示例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
示例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
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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