
ߊQc        6   @   sU  d  d k  Td  d k Z d  d k Z e d  Z e d j od  d k l Z d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d	 d
 d d d d d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ Z dA Z	 e dB e dC e	  Z
 e
 i dD dE dF dG dH dI dJ e dK dL e
 i dM dN dF dO dH dP dQ dR dJ e dK dS e e
 i dT dU dF dV dH dP dQ dW dK dX e
 i dY dZ dF d[ dH dP dQ dW dK d\ e
 i d] d^ dF d_ dH dP dQ dW dK d` e
 i da db dF dc dH dP dQ dW dK dd e
 i de df dF dg dH dP dQ dW dK dh e
 i di dj dF dk dH dP dQ dW dK dl e
 i dm dn dF do dH dP dQ dW dK dp e
 i dq dr dF ds dH dP dQ dW dK dt e
 i du dv dF dw dH dP dQ dW dK dx e
 i dy dz dF d{ dH dI dJ e dK d| e
 i d} d~ dF d dH dI dJ e dK d e
 i d d dF d dH dI dJ e dK d e
 i d d dF d dH dI dJ e dK d e
 i d d dF d dH dP dQ dW dK d e
 i d d dF d dH dP dQ dW dK d e
 i   \ Z Z d e j oU e i d  Z g  Z e i i   D] Z e e i d  d q`[ e e e d +n e i o e i o e
 i d  n e i d j  o e
 i d  n e i o d e _ e e _ n e i o d e _ e e _ n e i e j Z e  d g  dc g  dg g  d_ g  dk g  do g  ds g   Z! e o
 e i n e i Z" e o e" dG j p e i# oM e$ e _# e Z" e e e"  Z% e e% d <e! d i& e%  e i' d d  nV e( e  d j o e
 i d  n e e e" e d  Z% e e% d <e! d i& e%  e( e  Z) e i* e j o
 e) d j o7e e$ e i* e d  Z% e$ e% d <e! dc i& e%  e i+ e j o
 e) d j o e e e i+ e d  Z% e e% d <e! dg i& e%  e i, e j o
 e) d j o8 e e e i, e d  Z% e e% d <e! d_ i& e%  n nV e i, e j o
 e) d j o8 e e e i, e d  Z% e e% d <e! d_ i& e%  n nve i+ e j o
 e) d j o e e e i+ e d  Z% e e% d <e! dg i& e%  e i, e j o
 e) d j o8 e e e i, e d  Z% e e% d <e! d_ i& e%  n ne i, e j o
 e) d j o8 e e e i, e d  Z% e e% d <e! d_ i& e%  nwe i- e j o
 e) d j oA e e e i- e d  Z% e e% d <e! dk i& e%  e e _- ne i. e j o
 e) d j oA e e e i. e d  Z% e e% d <e! do i& e%  e e _. n e i/ e j o
 e) d j oA e e e i/ e d  Z% e e% d <e! ds i& e%  e e _/ n] xY e d D]M Z0 e o
 e i n e i Z" e e e" e0  Z% e e% d <e! d i& e%  q	Wxe! D]Z1 xe2 e( e! e1   D]lZ e! e1 e Z3 e3 d o e  d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e i4 dG e i# dO e i  nj e5 d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d d e3 d dO e i  
e! e1 e <q-
Wq
We( e! dc  d j oA x: e2 e( e! d   D]" Z e! d e c e! dc d 8<qWn e( e! dg  d j oA x: e2 e( e! d   D]" Z e! d e c e! dg d 8<q'Wn e( e! d_  d j oA x: e2 e( e! d   D]" Z e! d e c e! d_ d 7<qWn e( e! dk  d j oL xE e2 e( e! d   D]- Z e! d e i6 e! dk d  e! d e <qWn e( e! do  d j oL xE e2 e( e! d   D]- Z e! d e i7 e! do d  e! d e <q:Wn e( e! ds  d j oL xE e2 e( e! d   D]- Z e! d e i8 e! ds d  e! d e <qWn e i. e j oG x@ e2 e( e! d   D]( Z e! d e i9 e i.  e! d e <qWn e i/ e j oG x@ e2 e( e! d   D]( Z e! d e i: e i/  e! d e <qPWnX e i; e j oG x@ e2 e( e! d   D]( Z e! d e i< e i;  e! d e <qWn e i d j o d n3 e i d d g j o d e i n d d e i Z= xe! d D]Z> e? e> e   od d d d d d d d d d d d d d d d d g Z@ e i e@ j o e i ZA e ZB ne ZA e i e j o d e= n d e i j o d e= n d e i j o d e= n d e i j o d e= n d e i j o d e= nv d e i j o d e= n[ d e i j o d e= n@ d e i j o d e= n% d e i j o e i e= n e i ZB e> iC d eB d eA d e iD d e iE  GHnk e i e> iF   j o e ZB e i ZA n+ e i e j o d e= n e i ZB e ZA e> iC d eB d eA  GHq.We iG d  n d S(   i(   t   *Nc         C   s_  d d d d d d g } d d d	 d
 d d d d d g	 } d d
 d d d d g } d d
 d d d d g } t  d d d d d d  } |  o: x | D] } d | | <q WxR | D] } d | | <q Wn7 x | D] } d | | <q Wx | D] } d | | <q W| d j o | Sd }	 | d j o
 d }	 ny |  o | n | }
 g  } |
 D]/ } | | j p | d | j o | | qIqI~ } t |  d j o | d }	 n |	 d j odd | d <| | d <| d j o t |  d j o | d d !d j o t i i | d  o d d k } t | d  } | i |  } | i	   | i
 d  p | d i
 d  o t d | d   n | d d } n | d } | | d <d | d <q[d | d <|  o| d d j o d n | d j o d n d | j o d  d! t i n d" | j o d# d! t i n d$ | j o d% d! t i n d& | j o d' d! t i na d( | j o d) d! t i nB d* | j o d+ d! t i n# d, | j o d- d! t i n | | d <q[| d d j o d n | d j o d n | | d <nI|	 d j o	d | d <d | d <d | d <d | d <| i   } | d } x_ t d. t |   D]H } | d d/ j o# | | d d/ j o | d/ 7} n | | | 7} qtW|  o | }
 n* | }
 x | D] } |
 i | d  qW| i d/  } xNt t |   D]} | d0 d j oY | | } | |
 j o t d1 |   n |  o" | d d j o | d d !} q!q|  oE | d	 j o8 t d | |  \ } | | <} t | |  | | <n | | } | d j o | n$ d2 | j o t |  n
 t |  | | <qWn3 |	 | d <d | d <d | d <d | d <| | |	 <| S(3   s  
	#+
	# NAME:
	#	parse_input_times
	# PURPOSE:
	#	Interpret input from command line
	# CALLING SEQUENCE:
	#	tt  = parse_input_times( is_date, marker, arg )
	# INPUTS:
	#	is_date     True : 'arg' is a date
	#	            False: 'arg' is a delta time
	#	marker		identifies the type of information
	#	            that 'arg' represents
	#
	#	            marker = 're=<regex string>'
	#				Then 'arg' is the string to be processed
	#				with the regex.
	#
	#	            marker = '<time format string>'
	#	            (the format could be unspecified, i.e. None)
	#	            Then arg is the string time to be
	#	            interpreted with this format (it it's None
	#	            we're going to guess)
	#
	#	arg			one of the input args from the command
	#	            line
	# OUTPUTS:
	#	tt			dictionary with a lot of fields needed
	#				by the eon_date or eon_delta __init__ method.
	#	            The following relevant combinations can occur.
	#
	#	For times specified as a string in some format:
	#
	#	tt['special'] = ''
	#	tt['ctime'  ] = arg             '2009-10-10 20:00:00'
	#	tt['regex'  ] = None			
	#	tt['format' ] = time format     'YYYY-MM-DD hh:mm:ss'
	#
	#	For times specified as a regex:
	#	re=^daily\.l\d\.t\d\.c\d{6}\.(\d{4})(\d{2})(\d{2})\..+\.warts(\.gz)?$
	#	daily.l7.t3.c001991.20120518.her-gr.warts.gz
	#
	#	tt['special'] = ''
	#	tt['ctime'  ] = arg
	#	tt['regex'  ] = marker[3:]
	#	tt['format' ] = None
	#
	#	For times specified by a list of separate components:
	#	"year=2000 doy=10 hour=5 ...."
	#
	#	tt['special'] = 'time'
	#	tt['ctime'  ] = ''
	#	tt['format' ] = None
	#	tt['regex'  ] = None
	#	tt['year'   ] = value or None
	#	tt['doy'    ] = value or None (always None for delta time)
	#	tt['month'  ] = value or None (always None for delta time)
	#	tt['day'    ] = value of None
	#	tt['hour'	] = value or None
	#	tt['minute' ] = value or None
	#	tt['second' ] = value or None
	#	tt['chipsec'] = value or None
	#	tt;'timezone']= value or None (always None for delta time)
	#
	#	For times presented as a single number:
	#
	#	tt['special'] = marker          'posix'
	#	tt['ctime'  ] = ''
	#	tt['format' ] = None
	#	tt['regex'  ] = None
	#	tt[marker   ] = arg             '123456789.00'
	#-
	t   posixt   njdt   mjdt   jdt   bepocht   jepocht   yeart   doyt   montht   dayt   hourt   minutet   secondt   chipsect   timezonet   ctimet   formatt   regext    t   timet   si    t   speciali   s   re=iNt   filet   tregexs(   __main__, no 'tregex' in YAML file, '%s's   -ymds   YYYY-MM-DD hh:mm:ss.t   dt   _ymdt   YYYY_MM_DD_hhmmsst   ymds   YYYYMMDD-hhmmsss   -ydoys   YYYY-DOY hh:mm:ss.t   _ydoyt   YYYY_DOY_hhmmsst   ydoys   YYYYDOY-hhmmsst   isos   YYYY-MM-DDThh:mm:ssi   t   =i   s*   __main__, invalid time specification, '%s't   .(   t   dictt   Nonet   lent   ost   patht   isfilet   yamlt   opent   loadt   closet   has_keyt   EonErrort   optionst   exponentt   splitt   ranget   appendt   convert_montht   strt   floatt   long(   t   is_datet   markert   argt   epoch_optionst   date_optionst   duration_optionst   delta_optionst   ttt   keyt   special_optiont   all_optionst   _[1]t   optR)   t	   yaml_fileR   t   specst   spect   it   dummy(    (    s*   /home/pphick/eclipse/general/python/eon.pyt   parse_input_times   s    N!        

C 

4
&







 &  
 
F




t   __main__(   t   OptionParsers   
 for date conversion:
s(     %prog -i IN_DATE <DATE> -o <OUT_DATE>
si       IN_DATE is format build from YYYY, MM, DD, hh, mm, ss[.ddd...], timezone (followed by matching date)
s7               or  'ymd'   same as format YYYYMMDD-hhmmss
s;               or '-ymd'   same as format YYYY-MM-DD hh:mm:ss
s9               or '_ymd'   same as format YYYY_MM_DD_hhmmss
s6               or  'ydoy'  same as format YYYYDOY-hhmmss
s9               or '-ydoy'  same as format YYYY-DOY hh:mm:ss
s7               or '_ydoy'  same as format YYYY_DOY_hhmmss
s;               pr 'iso8601'same as format YYYY-DD-MMThh:mm:ss
s3               or 'time'   followed by one or more of sp   'year=<year> doy=<doy> month=<month> day=<day> hour=<hour> minute=<minute> second=<second> timezone=<timezone>'
sS               or 'posix'  followed by posix time (secs since 1970/01/01 00:00:00 UTC
sT               or 'jd'     followed by Julian day (days since -4713/11/24 12:00:00 UTC
sZ               or 'njd'    followed by 'new' Julian day (days since 2000/01/01 12:00:00 UTC)
sZ               or 'mjd'    followed modified Julian day (days since 1858/11/16 12:00:00 UTC)
s1               or 'jepoch' followed by Julian epoch
s4               or 'bepoch' followed by Besselian epoch
s&   
 for delta (time period) conversion:
s0     %prog -I IN_DELTA <DELTA> -output <OUT_DELTA>
s`       IN_DELTA is format build from YYYY, DD, hh, mm, ss[.ddd...] followed by matching delta time
sz               or 'time '     followed by one or more of 'year=<year> day=<day> hour=<hour> minute=<minute> second=<second>'
s:               or 'year[s]'   followed by nr of Julian years
s2               or 'day[s]'    followed by nr of days
s3               or 'hour[s]'   followed by nr of hours
s5               or 'minute[s]' followed by nr of minutes
s5               or 'second[s]' followed by nr of seconds
s   
 for date subtraction:
sC     %prog -i IN_DATE <DATE> -s MINUS_DATE <DATE> -output <OUT_DELTA>
s)       SUB_DATE has same options as IN_DATE
s2               (can only be combined with --in-date)
s'   
 for delta (time period) subtraction:
sF     %prog -i IN_DATE  <DATE>  -S MINUS_DELTA <DELTA> -output <OUT_DATE>
sG     %prog -i IN_DELTA <DELTA> -S MINUS_DELTA <DELTA> -output <OUT_DELTA>
s-       MINUS_DELTA has same options as IN_DELTA
s$   
 for delta (time period) addition:
sE     %prog -i IN_DATE  <DATE>  -A PLUS_DELTA <DELTA> -output <OUT_DATE>
sF     %prog -i IN_DELTA <DELTA> -A PLUS_DELTA <DELTA> -output <OUT_DELTA>
s,       PLUS_DELTA has same options as IN_DELTA
s   
 --output options for date:
sj       OUT_DATE is format build from YYYY, MM, MON, Month, DD, hh, mm, ss[.ddd...], timezone, DOW, dayofweek
s;               or 'iso8601'same as format YYYY-DD-MMThh:mm:ss
sM               or 'posix'  gives posix time (secs since 1970/01/01 00:00:00 UTC
sN               or 'jd'     gives Julian day (days since -4713/11/24 12:00:00 UTC
sT               or 'njd'    gives 'new' Julian day (days since 2000/01/01 12:00:00 UTC)
sW               or 'mjd'    gives modified Julian day (days since 1858/11/16 12:00:00 UTC)
s+               or 'jepoch' gives Julian epoch
s.               or 'bepoch' gives Besselian epoch
s;               or 'dow     gives day of week (number and name)s,   
 --round  options for delta (time period):
s,   
 --bot    options for delta (time period):
s,   
 --eot    options for delta (time period):
s,   
 --output options for delta (time period):
sA       OUT_DELTA is format build from YYYY, DD, hh, mm, ss[.ddd...]
s8               or 'years'   followed by nr of Julian years
s0               or 'days'    followed by nr of days
s1               or 'hours'   followed by nr of hours
s3               or 'minutes' followed by nr of minutes
s3               or 'seconds' followed by nr of seconds
s   1.04t   usaget   versions   -ns   --nowt   destt   nowt   actiont
   store_truet   defaultt   helps<   fill missing leading fields in input dates from current times   -es
   --exponentR0   t   storet   typet   ints3   sets time precision to 10^(-exponent) (default: %s)s   -is	   --in-datet   in_datet   strings*   format spec for input date (default: none)s   -Is
   --in-deltat   in_deltas1   format spec for input time period (default: none)s   -As   --plus-deltat
   plus_deltas/   time period to add to input date or time periods   -ss   --minus-datet   sub_dates    date to subtract from input dates   -Ss   --minus-deltat   minus_deltas6   time period to subtract from input date or time periods   -Rs   --roundt   round_deltas   time period used for roundings   -Bs   --bott	   bot_deltas"   time period used for rounding downs   -Es   --eott	   eot_deltas    time period used for rounding ups   -os   --outputt   outputs+   format spec for output time (default: none)s   -js   --juliant   julian_inputs   treat input as Julian dates   -Js   --Juliant   julian_outputs   present output as Julian dates   -ps   --posixt   in_date_posixs   shortcut for --in-date=posixs   -Ps   --Posixt   out_date_posixs   shortcut for --output=posixs   -Zs
   --timezonet   timezone_outputs"   timezone for output (default: UTC)R   s
   --deadlinet   deadlines   deadline specificationt   -s   
i    i   s)   --in-date and --in-delta are incompatibles/   --exponent <exponent> must be positive definiteR   t   maint   dates   no time arguments availablei   i   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   t   julianR   R   R   R"   t   julian_yeart   julian_montht
   julian_dayt   dows   YYYY-MM-DD hh:mm:ssR   s   -ymdR   s   YYYYMMDD-hhmmssR   s   -ydoys   YYYY-DOY hh:mm:ssR   s   YYYYDOY-hhmmssR    s   YYYY-MM-DDThh:mm:sst   attrs   DDD:hh:mm:ss(H   t   eon_datet   sysR&   R$   RJ   t   __name__t   optparseRL   RM   RN   t   parsert
   add_optiont   Falset
   g_EXPONENTt
   parse_argsR/   t   argst   indext   nRC   t   stdint	   readlinest   xR1   RX   RZ   t   errorR0   Rd   Re   Ra   t   main_is_dateR#   t   tiRD   RP   t   Truet   tpR3   t   insertR%   t   nargR\   R]   R[   R^   R_   R`   R:   R@   R2   t   tRb   t	   eon_deltat   roundt   bott   eott   bopt   eopRg   t   set_deadlinet   decimal_partR?   t
   isinstancet   time_optionsRp   R   t   getRc   Rf   t   all_attrt   exit(    (    (    s*   /home/pphick/eclipse/general/python/eon.pyt   <module>   s$  
AF
	
				











 
  








 $ $ $ / / / * * *$ 					
					