LEFT | RIGHT |
1 # This file is part of the Adblock Plus website, | 1 # This file is part of the Adblock Plus website, |
2 # Copyright (C) 2006-2015 Eyeo GmbH | 2 # Copyright (C) 2006-2015 Eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 10 matching lines...) Expand all Loading... |
21 parsed = [] | 21 parsed = [] |
22 for key, value in interface_items.iteritems(): | 22 for key, value in interface_items.iteritems(): |
23 if "(" in key: | 23 if "(" in key: |
24 # Item is a method | 24 # Item is a method |
25 match = re.match(r"^\s*(%s)\s+(\S+)\s*\(\s*([^\)]*)\s*\)\s*$" % TYPE_REGEX
P, key) | 25 match = re.match(r"^\s*(%s)\s+(\S+)\s*\(\s*([^\)]*)\s*\)\s*$" % TYPE_REGEX
P, key) |
26 if not match: | 26 if not match: |
27 warnings.warn("Skipped malformed method: '%s'" % key) | 27 warnings.warn("Skipped malformed method: '%s'" % key) |
28 continue | 28 continue |
29 return_type, property_name, argument_string = match.groups() | 29 return_type, property_name, argument_string = match.groups() |
30 arguments = [] | 30 arguments = [] |
31 if "version" in value: | |
32 property_version = value["version"] | |
33 else: | |
34 property_version = "" | |
35 if argument_string: | 31 if argument_string: |
36 for argument in argument_string.split(","): | 32 for argument in argument_string.split(","): |
37 if argument.strip(): | 33 if argument.strip(): |
38 match = re.match(r"^\s*(%s)\s+(\S+)\s*$" % TYPE_REGEXP, argument) | 34 match = re.match(r"^\s*(%s)\s+(\S+)\s*$" % TYPE_REGEXP, argument) |
39 if not match: | 35 if not match: |
40 warnings.warn("Skipped malformed argument: '%s'" % argument) | 36 warnings.warn("Skipped malformed argument: '%s'" % argument) |
41 continue | 37 continue |
42 argument_type, argument_name = match.groups() | 38 argument_type, argument_name = match.groups() |
43 arguments.append({ | 39 arguments.append({ |
44 "name": argument_name, | 40 "name": argument_name, |
45 "type": argument_type | 41 "type": argument_type |
46 }) | 42 }) |
47 parsed.append({ | 43 value.update({ |
48 "type": "method", | 44 "type": "method", |
49 "name": property_name, | 45 "name": property_name, |
50 "version": property_version, | |
51 "return_type": return_type, | 46 "return_type": return_type, |
52 "arguments": arguments | 47 "arguments": arguments |
53 }) | 48 }) |
| 49 parsed.append(value) |
54 else: | 50 else: |
55 # Item is a property | 51 # Item is a property |
56 match = re.match(r"^\s*(readonly\s+)?(%s)\s+(\S+)\s*$" % TYPE_REGEXP, key) | 52 match = re.match(r"^\s*(readonly\s+)?(%s)\s+(\S+)\s*$" % TYPE_REGEXP, key) |
57 if not match: | 53 if not match: |
58 warnings.warn("Skipped malformed property: '%s'" % key) | 54 warnings.warn("Skipped malformed property: '%s'" % key) |
59 continue | 55 continue |
60 property_modifier, property_type, property_name = match.groups() | 56 property_modifier, property_type, property_name = match.groups() |
61 parsed.append({ | 57 value.update({ |
62 "type": property_type, | 58 "type": property_type, |
63 "name": property_name, | 59 "name": property_name, |
64 "modifier": property_modifier or "" | 60 "modifier": property_modifier or "" |
65 }) | 61 }) |
| 62 parsed.append(value) |
66 parsed.sort(key=lambda x: x["name"]) | 63 parsed.sort(key=lambda x: x["name"]) |
67 return parsed | 64 return parsed |
LEFT | RIGHT |