
    -Ph,                         d Z ddlZddlZddlZddlZddlmZ dZ	 e
d          Z ej        dd                     eej         ee                              z   dz             Z	 	 ddZ G d d          ZdS )zr:mod:`sassutils.builder` --- Build the whole directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    N)compile)SUFFIXESSUFFIX_PATTERNManifestbuild_directory)sassscssz[.](|z)$nestedFc           	         ||| }|}i }t           j                            |          st          j        |           t          j        |           D ]}t           j                            | |          }t                              |          r	t           j                            |          r|d         dk    rj|r"t           j        	                    |          \  }}	t           j                            ||          dz   }
t          |||g          }t          |
ddd	          5 }|                    |           ddd           n# 1 swxY w Y   t           j                            |
|          |t           j                            ||          <   Gt           j                            |          rJt           j                            ||          }
t          ||
||||
          }|                    |           |S )a  Compiles all Sass/SCSS files in ``path`` to CSS.

    :param sass_path: the path of the directory which contains source files
                      to compile
    :type sass_path: :class:`str`, :class:`basestring`
    :param css_path: the path of the directory compiled CSS files will go
    :type css_path: :class:`str`, :class:`basestring`
    :param output_style: an optional coding style of the compiled result.
                         choose one of: ``'nested'`` (default), ``'expanded'``,
                         ``'compact'``, ``'compressed'``
    :type output_style: :class:`str`
    :returns: a dictionary of source filenames to compiled CSS filenames
    :rtype: :class:`collections.abc.Mapping`

    .. versionadded:: 0.6.0
       The ``output_style`` parameter.

    Nr   _.css)filenameoutput_styleinclude_pathswutf-8 encodingnewline)r   
_root_sass	_root_cssstrip_extension)ospathisdirmkdirlistdirjoinr   searchisfilesplitextr   openwriterelpathr   update)	sass_pathcss_pathr   r   r   r   resultnamesass_fullnamer   css_fullnamecsscss_file	subresults                 Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sassutils/builder.pyr   r      s(   , Y.
	F7=="" 

9%% % %Y55  && 	%27>>-+H+H 	%Aw#~~ 1'**400a7<<$77&@L&))l  C
 cGR   $s###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $
 i88 27??=*==>>W]]=)) 		%7<<$77L'|)%# /  I MM)$$$Ms   )EE	E	c                   R    e Zd ZdZed             Z	 	 	 ddZd Zd ZddZ	dd
Z
dS )r   a  Building manifest of Sass/SCSS.

    :param sass_path: the path of the directory that contains Sass/SCSS
                      source files
    :type sass_path: :class:`str`, :class:`basestring`
    :param css_path: the path of the directory to store compiled CSS
                     files
    :type css_path: :class:`str`, :class:`basestring`
    :param strip_extension: whether to remove the original file extension
    :type strip_extension: :class:`bool`
    c                    |i }nNt          |t          j        j                  rt	          |          }nt          dt          |          z             |                                D ]\  }}t          |t                    st          dt          |          z             t          |t                    rOt          |t                    r
t          | }npt          |t          j        j                  rt          di |}nDt          |t                    rt          |          }nt          dt          |          z             |||<   |S )Nz(manifests must be a mapping object, not z4manifest keys must be a string of package name, not zumanifest values must be a sassutils.builder.Manifest, a pair of (sass_path, css_path), or a string of sass_path, not  )
isinstancecollectionsabcMappingdict	TypeErrorrepritemsstrr   tuple)cls	manifestspackage_namemanifests       r1   normalize_manifestszManifest.normalize_manifestsc   sk   II	;?#:;; 	YII:Y    '0oo&7&7 	/ 	/"L(lC00 !#'#5#56   (H-- He,, #X.Hko&=>> 	#//h//Hc** #H--&(,X7  
 '/Il##    Nc                 6   t          |t                    st          dt          |          z             ||}n4t          |t                    st          dt          |          z             ||}n4t          |t                    st          dt          |          z             |t	          j        dt                     d}n7t          |t                    s"t          d                    |                    || _	        || _
        || _        || _        d S )Nz sass_path must be a string, not zcss_path must be a string, not z wsgi_path must be a string, not zt`strip_extension` was not specified, defaulting to `False`.
In the future, `strip_extension` will default to `True`.Fz%strip_extension must be bool not {!r})r5   r=   r:   r;   warningswarnFutureWarningboolformatr(   r)   	wsgi_pathr   )selfr(   r)   rK   r   s        r1   __init__zManifest.__init__   sN    )S)) 	2Y     HHHc** 	1X    IIIs++ 	2Y    "MK  
 $OOOT22 	7>>#   
 # ".rD   c                     t           j                            || j        |          }| j        r"t           j                            |          \  }}|dz   }t           j                            || j        |          }||fS )a  Gets a proper full relative path of Sass source and
        CSS source that will be generated, according to ``package_dir``
        and ``filename``.

        :param package_dir: the path of package directory
        :type package_dir: :class:`str`, :class:`basestring`
        :param filename: the filename of Sass/SCSS source to compile
        :type filename: :class:`str`, :class:`basestring`
        :returns: a pair of (sass, css) path
        :rtype: :class:`tuple`

        r   )r   r   r    r(   r   r#   r)   )rL   package_dirr   r(   r   css_filenamer)   s          r1   resolve_filenamezManifest.resolve_filename   so     GLLdnhGG	 	5'**844KHa&(7<<T]LII(""rD   c                 
   t           j                            |          \  }}| j        rYdD ]Q}t           j                            || j        ||z             }t           j                            |          r||z   c S R|dz   S |S )ar  Retrieves the probable source path from the output filename.  Pass
        in a .css path to get out a .scss path.

        :param package_dir: the path of the package directory
        :type package_dir: :class:`str`
        :param filename: the css filename
        :type filename: :class:`str`
        :returns: the scss filename
        :rtype: :class:`str`
        ).scssz.sassrS   )r   r   r#   r   r    r(   exists)rL   rO   r   r   ext	test_paths         r1   unresolve_filenamezManifest.unresolve_filename   s     g&&x00! 
	) * *GLLC 	 7>>),, *#c>)))*  '))OrD   r   c                 "    t           j                            | j                  }t           j                            | j                  }t          ||| j                                                  }t           fd|D                       S )a  Builds the Sass/SCSS files in the specified :attr:`sass_path`.
        It finds :attr:`sass_path` and locates :attr:`css_path`
        as relative to the given ``package_dir``.

        :param package_dir: the path of package directory
        :type package_dir: :class:`str`, :class:`basestring`
        :param output_style: an optional coding style of the compiled result.
                             choose one of: ``'nested'`` (default),
                             ``'expanded'``, ``'compact'``, ``'compressed'``
        :type output_style: :class:`str`
        :returns: the set of compiled CSS filenames
        :rtype: :class:`frozenset`

        .. versionadded:: 0.6.0
           The ``output_style`` parameter.

        )r   r   c              3   b   K   | ])}t           j                            j        |          V  *d S )N)r   r   r    r)   ).0r   rL   s     r1   	<genexpr>z!Manifest.build.<locals>.<genexpr>   sI       
 
 GLL11
 
 
 
 
 
rD   )	r   r   r    r(   r)   r   r   values	frozenset)rL   rO   r   r(   r)   	css_filess   `     r1   buildzManifest.build   s    $ GLLdn==	7<<T];;#x% 0
 
 
 &((	 	
  
 
 
 
%
 
 
 
 
 	
rD   Fc                    |                      ||          \  }}t          j                            || j                  }t          j                            || j        |          }|r|dz   }t          ||g||          \  }	}nt          ||g          }	d}d}t          j                            |          }
t          j                            |
          st          j	        |
           t          |ddd          5 }|                    |	           ddd           n# 1 swxY w Y   |r@t          |ddd          5 }|                    |           ddd           n# 1 swxY w Y   |S )	a  Builds one Sass/SCSS file.

        :param package_dir: the path of package directory
        :type package_dir: :class:`str`, :class:`basestring`
        :param filename: the filename of Sass/SCSS source to compile
        :type filename: :class:`str`, :class:`basestring`
        :param source_map: whether to use source maps.  if :const:`True`
                           it also write a source map to a ``filename``
                           followed by :file:`.map` suffix.
                           default is :const:`False`
        :type source_map: :class:`bool`
        :returns: the filename of compiled CSS
        :rtype: :class:`str`, :class:`basestring`

        .. versionadded:: 0.4.0
           Added optional ``source_map`` parameter.

        z.map)r   r   source_map_filenameoutput_filename_hint)r   r   Nr   r   r   r   )rQ   r   r   r    r(   r)   r   dirnamerT   makedirsr$   r%   )rL   rO   r   
source_mapsass_filenamerP   	root_pathr)   source_map_pathr.   
css_folderfs               r1   	build_onezManifest.build_one   s   & '+&;&;'
 '
#| GLLdn==	7<<T]LII 	*V3O%&(k$3%-	  OC =LLLC"OJW__X..
w~~j)) 	$K
###(C'2>>> 	!GGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$w   $
###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ s$   ?D!!D%(D%E##E'*E')NNN)r   )F)__name__
__module____qualname____doc__classmethodrC   rM   rQ   rW   r_   rk   r4   rD   r1   r   r   V   s        
 
   [H  */ */ */ */X# # #(  0
 
 
 
</ / / / / /rD   r   )r   NNF)ro   collections.abcr6   os.pathr   rerF   r   r   __all__r]   r   r    mapescapesortedr   r   r   r4   rD   r1   <module>rx      s          				       
E 9%&& 
SXXcc")VVH%5%566777$>  '/5:: : : :zT T T T T T T T T TrD   