13aa194e1878e7268fcd338c4c6f6cf479a9459f,pyemma/util/contexts.py,,settings,#,68

Before Change


    // validate:
    valid_keys = config.keys()
    for k in kwargs.keys():
        if k not in valid_keys:
            raise ValueError("not a valid settings: {key}".format(key=k))

    old_settings = {}
    for k, v in kwargs.items():
        old_settings[k] = getattr(config, k)
        setattr(config, k, v)

    yield

    // restore old settings
    for k, v in old_settings.items():
        setattr(config, k, v)


@contextmanager
def attribute(obj, attr, val):
    previous = getattr(obj, attr)
    setattr(obj, attr, val)

After Change


        for k, v in kwargs.items():
            old_settings[k] = getattr(config, k)
            setattr(config, k, v)
        yield
    finally:
        // restore old settings
        for k, v in old_settings.items():
            setattr(config, k, v)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: markovmodel/PyEMMA
Commit Name: 13aa194e1878e7268fcd338c4c6f6cf479a9459f
Time: 2018-06-18
Author: m.scherer@fu-berlin.de
File Name: pyemma/util/contexts.py
Class Name:
Method Name: settings


Project Name: pantsbuild/pants
Commit Name: 155077e9dcb990d560c1fdc1cabb84b149974679
Time: 2019-05-16
Author: stuhood@gmail.com
File Name: src/python/pants/rules/core/test.py
Class Name:
Method Name: coordinator_of_tests


Project Name: pantsbuild/pants
Commit Name: ac0b7e4b3d8267c682b2e821f8db592ca94103e3
Time: 2018-03-18
Author: stuhood@twitter.com
File Name: src/python/pants/engine/legacy/graph.py
Class Name: LegacyBuildGraph
Method Name: _inject_specs