Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+52 added−38 removed
other:+52 added−38 removed
Provenance
Commit
49f1ec1
Tree
d535c29
Author
Kenneth Reitz <me@kennethreitz.com>
Committer
Kenneth Reitz <me@kennethreitz.com>
Parent
0741448
2 files changed+52 added−38 removed
added:requests/config.py+52 added
1+# -*- coding: utf-8 -*-2+3+"""4+requests.config5+~~~~~~~~~~~~~~~6+7+This module provides the Requests settings feature set.8+9+"""10+11+# Time (in seconds) to allow the request to connect to12+# the remote host before timing it out.13+14+# timeout = None15+16+17+class Settings(object):18+ _singleton = {}19+ __attrs__ = ('timeout',)20+21+ def __init__(self, **kwargs):22+ super(Settings, self).__init__()23+24+ self.__dict__ = self._singleton25+26+ def __getattribute__(self, key):27+ if key in object.__getattribute__(self, '__attrs__'):28+ try:29+ return object.__getattribute__(self, key)30+ except AttributeError:31+ return None32+ return object.__getattribute__(self, key)33+34+35+ def __enter__(self):36+ pass37+38+ def __exit__(self, *args):39+40+ self.__dict__.update(self.__cache.copy())41+ del self.__cache42+43+44+ def __call__(self, *args, **kwargs):45+ r = self.__class__()46+ r.__cache = self.__dict__.copy()47+ self.__dict__.update(*args, **kwargs)48+49+ return r50+51+52+settings = Settings()
deleted:requests/settings.py-38 removed
1-# -*- coding: utf-8 -*-2-3-"""4-requests.settings5-~~~~~~~~~~~~~~~~~6-7-This module provides the Requests settings feature set.8-9-"""10-11-# Time (in seconds) to allow the request to connect to12-# the remote host before timing it out.13-timeout = None14-15-class Settings(object):16-17- def __init__(self, **settings):18- self._cache_settings(**settings)19- self._alter_settings(**settings)20-21- def __enter__(self):22- pass23-24- def __exit__(self, type, value, traceback):25- self._restore_settings()26-27- def _cache_settings(self, **settings):28- self.cache = {}29- for setting in settings:30- self.cache[setting] = globals()[setting]31-32- def _alter_settings(self, **settings):33- for setting, value in settings.items():34- globals()[setting] = value35-36- def _restore_settings(self):37- for setting, value in self.cache.items():38- globals()[setting] = value