Commit 88c95474ad6411ab59fd68a61831c0d1d3db5c68
1 parent
75849cb9
Exists in
master
Improve perfs of friendly regex.
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
flaskr/controllers/main_controller.py
... | ... | @@ -157,13 +157,15 @@ def gather_addresses(from_list, from_file): |
157 | 157 | addresses = from_list.replace("\r", '').split("\n") |
158 | 158 | |
159 | 159 | clean_addresses = [] |
160 | + # Ignore inevitable copy/paste bloopers | |
161 | + to_ignore = re.compile(r"City\s*,\s*Country", re.I & re.U) | |
160 | 162 | for address in addresses: |
161 | 163 | if not address: |
162 | 164 | continue |
163 | 165 | if type(address).__name__ == 'str': |
164 | 166 | address = unicode(address, 'utf-8') |
165 | - if re.match(r"City\s*,\s*Country", address, re.I & re.U) is not None: | |
166 | - continue # ignore inevitable copy/paste bloopers | |
167 | + if to_ignore.match(address) is not None: | |
168 | + continue | |
167 | 169 | clean_addresses.append(address) |
168 | 170 | addresses = clean_addresses |
169 | 171 | ... | ... |