Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (25 sloc) 808 Bytes
def lines(file_name):
with open(file_name) as config:
for line in config:
if not ignore(line):
yield line.strip()
except OSError:
raise ValueError('File {file} not found'.format(file=file_name))
def ignore(line):
ls = line.strip()
return (not ls
or ls.startswith('#')
or len(ls.split()) < 2)
def break_line(line):
tokens = line.split()
return tokens[-1], tokens[:-1]
def list_to_keys(value, keys):
return {key: value for key in keys}
def shortcut(line):
return {key: url for key, url in list_to_keys(*break_line(line)).items()}
def parse(file_name='shorturls.cfg'):
shorts = {}
for line in lines(file_name):
return shorts
You can’t perform that action at this time.