2 # -*- coding: utf-8 -*-
3 # vim: ts=4 et sw=4 sts=4 ai sta:
14 raise SystemExit("Usage: %s <projects.json>" % argv[0])
16 # TODO: read from domains file
22 'Graphics & UI Framework',
26 'Network & Connectivity',
27 'Platform Development',
37 # Interesting for us branches.
38 # TODO: read from branches file
40 'tizen', 'tizen_2.2', 'tizen_2.1', 'tizen_2.0'
43 # Mappings between domain names and ACLs
48 for domain in domains:
49 domain_converted = "scm/acls/domain_"+domain.replace("&","and").replace(" ","_").lower()
50 domain_to_acl[domain] = domain_converted
51 acl_to_domain[domain_converted] = domain
53 projects = json.load(open(argv[1],"r"))
55 git_names = sorted(projects.keys())
60 for name in git_names:
61 if 'parent' not in projects[name]:
64 if name.startswith("scm/"):
67 out_projects[name] = {
75 if projects[name]['parent'] in acl_to_domain:
76 out_projects[name]['domain'] = acl_to_domain[projects[name]['parent']]
78 out_projects[name]['domain'] = ''
79 out_projects[name]['comments'].append('Missing domain!')
80 if 'description' in projects[name] and projects[name]['description']:
81 for line in re.split(r";[\n ]", projects[name]['description']):
86 tup = line.split(": ", 1)
90 if tup[0] == 'Domain':
91 # Let's check if domain matches with ACLs
92 if out_projects[name]['domain'] != tup[1]:
93 out_projects[name]['description_domain'] = tup[1]
94 emes="Domain mismatch: '%s' vs. '%s'" % \
95 (out_projects[name]['domain'], tup[1])
96 out_projects[name]['comments'].append(emes)
98 out_projects[name][tup[0].lower()] = re.split(r", ?", tup[1])
99 if 'branches' in projects[name]:
100 # TODO: Add information about branches
102 out_projects[name]['branches'] = { branch: False for branch in branches }
103 for branch in branches:
104 if branch in projects[name]['branches']:
105 out_projects[name]['branches'][branch] = True
108 out_projects[name]['branches'][branch] = False
110 # Project doesn't have any of interesting for us branches
111 del out_projects[name]
114 with codecs.open("git-trees.new", "wb", encoding="utf-8") as outfile:
115 dump_all(out_projects, outfile)
118 def dump_all(git_trees, outfp = None):
119 names = sorted(git_trees.keys())
121 out = dumps_one_project(git_trees[name])
123 outfp.write("\n"+out)
126 def dumps_one_project(git_dict):
130 out.append("T: %s" % git_dict['path'])
131 out.append("D: %s" % git_dict['domain'])
132 if 'description' in git_dict:
133 for line in git_dict['description']:
134 out.append("O: %s" % line)
135 if 'profiles' in git_dict:
136 for profile in git_dict['profiles']:
137 out.append("P: %s" % profile)
138 if 'status' in git_dict:
139 out.append("S: %s" % git_dict['status'])
140 for role in ("maintainers", "integrators", "reviewers"):
142 for person in git_dict[role]:
143 out.append("%s: %s" % (role[0].upper(), person))
144 if 'branches' in git_dict:
145 for branch in git_dict['branches']:
146 if git_dict['branches'][branch]:
147 out.append("B: %s" % branch)
148 if 'licenses' in git_dict:
149 for license in git_dict['licenses']:
150 out.append("L: %s" % license)
151 if 'homepage' in git_dict:
152 out.append("H: %s" % git_dict['homepage'])
153 if 'upstream url' in git_dict:
154 out.append("U: %s" % git_dict['upstream url'])
155 if 'upstream vcs' in git_dict:
156 out.append("V: %s" % git_dict['upstream vcs'])
157 if 'comments' in git_dict:
158 for line in git_dict['comments']:
159 out.append("C: %s" % line)
160 return "\n".join(out)+"\n"
163 if __name__ == '__main__':