| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2015 Google Inc. All Rights Reserved. | |
| 3 # | |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 # you may not use this file except in compliance with the License. | |
| 6 # You may obtain a copy of the License at | |
| 7 # | |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 # | |
| 10 # Unless required by applicable law or agreed to in writing, software | |
| 11 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 # See the License for the specific language governing permissions and | |
| 14 # limitations under the License. | |
| 15 | |
| 16 | |
| 17 class Rule(object): | |
| 18 """An optional base class for rule implementations. | |
| 19 | |
| 20 The rule_parser looks for the 'IsType' and 'ApplyRule' methods by name, so | |
| 21 rules are not strictly required to extend this class. | |
| 22 """ | |
| 23 | |
| 24 def IsType(self, rule_type_name): | |
| 25 """Returns True if the name matches this rule.""" | |
| 26 raise NotImplementedError | |
| 27 | |
| 28 def ApplyRule(self, return_value, request, response): | |
| 29 """Invokes this rule with the given args. | |
| 30 | |
| 31 Args: | |
| 32 return_value: the prior rule's return_value (if any). | |
| 33 request: the httparchive ArchivedHttpRequest. | |
| 34 response: the httparchive ArchivedHttpResponse, which may be None. | |
| 35 Returns: | |
| 36 A (should_stop, return_value) tuple. Typically the request and response | |
| 37 are treated as immutable, so it's the caller's job to apply the | |
| 38 return_value (e.g., set response fields). | |
| 39 """ | |
| 40 raise NotImplementedError | |
| OLD | NEW |