3
(hM                 @   s   G d d de Ze ZdS )c               @   sL   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	e
dd ZdS )RegistryzFrontend module registry.c             C   s
   i | _ d S )N)	_registry)self r   G/tmp/pip-install-q3hcpn_q/django-material/material/frontend/registry.py__init__   s    zRegistry.__init__c             C   s    t dd | jj D dd dS )z8List of modules in the forntend according to it's order.c             S   s   g | ]}|qS r   r   ).0moduler   r   r   
<listcomp>	   s    z$Registry.modules.<locals>.<listcomp>c             S   s   | j | jfS )N)orderlabel)r   r   r   r   <lambda>
   s    z"Registry.modules.<locals>.<lambda>)key)sortedr   values)r   r   r   r   modules   s    zRegistry.modulesc             C   s   dd | j  D S )zList of installed modules.

        A frontend module itself determines if it installed or not.
        If the module instance have no `installed` attribute, the
        module considered installed.
        c             S   s   g | ]}t |d dr|qS )	installedT)getattr)r   r   r   r   r   r	      s    z.Registry.installed_modules.<locals>.<listcomp>)r   )r   r   r   r   installed_modules   s    zRegistry.installed_modulesc                s    fdd| j  D S )z'List of modules permitted for the user.c                s   g | ]}|j  r|qS r   )Zhas_perm)r   r   )userr   r   r	      s    z.Registry.available_modules.<locals>.<listcomp>)r   )r   r   r   )r   r   available_modules   s    zRegistry.available_modulesc             C   s   | j j|dS )zGet module by label.N)r   get)r   Zmodule_labelr   r   r   
get_module   s    zRegistry.get_modulec             C   s   || j |j< dS )zHRegister a module.

        Can be called on the package level.
        N)r   r   )r   r   r   r   r   register   s    zRegistry.registerc             C   s&   g }x| j  D ]}|j|j qW |S )zCollected list of all modules url.

        Even uninstalled modules urls returned here. The module url
        config have the responsibility to check the module installed
        state.
        )r   appendurls)r   patternsr   r   r   r   r   &   s    zRegistry.urlsN)__name__
__module____qualname____doc__r   r   r   r   r   r   propertyr   r   r   r   r   r      s   
r   N)objectr   r   r   r   r   r   <module>   s   3