o
    €Ï	  ã                   @   sd   d Z ddlmZ ddlmZ ddlmZ ddlZddd„Ze g d¢¡Zd	d
„ Z	dd„ Z
dd„ ZdS )z Utilities for manipulating text.é    )Úabsolute_import)Údivision)Úunicode_literalsNc                 C   s   | dkr|S |p|d S )a  Pluralize word based on num.

  Args:
    num: int, the number of objects to count.
    word: str, the word to pluralize.
    plural: str, the plural form of word if not "add s"

  Returns:
    str: the plural or singular form of word in accord with num.
  é   Ús© )ÚnumÚwordÚpluralr   r   ú:/tmp/google-cloud-sdk/lib/googlecloudsdk/core/util/text.pyÚ	Pluralize   s   r   ))Úsecondr   )Úminuteé<   )Úhouri  )Údayi€Q c                 C   s   | d dv rdS dS )z&Gets article (a or an) for given noun.r   )ÚaÚeÚiÚoÚuÚanr   r   )Únounr   r   r   Ú
GetArticle/   s   r   c                 C   s   | j d d d | j S )zGRe-implementation of datetime.timedelta.total_seconds() for Python 2.6.é   r   )ÚdaysÚseconds)Údeltar   r   r   Ú_TotalSeconds4   s   r   c                 C   sP   t t| ƒƒ}|}d}t ¡ D ]\}}||k r n|}|| }qd |t||ƒ¡S )a«  Pretty print the given time delta.

  Rounds down.

  >>> _PrettyTimeDelta(datetime.timedelta(seconds=0))
  '0 seconds'
  >>> _PrettyTimeDelta(datetime.timedelta(minutes=1))
  '1 minute'
  >>> _PrettyTimeDelta(datetime.timedelta(hours=2))
  '2 hours'
  >>> _PrettyTimeDelta(datetime.timedelta(days=3))
  '3 days'

  Args:
    delta: a datetime.timedelta object

  Returns:
    str, a human-readable version of the time delta
  r   z{0} {1})Úintr   Ú_SECONDS_PERÚitemsÚformatr   )r   r   r   Úunitr   Úseconds_perr   r   r   ÚPrettyTimeDelta9   s   
r%   )N)Ú__doc__Ú
__future__r   r   r   Úcollectionsr   ÚOrderedDictr    r   r   r%   r   r   r   r   Ú<module>   s   
