Print referrers tree to console.

        keyword arguments
        tree -- if not None, the passed tree will be printed. Otherwise it is
        based on the rootobject.
427773
def print_tree(self, tree=None):
        
        if tree is None:
            self._print(self.root, '', '')
        else:
            self._print(tree, '', '')
377332
def _print(self, tree, prefix, carryon):
        
        level = prefix.count(self.cross) + prefix.count(self.vline)
        len_children = 0
        if isinstance(tree , _Node):
            len_children = len(tree.children)

        # add vertex
        prefix += str(tree)
        # and as many spaces as the vertex is long
        carryon += self.space * len(str(tree))
        if (level == self.maxdepth) or (not isinstance(tree, _Node)) or\
           (len_children == 0):
            self.stream.write(prefix+'\n')
            return
        else:
            # add in between connections
            prefix += self.hline
            carryon += self.space
            # if there is more than one branch, add a cross
            if len(tree.children) > 1:
                prefix += self.cross
                carryon += self.vline
            prefix += self.hline
            carryon += self.space

            if len_children > 0:
                # print the first branch (on the same line)
                self._print(tree.children[0], prefix, carryon)
                for b in range(1, len_children):
                    # the caryon becomes the prefix for all following children
                    prefix = carryon[:-2] + self.cross + self.hline
                    # remove the vlines for any children of last branch
                    if b == (len_children-1):
                        carryon = carryon[:-2] + 2*self.space
                    self._print(tree.children[b], prefix, carryon)
                    # leave a free line before the next branch
                    if b == (len_children-1):
                        if len(carryon.strip(' ')) == 0:
                            return
                        self.stream.write(carryon[:-2].rstrip()+'\n')
914987
def tree(self):
        
        self.msg.template(78)
        print("| Dependencies\n"
              "| -- Packages")
        self.msg.template(78)
        self.data()
        for pkg, dep in self.dmap.iteritems():
            print("+ {0}{1}{2}".format(self.green, pkg, self.endc))
            print("|")
            for d in dep:
                print("+-- {0}".format(d))
                print("|")
            sys.stdout.write("\x1b[1A{0}\n".format(" "))
            sys.stdout.flush()
        self.summary()
        if self.image:
            Graph(self.image).dependencies(self.dmap)
913997
def display_hierarchy_helper(root, parent_id_to_children, depth):
  
  print '%s%s (%s)' % ('%s+--' % ('|'.join(['  '] * depth)),
                       root['name'], root['id'])

  # Recurse for each child of this root that has children.
  for child in parent_id_to_children.get(root['id'], []):
    display_hierarchy_helper(child, parent_id_to_children, depth + 1)
1014624
public static void main(String[] args) {
    try {
      TreeFactory tf = new LabeledScoredTreeFactory();
      Reader r = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), "UTF-8"));
      TreeReader tr = new PennTreeReader(r, tf);
      Tree t = tr.readTree();
      while (t != null) {
        System.out.println(t);
        System.out.println();
        t = tr.readTree();
      }
      r.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
68749
def iterator(self, *args):
        
        if len(args) > 1:
            return ClickableTreeWidget.Iterator(*args)
        else:
            return ClickableTreeWidget.Iterator(self, *args)
985100
def command_copytree(args):
    
    for srcdir in args.srcdirs:
        basename = os.path.basename(srcdir)
        destdir2 = os.path.normpath(os.path.join(args.destdir, basename))
        if os.path.exists(destdir2):
            shutil.rmtree(destdir2)
        sys.stdout.write("copytree: %s => %s\n" % (srcdir, destdir2))
        shutil.copytree(srcdir, destdir2)
    return 0
459199
def print_tree(self, filename, tree=None):
        
        old_stream = self.stream
        self.stream = open(filename, 'w')
        try:
            super(FileBrowser, self).print_tree(tree=tree)
        finally:
            self.stream.close()
            self.stream = old_stream
712925
def print_curation_tree(self, unit_id):
        '''
        '''
        root_ids = []
        for i in range(len(self._roots)):
            root_id = self._roots[i].unit_id
            root_ids.append(root_id)
        if(unit_id in root_ids):
            root_index = root_ids.index(unit_id)
            print(self._roots[root_index])
        else:
            raise ValueError("invalid unit id")
381896
def tree_handler(*args, **kwargs):
    
    global _TREE_HANDLER

    if not _TREE_HANDLER:
        _TREE_HANDLER = TreeHandler(*args, **kwargs)

    return _TREE_HANDLER
1065988
def print(self, *args, **kwargs):
        
        print(self, *args, **kwargs)
        self.data = ''
        return self
1026676
def cprint(*text, **kwargs):
    
    print(
        colorize(
            kwargs.get('bg')   or BgColor.Null,
            kwargs.get('base') or Base.Null,
            kwargs.get('fg')   or FgColor.Null,
            *text
        ),
        file=kwargs.get('file') or sys.stdout
    )
1227532
public void printTree(CommonTree t, int indent) {
        if ( t != null ) {
            StringBuffer sb = new StringBuffer(indent);
            for ( int i = 0; i < indent; i++ )
                sb = sb.append("   ");
            for ( int i = 0; i < t.getChildCount(); i++ ) {
                System.out.println("" + i + sb.toString() + t.getChild(i).toString());
                printTree((CommonTree)t.getChild(i), indent+1);
            }
        }
    }
104571
def default_tree_traversal(root, leaves):
    
    objs = [('#', root)]
    while len(objs) > 0:
        path, obj = objs.pop()

        # name of child are json-pointer encoded, we don't have
        # to encode it again.
        if obj.__class__ not in leaves:
            objs.extend(map(lambda i: (path + '/' + i[0],) + (i[1],), six.iteritems(obj._children_)))

        # the path we expose here follows JsonPointer described here
        #   http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
        yield path, obj
642411
def _print_refs(self, refs, total, prefix='    ',
                    level=1, minsize=0, minpct=0.1):
        
        lrefs = list(refs)
        lrefs.sort(key=lambda x: x.size)
        lrefs.reverse()
        for ref in lrefs:
            if ref.size > minsize and (ref.size*100.0/total) > minpct:
                self.stream.write('%-50s %-14s %3d%% [%d]\n' % (
                    trunc(prefix+str(ref.name), 50),
                    pp(ref.size),
                    int(ref.size*100.0/total),
                    level
                ))
                self._print_refs(ref.refs, total, prefix=prefix+'  ',
                                 level=level+1)
1341621
public static boolean referencesOuter(Tree tree, Symbol owner, VisitorState state) {
    CanBeStaticAnalyzer scanner = new CanBeStaticAnalyzer(owner, state);
    ((JCTree) tree).accept(scanner);
    return !scanner.canPossiblyBeStatic || !scanner.outerReferences.isEmpty();
  }
1100879
def print_help(self):
        
        keyfunc = lambda x: (x.resource_name, x.__doc__.strip())
        resources = groupby(sorted(filter(lambda x: (hasattr(x, 'is_api_call') and
                                                     x.is_api_call and x.is_supported_api),
                                          [getattr(self, resource) for resource in dir(self)]),
                                   key=keyfunc),
                            key=keyfunc)
        for resource_desc, resource_methods in resources:
            print resource_desc[0]
            print '\t', resource_desc[1]
            print
            print '\t', 'Available methods:'
            for r in resource_methods:
                method_header = r.__name__ + '('
                if r._get_args:
                    method_header += ','.join(r._get_args)
                if r._put_or_post_args:
                    put_or_post_args = [arg['name'] for arg in reduce(lambda x, y: x+y, r._put_or_post_args.values())]
                    method_header += ',{' + ','.join(put_or_post_args) + '}'
                method_header += ')'
                method_desc = ""
                if r.__name__.startswith('create'):
                    method_desc = 'Corresponding API call: POST to ' + r._resource_uri
                if r.__name__.startswith('update'):
                    method_desc = 'Corresponding API call: PUT to ' + r._resource_uri
                if r.__name__.startswith('read'):
                    method_desc = 'Corresponding API call: GET to ' + r._resource_uri
                if r.__name__.startswith('delete'):
                    method_desc = 'Corresponding API call: DELETE to ' + r._resource_uri

                print '\t\t', method_header, ' - ', method_desc
            print