<s> import os <EOL> from six . moves . urllib_parse import urlparse <EOL> def from_docker_envvars ( config ) : <EOL> if '<STR_LIT>' in os . environ : <EOL> pg_url = urlparse ( os . environ [ '<STR_LIT>' ] ) <EOL> if not pg_url . scheme == '<STR_LIT>' : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> host , port = pg_url . netloc . split ( '<STR_LIT::>' ) <EOL> uri = '<STR_LIT>' . format ( <EOL> user = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> password = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> host = host , <EOL> port = port , <EOL> database = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> config [ '<STR_LIT>' ] = uri <EOL> if '<STR_LIT>' in os . environ : <EOL> redis_url = urlparse ( os . environ [ '<STR_LIT>' ] ) <EOL> if not redis_url . scheme == '<STR_LIT>' : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> host , port = redis_url . netloc . split ( '<STR_LIT::>' ) <EOL> uri = '<STR_LIT>' . format ( host = host , port = port , ) <EOL> config [ '<STR_LIT>' ] = uri <EOL> config [ '<STR_LIT>' ] = host <EOL> config [ '<STR_LIT>' ] = int ( port ) </s>
