PK!9split_settings/__init__.py# -*- coding: utf-8 -*- """ Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files. """ PK!split_settings/py.typedPK!e::split_settings/tools.py# -*- coding: utf-8 -*- """ Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files. """ import glob import inspect import os import sys import types __all__ = ('optional', 'include') # noqa: WPS410 #: Special magic attribute that is sometimes set by `uwsgi` / `gunicord`. _INCLUDED_FILE = '__included_file__' def optional(filename: str) -> str: """ This functions is used for compatibility reasons. It masks the old `optional` class with the name error. Now `invalid-name` is removed from `pylint`. Args: filename: the filename to be optional Returns: new instance of :class:`_Optional` """ return _Optional(filename) class _Optional(str): # noqa: WPS600 """ Wrap a file path with this class to mark it as optional. Optional paths don't raise an :class:`IOError` if file is not found. """ def include(*args: str, **kwargs) -> None: # noqa: WPS210, C901 """ Used for including Django project settings from multiple files. Usage: .. code:: python from split_settings.tools import optional, include include( 'components/base.py', 'components/database.py', optional('local_settings.py'), scope=globals(), # optional scope ) Args: args: File paths (``glob`` - compatible wildcards can be used). kwargs: Settings context, may contain ``scope=globals()`` or be empty. Raises: IOError: if a required settings file is not found. """ # we are getting globals() from previous frame # globals - it is caller's globals() scope = kwargs.pop('scope', inspect.stack()[1][0].f_globals) scope.setdefault('__included_files__', []) included_files = scope.get('__included_files__') including_file = scope.get( _INCLUDED_FILE, scope['__file__'].rstrip('c'), ) conf_path = os.path.dirname(including_file) for conf_file in args: saved_included_file = scope.get(_INCLUDED_FILE) pattern = os.path.join(conf_path, conf_file) # find files per pattern, raise an error if not found # (unless file is optional) files_to_include = glob.glob(pattern) if not files_to_include and not isinstance(conf_file, _Optional): raise IOError('No such file: {0}'.format(pattern)) for included_file in files_to_include: included_file = os.path.abspath(included_file) # noqa: WPS440 if included_file in included_files: continue included_files.append(included_file) scope[_INCLUDED_FILE] = included_file with open(included_file, 'rb') as to_compile: compiled_code = compile( # noqa: WPS421 to_compile.read(), included_file, 'exec', ) exec(compiled_code, scope) # noqa: S102, WPS421 # Adds dummy modules to sys.modules to make runserver autoreload # work with settings components: rel_path = os.path.relpath(included_file) module_name = '_split_settings.{0}'.format( rel_path[:rel_path.rfind('.')].replace('/', '.'), ) module = types.ModuleType(str(module_name)) module.__file__ = included_file # noqa: WPS609 sys.modules[module_name] = module if saved_included_file: scope[_INCLUDED_FILE] = saved_included_file elif _INCLUDED_FILE in scope: scope.pop(_INCLUDED_FILE) PK!nӺx-django_split_settings-1.0.0.dist-info/LICENSECopyright (c) 2013, 2General Oy All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of django-split-settings nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK!HڽTU+django_split_settings-1.0.0.dist-info/WHEEL A н#Z;/"d&F[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-6㔍Mzz檉MX^a*CN^ôݧYRʼ=M݌LQ6~fjڰ%]lUH?wu$e.NNyR]j7 Sq'BGs=Z9z*rŮ_Bǥukז6bv Ht\Apitn]s*L.F)Ebe7jM``#_7u_"Ƚn!}ͶI,7JD:f+2K/2.;`PK!9split_settings/__init__.pyPK!split_settings/py.typedPK!e::split_settings/tools.pyPK!nӺx-django_split_settings-1.0.0.dist-info/LICENSEPK!HڽTU+django_split_settings-1.0.0.dist-info/WHEELPK!HFi@=.sdjango_split_settings-1.0.0.dist-info/METADATAPK!HGeM,django_split_settings-1.0.0.dist-info/RECORDPK<