Project Name: chubin+cheat.sh
Language: Python
Statement Type: API

Source Code:
def _load_config_from_file(default_config, filename):
    import yaml

    update = {}
    if not os.path.exists(filename):
        return update

    with open(filename) as f:
        newconfig = yaml.load(f.read(), Loader=yaml.SafeLoader)
    for key, val in default_config.items():
        newval = _get_nested(newconfig, key)
        if newval is None:
            continue

        if isinstance(val, int):
            try:
                newval = int(newval)
            except (ValueError, TypeError):
                continue

        update[key] = newval

    return update

_load_config_from_file(default_config={'adapters.active': ['tldr', 'cheat', 'fosdem', 'translation', 'rosetta', 'late.nz', 'question', 'cheat.sheets', 'cheat.sheets dir', 'learnxiny', 'rfc', 'oeis', 'chmod'], 'adapters.mandatory': ['search'], 'cache.redis.db': 0, 'cache.redis.host': 'localhost', 'cache.redis.port': 6379, 'cache.redis.prefix': '', 'cache.type': 'redis', 'frontend.styles': ['abap', 'algol', 'algol_nu', 'arduino', 'autumn', 'borland', 'bw', 'colorful', 'default', 'dracula', 'emacs', 'friendly', 'friendly_grayscale', 'fruity', 'github-dark', 'gruvbox-dark', 'gruvbox-light', 'igor', 'inkpot', 'lightbulb', 'lilypond', 'lovelace', 'manni', 'material', 'monokai', 'murphy', 'native', 'nord', 'nord-darker', 'one-dark', 'paraiso-dark', 'paraiso-light', 'pastie', 'perldoc', 'rainbow_dash', 'rrt', 'sas', 'solarized-dark', 'solarized-light', 'staroffice', 'stata-dark', 'stata-light', 'tango', 'trac', 'vim', 'vs', 'xcode', 'zenburn'], 'log.level': 4, 'path.internal.ansi2html': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/ansi2html.sh', 'path.internal.bin': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin', 'path.internal.bin.upstream': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin/upstream', 'path.internal.malformed': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static/malformed-response.html', 'path.internal.pages': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share', 'path.internal.static': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static', 'path.internal.templates': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/templates', 'path.internal.vim': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/vim', 'path.log.main': 'log/main.log', 'path.log.queries': 'log/queries.log', 'path.log.fetch': 'log/fetch.log', 'path.repositories': 'upstream', 'path.spool': 'spool', 'path.workdir': '/home/jinjun/.cheat.sh', 'routing.pre': [('^$', 'search'), ('^[^/]*/rosetta(/|$)', 'rosetta'), ('^rfc/', 'rfc'), ('^oeis/', 'oeis'), ('^chmod/', 'chmod'), ('^:', 'internal'), ('/:list$', 'internal'), ('/$', 'cheat.sheets dir')], 'routing.main': [('', 'cheat.sheets'), ('', 'cheat'), ('', 'tldr'), ('', 'late.nz'), ('', 'fosdem'), ('', 'learnxiny')], 'routing.post': [('^[^/ +]*$', 'unknown'), ('^[a-z][a-z]-[a-z][a-z]$', 'translation')], 'routing.default': 'question', 'upstream.url': 'https://cheat.sh', 'upstream.timeout': 5, 'search.limit': 20, 'server.bind': '0.0.0.0', 'server.port': 8002}, filename='/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/etc/config.yaml')

Selected Statement: with open(filename) as f:

Function Input:
default_config: {'adapters.active': ['tldr', 'cheat', 'fosdem', 'translation', 'rosetta', 'late.nz', 'question', 'cheat.sheets', 'cheat.sheets dir', 'learnxiny', 'rfc', 'oeis', 'chmod'], 'adapters.mandatory': ['search'], 'cache.redis.db': 0, 'cache.redis.host': 'localhost', 'cache.redis.port': 6379, 'cache.redis.prefix': '', 'cache.type': 'redis', 'frontend.styles': ['abap', 'algol', 'algol_nu', 'arduino', 'autumn', 'borland', 'bw', 'colorful', 'default', 'dracula', 'emacs', 'friendly', 'friendly_grayscale', 'fruity', 'github-dark', 'gruvbox-dark', 'gruvbox-light', 'igor', 'inkpot', 'lightbulb', 'lilypond', 'lovelace', 'manni', 'material', 'monokai', 'murphy', 'native', 'nord', 'nord-darker', 'one-dark', 'paraiso-dark', 'paraiso-light', 'pastie', 'perldoc', 'rainbow_dash', 'rrt', 'sas', 'solarized-dark', 'solarized-light', 'staroffice', 'stata-dark', 'stata-light', 'tango', 'trac', 'vim', 'vs', 'xcode', 'zenburn'], 'log.level': 4, 'path.internal.ansi2html': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/ansi2html.sh', 'path.internal.bin': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin', 'path.internal.bin.upstream': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin/upstream', 'path.internal.malformed': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static/malformed-response.html', 'path.internal.pages': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share', 'path.internal.static': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static', 'path.internal.templates': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/templates', 'path.internal.vim': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/vim', 'path.log.main': 'log/main.log', 'path.log.queries': 'log/queries.log', 'path.log.fetch': 'log/fetch.log', 'path.repositories': 'upstream', 'path.spool': 'spool', 'path.workdir': '/home/jinjun/.cheat.sh', 'routing.pre': [('^$', 'search'), ('^[^/]*/rosetta(/|$)', 'rosetta'), ('^rfc/', 'rfc'), ('^oeis/', 'oeis'), ('^chmod/', 'chmod'), ('^:', 'internal'), ('/:list$', 'internal'), ('/$', 'cheat.sheets dir')], 'routing.main': [('', 'cheat.sheets'), ('', 'cheat'), ('', 'tldr'), ('', 'late.nz'), ('', 'fosdem'), ('', 'learnxiny')], 'routing.post': [('^[^/ +]*$', 'unknown'), ('^[a-z][a-z]-[a-z][a-z]$', 'translation')], 'routing.default': 'question', 'upstream.url': 'https://cheat.sh', 'upstream.timeout': 5, 'search.limit': 20, 'server.bind': '0.0.0.0', 'server.port': 8002}
filename: '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/etc/config.yaml'

Variable Values Before Statement:
filename: '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/etc/config.yaml'

Value After Statement Execution: <_io.TextIOWrapper name

Variable States During Runtime (line, value):
default_config: 1
{'adapters.active': ['tldr', 'cheat', 'fosdem', 'translation', 'rosetta', 'late.nz', 'question', 'cheat.sheets', 'cheat.sheets dir', 'learnxiny', 'rfc', 'oeis', 'chmod'], 'adapters.mandatory': ['search'], 'cache.redis.db': 0, 'cache.redis.host': 'localhost', 'cache.redis.port': 6379, 'cache.redis.prefix': '', 'cache.type': 'redis', 'frontend.styles': ['abap', 'algol', 'algol_nu', 'arduino', 'autumn', 'borland', 'bw', 'colorful', 'default', 'dracula', 'emacs', 'friendly', 'friendly_grayscale', 'fruity', 'github-dark', 'gruvbox-dark', 'gruvbox-light', 'igor', 'inkpot', 'lightbulb', 'lilypond', 'lovelace', 'manni', 'material', 'monokai', 'murphy', 'native', 'nord', 'nord-darker', 'one-dark', 'paraiso-dark', 'paraiso-light', 'pastie', 'perldoc', 'rainbow_dash', 'rrt', 'sas', 'solarized-dark', 'solarized-light', 'staroffice', 'stata-dark', 'stata-light', 'tango', 'trac', 'vim', 'vs', 'xcode', 'zenburn'], 'log.level': 4, 'path.internal.ansi2html': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/ansi2html.sh', 'path.internal.bin': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin', 'path.internal.bin.upstream': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin/upstream', 'path.internal.malformed': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static/malformed-response.html', 'path.internal.pages': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share', 'path.internal.static': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static', 'path.internal.templates': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/templates', 'path.internal.vim': '/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/vim', 'path.log.main': 'log/main.log', 'path.log.queries': 'log/queries.log', 'path.log.fetch': 'log/fetch.log', 'path.repositories': 'upstream', 'path.spool': 'spool', 'path.workdir': '/home/jinjun/.cheat.sh', 'routing.pre': [('^$', 'search'), ('^[^/]*/rosetta(/|$)', 'rosetta'), ('^rfc/', 'rfc'), ('^oeis/', 'oeis'), ('^chmod/', 'chmod'), ('^:', 'internal'), ('/:list$', 'internal'), ('/$', 'cheat.sheets dir')], 'routing.main': [('', 'cheat.sheets'), ('', 'cheat'), ('', 'tldr'), ('', 'late.nz'), ('', 'fosdem'), ('', 'learnxiny')], 'routing.post': [('^[^/ +]*$', 'unknown'), ('^[a-z][a-z]-[a-z][a-z]$', 'translation')], 'routing.default': 'question', 'upstream.url': 'https://cheat.sh', 'upstream.timeout': 5, 'search.limit': 20, 'server.bind': '0.0.0.0', 'server.port': 8002}
filename: 1
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/etc/config.yaml'
yaml: 2
<module 'yaml' from '/local/rcs/jinjun/miniforge3/envs/chubin+cheat.sh/lib/python3.9/site-packages/yaml/__init__.py'>
update: 4
21
cache.type: redis
f: 8
<_io.TextIOWrapper name='/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/etc/config.yaml' mode='r' encoding='UTF-8'>
newconfig: 9
{'server': {'address': '0.0.0.0'}, 'cache': {'type': 'redis'}}
key: 10
'adapters.active'
10
'adapters.mandatory'
10
'cache.redis.db'
10
'cache.redis.host'
10
'cache.redis.port'
10
'cache.redis.prefix'
10
'cache.type'
10
'frontend.styles'
10
'log.level'
10
'path.internal.ansi2html'
10
'path.internal.bin'
10
'path.internal.bin.upstream'
10
'path.internal.malformed'
10
'path.internal.pages'
10
'path.internal.static'
10
'path.internal.templates'
10
'path.internal.vim'
10
'path.log.main'
10
'path.log.queries'
10
'path.log.fetch'
10
'path.repositories'
10
'path.spool'
10
'path.workdir'
10
'routing.pre'
10
'routing.main'
10
'routing.post'
10
'routing.default'
10
'upstream.url'
10
'upstream.timeout'
10
'search.limit'
10
'server.bind'
10
'server.port'
val: 10
tldr, cheat, fosdem, translation, rosetta, late.nz, question, cheat.sheets, cheat.sheets dir, learnxiny, rfc, oeis, chmod
10
search
10
0
10
'localhost'
10
6379
10
''
10
'redis'
10
abap algol algol_nu arduino autumn borland bw colorful default dracula emacs friendly friendly_grayscale fruity github-dark gruvbox-dark gruvbox-light igor inkpot lightbulb lilypond lovelace manni material monokai murphy native nord nord-darker one-dark paraiso-dark paraiso-light pastie perldoc rainbow_dash rrt sas solarized-dark solarized-light staroffice stata-dark stata-light tango trac vim vs xcode zenburn
10
4
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/ansi2html.sh'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/bin/upstream'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static/malformed-response.html'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/static'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/templates'
10
'/local/rcs/jinjun/code/pytrace-collector/logs/self_collected/tried/chubin+cheat.sh/chubin+cheat.sh/share/vim'
10
'log/main.log'
10
'log/queries.log'
10
'log/fetch.log'
10
'upstream'
10
'spool'
10
'/home/jinjun/.cheat.sh'
10
[('^$', 'search'), ('^[^/]*/rosetta(/|$)', 'rosetta'), ('^rfc/', 'rfc'), ('^oeis/', 'oeis'), ('^chmod/', 'chmod'), ('^:', 'internal'), ('/:list$', 'internal'), ('/$', 'cheat.sheets dir')]
10
[('', 'cheat.sheets'), ('', 'cheat'), ('', 'tldr'), ('', 'late.nz'), ('', 'fosdem'), ('', 'learnxiny')]
10
[('^[^/ +]*$', 'unknown'), ('^[a-z][a-z]-[a-z][a-z]$', 'translation')]
10
'question'
10
'https://cheat.sh'
10
5
10
20
10
'0.0.0.0'
10
8002
newval: 11
None
11
'redis'
11
None