text stringlengths 0 828 |
|---|
if hasattr(self, ""PATH_SETTINGS""): |
for path in self.PATH_SETTINGS: |
sys.path.extend(getattr(self,path)) |
self.settings_list = list(set(self.settings_list))" |
596,"def _setup(self): |
"""""" |
Perform initial setup of the settings class, such as getting the settings module and setting the settings |
"""""" |
settings_module = None |
#Get the settings module from the environment variables |
try: |
settings_module = os.environ[global_settings.MODULE_VARIABLE] |
except KeyError: |
error_message = ""Settings not properly configured. Cannot find the environment variable {0}"".format(global_settings.MODULE_VARIABLE) |
log.exception(error_message) |
self._initialize(settings_module) |
self._configure_logging()" |
597,"def _configure_logging(self): |
"""""" |
Setting up logging from logging config in settings |
"""""" |
if not self.LOGGING_CONFIG: |
#Fallback to default logging in global settings if needed |
dictConfig(self.DEFAULT_LOGGING) |
else: |
dictConfig(self.LOGGING_CONFIG)" |
598,"def ensure_context(**vars): |
""""""Ensures that a context is in the stack, creates one otherwise. |
"""""" |
ctx = _context_stack.top |
stacked = False |
if not ctx: |
ctx = Context() |
stacked = True |
_context_stack.push(ctx) |
ctx.update(vars) |
try: |
yield ctx |
finally: |
if stacked: |
_context_stack.pop()" |
599,"def request_context(app, request): |
""""""Creates a Context instance from the given request object |
"""""" |
vars = {} |
if request.view_args is not None: |
vars.update(request.view_args) |
vars.update({ |
""request"": request, |
""GET"": AttrDict(request.args.to_dict()), |
""POST"" : AttrDict(request.form.to_dict()), |
""app"": app, |
""config"": app.config, |
""session"": session, |
""g"": g, |
""now"": datetime.datetime.now, |
""utcnow"": datetime.datetime.utcnow, |
""today"": datetime.date.today}) |
context = Context(vars) |
context.vars[""current_context""] = context |
return context" |
600,"def clone(self, **override_vars): |
""""""Creates a copy of this context"""""" |
c = Context(self.vars, self.data) |
c.executed_actions = set(self.executed_actions) |
c.vars.update(override_vars) |
return c" |
601,"def setup(): |
""""""import the matplotlib modules and set the style |
Returns |
------- |
plt: pylab |
imported pylab module |
mpl: matplotlib module |
imported matplotlib module |
"""""" |
# Latex support can be activated using an environment variable, otherwise |
# the default settings are: |
# - for windows: off |
# - else: on |
use_latex = False |
if('DD_USE_LATEX' in os.environ): |
if os.environ['DD_USE_LATEX'] == '1': |
use_latex = True |
else: |
if platform.system() == ""Windows"": |
use_latex = False |
else: |
use_latex = True |
already_loaded = 'matplotlib' in sys.modules |
# just make sure we can access matplotlib as mpl |
import matplotlib as mpl |
if not already_loaded: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.