File: globals.py

package info (click to toggle)
python-dynaconf 3.2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: python: 21,464; sh: 9; makefile: 4
file content (13 lines) | stat: -rw-r--r-- 472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
from threading import local
_local=local()
def get_current_context(silent=False):
	try:return _local.stack[-1]
	except(AttributeError,IndexError):
		if not silent:raise RuntimeError('There is no active click context.')
def push_context(ctx):_local.__dict__.setdefault('stack',[]).append(ctx)
def pop_context():_local.stack.pop()
def resolve_color_default(color=None):
	A=color
	if A is not None:return A
	B=get_current_context(silent=True)
	if B is not None:return B.color