Merge lp:~janos-gyerik/ubuntu-accomplishments-daemon/parse-the-optional-example-and-regex-sections-in-extrainformation into lp:ubuntu-accomplishments-daemon

Proposed by Janos Gyerik
Status: Merged
Merged at revision: 83
Proposed branch: lp:~janos-gyerik/ubuntu-accomplishments-daemon/parse-the-optional-example-and-regex-sections-in-extrainformation
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 78 lines (+32/-2)
1 file modified
accomplishments/daemon/api.py (+32/-2)
To merge this branch: bzr merge lp:~janos-gyerik/ubuntu-accomplishments-daemon/parse-the-optional-example-and-regex-sections-in-extrainformation
Reviewer Review Type Date Requested Status
Ubuntu Accomplishments Daemon Developers Pending
Review via email: mp+111721@code.launchpad.net

Description of the change

Note the [example] and [regex] sections are still optional. If they are present in the extrainformation files, they will be parsed and passed on to dbus, so the client can get them when opening the identity screen with ctrl-i

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accomplishments/daemon/api.py'
2--- accomplishments/daemon/api.py 2012-06-12 20:23:01 +0000
3+++ accomplishments/daemon/api.py 2012-06-23 18:42:17 +0000
4@@ -628,6 +628,12 @@
5 for i in ei:
6 label = self.accDB[collection]['extra-information'][i]['label']
7 desc = self.accDB[collection]['extra-information'][i]['description']
8+ example = self.accDB[collection]['extra-information'][i].get('example')
9+ if example is None:
10+ example = ''
11+ regex = self.accDB[collection]['extra-information'][i].get('regex')
12+ if regex is None:
13+ regex = ''
14 # we also need to know whether user has already set this item's value.
15 # to do this, simply check whether trophies/.extrainformation/<item> file exists.
16 try:
17@@ -642,6 +648,8 @@
18 "needs-information" : i,
19 "label" : label,
20 "description" : desc,
21+ "example" : example,
22+ "regex" : regex,
23 "value" : value}
24 except IOError as e:
25 # we got an exception, so it seems that the file is not present - we'll use "" as the value, to indicate that it's empty
26@@ -649,7 +657,8 @@
27 "collection" : collection,
28 "needs-information" : i,
29 "label" : label,
30- "description" : desc,
31+ "example" : example,
32+ "regex" : regex,
33 "value" : ""}
34
35 # since the collected all data related to this particular ExtraInformation field, append it to the list
36@@ -943,12 +952,14 @@
37 extrainfopath = os.path.join(extrainfodir,extrainfofile)
38 eicfg = ConfigParser.RawConfigParser()
39 eicfg.read(extrainfopath)
40+
41 if eicfg.has_option("label",self.lang):
42 label = eicfg.get("label",self.lang)
43 elif eicfg.has_option("label",self.lang.split("_")[0]):
44 label = eicfg.get("label",self.lang.split("_")[0])
45 else:
46 label = eicfg.get("label",langdefault)
47+
48 if eicfg.has_option("description",self.lang):
49 description = eicfg.get("description",self.lang)
50 elif eicfg.has_option("description",self.lang.split("_")[0]):
51@@ -956,7 +967,26 @@
52 else:
53 description = eicfg.get("description",langdefault)
54
55- extrainfo[extrainfofile] = {'label':label,'description':description}
56+ if eicfg.has_option("example", self.lang):
57+ example = eicfg.get("example", self.lang)
58+ elif eicfg.has_option("example", self.lang.split("_")[0]):
59+ example = eicfg.get("example", self.lang.split("_")[0])
60+ elif eicfg.has_option("example", langdefault):
61+ example = eicfg.get("example", langdefault)
62+ else:
63+ example = None
64+
65+ if eicfg.has_option("regex", "value"):
66+ regex = eicfg.get("regex", "value")
67+ else:
68+ regex = None
69+
70+ extrainfo[extrainfofile] = {
71+ 'label': label,
72+ 'description': description,
73+ 'example': example,
74+ 'regex': regex,
75+ }
76
77 # Store data about this colection
78 collectiondata = {'langdefault':langdefault,'name':collectionname, 'acc_num':accno, 'type':"collection", 'base-path': collpath, 'categories' : collcategories, 'extra-information': extrainfo, 'authors':collauthors}

Subscribers

People subscribed via source and target branches