Exemple #1
0
 def print_ascii(self, fout=None, pars=None):
     box_tr = MyLeftAligned(pars,
                            draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1))
     if fout is None:
         print(box_tr(self))
     else:
         fout.write(box_tr(self))
Exemple #2
0
def print_diff(common_paths):
    comm_path_str = common_paths_to_str(common_paths)
    common_paths = common_paths_from_str(comm_path_str)
    untracked_files = {k: v for k, v in common_paths.items() if not v['synid']}
    remote_files = {
        k: v
        for k, v in common_paths.items() if not v['local_md5']
    }
    mismatch_files = {
        k: v
        for k, v in common_paths.items()
        if ((None not in [v['local_md5'], v['remote_md5']])
            & (len(set([v['local_md5'], v['remote_md5']]))) > 1)
    }
    d = {
        'Untracked files:': untracked_files,
        'Remote files:': remote_files,
        'Mismatched_files:': mismatch_files
    }
    for k, v in d.items():
        head_str = k + '  ' + str(len(v)) + ' file(s).'
        print(head_str)
        if len(v) > 0:
            tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, horiz_len=1))
            tree = paths_to_tree(v)
            print('  ' + tr(tree).replace('\n', '\n  '))
        print()
        print()
    def show(self, what):

        print self.data_refining

        if len(what) == 0 or 'Plain' in what:
            scaffold_nodes = self.data_refining['scaffolding']
            for scaffold_node, ports in scaffold_nodes.items():
                print(Fore.BLUE + "--- scaffold_node: %s" % (scaffold_node))
                print(Style.RESET_ALL)
                for p_id, ctx in ports.items():
                    print self.service_fmt % (ctx["srv"]['@name'], p_id)
                    for key in ['connected', 'disjoined']:
                        print CohesionTermCb.append_str(
                            key, " ".join(ctx[key]))

            print "\n"

        # JSON
        if 'Json' in what:
            print 'JSON \n'
            print json.dumps(self.data_refining)

        # maybe deep copy if data reused
        if 'Tree' in what:
            # TREE
            Construer.traverse(self.data_refining, TermTreeConvCb())
            tr = LeftAligned(draw=BoxStyle(gfx=BOX_HEAVY))
            print(tr(self.data_refining))
Exemple #4
0
 def render(self, colorize: bool = False) -> None:
     """Renders an ASCII tree using our user hierarchical namespace
     traversal object."""
     print(
         asciitree.LeftAligned(traverse=UserNamespaceTraversal(
             self._nstypename, colorize),
                               draw=BoxStyle(gfx=BOX_LIGHT,
                                             horiz_len=2))(self._roots))
Exemple #5
0
    def __repr__(self):

        if self.is_leaf:
            return f"{self.value}"

        else:
            tr = LeftAligned(draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1))

            out_final = {}
            out_final[self.name] = self.to_dict()
            return tr(out_final)
Exemple #6
0
 def dependency_graph(self, package_name):
     """
     takes package_name and outputs its dependencies and their own dependencies plus an asciitree of this arrangement.
     :param package_name:
     :return: dictionary of dictionaries with dependencies of package name
     """
     sub_tr = {package_name: self.sub_graph(package_name)}
     tree = sub_tr
     for node in sub_tr[package_name]:
         tree[package_name][node] = self.sub_graph(node)
     box_tr = LeftAligned(draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1))
     return box_tr(tree)
Exemple #7
0
def process(input, output):
	if format() == 'xml':
		o = xmltodict.parse(input.read())
	elif format() == 'yaml':
		o = yaml.load(input)
	else:
		o = json.load(input)

	if ascii():
		tr = LeftAligned()
	else:
		tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, horiz_len=1))

	output.write(tr(treeFix(o)))
Exemple #8
0
def cli(gh, repos):
    """ Show a tree of forks """
    if not repos:
        repos = [gh.repository()]
    repos = [r.get() for r in repos]
    traverser = ForkTraversal(gh, repos)
    tree = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT), traverse=traverser)
    first = True
    for r in repos:
        if r["full_name"] not in traverser.seen:
            if first:
                first = False
            else:
                click.echo()
            click.echo(tree(r))
Exemple #9
0
def printFeatureTreeOfBundle( feature, bundleString ) : 
    # First seache bundle in feature
    bundles=searchBundleVersions(feature, bundleString)    
    root=OD()
    bundlesRoot=OD()
    root['b: ' + bundleString]=bundlesRoot
    if ( len ( bundles ) == 0 ) : 
        bundleRoot=OD()        
        bundlesRoot["Not found"]={}
    else :
        for bundle in bundles :         
            featuresOfBundle=searchFeatureOfBundle(feature, bundle)
            bundleRoot=OD()
            bundlesRoot['b: ' + bundle.toStr(ver=True)]=bundleRoot    
            loadParentTree( bundleRoot, featuresOfBundle )            
    tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, label_space=0, indent=0))
    print(tr(root))
Exemple #10
0
def show_tree(hdf5_file):
    tree = {hdf5_file: OrderedDict()}

    f = h5py.File(hdf5_file, 'r')
    for k, v in f.items():
        tree[hdf5_file][k] = OrderedDict()
        for k2, v2 in v.items():
            tree[hdf5_file][k][f'{k2} -> {v2.shape}  {v2.dtype}'] = OrderedDict()            

    chrs = dict(
            UP_AND_RIGHT=u"\u2514",
            HORIZONTAL=u"\u2500",
            VERTICAL=u"\u2502",
            VERTICAL_AND_RIGHT=u"\u251C"
        )

    tr = LeftAligned(draw=BoxStyle(gfx = chrs, horiz_len=1))
    print(tr(tree))
Exemple #11
0
    def process(self, input, output=sys.stdout):
        if type(input) in self.collections:
            o = input
        elif isinstance(input, IOBase) or isinstance(input, StringIO):
            input = input.read()
        if type(input) in [str]:
            if self.format == 'xml':
                o = xmltodict.parse(input)
            elif self.format == 'yaml':
                o = yaml.load(input)
            else:  # == 'json'
                o = json.loads(input)
        if self.ascii:
            tr = LeftAligned()
        else:
            tr = LeftAligned(
                draw=BoxStyle(label_space=0, gfx=BOX_LIGHT, horiz_len=1))

        output.write(tr(self.treeFix(o)))
Exemple #12
0
 def get_printable(self, level=0):
     try:
         from asciitree import LeftAligned
         from collections import OrderedDict as OD
         from asciitree.drawing import BoxStyle, BOX_DOUBLE, BOX_ASCII
         def get_ascii_tree(node):
             if node.is_leaf():
                 return str(node.sym), {}
             return str(node.sym), OD(map(get_ascii_tree, node.childs))
         tree = {str(self.sym): get_ascii_tree(self)[1]}
         tr = LeftAligned(draw=BoxStyle(gfx=BOX_ASCII, indent=0))
         return str(tr(tree))
     except Exception as e:
         print(e.args)
     if self.is_leaf():
         return " " * level + str(self.sym) + '\n'
     pp = " " * level + str(self.sym) + '\n'
     for child in self.childs:
         pp += child.get_printable(level+1)
     return pp
Exemple #13
0
def show_configuration(sub_menu: Optional[str] = None):
    """
    display the current configuration or a sub menu if
    provided
    """

    tr = LeftAligned(draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1))

    out_final = {}

    if sub_menu is None:

        out_final["CONFIG"] = _to_dict(threeML_config)

    else:

        assert sub_menu in threeML_config, "not a valild topic"

        out_final[sub_menu] = _to_dict(threeML_config[sub_menu])

    print(tr(out_final))
Exemple #14
0
def _track_to_tree(root_name: str, track: Track) -> str:
    rooted_tree: Dict = {root_name: _process_track(track)}
    box_tr: LeftAligned = LeftAligned(
        draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1, indent=1))
    return box_tr(rooted_tree)
Exemple #15
0
def tree_structure(file_list):
    list_dict = {" .": OD(build_nested(file_list))}
    tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, horiz_len=1))
    return tr(list_dict)
Exemple #16
0
            {'want': OD([
                ('to', {}),
                ('draw', {}),
            ])}),
        ('trees', {}),
        ('in', {
            'your': {
                'terminal': {}
            }
        })
    ])
}

print(tr(tree))

# construct a more complex tree by copying the tree and grafting it onto itself
tree2 = deepcopy(tree)
tree2['asciitree']['trees'] = deepcopy(tree2['asciitree'])
print(tr(tree2))

# use a box style
box_tr = LeftAligned(draw=BoxStyle(gfx=BOX_DOUBLE, horiz_len=1))
print(box_tr(tree))

# more airy
air_tr = LeftAligned(draw=BoxStyle(gfx=BOX_BLANK,
                                   label_space=0,
                                   label_format='[{}]',
                                   indent=0))
print(air_tr(tree))
Exemple #17
0
 def __init__(self):
       self.tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, horiz_len=1))
    for item in result_set:
        dn_ = item[0][0]
        tmp = dn_.split(",")
        t = get_list_match(dn, tmp)
        if t:
            out.append(t)
    return out


def fill_dic_b(dic, dn):
    t = get_items(dn)
    str_dn = ','.join(dn)
    for i in t:
        dic[str_dn] = {}
        fill_dic(dic[str_dn], i)


def fill_dic(dic, dn):
    str_dn = ','.join(dn)
    dic[str_dn] = {}

    t = get_items(dn)
    for i in t:
        fill_dic(dic[str_dn], i)


fill_dic(main_dic, baseDN.split(","))

box_tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, horiz_len=1))
print(box_tr(main_dic))
Exemple #19
0
def printFeatureTree( feature, loadDuplicateFeature ) : 
    root=OD()
    loadTree( root, feature, loadDuplicateFeature )
    tr = LeftAligned(draw=BoxStyle(gfx=BOX_LIGHT, label_space=0, indent=0))
    print(tr(root))