Skip to content
Myr

config.py => _config.py

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 185450c · Browse files · 2 files+68 added−68 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+68 added−68 removed

  • other:+68 added−68 removed

2 files+68 added−68 removed

added:requests/_config.py+68 added
1# -*- coding: utf-8 -*-23"""4requests.config5~~~~~~~~~~~~~~~67This module provides the Requests settings feature set.89"""1011class Settings(object):12 _singleton = {}1314 # attributes with defaults15 __attrs__ = []1617 def __init__(self, **kwargs):18 super(Settings, self).__init__()1920 self.__dict__ = self._singleton212223 def __call__(self, *args, **kwargs):24 # new instance of class to call25 r = self.__class__()2627 # cache previous settings for __exit__28 r.__cache = self.__dict__.copy()29 map(self.__cache.setdefault, self.__attrs__)3031 # set new settings32 self.__dict__.update(*args, **kwargs)3334 return r353637 def __enter__(self):38 pass394041 def __exit__(self, *args):4243 # restore cached copy44 self.__dict__.update(self.__cache.copy())45 del self.__cache464748 def __getattribute__(self, key):49 if key in object.__getattribute__(self, '__attrs__'):50 try:51 return object.__getattribute__(self, key)52 except AttributeError:53 return None54 return object.__getattribute__(self, key)555657settings = Settings()5859settings.base_headers = {'User-Agent': 'python-requests.org'}60settings.accept_gzip = True61settings.proxies = None62settings.verbose = None63settings.timeout = None64settings.max_redirects = 3065settings.decode_unicode = True6667#: Use socket.setdefaulttimeout() as fallback?68settings.timeout_fallback = True
deleted:requests/config.py-68 removed
1# -*- coding: utf-8 -*-23"""4requests.config5~~~~~~~~~~~~~~~67This module provides the Requests settings feature set.89"""1011class Settings(object):12 _singleton = {}1314 # attributes with defaults15 __attrs__ = []1617 def __init__(self, **kwargs):18 super(Settings, self).__init__()1920 self.__dict__ = self._singleton212223 def __call__(self, *args, **kwargs):24 # new instance of class to call25 r = self.__class__()2627 # cache previous settings for __exit__28 r.__cache = self.__dict__.copy()29 map(self.__cache.setdefault, self.__attrs__)3031 # set new settings32 self.__dict__.update(*args, **kwargs)3334 return r353637 def __enter__(self):38 pass394041 def __exit__(self, *args):4243 # restore cached copy44 self.__dict__.update(self.__cache.copy())45 del self.__cache464748 def __getattribute__(self, key):49 if key in object.__getattribute__(self, '__attrs__'):50 try:51 return object.__getattribute__(self, key)52 except AttributeError:53 return None54 return object.__getattribute__(self, key)555657settings = Settings()5859settings.base_headers = {'User-Agent': 'python-requests.org'}60settings.accept_gzip = True61settings.proxies = None62settings.verbose = None63settings.timeout = None64settings.max_redirects = 3065settings.decode_unicode = True6667#: Use socket.setdefaulttimeout() as fallback?68settings.timeout_fallback = True