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


Python asciitree.LeftAligned方法代码示例

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


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

示例1: main

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def main(unused_argv):
  logging.set_verbosity(logging.INFO)
  with tf.Session() as sess:
    src = gen_parser_ops.document_source(batch_size=32,
                                         corpus_name=FLAGS.corpus_name,
                                         task_context=FLAGS.task_context)
    sentence = sentence_pb2.Sentence()
    while True:
      documents, finished = sess.run(src)
      logging.info('Read %d documents', len(documents))
      for d in documents:
        sentence.ParseFromString(d)
        tr = asciitree.LeftAligned()
        d = to_dict(sentence)
        print 'Input: %s' % sentence.text
        print 'Parse:'
        tr_str = tr(d)
        pat = re.compile(r'\s*@\d+$')
        for tr_ln in tr_str.splitlines():
          print pat.sub('', tr_ln)

      if finished:
        break 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:25,代码来源:conll2tree.py

示例2: main

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def main(unused_argv):
  logging.set_verbosity(logging.INFO)
  with tf.Session() as sess:
    src = gen_parser_ops.document_source(batch_size=32,
                                         corpus_name=FLAGS.corpus_name,
                                         task_context=FLAGS.task_context)
    sentence = sentence_pb2.Sentence()
    while True:
      documents, finished = sess.run(src)
      logging.info('Read %d documents', len(documents))
      for d in documents:
        sentence.ParseFromString(d)
        tr = asciitree.LeftAligned()
        d = to_dict(sentence)
        print('Input: %s' % sentence.text)
        print('Parse:')
        tr_str = tr(d)
        pat = re.compile(r'\s*@\d+$')
        for tr_ln in tr_str.splitlines():
          print(pat.sub('', tr_ln))

      if finished:
        break 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:25,代码来源:conll2tree.py

示例3: formatted_tree

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def formatted_tree(params, folder):
    def tree_node(node):
        name = node.name

        sfs = [params.folder_cache[sfuid] for sfuid in node.subfolders]

        if len(sfs) == 0:
            return name, {}

        sfs.sort(key=lambda f: f.name.lower(), reverse=False)
        tns = [tree_node(sf) for sf in sfs]
        return name, OD(tns)

    t = tree_node(folder)
    tree = {
        t[0]: t[1]
    }
    tr = LeftAligned()
    print(tr(tree))
    print('') 
开发者ID:Keeper-Security,项目名称:Commander,代码行数:22,代码来源:display.py

示例4: main

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def main(unused_argv):
  logging.set_verbosity(logging.INFO)
  with tf.Session() as sess:
    src = gen_parser_ops.document_source(batch_size=32,
                                         corpus_name=FLAGS.corpus_name,
                                         task_context=FLAGS.task_context)
    sentence = sentence_pb2.Sentence()
    while True:
      documents, finished = sess.run(src)
      logging.info('Read %d documents', len(documents))
      for d in documents:
        sentence.ParseFromString(d)
        tr = asciitree.LeftAligned()
        d = to_dict(sentence)
        print 'Input: %s' % sentence.text
        print 'Parse:'
        print tr(d)

      if finished:
        break 
开发者ID:llSourcell,项目名称:AI_Reader,代码行数:22,代码来源:conll2tree.py

示例5: print_tree

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def print_tree(token, colors=True):
    label, children = _token2label_tree(token, colors=colors)
    tr = LeftAligned()
    print(tr({label: children})) 
开发者ID:graphbrain,项目名称:graphbrain,代码行数:6,代码来源:nlp.py

示例6: __bytes__

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def __bytes__(self):
        drawer = LeftAligned(
            traverse=TreeTraversal(),
            draw=BoxStyle(gfx=self.bytes_kwargs, **self.text_kwargs),
        )
        root = self.node_cls(self.group, level=self.level)
        result = drawer(root)

        # Unicode characters slip in on Python 3.
        # So we need to straighten that out first.
        if not PY2:
            result = result.encode()

        return result 
开发者ID:mirnylab,项目名称:cooler,代码行数:16,代码来源:fileops.py

示例7: __unicode__

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def __unicode__(self):
        drawer = LeftAligned(
            traverse=TreeTraversal(),
            draw=BoxStyle(gfx=self.unicode_kwargs, **self.text_kwargs),
        )
        root = self.node_cls(self.group, level=self.level)
        return drawer(root) 
开发者ID:mirnylab,项目名称:cooler,代码行数:9,代码来源:fileops.py

示例8: process

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def process(irr_host, afi, db, as_set, search):
    import datetime
    now = datetime.datetime.now()
    now = now.strftime("%Y-%m-%d %H:%M")
    print "IRRTree (%s) report for '%s' (IPv%i), using %s at %s" \
        % (irrtree.__version__, as_set, afi, irr_host, now)

    if search and "-" not in db.keys():
        if not search in db.keys():
            print "NOT_FOUND: %s not present in %s or any of its members" % (search, as_set)
            sys.exit()

    def print_member(as_set, db, search):
        if not "-" in as_set:
            res = "%s (%s pfxs)" % (as_set, resolve_prefixes(db, as_set))
        elif search:
            res = "%s (%s ASNs)" % (as_set, len(db[as_set]['origin_asns']))
        else:
            res = "%s (%s ASNs, %s pfxs)" % (as_set,
                                             len(db[as_set]['origin_asns']),
                                             resolve_prefixes(db, as_set))
        return res

    def getasncount(db, item):
        v = db[item]
        if type(v) == set:
            ret = (0, len(v))
        else:
            ret = (len(v['origin_asns']), resolve_prefixes(db, item))
        return ret

    def resolve_tree(as_set, db, tree=OD(), seen=set()):
        seen.add(as_set)
        for member in sorted(db[as_set]['members'], key=lambda x:
                             getasncount(db, x), reverse=True):
            if member in seen:
                tree["%s - already expanded" % print_member(member, db, search)] = {}
                continue
            if "-" in member:
                seen.add(member)
                tree["%s" % print_member(member, db, search)] = resolve_tree(member, db, OD(), seen)
            else:
                if not search or search == member:
                    tree["%s" % print_member(member, db, search)] = {}
                else:
                    continue
        return tree

    tree = OD()
    tree["%s" % print_member(as_set, db, search)] = resolve_tree(as_set, db)
    tr = asciitree.LeftAligned()
    print tr(tree) 
开发者ID:job,项目名称:irrtree,代码行数:54,代码来源:cli.py

示例9: create_tree

# 需要导入模块: import asciitree [as 别名]
# 或者: from asciitree import LeftAligned [as 别名]
def create_tree(table: dict,
                root: str,
                mark: str,
                f_pid: str = "pid",
                f_id: str = "id",
                f_label: str = "item",
                f_ctime: str = "ctime",
                v_none: str = "null") -> str:
    """
    Creates the ascii checkpoint tree.

    Args:
        table: List of checkpoints as a table.
        root: Root label of the tree.
        mark: Current snapshot name. Mark the element with an '*'
        f_pid: Field of the table that contains the parent id of the node.
        f_id: Field of the table that contains the id of the node.
        f_label: Field with the label of the node.
        f_ctime: Field with the timestamp creation date.
        v_none: Value to be used for empty fields.
    Returns:
        A string containing the tree of snapshots
    """
    items = [(c[f_pid], c[f_id]) for c in table]
    tree = {root: OD()}
    inserted = []

    while [x[1] for x in items if x[1] not in inserted]:
        for parent, item in items:
            if parent == v_none:
                parent = root
            inserts = walk(tree, parent, item)
            inserted.extend(list(inserts))

    tr = LeftAligned()
    tr_tree = tr(tree)

    for cell in table:
        if cell[f_label] == mark:
            cell[f_label] = "{}*".format(cell[f_label])

        tr_tree = tr_tree.replace(cell[f_id],
                                  "{} ({})".format(
                                      cell[f_label],
                                      convert_dt(cell[f_ctime])))
    return tr_tree 
开发者ID:avanzzzi,项目名称:hypy,代码行数:48,代码来源:snaptree.py


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