Skip to content
Myr

new settings module

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 ef81c16 · Browse files · 2 files+40 added−1 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+40 added−1 removed

  • other:+40 added−1 removed

2 files+40 added−1 removed

modified:requests/core.py+1 added-1 removed
17 unmodified lines
18__license__ = 'ISC'19__copyright__ = 'Copyright 2011 Kenneth Reitz'20212222from models import HTTPError, auth_manager23from api import *24from exceptions import *25from settings import *
added:requests/settings.py+39 added
1# -*- coding: utf-8 -*-23"""4requests.settings5~~~~~~~~~~~~~~~~~67This module provides the Requests settings feature set.89"""101112class Settings(object):1314 def __init__(self, **settings):15 self._cache_settings(**settings)16 self._alter_settings(**settings)1718 def __enter__(self):19 pass2021 def __exit__(self, type, value, traceback):22 self._restore_settings()2324 def _cache_settings(self, **settings):25 self.cache = {}26 for setting in settings:27 self.cache[setting] = globals()[setting]2829 def _alter_settings(self, **settings):30 for setting, value in settings.items():31 globals()[setting] = value3233 def _restore_settings(self):34 for setting, value in self.cache.items():35 globals()[setting] = value363738settings = Settings39timeout = None