Skip to content
Myr

cleanup — comments

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 982fd9d · Browse files · 1 file+23 added−20 removed
This commit

State

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

Diff stats

1 file+23 added−20 removed

  • other:+23 added−20 removed

1 file+23 added−20 removed

modified:requests/config.py+23 added-20 removed
6 unmodified lines
7This module provides the Requests settings feature set.89"""1011# Time (in seconds) to allow the request to connect to12# the remote host before timing it out.1314# timeout = None151611class Settings(object):12 _singleton = {}1314 # attributes with defaults15 __attrs__ = ('timeout',)1617 def __init__(self, **kwargs):18 super(Settings, self).__init__()1920 self.__dict__ = self._singleton2126 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)2223 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()2930 # set new settings31 self.__dict__.update(*args, **kwargs)3233 return r343536 def __enter__(self):37 pass383940 def __exit__(self, *args):4142 # restore cached copy43 self.__dict__.update(self.__cache.copy())44 del self.__cache454644 def __call__(self, *args, **kwargs):45 r = self.__class__()46 r.__cache = self.__dict__.copy()47 self.__dict__.update(*args, **kwargs)47 def __getattribute__(self, key):48 if key in object.__getattribute__(self, '__attrs__'):49 try:50 return object.__getattribute__(self, key)51 except AttributeError:52 return None53 return object.__getattribute__(self, key)5449 return r505155settings = Settings()