Commit c1808b38f9f2153945efda1b5f1423e22ec70313
1 parent
f7099529
Exists in
master
and in
1 other branch
Adding private _debtags_list_to_dict.
Showing
1 changed file
with
26 additions
and
26 deletions
Show diff stats
src/web/server.py
| ... | ... | @@ -59,37 +59,37 @@ class Thanks: |
| 59 | 59 | |
| 60 | 60 | class Package: |
| 61 | 61 | def GET(self, pkg): |
| 62 | - json_source = "http://dde.debian.net/dde/q/udd/packages/all/%s?t=json" % pkg #FIXME: go to config | |
| 62 | + json_source = "http://dde.debian.net/dde/q/udd/packages/all/%s?t=json" % pkg #FIXME: url goes to config | |
| 63 | 63 | json_data = json.load(urllib.urlopen(json_source)) |
| 64 | - tags = debtags_list_to_dict(json_data['r']['tag']) | |
| 64 | + tags = self._debtags_list_to_dict(json_data['r']['tag']) | |
| 65 | 65 | json_data['r']['tag'] = tags |
| 66 | 66 | return render_plain.package(json_data['r']) |
| 67 | 67 | |
| 68 | -def debtags_list_to_dict(debtags_list): | |
| 69 | - """ in: | |
| 70 | - ['use::editing', | |
| 71 | - 'works-with-format::gif', | |
| 72 | - 'works-with-format::jpg', | |
| 73 | - 'works-with-format::pdf'] | |
| 74 | - out: | |
| 75 | - {'use': [editing], | |
| 76 | - 'works-with-format': ['gif', 'jpg', 'pdf']' | |
| 77 | - } | |
| 78 | - """ | |
| 79 | - debtags = {} | |
| 80 | - subtags = [] | |
| 81 | - for tag in debtags_list: | |
| 82 | - match = re.search(r'^(.*)::(.*)$', tag) | |
| 83 | - if not match: | |
| 84 | - log.error("Could not parse debtags format from tag: %s", tag) | |
| 85 | - facet, subtag = match.groups() | |
| 86 | - subtags.append(subtag) | |
| 87 | - if facet not in debtags: | |
| 88 | - debtags[facet] = subtags | |
| 89 | - else: | |
| 90 | - debtags[facet].append(subtag) | |
| 68 | + def _debtags_list_to_dict(self, debtags_list): | |
| 69 | + """ in: | |
| 70 | + ['use::editing', | |
| 71 | + 'works-with-format::gif', | |
| 72 | + 'works-with-format::jpg', | |
| 73 | + 'works-with-format::pdf'] | |
| 74 | + out: | |
| 75 | + {'use': [editing], | |
| 76 | + 'works-with-format': ['gif', 'jpg', 'pdf']' | |
| 77 | + } | |
| 78 | + """ | |
| 79 | + debtags = {} | |
| 91 | 80 | subtags = [] |
| 92 | - return debtags | |
| 81 | + for tag in debtags_list: | |
| 82 | + match = re.search(r'^(.*)::(.*)$', tag) | |
| 83 | + if not match: | |
| 84 | + log.error("Could not parse debtags format from tag: %s", tag) | |
| 85 | + facet, subtag = match.groups() | |
| 86 | + subtags.append(subtag) | |
| 87 | + if facet not in debtags: | |
| 88 | + debtags[facet] = subtags | |
| 89 | + else: | |
| 90 | + debtags[facet].append(subtag) | |
| 91 | + subtags = [] | |
| 92 | + return debtags | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | class AppRecommender: | ... | ... |