mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
32 lines
634 B
Python
32 lines
634 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
import inspect
|
|
|
|
import packages
|
|
from core import *
|
|
|
|
from core import __version__
|
|
|
|
timeout = None
|
|
|
|
class settings:
|
|
"""Context manager for settings."""
|
|
|
|
cache = {}
|
|
|
|
def __init__(self, timeout):
|
|
self.module = inspect.getmodule(self)
|
|
|
|
# Cache settings
|
|
self.cache['timeout'] = self.module.timeout
|
|
|
|
self.module.timeout = timeout
|
|
|
|
def __enter__(self):
|
|
pass
|
|
|
|
def __exit__(self, type, value, traceback):
|
|
# Restore settings
|
|
for key in self.cache:
|
|
setattr(self.module, key, self.cache[key])
|