Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
ddomingof committed Oct 4, 2018
1 parent 244dd9b commit 531269d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/pathme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
import os
import pickle
from typing import AnyStr, Dict, Iterable, List, Optional
from typing import Dict, Iterable, List, Optional
from urllib.request import urlretrieve

import click
Expand Down Expand Up @@ -34,17 +34,22 @@ def get_files_in_folder(path: str) -> List[str]:
]


def check_multiple(element: Iterable, element_name: AnyStr):
def check_multiple(element, element_name):
"""Check whether element is iterable.
:param element: variable to check
:param element_name: name to print
:return:
"""
if isinstance(element, Iterable):
log.warning('Multiple {}: {}'.format(element_name, element))
# TODO: print the wikipathways bps that return a set because they are probably wrong.
if len(element) != 0:
return list(element)[0]
else:
log.warning('Empty list/set %s', element)

else:
return element
log.warning('Empty list/set %s', element)

return element


def parse_id_uri(uri):
Expand Down

0 comments on commit 531269d

Please sign in to comment.