Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: filters/parse_interface.py

Issue 6265373108207616: Issue #1170 adblockplus.org migration from Anwiki to our CMS. (Closed)
Patch Set: Created Sept. 17, 2014, 8:22 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | filters/subscription_sort.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import re
2 from jinja2 import environmentfilter
3 # readonly PRInt32 subscriptionCount
4 # void removePatterns ( arrayof wstring patterns )
5 # wstring updateExternalSubscription ( AString id, AUTF8String title, arrayof ws tring patterns )
6
7 @environmentfilter
8 def parse_interface(environment, interfaces):
9 parsed = []
10 for property_key, property in interfaces.iteritems():
11 if property_key.find("(") > -1:
12 match = re.match("^(arrayof\W+\w+|\w+)\W+(\w+)[\W\(]+([^\)]*)[\W\)]+$", pr operty_key)
13 if not match:
14 continue
15 return_type, property_name, argument_string = match.groups()
16 arguments = []
17 if "version" in property:
18 property_version = property["version"]
19 else:
20 property_version = ""
21 if argument_string:
22 for i, argument in enumerate(argument_string.split(",")):
23 parts = argument.split(" ")
24 argument_name = parts[-1]
25 argument_type = " ".join(parts[:-1])
26 arguments.append({
27 "name": argument_name,
28 "type": argument_type
29 })
30 parsed.append({
31 "type": "method",
32 "name": property_name,
33 "version": property_version,
34 "return_type": return_type,
35 "arguments": arguments,
36 })
37 else:
38 parts = property_key.split()
39 property = { }
40 property["type"], property["name"] = parts[-2:]
41 if len(parts) == 3:
42 property["modifier"] = parts[0]
43 parsed.append(property)
44 parsed = sorted(parsed, key=lambda x: x["name"])
45 return parsed
OLDNEW
« no previous file with comments | « no previous file | filters/subscription_sort.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld