コード例 #1
0
def test_get_partial_dict():
    eq_(
        get_partial_dict('prefix', {
            'prefix.xyz': 1,
            'prefix.zyx': 2,
            'xy': 3
        }), {
            'xyz': 1,
            'zyx': 2
        })
コード例 #2
0
ファイル: tgconfig.py プロジェクト: hhy5277/tg2
    def __getattr__(self, key):
        """Our custom attribute getter.

        Tries to get the attribute off the wrapped object first,
        if that does not work, tries dictionary lookup, and finally
        tries to grab all keys that start with the attribute and
        return sub-dictionaries that can be looked up.

        """
        try:
            return self.config_proxy.__getattribute__(key)
        except AttributeError:
            try:
                return self.config_proxy.current_conf()[key]
            except KeyError:
                return get_partial_dict(key, self.config_proxy.current_conf(), Bunch)
コード例 #3
0
def test_get_partial_dict():
    eq_(get_partial_dict('prefix', {'prefix.xyz':1, 'prefix.zyx':2, 'xy':3}),
        {'xyz':1,'zyx':2})
コード例 #4
0
ファイル: util.py プロジェクト: garrettmc/TGWikiTutorial
 def __getattr__(self, name):
     try:
         return self[name]
     except KeyError:
         return get_partial_dict(name, self, Bunch)
コード例 #5
0
 def __getattr__(self, name):
     try:
         return self[name]
     except KeyError:
         return get_partial_dict(name, self, Bunch)