OLD | NEW |
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 Loading... |
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 SELECTOR_TYPE: # flake8: noqa (this is a namespace of constants). | 52 class SELECTOR_TYPE: # noqa: N801 |
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 FILTER_ACTION: # flake8: noqa (this is a namespace of constants). | 62 class FILTER_ACTION: # noqa: N801 |
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 FILTER_OPTION: # flake8: noqa (this is a namespace of constants). | 71 class FILTER_OPTION: # noqa: N801 |
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 Loading... |
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' |
OLD | NEW |