
    	                     v    d Z ddlmZ ddlmZ ddlmZ ddlZddZ ej                  g d      Zd Z	d	 Z
d
 Zy)z Utilities for manipulating text.    )absolute_import)division)unicode_literalsNc                 "    | dk(  r|S |xs |dz   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plurals      $lib/googlecloudsdk/core/util/text.py	Pluralizer      s     	AXK		4#:    ))secondr   )minute<   )houri  )dayiQ c                     | 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	   )nouns    r   
GetArticler   /   s    a55>3>r   c                 F    | j                   dz  dz  dz  | j                  z   S )zGRe-implementation of datetime.timedelta.total_seconds() for Python 2.6.   r   )daysseconds)deltas    r   _TotalSecondsr#   4   s#    	b2		"U]]	22r   c                     t        t        |             }|}d}t        j                         D ]  \  }}||k  r n	|}||z  } dj	                  |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_pers         r   PrettyTimeDeltar+   9   sj    ( e$%'#	$$**,naD
[
 C	 -
 
		#yd3	44r   )N)__doc__
__future__r   r   r   collectionsr   OrderedDictr&   r   r#   r+   r	   r   r   <module>r0      sC    ' &  '  '{&& ( ?
3
5r   