<s> """<STR_LIT>""" <EOL> from functools import reduce <EOL> def dpath ( dict_ , path ) : <EOL> """<STR_LIT>""" <EOL> from operator import getitem <EOL> paths = path . split ( '<STR_LIT:.>' ) <EOL> return reduce ( <EOL> getitem , <EOL> paths , <EOL> dict_ <EOL> ) <EOL> def credentials ( filename = None , root = None ) : <EOL> """<STR_LIT>""" <EOL> if filename is not None : <EOL> import json <EOL> with open ( filename , '<STR_LIT:rb>' ) as f : <EOL> conf = json . load ( f ) <EOL> if root is not None : <EOL> conf = dpath ( conf , root ) <EOL> else : <EOL> import os <EOL> try : <EOL> conf = { <EOL> '<STR_LIT:username>' : os . environ [ '<STR_LIT>' ] , <EOL> '<STR_LIT:password>' : os . environ [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : os . environ [ '<STR_LIT>' ] , <EOL> } <EOL> except KeyError : <EOL> raise TypeError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> return conf </s>
