Simplify some code
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
import tld
|
||||
import json
|
||||
|
||||
def load_file(path):
|
||||
with open(path, 'r') as f:
|
||||
result = [line.rstrip('\n').encode('utf-8').decode('utf-8') for line in f]
|
||||
return '\n'.join(result)
|
||||
|
||||
def host(string):
|
||||
if string and '*' not in string:
|
||||
try:
|
||||
return tld.get_fld(string, fix_protocol=True)
|
||||
except:
|
||||
return False
|
||||
if string and '*' not in string:
|
||||
return tld.get_fld(string, fix_protocol=True, fail_silently=True)
|
||||
|
||||
def load_json(file):
|
||||
return json.loads(load_file('./db/details.json'))
|
||||
with open(file) as f:
|
||||
return json.load(f)
|
||||
|
||||
Reference in New Issue
Block a user