You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
845 B
32 lines
845 B
def extract_wiki_definitions(file_handle): |
|
for line in fh: |
|
if line.startswith('wikis = ['): |
|
break |
|
for line in fh: |
|
if line.startswith(']'): |
|
raise StopIteration |
|
parts = split_wiki_definitions(line) |
|
if parts is not None: |
|
yield parts[1], parts[3] |
|
|
|
|
|
def split_wiki_definitions(line): |
|
for quote in ('"', "'"): |
|
parts = line.split(quote) |
|
if len(parts) == 5: |
|
return parts |
|
return None |
|
|
|
|
|
def extract_data_dir(fh): |
|
for line in fh: |
|
parts = line.split('=', 1) |
|
if len(parts) == 2: |
|
name, value = parts |
|
if name.strip() == 'data_dir': |
|
value = value.strip() |
|
return value[1:-1] |
|
|
|
|
|
def dict_helper(dict_like): |
|
return [' %s: %s' % (k, v) for k, v in dict_like.items()]
|
|
|