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


Python path.append方法代码示例

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


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

示例1: get_packages_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def get_packages_path(self):
		""" return the list of path to search packages for depending on client OS and architecture """
		path=[]
		if self.is_windows():
			if self.is_proc_arch_64_bits():
				path.append(os.path.join("packages","windows","amd64"))
			else:
				path.append(os.path.join("packages","windows","x86"))
			path.append(os.path.join("packages","windows","all"))
		elif self.is_unix():
			if self.is_proc_arch_64_bits():
				path.append(os.path.join("packages","linux","amd64"))
			else:
				path.append(os.path.join("packages","linux","x86"))
			path.append(os.path.join("packages","linux","all"))
		path.append(os.path.join("packages","all"))
		return path 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:19,代码来源:PupyClient.py

示例2: _get_cp_pairs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def _get_cp_pairs(base_font, target_font):
    """Return a list of tuples of base glyph ix, target glyph ix,
    codepoint for all codepoints in either font.  When a codepoint
    is in only one font, the id for the other glyph is -1."""

    base_cp_map = _get_cp_to_glyphix(base_font)
    target_cp_map = _get_cp_to_glyphix(target_font)

    pairs = []
    base_keys = set(base_cp_map.keys())
    target_keys = set(target_cp_map.keys())
    matched = base_keys & target_keys
    for k in sorted(matched):
        pairs.append((base_cp_map[k], target_cp_map[k], k))
    for k in sorted(base_keys - matched):
        pairs.append((base_cp_map[k], -1, k))
    for k in sorted(target_keys - matched):
        pairs.append((-1, target_cp_map[k], k))
    return pairs 
开发者ID:googlefonts,项目名称:nototools,代码行数:21,代码来源:glyph_image_pair.py

示例3: check_if_match

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def check_if_match():
    diff = 0
    bad_chars = defaultdict(list)
    minlen = min(len(buffers[0]), len(buffers[1]))

    for i in range(minlen):
        if buffers[0][i] != buffers[1][i]:
            diff += 1
            bad_chars[buffers[0][i]].append(buffers[1][i])

    if len(buffers[0]) > minlen:
        bad_chars[-1].append(buffers[1][-1])
    elif len(buffers[1]) > minlen:
        bad_chars[-1].append(buffers[0][-1])

    return (diff, bad_chars) 
开发者ID:mgeeky,项目名称:expdevBadChars,代码行数:18,代码来源:badchars.py

示例4: draw_spline

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def draw_spline(self, drawing, splines, fill):
		if fill==(255,255,255):
			return
		path = []
		# points = []
		for spline in splines:
			curves = list(spline.Quadratic_Bezier_Fit())
			path.append('M')
			path.append(self.scale_pt(curves[0][0]))
			for curve in curves:
				path.append('Q')
				path.append(self.scale_pt(curve[1]))
				path.append(self.scale_pt(curve[2]))
				p0 = self.scale_pt(curve[0])
				p1 = self.scale_pt(curve[2])
			path.append('Z')
		drawing.add(drawing.path(path, stroke = color(fill), fill = color(fill))) 
开发者ID:vvanirudh,项目名称:Pixel-Art,代码行数:19,代码来源:output.py

示例5: nestTree

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def nestTree(parent_node,path,export_data,count_nodes):
    ### export_data,count_nodes are used for QC only
    children = edges[parent_node]
    path.append(0)
    for child in children.keys():
        tuple_path = tuple(path)
        #count_nodes+=1
        #try: temp = string.join(edges[child].keys(),'|')
        #except Exception: temp = ''
        #export_data.write(str(tuple_path)+'\t'+child+'\t'+temp+'\n')
        p = list(path)  ### Otherwise, the same path somehow gets used (alternative to copy.deepcopy())
        if child in edges:
            count_nodes = nestTree(child,p,export_data,count_nodes)
        #if count_nodes==1000: kill

        path_ontology_db[tuple_path] = child
        if child not in built_ontology_paths:
            built_ontology_paths[child] = [tuple_path]
        elif tuple_path not in built_ontology_paths[child]:
            built_ontology_paths[child].append(tuple_path)
        path[-1]+=1
    return count_nodes 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:24,代码来源:OBO_import.py

示例6: verifyNestedFileCreation

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def verifyNestedFileCreation(species,mod_types,ontology_type):
    ### Determine which mods are present for Ontology
    program_type,database_dir = unique.whatProgramIsThis()
    mods_present = []; nested_present=[]; verified = 'no'
    for mod in mod_types:
        ontology_file = database_dir+'/'+species+'/gene-go/'+mod+'-'+ontology_type+'.txt'
        count = verifyFileLength(ontology_file) ### See if there are lines present in the file (if present)
        if count>1: mods_present.append(mod)
    if len(mods_present)>0:
        for mod in mods_present:
            if ontology_type == 'GeneOntology': ontology_type = 'GO'
            ontology_file = database_dir+'/'+species+'/nested/'+mod+'_to_Nested-'+ontology_type+'.txt'
            count = verifyFileLength(ontology_file) ### See if there are lines present in the file (if present)
            if count>1: nested_present.append(mod)
        if len(nested_present) == len(mods_present): verified = 'yes'
    return verified 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:18,代码来源:OBO_import.py

示例7: _find_input_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def _find_input_path(src, dst_predicate):
  """Finds an input path from `src` to a node that satisfies `dst_predicate`.

  TensorFlow graphs are directed. We generate paths from outputs to inputs,
  recursively searching both direct (i.e. data) and control inputs. Graphs with
  while_loop control flow may contain cycles. Therefore we eliminate loops
  during the DFS.

  Args:
    src: tf.Tensor or tf.Operation root node.
    dst_predicate: function taking one argument (a node), returning true iff a
        a target node has been found.

  Returns:
    a path from `src` to the first node that satisfies dest_predicate, or the
    empty list otherwise.
  """
  path_to = {src: None}

  def dfs(x):
    if dst_predicate(x):
      return x
    x_op = _as_op(x)
    for y in x_op.control_inputs + list(x_op.inputs):
      # Check if we've already visited node `y`.
      if y not in path_to:
        path_to[y] = x
        res = dfs(y)
        if res is not None:
          return res
    return None

  dst = dfs(src)
  path = []
  while dst in path_to:
    path.append(dst)
    dst = path_to[dst]
  return list(reversed(path)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:40,代码来源:graph_builder_test.py

示例8: make_undirected

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def make_undirected(self):
  
    t0 = time()

    for v in self.keys():
      for other in self[v]:
        if v != other:
          self[other].append(v)
    
    t1 = time()
    logger.info('make_directed: added missing edges {}s'.format(t1-t0))

    self.make_consistent()
    return self 
开发者ID:cambridgeltl,项目名称:link-prediction_with_deep-learning,代码行数:16,代码来源:graph.py

示例9: random_walk

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def random_walk(self, path_length, alpha=0, rand=random.Random(), start=None):
    """ Returns a truncated random walk.

        path_length: Length of the random walk.
        alpha: probability of restarts.
        start: the start node of the random walk.
    """
    G = self
    if start:
      path = [start]
    else:
      # Sampling is uniform w.r.t V, and not w.r.t E
      path = [rand.choice(G.keys())]

    while len(path) < path_length:
      cur = path[-1]
      if len(G[cur]) > 0:
        if rand.random() >= alpha:
          path.append(rand.choice(G[cur]))
        else:
          path.append(path[0])
      else:
        break
    return path

# TODO add build_walks in here 
开发者ID:cambridgeltl,项目名称:link-prediction_with_deep-learning,代码行数:28,代码来源:graph.py

示例10: build_deepwalk_corpus

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def build_deepwalk_corpus(G, num_paths, path_length, alpha=0,
                      rand=random.Random(0)):
  walks = []

  nodes = list(G.nodes())
  
  for cnt in range(num_paths):
    rand.shuffle(nodes)
    for node in nodes:
      walks.append(G.random_walk(path_length, rand=rand, alpha=alpha, start=node))
  
  return walks 
开发者ID:cambridgeltl,项目名称:link-prediction_with_deep-learning,代码行数:14,代码来源:graph.py

示例11: load_edgelist

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def load_edgelist(file_, undirected=True):
  G = Graph()
  with open(file_) as f:
    for l in f:
      x, y = l.strip().split()[:2]
      x = int(x)
      y = int(y)
      G[x].append(y)
      if undirected:
        G[y].append(x)
  
  G.make_consistent()
  return G 
开发者ID:cambridgeltl,项目名称:link-prediction_with_deep-learning,代码行数:15,代码来源:graph.py

示例12: from_networkx

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def from_networkx(G_input, undirected=True):
    G = Graph()

    for idx, x in enumerate(G_input.nodes_iter()):
        for y in iterkeys(G_input[x]):
            G[x].append(y)

    if undirected:
        G.make_undirected()

    return G 
开发者ID:cambridgeltl,项目名称:link-prediction_with_deep-learning,代码行数:13,代码来源:graph.py

示例13: received

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def received(self):
        """Returns the list of Received: headers of the email, or None if the headers are not available."""
        if not self.headers:
            return None

        result = []

        for key, value in self.headers:
            if key == 'Received':
                result.append(value)

        return result 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:14,代码来源:email.py

示例14: attachments

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def attachments(self):
        """Returns the list of F_FILE observables that were attachments to the email (not considered the body.)"""
        result = []

        for _file in self.observables:
            if _file.type != F_FILE:
                continue

            # skip any file with an auto-generated name (these are typically part of the body)
            if os.path.basename(_file.value).startswith('email.rfc822.'):
                continue

            result.append(_file)

        return result 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:17,代码来源:email.py

示例15: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import append [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        
        # load the list of url patterns we want to alert on
        self.url_patterns = []
        for key in self.config.keys():
            if key.startswith('url_pattern_'):
                try:
                    pattern = self.config[key]
                    self.url_patterns.append(re.compile(pattern))
                except Exception as e:
                    logging.error(f"unable to add pattern {self.config[key.value]}: {e}") 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:14,代码来源:email.py


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