Mercurial > repos > rmarenco > hubarchivecreator
comparison trackHub/tracks_partial.py @ 16:3233451a3bd6 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
author | rmarenco |
---|---|
date | Sun, 25 Sep 2016 11:25:38 -0400 |
parents | fb5e60d4d18a |
children |
comparison
equal
deleted
inserted
replaced
15:2a45cd656e8e | 16:3233451a3bd6 |
---|---|
29 """ | 29 """ |
30 rval = [ | 30 rval = [ |
31 '<html><head><title>Files for Composite Dataset (%s)</title></head><p/>\ | 31 '<html><head><title>Files for Composite Dataset (%s)</title></head><p/>\ |
32 This composite dataset is composed of the following files:<p/><ul>' % ( | 32 This composite dataset is composed of the following files:<p/><ul>' % ( |
33 self.file_ext)] | 33 self.file_ext)] |
34 for composite_name, composite_file in self.get_composite_files(dataset=dataset).iteritems(): | 34 |
35 opt_text = '' | 35 def create_tree(path, tree): |
36 if composite_file.optional: | 36 if path[0] in tree: |
37 opt_text = ' (optional)' | 37 create_tree(path[1:], tree[path[0]]) |
38 rval.append('<li><a href="%s">%s</a>%s' % (composite_name, composite_name, opt_text)) | 38 else: |
39 tree[path[0]] = {} | |
40 if len(path) == 1: | |
41 return | |
42 else: | |
43 create_tree(path[1:], tree[path[0]]) | |
44 | |
45 def print_tree(tree, level): | |
46 if len(tree) == 0: | |
47 return | |
48 | |
49 for vertex in tree: | |
50 composite_name = vertex | |
51 bullet_point = '<li><a href="{0}>{0}</a></li>'.format(composite_name) | |
52 rval.append(bullet_point) | |
53 # Parent, so need to create a sub <ul> | |
54 if len(tree[vertex]) > 0: | |
55 rval.append('<ul>') | |
56 print_tree(tree[vertex], level+1) | |
57 rval.append('</ul>') | |
58 | |
59 walkable_tree = {} | |
60 | |
61 for composite_name_full_path, composite_file in self.get_composite_files(dataset=dataset).iteritems(): | |
62 paths = composite_name_full_path.split('/') | |
63 # Prepare the tree from to perform a Depth First Search | |
64 create_tree(paths, walkable_tree) | |
65 | |
66 # Perform a Depth First Search to print all the directory and files properly | |
67 print_tree(walkable_tree, 0) | |
68 | |
69 # rval.append('<li><a href="%s">%s</a>%s' % (composite_name, composite_name, opt_text)) | |
39 rval.append('</ul></html>') | 70 rval.append('</ul></html>') |
40 return "\n".join(rval) | 71 return "\n".join(rval) |
41 | 72 |
42 def set_peek( self, dataset, is_multi_byte=False ): | 73 def set_peek( self, dataset, is_multi_byte=False ): |
43 if not dataset.dataset.purged: | 74 if not dataset.dataset.purged: |