ndexbio / ndex-python

NDEx Python Client v3.1 - Superseded by the NDEx2 Client v1.0
2 stars 6 forks source link

Check username and password from environment variables #9

Open cthoyt opened 7 years ago

cthoyt commented 7 years ago

It would be convenient to set the username and password in the environment variables, and have the python client look for those automatically if the username and password aren't explicitly set in the kwargs, maybe like this:

class NdexGraph (MultiDiGraph):
    """A graph compatible with NDEx"""
    def __init__(self, cx=None, server=None, username=None, password=None, uuid=None, networkx_G=None, data=None, **attr):

        ...

        if username is None and 'NDEX_USERNAME' in os.environ:
              username = os.environ['NDEX_USERNAME']

        if password is None and 'NDEX_PASSWORD' in os.environ:
              password = os.environ['NDEX_PASSWORD']

        ...