
    ~+hu                        d dl Z d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 	 d dl
Zd dlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ dZ G d de      Z G d de      Zd Z G d de      Z G d de      Zg dZ G d de      Z  G d dee       Z! G d de      Z" G d de!      Z#d  Z$y# e$ r d dlZd dlmZ Y w xY w)!    N)path)chain)six)map)is_url)	has_magic   )	get_cache)get_versionerget_manifest)get_updater)urlparse)EnvironmentRegisterErrorc                       e Zd Zy)r   N)__name__
__module____qualname__     @/var/www/html/venv/lib/python3.12/site-packages/webassets/env.pyr   r      s    r   r   c                   N    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zy)ConfigStoragea   This is the backend which :class:`Environment` uses to store
    its configuration values.

    Environment-subclasses like the one used by ``django-assets`` will
    often want to use a custom ``ConfigStorage`` as well, building upon
    whatever configuration the framework is using.

    The goal in designing this class therefore is to make it easy for
    subclasses to change the place the data is stored: Only
    _meth:`__getitem__`, _meth:`__setitem__`, _meth:`__delitem__` and
    _meth:`__contains__` need to be implemented.

    One rule: The default storage is case-insensitive, and custom
    environments should maintain those semantics.

    A related reason is why we don't inherit from ``dict``. It would
    require us to re-implement a whole bunch of methods, like pop() etc.
    c                     || _         y Nenv)selfr   s     r   __init__zConfigStorage.__init__0   s	    r   Nc                 H    	 | j                  |      S # t        $ r |cY S w xY wr   )__getitem__KeyError)r   keydefaults      r   getzConfigStorage.get3   s,    	##C(( 	N	s    !!c                 <    |D ]  }| j                  |||           y r   )__setitem__)r   dr#   s      r   updatezConfigStorage.update9   s%     	*CS!C&)	*r   c                 T    || vr| j                  ||       |S | j                  |      S r   )r'   r!   r   r#   values      r   
setdefaultzConfigStorage.setdefault=   s/    d?S%(L$$r   c                     t               r   NotImplementedErrorr   r#   s     r   __contains__zConfigStorage.__contains__C       !##r   c                     t               r   r/   r1   s     r   r!   zConfigStorage.__getitem__F   r3   r   c                     t               r   r/   r+   s      r   r'   zConfigStorage.__setitem__I   r3   r   c                     t               r   r/   r1   s     r   __delitem__zConfigStorage.__delitem__L   r3   r   c                      y)zlFor deprecated keys, fake the values as good as we can.
        Subclasses need to call this in __getitem__.Nr   r1   s     r   _get_deprecatedzConfigStorage._get_deprecatedO   s     	r   c                      y)zSame for __setitem__.Nr   r+   s      r   _set_deprecatedzConfigStorage._set_deprecatedT   s    r   r   )r   r   r   __doc__r   r%   r)   r-   r2   r!   r'   r7   r9   r;   r   r   r   r   r      s9    &*%$$$$
r   r   c                 T    | | dd dk7  xr dxs dz  } t        j                  | |      S )zJoin url prefix with fragment.N/ )r   urljoin)prefixfragments     r   url_prefix_joinrD   Y   s6     fRSkS (S.B.FFH--r   c                   L    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)Resolvera  Responsible for resolving user-specified :class:`Bundle`
    contents to actual files, as well as to urls.

    In this base version, this is essentially responsible for searching
    the load path for the queried file.

    A custom implementation of this class is tremendously useful when
    integrating with frameworks, which usually have some system to
    spread static files across applications or modules.

    The class is designed for maximum extensibility.
    c                 ,    d }t         |||            S )zZEvaluates a glob expression.
         Yields a sorted list of absolute filenames.
        c              3      K   t        j                  | |      }t        j                  |      D ]/  }t        j                  |      rt        j
                  |       1 y wr   )r   joinglobiglobisdirnormpath)basedirexprfilenames      r   glob_generatorz%Resolver.glob.<locals>.glob_generatorr   sL     99Wd+D JJt, .::h'mmH--.s   AA!)sorted)r   rN   rO   rQ   s       r   rJ   zResolver.globn   s    	. nWd344r   c                     t        j                  ||      }t        |      r| j                  ||      S t        j                  |      r|S t        d|z        )zSearches for ``item`` within ``directory``. Is able to
        resolve glob instructions.

        Subclasses can call this when they have narrowed done the
        location of a bundle item to a single directory.
        z'%s' does not exist)r   rI   r   rJ   existsIOError)r   	directoryitemrO   s       r   consider_single_directoryz"Resolver.consider_single_directory}   sN     yyD)T?99Y--{{4 /$677r   c                 :    | j                  |j                  |      S )zjThis is called by :meth:`search_for_source` when no
        :attr:`Environment.load_path` is set.
        )rX   rV   r   ctxrW   s      r   search_env_directoryzResolver.search_env_directory   s     --cmmTBBr   c                    t        |      r6g }|j                  D ]#  }|j                  | j                  ||             % |S |j                  D ]  }| j                  ||      }|s|c S  t	        d|d|j                        )zThis is called by :meth:`search_for_source` when a
        :attr:`Environment.load_path` is set.

        If you want to change how the load path is processed,
        overwrite this method.
        'z' not found in load path: )r   	load_pathextendrJ   rU   )r   r[   rW   resultr   s        r   search_load_pathzResolver.search_load_path   s     T?F 5diid345M
  "4.!M" cmm% & &r   c                 b    |j                   r| j                  ||      S | j                  ||      S )a$  Called by :meth:`resolve_source` after determining that
        ``item`` is a relative filesystem path.

        You should always overwrite this method, and let
        :meth:`resolve_source` deal with absolute paths, urls and
        other types of items that a bundle may contain.
        )r_   rb   r\   rZ   s      r   search_for_sourcezResolver.search_for_source   s1     ==((d33,,S$77r   c                    t        |j                  j                               }	 |j                  |j                  |j
                  f       t        t        d |            }|j                  d d       t        j                  |      }|D ]U  \  }}|j                  |      s|t        |      dz   d }|j                  t        j                  d      }t!        ||      c S  t#        d|z        # t        $ r Y w xY w)	a2  Searches the environment-wide url mapping (based on the
        urls assigned to each directory in the load path). Returns
        the correct url for ``filepath``.

        Subclasses should be sure that they really want to call this
        method, instead of simply falling back to ``super()``.
        c                 b    t        j                  t        j                  | d               | d   fS )Nr   r	   )r   rM   abspath)p_us    r   <lambda>z,Resolver.query_url_mapping.<locals>.<lambda>   s%    t||CF';<c!fE r   c                     t        | d         S )Nr   )len)is    r   ri   z,Resolver.query_url_mapping.<locals>.<lambda>   s    3qt9 r   T)r#   reverser	   Nr?   zCannot determine url for %s)listurl_mappingitemsappendrV   urlEnvironmentErrorr   sortr   rM   
startswithrk   replaceosseprD   
ValueError)r   r[   filepathmappingneedle	candidaterr   rel_paths           r   query_url_mappingzResolver.query_url_mapping   s     s,,./	NNCMM37734 sE  	,d;x(% 	6NIs  +!#i.1"4"56 $++BFFC8&sH55	6 6ABB)   		s   'C3 3	C?>C?c                     t        |t        j                        s|S t        |      st	        j
                  |      r|S | j                  ||      S )a  Given ``item`` from a Bundle's contents, this has to
        return the final value to use, usually an absolute
        filesystem path.

        .. note::
            It is also allowed to return urls and bundle instances
            (or generally anything else the calling :class:`Bundle`
            instance may be able to handle). Indeed this is the
            reason why the name of this method does not imply a
            return type.

        The incoming item is usually a relative path, but may also be
        an absolute path, or a url. These you will commonly want to
        return unmodified.

        This method is also allowed to resolve ``item`` to multiple
        values, in which case a list should be returned. This is
        commonly used if ``item`` includes glob instructions
        (wildcards).

        .. note::
            Instead of this, subclasses should consider implementing
            :meth:`search_for_source` instead.
        )
isinstancer   string_typesr   r   isabsrd   rZ   s      r   resolve_sourcezResolver.resolve_source   sC    6 $ 0 01K$<4::d+K%%c400r   c                 B    t        j                  |j                  |      S )a}  Given ``target``, this has to return the absolute
        filesystem path to which the output file of ``bundle``
        should be written.

        ``target`` may be a relative or absolute path, and is
        usually taking from the :attr:`Bundle.output` property.

        If a version-placeholder is used (``%(version)s``, it is
        still unresolved at this point.
        )r   rI   rV   )r   r[   targetbundles       r   resolve_output_to_pathzResolver.resolve_output_to_path   s     yy//r   c                 &    | j                  ||      S )a  Given the absolute filesystem path in ``filepath``, as
        well as the original value from :attr:`Bundle.contents` which
        resolved to this path, this must return the absolute url
        through which the file is to be referenced.

        Depending on the use case, either the ``filepath`` or the
        ``item`` argument will be more helpful in generating the url.

        This method should raise a ``ValueError`` if the url cannot
        be determined.
        )r   )r   r[   rz   rW   s       r   resolve_source_to_urlzResolver.resolve_source_to_url
  s     %%c844r   c                 |    t        j                  |      st        |j                  |      S | j	                  ||      S )a?  Given ``target``, this has to return the url through
        which the output file can be referenced.

        ``target`` may be a relative or absolute path, and is
        usually taking from the :attr:`Bundle.output` property.

        This is different from :meth:`resolve_source_to_url` in
        that you do not passed along the result of
        :meth:`resolve_output_to_path`. This is because in many
        use cases, the filesystem is not available at the point
        where the output url is needed (the media server may on
        a different machine).
        )r   r   rD   rr   r   )r   r[   r   s      r   resolve_output_to_urlzResolver.resolve_output_to_url  s8     zz&! #377F33 ))#v66r   N)r   r   r   r<   rJ   rX   r\   rb   rd   r   r   r   r   r   r   r   r   rF   rF   `   s=    58 C&08 CD!1F057r   rF   c                   L    e Zd Zd Zd Zd Zd Zd Zd ZeZ	d Z
d Zd	 Zd
 Zy)BundleRegistryc                      i | _         g | _        y r   )_named_bundles_anon_bundlesr   s    r   r   zBundleRegistry.__init__2  s     r   c                 h    t        t        j                  | j                        | j                        S r   )r   r   
itervaluesr   r   r   s    r   __iter__zBundleRegistry.__iter__6  s$    S^^D$7$78$:L:LMMr   c                      | j                   |   S r   r   r   names     r   r!   zBundleRegistry.__getitem__9  s    ""4((r   c                     || j                   v S r   r   r   s     r   r2   zBundleRegistry.__contains__<  s    t****r   c                 X    t        | j                        t        | j                        z   S r   )rk   r   r   r   s    r   __len__zBundleRegistry.__len__?  s#    4&&'#d.@.@*AAAr   c                      y)NTr   r   s    r   __bool__zBundleRegistry.__bool__B  s    r   c                    ddl m} t        |t              r/|s-|s+|j	                         D ]  \  }}| j                  ||        yt        |      dk(  rt        d      t        |      dk(  r|st        |d   |      r|d   }n ||i |}|j                  s| j                  ||      S || j                  v r6| j                  |   |k(  r	 |S t        dd|d| j                  |   z         || j                  |<   | |_        |S )	a  Register a :class:`Bundle` with the given ``name``.

        This can be called in multiple ways:

        - With a single :class:`Bundle` instance::

              env.register('jquery', jquery_bundle)

        - With a dictionary, registering multiple bundles at once:

              bundles = {'js': js_bundle, 'css': css_bundle}
              env.register(bundles)

          .. note::
              This is a convenient way to use a :doc:`loader <loaders>`:

                   env.register(YAMLLoader('assets.yaml').load_bundles())

        - With many arguments, creating a new bundle on the fly::

              env.register('all_js', jquery_bundle, 'common.js',
                           filters='rjsmin', output='packed.js')
        r	   BundleNr   z#at least two arguments are requiredz%Another bundle is already registered zas "z": )r   r   r   dictrp   registerrk   	TypeErrormergedecompose_bundler   r   r   )r   r   argskwargsr   r   s         r   r   zBundleRegistry.registerF  s   2 	# dD!$v $

 ,fdF+,t9>ABB4yA~fDGV1La00<<,,T6::t***&&t,6 M ((O9=t?R?RSW?X(Y)Z [ [ -3##D)!
Mr   c                 V    |D ]$  }| j                   j                  |       | |_        & y)a.  Register a list of bundles with the environment, without
        naming them.

        This isn't terribly useful in most cases. It exists primarily
        because in some cases, like when loading bundles by searching
        in templates for the use of an "assets" tag, no name is available.
        N)r   rq   r   )r   bundlesr   s      r   addzBundleRegistry.add~  s.      	F%%f-FJ	r   c                    ddl m} |j                  st        d      |j                  D ]  }t        ||      st        d       | |_        g }|j                         }|D ])  \  }}| j                  |||      }	|j                  |	       + |S )Nr	   r   z.If `merge` is False, an output must be definedz4Nested bundles are not allowed when `merge` is False)
r   r   outputr   contentsr   r   resolve_contentsregister_decomposedrq   )
r   r   r   r   contentr   r   _rg   nbs
             r   r   zBundleRegistry.decompose_bundle  s    "}} PQQ 	\G'6*#$Z[[	\ 
**," 	JAw))$@BNN2	 r   c                 T   ddl m} t        j                  || j                        }t        j
                  |      }t        j                  |      \  }}t        j                  |      \  }	}
|rt        j                  ||      n|}|j                  j                  d|      j                  d|	      j                  d|
j                  d            } ||||j                  |j                  |j                  |j                        }|j                  |_        | j!                  ||      S )Nr	   r   z%(name)sz%(path)sz%(ext)s.)r   filtersdependsremove_duplicatesextra)r   r   r   relpathrV   basenamesplitextrI   r   rv   stripr   r   r   r   _configr   )r   r   r   rg   r   r   r   rP   r   rz   fileextnew_namer   
new_bundles                 r   r   z"BundleRegistry.register_decomposed  s    ",,w7==)mmH-! MM'2'04499T8,( MMWZ*WZ*WYc 23	 	 NNNN$66,,

 $^^
}}Xz22r   N)r   r   r   r   r   r!   r2   r   r   __nonzero__r   r   r   r   r   r   r   r   r   0  s<     N)+BK6p
&3r   r   )rV   rr   debugcacheupdater
auto_build
url_expireversionsmanifestr_   ro   cache_file_modec                      e Zd ZdZd Zd,dZd Zd Z eeed      Z	d	 Z
d
 Z eee
d      Zd Zd Z eeed      Zd Zd Z eeed      Zd Zd Z eeed      Zd Zd Z eeed      Zd Zd Z eeed      Zd Zd Z eeed      Zd Zd Z  ee ed       Z!d! Z"d" Z# ee#e"d#      Z$d$ Z%d% Z& ee&e%d&      Z'd' Z(d( Z) ee)e(d)      Z*d* Z+d+ Z, ee,e+      Z-y)-ConfigurationContextah  Interface to the webassets configuration key-value store.

    This wraps the :class:`ConfigStorage`` interface and adds some
    helpers. It allows attribute-access to the most important
    settings, and transparently instantiates objects, such that
    ``env.manifest`` gives you an object, even though the configuration
    contains the string "json".
    c                     || _         y r   _storage)r   storages     r   r   zConfigurationContext.__init__  s	    r   Nc                 ^    | j                   j                  |       |r|| j                  |<   yy)znAppends ``path`` to :attr:`load_path`, and adds a
        corresponding entry to :attr:`url_mapping`.
        N)r_   rq   ro   )r   r   rr   s      r   append_pathz ConfigurationContext.append_path  s.     	d#%(DT" r   c                 "    || j                   d<   y Nr   r   )r   r   s     r   
_set_debugzConfigurationContext._set_debug  s    !&gr   c                      | j                   d   S r   r   r   s    r   
_get_debugzConfigurationContext._get_debug  s    }}W%%r   aO  Enable/disable debug mode. Possible values are:

        ``False``
            Production mode. Bundles will be merged and filters applied.
        ``True``
            Enable debug mode. Bundles will output their individual source
            files.
        *"merge"*
            Merge the source files, but do not apply filters.
    )docc                 "    || j                   d<   y Nr   r   )r   modes     r   _set_cache_file_modez)ConfigurationContext._set_cache_file_mode  s    +/'(r   c                      | j                   d   S r   r   r   s    r   _get_cache_file_modez)ConfigurationContext._get_cache_file_mode  s    }}.//r   a  Controls the mode of files created in the cache. The default mode
    is 0600.  Follows standard unix mode.
    Possible values are any unix mode, e.g.:

      ``0660``
          Enable the group read+write bits

      ``0666``
          Enable world read+write bits

    c                 "    || j                   d<   y Nr   r   )r   enables     r   
_set_cachezConfigurationContext._set_cache  s    !'gr   c                 z    t        | j                  d   |       }|| j                  d   k7  r|| j                  d<   |S r   )r
   r   )r   r   s     r   
_get_cachezConfigurationContext._get_cache  s;    $--0$7DMM'**%*DMM'"r   a  Controls the behavior of the cache. The cache will speed up rebuilding
    of your bundles, by caching individual filter results. This can be
    particularly useful while developing, if your bundles would otherwise take
    a long time to rebuild.

    Possible values are:

      ``False``
          Do not use the cache.

      ``True`` (default)
          Cache using default location, a ``.webassets-cache`` folder inside
          :attr:`directory`.

      *custom path*
         Use the given directory as the cache directory.
    c                 "    || j                   d<   y Nr   r   )r   r,   s     r   _set_auto_buildz$ConfigurationContext._set_auto_build  s    &+l#r   c                      | j                   d   S r   r   r   s    r   _get_auto_buildz$ConfigurationContext._get_auto_build      }}\**r   aS  Controls whether bundles should be automatically built, and
    rebuilt, when required (if set to ``True``), or whether they
    must be built manually be the user, for example via a management
    command.

    This is a good setting to have enabled during debugging, and can
    be very convenient for low-traffic sites in production as well.
    However, there is a cost in checking whether the source files
    have changed, so if you care about performance, or if your build
    process takes very long, then you may want to disable this.

    By default automatic building is enabled.
    c                 "    || j                   d<   y )Nr   r   r   r   s     r   _set_manifestz"ConfigurationContext._set_manifest'      $,j!r   c                 |    t        | j                  d   |       }|| j                  d   k7  r|| j                  d<   |S )Nr   r   )r   r   r   s     r   _get_manifestz"ConfigurationContext._get_manifest)  s;    j 9tDt}}Z00(0DMM*%r   a4  A manifest persists information about the versions bundles
    are at.

    The Manifest plays a role only if you insert the bundle version
    in your output filenames, or append the version as a querystring
    to the url (via the ``url_expire`` option). It serves two
    purposes:

        - Without a manifest, it may be impossible to determine the
          version at runtime. In a deployed app, the media files may
          be stored on a different server entirely, and be
          inaccessible from the application code. The manifest,
          if shipped with your application, is what still allows to
          construct the proper URLs.

        - Even if it were possible to determine the version at
          runtime without a manifest, it may be a costly process,
          and using a manifest may give you better performance. If
          you use a hash-based version for example, this hash would
          need to be recalculated every time a new process is
          started.

    Valid values are:

      ``"cache"`` (default)
          The cache is used to remember version information. This
          is useful to avoid recalculating the version hash.

      ``"file:{path}"``
          Stores version information in a file at {path}. If not
          path is given, the manifest will be stored as
          ``.webassets-manifest`` in ``Environment.directory``.

      ``"json:{path}"``
         Same as "file:{path}", but uses JSON to store the information.

      ``False``, ``None``
          No manifest is used.

      Any custom manifest implementation.
    c                 "    || j                   d<   y Nr   r   r   r   s     r   _set_versionsz"ConfigurationContext._set_versionsY  r   r   c                 x    t        | j                  d         }|| j                  d   k7  r|| j                  d<   |S r   )r   r   r   s     r   _get_versionsz"ConfigurationContext._get_versions[  s9     z!:;t}}Z00(0DMM*%r   a  Defines what should be used as a Bundle ``version``.

    A bundle's version is what is appended to URLs when the
    ``url_expire`` option is enabled, and the version can be part
    of a Bundle's output filename by use of the ``%(version)s``
    placeholder.

    Valid values are:

      ``timestamp``
          The version is determined by looking at the mtime of a
          bundle's output file.

      ``hash`` (default)
          The version is a hash over the output file's content.

      ``False``, ``None``
          Functionality that requires a version is disabled. This
          includes the ``url_expire`` option, the ``auto_build``
          option, and support for the %(version)s placeholder.

      Any custom version implementation.

    c                 "    || j                   d<   y Nr   r   r   r   s     r   set_updaterz ConfigurationContext.set_updaterz  s    #*i r   c                 x    t        | j                  d         }|| j                  d   k7  r|| j                  d<   |S r   )r   r   r   s     r   r   z ConfigurationContext.get_updater|  s9    dmmI67dmmI..'.DMM)$r   ay  Controls how the ``auto_build`` option should determine
    whether a bundle needs to be rebuilt.

      ``"timestamp"`` (default)
          Rebuild bundles if the source file timestamp exceeds the existing
          output file's timestamp.

      ``"always"``
          Always rebuild bundles (avoid in production environments).

      Any custom version implementation.
    c                 "    || j                   d<   y Nr   r   )r   r   s     r   _set_url_expirez$ConfigurationContext._set_url_expire  s    &0l#r   c                      | j                   d   S r   r   r   s    r   _get_url_expirez$ConfigurationContext._get_url_expire  r   r   a  If you send your assets to the client using a
    *far future expires* header (to minimize the 304 responses
    your server has to send), you need to make sure that assets
    will be reloaded by the browser when they change.

    If this is set to ``True``, then the Bundle URLs generated by
    webassets will have their version (see ``Environment.versions``)
    appended as a querystring.

    An alternative approach would be to use the ``%(version)s``
    placeholder in the bundle output file.

    The default behavior (indicated by a ``None`` value) is to add
    an expiry querystring if the bundle does not use a version
    placeholder.
    c                 "    || j                   d<   y )NrV   r   )r   rV   s     r   _set_directoryz#ConfigurationContext._set_directory      %.k"r   c                 x    	 t        j                  | j                  d         S # t        $ r t	        d      w xY w)NrV   z-The environment has no "directory" configured)r   rg   r   r"   rs   r   s    r   _get_directoryz#ConfigurationContext._get_directory  sC    	A<<k :;; 	A"?A A	As   !$ 9zThe base directory to which all paths will be relative to,
    unless :attr:`load_path` are given, in which case this will
    only serve as the output directory.

    In the url space, it is mapped to :attr:`urls`.
    c                 "    || j                   d<   y )Nrr   r   )r   rr   s     r   _set_urlzConfigurationContext._set_url  s    "er   c                 R    	 | j                   d   S # t        $ r t        d      w xY w)Nrr   z'The environment has no "url" configured)r   r"   rs   r   s    r   _get_urlzConfigurationContext._get_url  s5    	;=='' 	;"9; ;	;s    &zThe url prefix used to construct urls for files in
    :attr:`directory`.

    To define url spaces for other directories, see
    :attr:`url_mapping`.
    c                 "    || j                   d<   y Nr_   r   )r   r_   s     r   _set_load_pathz#ConfigurationContext._set_load_path  r  r   c                      | j                   d   S r  r   r   s    r   _get_load_pathz#ConfigurationContext._get_load_path  s    }}[))r   a!  An list of directories that will be searched for source files.

    If this is set, source files will only be looked for in these
    directories, and :attr:`directory` is used as a location for
    output files only.

    .. note:
        You are free to add :attr:`directory` to your load path as
        well.

    .. note:
        Items on the load path are allowed to contain globs.

    To modify this list, you should use :meth:`append_path`, since
    it makes it easy to add the corresponding url prefix to
    :attr:`url_mapping`.
    c                 "    || j                   d<   y Nro   r   )r   ro   s     r   _set_url_mappingz%ConfigurationContext._set_url_mapping  s    '2m$r   c                      | j                   d   S r  r   r   s    r   _get_url_mappingz%ConfigurationContext._get_url_mapping  s    }}]++r   ai  A dictionary of directory -> url prefix mappings that will
    be considered when generating urls, in addition to the pair of
    :attr:`directory` and :attr:`url`, which is always active.

    You should use :meth:`append_path` to add directories to the
    load path along with their respective url spaces, instead of
    modifying this setting directly.
    c                 "    || j                   d<   y Nresolverr   )r   r  s     r   _set_resolverz"ConfigurationContext._set_resolver  r   r   c                      | j                   d   S r  r   r   s    r   _get_resolverz"ConfigurationContext._get_resolver  s    }}Z((r   r   ).r   r   r   r<   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  rV   r  r	  rr   r  r  r_   r  r  ro   r  r  r  r   r   r   r   r     s    )'&Z	
	E0035I
	O(
 Z	E&,+/?	J-
 }()	HV-
 }	H4+
 {K	G1+/?	J$/A 	I#; 8X	C/*	I&3,+-=	K-)}5Hr   r   c                   .    e Zd ZdZdZeZd Zed        Z	y)BaseEnvironmentzrAbstract base class for :class:`Environment` with slightly more
    generic assumptions, to ease subclassing.
    Nc                 T   t         j                  |        | j                  |       | _        t        j                  | | j                         | j
                  j                  dd       | j
                  j                  dd       | j
                  j                  dd        | j
                  j                  dd       | j
                  j                  dd       | j
                  j                  dd	       | j
                  j                  d
d       | j
                  j                  dg        | j
                  j                  di        | j
                  j                  d| j                                | j
                  j                  dd        | j
                  j                  |       y )Nr   Fr   Tr   r   r   r   hashr   	timestampr_   ro   r  r   )	r   r   config_storage_classr   r   configr-   resolver_classr)   )r   r!  s     r   r   zBaseEnvironment.__init__  s0   %006%%dDLL9 	w.w-|T2|T2z73z62y+6{B/}b1z4+>+>+@A0$76"r   c                     | j                   S )z<Key-value configuration. Keys are case-insensitive.
        )r   r   s    r   r!  zBaseEnvironment.config  s     ||r   )
r   r   r   r<   r   rF   r"  r   r  r!  r   r   r   r  r    s-      N#2  r   r  c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)DictConfigStoragez6Using a lower-case dict for configuration values.
    c                 D    i | _         t        j                  | g|i | y r   )_dictr   r   )r   akws      r   r   zDictConfigStorage.__init__  s!    
t.a.2.r   c                 T    | j                   j                  |j                               S r   )r'  r2   lowerr1   s     r   r2   zDictConfigStorage.__contains__!  s    zz&&syy{33r   c                     |j                         }| j                  |      }||S | j                  j                  |      S r   )r+  r9   r'  r!   r+   s      r   r!   zDictConfigStorage.__getitem__#  s<    iik$$S)}Lzz%%c**r   c                     |j                         }| j                  ||      s+| j                  j                  |j                         |       y y r   )r+  r;   r'  r'   r+   s      r   r'   zDictConfigStorage.__setitem__)  s<    iik##C/JJ""399;6 0r   c                 V    | j                   j                  |j                                y r   )r'  r7   r+  r1   s     r   r7   zDictConfigStorage.__delitem__-  s    

syy{+r   N)	r   r   r   r<   r   r2   r!   r'   r7   r   r   r   r%  r%    s     /4+7,r   r%  c                   (     e Zd ZdZeZd fd	Z xZS )r   zzOwns a collection of bundles, and a set of configuration values which
    will be used when processing these bundles.
    c                 R    t        t        | 
  di | ||| _        ||| _        y y )Nr   )superr   r   rV   rr   )r   rV   rr   more_config	__class__s       r   r   zEnvironment.__init__8  s3    k4)8K8 &DN?DH r   )NN)r   r   r   r<   r%  r   r   __classcell__)r3  s   @r   r   r   1  s     - r   r   c                 \    | | S | j                         } | dv ry| dv ry| dv ryt               )z{Resolve the given string value to a debug option.

    Can be used to deal with os environment variables, for example.
    )true1T)false0F)r   r   )r+  ry   )r,   s    r   parse_debug_valuer:  @  sB    
 }KKME	.	 	*	lr   )%rw   r   	itertoolsr   	webassetsr   webassets.six.movesr   webassets.utilsr   glob2rJ   r   ImportErrorr   r
   versionr   r   r   r   utilsr   __all__	Exceptionr   objectr   rD   rF   r   env_optionsr   r  r%  r   r:  r   r   r   <module>rG     s    	    # "
  0    +	I 	:F :z.M7v M7`F3V F3\j66 j6Z	'n&: 'T, ,,/ k  s   
B. .C ?C 