Skip to content

Commit 2038924

Browse files
committed
Use constants for invalid domains
1 parent 5b1760a commit 2038924

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

mapping_information/cardano_preprocessing/cardano_preprocessing.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
from urllib.parse import urlparse
1010

1111

12+
INVALID_HOMEPAGES = {
13+
'https://', 'http://', 'n/a', 'na', '-', '--', '---', '....', '...',
14+
'tbd', 'coming', 'coming soon', 'in process', 'no webside', 'no website',
15+
'none', 'null', 'undefined', 'unknown'
16+
}
17+
18+
INVALID_HOMEPAGE_SUBSTRINGS = [
19+
'foo.com', 'example.com', 'invalidurl', 'test.com',
20+
'localhost', '127.0.0.1', 'yourdomain', 'yoursite',
21+
'mysite.com', 'mypool.com', 'poolname.com'
22+
]
23+
24+
1225
def get_pool_data_BQ(force_query):
1326
"""
1427
Queries the BigQuery database for pool data and writes it to a json file.
@@ -269,27 +282,17 @@ def filter_homepage(homepage):
269282
"""
270283
if not homepage:
271284
return None
285+
272286
homepage = homepage.strip()
273287
if not homepage:
274288
return None
275289

276290
homepage_lower = homepage.lower()
277291

278-
INVALID_EXACT = {
279-
'https://', 'http://', 'n/a', 'na', '-', '--', '---', '....', '...',
280-
'tbd', 'coming', 'coming soon', 'in process', 'no webside', 'no website',
281-
'none', 'null', 'undefined', 'unknown'
282-
}
283-
if homepage_lower in INVALID_EXACT:
292+
if homepage_lower in INVALID_HOMEPAGES:
284293
return None
285294

286-
INVALID_SUBSTRINGS = [
287-
'foo.com', 'example.com', 'invalidurl', 'test.com',
288-
'localhost', '127.0.0.1', 'yourdomain', 'yoursite',
289-
'mysite.com', 'mypool.com', 'poolname.com'
290-
]
291-
292-
if any(kw in homepage_lower for kw in INVALID_SUBSTRINGS):
295+
if any(kw in homepage_lower for kw in INVALID_HOMEPAGE_SUBSTRINGS):
293296
return None
294297

295298
return homepage

0 commit comments

Comments
 (0)