本文整理汇总了Python中waflib.Utils.split_path方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.split_path方法的具体用法?Python Utils.split_path怎么用?Python Utils.split_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Utils
的用法示例。
在下文中一共展示了Utils.split_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def make_node(self, lst):
"""
Returns or creates a Node object corresponding to the input path without considering the filesystem.
:param lst: relative path
:type lst: string or list of string
:rtype: :py:class:´waflib.Node.Node´
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
cur = self
for x in lst:
if x == '..':
cur = cur.parent or cur
continue
try:
cur = cur.children[x]
except AttributeError:
cur.children = self.dict_class()
except KeyError:
pass
else:
continue
cur = self.__class__(x, cur)
return cur
示例2: find_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_node(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
cur=self
for x in lst:
if x=='..':
cur=cur.parent or cur
continue
try:
ch=cur.children
except AttributeError:
cur.children=self.dict_class()
else:
try:
cur=ch[x]
continue
except KeyError:
pass
cur=self.__class__(x,cur)
if not cur.exists():
cur.evict()
return None
if not cur.exists():
cur.evict()
return None
return cur
示例3: find_dir
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_dir(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
node=self.find_node(lst)
if node and not node.isdir():
return None
return node
示例4: find_or_declare_win32
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_or_declare_win32(self, lst):
# assuming that "find_or_declare" is called before the build starts, remove the calls to os.path.isfile
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
node = self.get_bld().search_node(lst)
if node:
if not node.isfile_cached():
try:
node.parent.mkdir()
except OSError:
pass
return node
self = self.get_src()
node = self.find_node(lst)
if node:
if not node.isfile_cached():
try:
node.parent.mkdir()
except OSError:
pass
return node
node = self.get_bld().make_node(lst)
node.parent.mkdir()
return node
示例5: find_or_declare
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_or_declare(self, lst):
"""
Use this method in the build phase to declare output files.
If 'self' is in build directory, it first tries to return an existing node object.
If no Node is found, it tries to find one in the source directory.
If no Node is found, a new Node object is created in the build directory, and the
intermediate folders are added.
:param lst: relative path
:type lst: string or list of string
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
node = self.get_bld().search_node(lst)
if node:
if not os.path.isfile(node.abspath()):
node.parent.mkdir()
return node
self = self.get_src()
node = self.find_node(lst)
if node:
return node
node = self.get_bld().make_node(lst)
node.parent.mkdir()
return node
示例6: to_src_nodes
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def to_src_nodes(lst):
"""Find file nodes only in src, TaskGen.to_nodes will not work for this since it gives
preference to nodes in build.
"""
if isinstance(lst, Node.Node):
if not lst.is_src():
raise Errors.WafError('buildcopy: node %s is not in src'%lst)
if not os.path.isfile(lst.abspath()):
raise Errors.WafError('buildcopy: Cannot copy directory %s (unsupported action)'%lst)
return lst
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
node = self.bld.path.get_src().search_node(lst)
if node:
if not os.path.isfile(node.abspath()):
raise Errors.WafError('buildcopy: Cannot copy directory %s (unsupported action)'%node)
return node
node = self.bld.path.get_src().find_node(lst)
if node:
if not os.path.isfile(node.abspath()):
raise Errors.WafError('buildcopy: Cannot copy directory %s (unsupported action)'%node)
return node
raise Errors.WafError('buildcopy: File not found in src: %s'%os.path.join(*lst))
示例7: find_resource
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_resource(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
node=self.get_bld().search_node(lst)
if not node:
node=self.get_src().find_node(lst)
if node and node.isdir():
return None
return node
示例8: search_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def search_node(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
cur=self
for x in lst:
if x=='..':
cur=cur.parent or cur
else:
try:
cur=cur.children[x]
except(AttributeError,KeyError):
return None
return cur
示例9: find_or_declare
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_or_declare(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
node=self.get_bld().search_node(lst)
if node:
if not os.path.isfile(node.abspath()):
node.parent.mkdir()
return node
self=self.get_src()
node=self.find_node(lst)
if node:
return node
node=self.get_bld().make_node(lst)
node.parent.mkdir()
return node
示例10: find_dir
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_dir(self, lst):
"""
Searches for a folder on the filesystem (see :py:meth:`waflib.Node.Node.find_node`)
:param lst: relative path
:type lst: string or list of string
:returns: The corresponding Node object or None if there is no such folder
:rtype: :py:class:`waflib.Node.Node`
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
node = self.find_node(lst)
if node and not node.isdir():
return None
return node
示例11: find_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_node(self, lst):
"""
Finds a node on the file system (files or folders), and creates the corresponding Node objects if it exists
:param lst: relative path
:type lst: string or list of string
:returns: The corresponding Node object or None if no entry was found on the filesystem
:rtype: :py:class:´waflib.Node.Node´
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
if lst and lst[0].startswith('\\\\') and not self.parent:
node = self.ctx.root.make_node(lst[0])
node.cache_isdir = True
return node.find_node(lst[1:])
cur = self
for x in lst:
if x == '..':
cur = cur.parent or cur
continue
try:
ch = cur.children
except AttributeError:
cur.children = self.dict_class()
else:
try:
cur = ch[x]
continue
except KeyError:
pass
# optimistic: create the node first then look if it was correct to do so
cur = self.__class__(x, cur)
if not cur.exists():
cur.evict()
return None
if not cur.exists():
cur.evict()
return None
return cur
示例12: make_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def make_node(self,lst):
if isinstance(lst,str):
lst=[x for x in Utils.split_path(lst)if x and x!='.']
cur=self
for x in lst:
if x=='..':
cur=cur.parent or cur
continue
try:
cur=cur.children[x]
except AttributeError:
cur.children=self.dict_class()
except KeyError:
pass
else:
continue
cur=self.__class__(x,cur)
return cur
示例13: find_or_declare
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_or_declare(self, lst):
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
if lst[0].startswith('\\\\'):
if len(lst) < 3:
return None
node = self.ctx.root.make_node(lst[0]).make_node(lst[1])
node.cache_isdir = True
node.parent.cache_isdir = True
ret = node.find_node(lst[2:])
if not ret:
ret = node.make_node(lst[2:])
if not os.path.isfile(ret.abspath()):
ret.parent.mkdir()
return ret
return self.find_or_declare_orig(lst)
示例14: search_node
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def search_node(self, lst):
"""
Returns a Node previously defined in the data structure. The filesystem is not considered.
:param lst: relative path
:type lst: string or list of string
:rtype: :py:class:´waflib.Node.Node´ or None if there is no entry in the Node datastructure
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
cur = self
for x in lst:
if x == '..':
cur = cur.parent or cur
else:
try:
cur = cur.children[x]
except (AttributeError, KeyError):
return None
return cur
示例15: find_resource
# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import split_path [as 别名]
def find_resource(self, lst):
"""
Use this method in the build phase to find source files corresponding to the relative path given.
First it looks up the Node data structure to find any declared Node object in the build directory.
If None is found, it then considers the filesystem in the source directory.
:param lst: relative path
:type lst: string or list of string
:returns: the corresponding Node object or None
:rtype: :py:class:`waflib.Node.Node`
"""
if isinstance(lst, str):
lst = [x for x in Utils.split_path(lst) if x and x != '.']
node = self.get_bld().search_node(lst)
if not node:
node = self.get_src().find_node(lst)
if node and node.isdir():
return None
return node