3
8ßL]<
  ã               @   sB   d Z ddlZddlZddlZddlZdd„ Zd
dd„Zdd	„ ZdS )zp Provides functions that mange strings to avoid characters that would be
    problematic in certain situations.
é    Nc             C   s.   t jd| ƒ}dd„ |D ƒ}dj|ƒjdƒ}|S )zm Munge a string to avoid characters that might be problematic as
        a filename in some filesystems.
    z
[^\w\.\-]+c             S   s   g | ]}|r|‘qS © r   )Ú.0Úxr   r   ú=/tmp/pip-install-5sebvq2j/traits/traits/util/clean_strings.pyú
<listcomp>   s    z"clean_filename.<locals>.<listcomp>Ú_Úascii)ÚreÚsplitÚjoinÚencode)ÚnameZ	wordpartsÚfilenamer   r   r   Úclean_filename   s    r   Fc             C   sB   | dkrt j jƒ } n
tj| ƒ} |s.| jdd�} | jƒ jddƒ}|S )aÐ   Return a timestamp that has been cleansed of characters that might
        cause problems in filenames, namely colons.  If no datetime object
        is provided, then uses the current time.

        Description
        -----------
        The timestamp is in ISO-8601 format with the following exceptions:

        * Colons ':' are replaced by underscores '_'.
        * Microseconds are not displayed if the 'microseconds' parameter is
          False.

        Parameters
        ----------
        dt : None or datetime.datetime
            If None, then the current time is used.
        microseconds : bool
            Display microseconds or not.

        Returns
        -------
        A string timestamp.
    Nr   )Úmicrosecondú:r   )ÚdatetimeÚnowÚcopyÚreplaceÚ	isoformat)ÚdtÚmicrosecondsZstampr   r   r   Úclean_timestamp$   s    
r   c             C   sF   t | ƒdkrB| jddƒjƒ } tj| ƒr.d|  } | d jƒ rBd|  } | S )z> Attempt to make a valid Python identifier out of a name.
    r   ú r   )Úlenr   ÚlowerÚkeywordÚ	iskeywordÚisdigit)r   r   r   r   Úpython_nameK   s    
r    )NF)Ú__doc__r   r   r   r	   r   r   r    r   r   r   r   Ú<module>
   s   
'