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

Delta Between Two Patch Sets: abp/filters/parser.py

Issue 29979570: Issue 7205 - Change classes that use ALL_CAPS naming to be CamelCase (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Created Jan. 12, 2019, 1:21 a.m.
Right Patch Set: Address comments on PS1 Created Jan. 12, 2019, 9:17 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp/filters/__init__.py ('k') | tests/test_parser.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 """ 43 """
44 44
45 def __init__(self, error, text): 45 def __init__(self, error, text):
46 Exception.__init__(self, '{} in "{}"'.format(error, text)) 46 Exception.__init__(self, '{} in "{}"'.format(error, text))
47 self.text = text 47 self.text = text
48 self.error = error 48 self.error = error
49 49
50 50
51 # Constants related to filters (see https://adblockplus.org/filters). 51 # Constants related to filters (see https://adblockplus.org/filters).
52 class SelectorType: # flake8: noqa (this is a namespace of constants). 52 class SelectorType:
Vasily Kuznetsov 2019/01/12 19:23:38 You should be able to delete the comment that disa
rhowell 2019/01/12 21:18:34 Done.
53 """Selector type constants.""" 53 """Selector type constants."""
54 54
55 URL_PATTERN = 'url-pattern' # Normal URL patterns. 55 URL_PATTERN = 'url-pattern' # Normal URL patterns.
56 URL_REGEXP = 'url-regexp' # Regular expressions for URLs. 56 URL_REGEXP = 'url-regexp' # Regular expressions for URLs.
57 CSS = 'css' # CSS selectors for hiding filters. 57 CSS = 'css' # CSS selectors for hiding filters.
58 XCSS = 'extended-css' # Extended CSS selectors (to emulate CSS4). 58 XCSS = 'extended-css' # Extended CSS selectors (to emulate CSS4).
59 ABP_SIMPLE = 'abp-simple' # Simplified element hiding syntax. 59 ABP_SIMPLE = 'abp-simple' # Simplified element hiding syntax.
60 60
61 61
62 class FilterAction: # flake8: noqa (this is a namespace of constants). 62 class FilterAction:
63 """Filter action constants.""" 63 """Filter action constants."""
64 64
65 BLOCK = 'block' # Block the request. 65 BLOCK = 'block' # Block the request.
66 ALLOW = 'allow' # Allow the request (whitelist). 66 ALLOW = 'allow' # Allow the request (whitelist).
67 HIDE = 'hide' # Hide selected element(s). 67 HIDE = 'hide' # Hide selected element(s).
68 SHOW = 'show' # Show selected element(s) (whitelist). 68 SHOW = 'show' # Show selected element(s) (whitelist).
69 69
70 70
71 class FilterOption: # flake8: noqa (this is a namespace of constants). 71 class FilterOption:
72 """Filter option constants.""" 72 """Filter option constants."""
73 73
74 # Resource types. 74 # Resource types.
75 OTHER = 'other' 75 OTHER = 'other'
76 SCRIPT = 'script' 76 SCRIPT = 'script'
77 IMAGE = 'image' 77 IMAGE = 'image'
78 STYLESHEET = 'stylesheet' 78 STYLESHEET = 'stylesheet'
79 OBJECT = 'object' 79 OBJECT = 'object'
80 SUBDOCUMENT = 'subdocument' 80 SUBDOCUMENT = 'subdocument'
81 DOCUMENT = 'document' 81 DOCUMENT = 'document'
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 for line in lines: 338 for line in lines:
339 parsed_line = parse_line(line, position) 339 parsed_line = parse_line(line, position)
340 yield parsed_line 340 yield parsed_line
341 341
342 if position != 'body' and parsed_line.type in {'header', 'metadata'}: 342 if position != 'body' and parsed_line.type in {'header', 'metadata'}:
343 # Continue parsing metadata until it's over... 343 # Continue parsing metadata until it's over...
344 position = 'metadata' 344 position = 'metadata'
345 else: 345 else:
346 # ...then switch to parsing the body. 346 # ...then switch to parsing the body.
347 position = 'body' 347 position = 'body'
LEFTRIGHT

Powered by Google App Engine
This is Rietveld