
    d`                     J   d Z ddlZddlZddlZddlmZ g dZeZ	 G d de          Z
 G d de          Zd	Zd
Zg dZ G d d          Z G d d          Z ed          Z ed          Z ed          Z ed          Z ed          \  ZZZZZZZd Zd Zd Zd Z d Z!d Z"d Z# G d de$          Z% G d de%          Z& G d  d!e%          Z' G d" d#          Z(d$ Z) G d% d&e&          Z* G d' d(e'          Z+ e&            Z,e,j-        Z.d) Z/e,j0        Z1e,j2        Z2e,j3        Z4e,j5        Z6e,j7        Z7e,j8        Z9e,j:        Z;e,j<        Z=d*Z>d+Z?e>e?fd,Z@e>e?fd-ZAd.ZB ejC        eBd	d	          D                                ZEd/ ZFd0 ZGeHd1k    r eGejI                   dS dS )2a$  Calendar printing functions

Note when comparing these calendars to the ones printed by cal(1): By
default, these calendars have Monday as the first day of the week, and
Sunday as the last (the European convention). Use setfirstweekday() to
set the first day of the week (0=Monday, 6=Sunday).    N)repeat)IllegalMonthErrorIllegalWeekdayErrorsetfirstweekdayfirstweekdayisleapleapdaysweekday
monthrangemonthcalendarprmonthmonthprcalcalendartimegm
month_name
month_abbrday_nameday_abbrCalendarTextCalendarHTMLCalendarLocaleTextCalendarLocaleHTMLCalendar
weekheaderMONDAYTUESDAY	WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYc                       e Zd Zd Zd ZdS )r   c                     || _         d S Nr   )selfr   s       /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/calendar.py__init__zIllegalMonthError.__init__   s    


    c                     d| j         z  S )Nz!bad month number %r; must be 1-12r&   r'   s    r(   __str__zIllegalMonthError.__str__   s    2TZ??r*   N__name__
__module____qualname__r)   r-    r*   r(   r   r      s7          @ @ @ @ @r*   r   c                       e Zd Zd Zd ZdS )r   c                     || _         d S r%   r
   )r'   r
   s     r(   r)   zIllegalWeekdayError.__init__"   s    r*   c                     d| j         z  S )Nz7bad weekday number %r; must be 0 (Monday) to 6 (Sunday)r5   r,   s    r(   r-   zIllegalWeekdayError.__str__$   s    H4<WWr*   Nr.   r2   r*   r(   r   r   !   s7          X X X X Xr*   r         )r         r9      r9   r;   r9   r9   r;   r9   r;   r9   c                   x    e Zd Zd  ed          D             Ze                    dd            d Zd Zd ZdS )	_localized_monthc                 J    g | ] }t          j        d |dz   d          j        !S i  r7   datetimedatestrftime.0is     r(   
<listcomp>z_localized_month.<listcomp>6   s-    GGGx}T1Q3**3GGGr*      r   c                     dS )N r2   )xs    r(   <lambda>z_localized_month.<lambda>7   s     r*   c                     || _         d S r%   formatr'   rO   s     r(   r)   z_localized_month.__init__9       r*   c                       j         |         }t          |t                    r fd|D             S  | j                  S )Nc                 0    g | ]} |j                   S r2   rN   rE   fr'   s     r(   rG   z0_localized_month.__getitem__.<locals>.<listcomp>?   #    222qAAdkNN222r*   )_months
isinstanceslicerO   r'   rF   funcss   `  r(   __getitem__z_localized_month.__getitem__<   sL    Qa 	&2222E22225%%%r*   c                     dS )N   r2   r,   s    r(   __len__z_localized_month.__len__C   s    rr*   N)	r/   r0   r1   rangerW   insertr)   r\   r_   r2   r*   r(   r=   r=   4   sr        GGUU2YYGGGGNN1ll###  & & &    r*   r=   c                   J    e Zd Zd  ed          D             Zd Zd Zd ZdS )_localized_dayc                 J    g | ] }t          j        d d|dz             j        !S r?   r@   rD   s     r(   rG   z_localized_day.<listcomp>J   s-    DDDaX]4AaC((1DDDr*      c                     || _         d S r%   rN   rP   s     r(   r)   z_localized_day.__init__L   rQ   r*   c                       j         |         }t          |t                    r fd|D             S  | j                  S )Nc                 0    g | ]} |j                   S r2   rN   rT   s     r(   rG   z._localized_day.__getitem__.<locals>.<listcomp>R   rV   r*   )_daysrX   rY   rO   rZ   s   `  r(   r\   z_localized_day.__getitem__O   sL    
1a 	&2222E22225%%%r*   c                     dS Nre   r2   r,   s    r(   r_   z_localized_day.__len__V   s    qr*   N)r/   r0   r1   r`   ri   r)   r\   r_   r2   r*   r(   rc   rc   G   s_         ED5588DDDE  & & &    r*   rc   z%Az%az%Bz%bre   c                 8    | dz  dk    o| dz  dk    p| dz  dk    S )z5Return True for leap years, False for non-leap years.   r   d     r2   )years    r(   r   r   f   s*    !8q=AdSjAo@qAr*   c                 \    | dz  } |dz  }|dz  | dz  z
  |dz  | dz  z
  z
  |dz  | dz  z
  z   S )zFReturn number of leap years in range [y1, y2).
       Assume y1 <= y2.r7   rm   rn   ro   r2   )y1y2s     r(   r	   r	   k   sL     !GB!GBEBEMb#gC/0BGb#g4EFFr*   c                     t           j        | cxk    rt           j        k    s
n d| dz  z   } t          j        | ||                                          S )zBReturn weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31).i  ro   )rA   MINYEARMAXYEARrB   r
   )rp   r   days      r(   r
   r
   s   sU    t7777x'77777dSj =uc**22444r*   c                     d|cxk    rdk    sn t          |          t          | |d          }t          |         |t          k    ot	          |           z   }||fS )zQReturn weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
       year, month.r7   rH   )r   r
   mdaysFebruaryr   )rp   r   day1ndayss       r(   r   r   z   sj     &&&4""D%LEX->&,,?E;r*   c                 R    t           |         |t          k    ot          |           z   S r%   )ry   rz   r   rp   r   s     r(   	_monthlenr      s!    <5H,=>>r*   c                 *    |dk    r| dz
  dfS | |dz
  fS )Nr7   rH   r2   r~   s     r(   
_prevmonthr      s'    zzAvrzU1W}r*   c                 *    |dk    r| dz   dfS | |dz   fS )NrH   r7   r2   r~   s     r(   
_nextmonthr      s'    {{AvqyU1W}r*   c                       e Zd ZdZddZd Zd Z eee          Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd ZddZddZddZdS )r   zo
    Base calendar class. This class doesn't do any formatting. It simply
    provides data to subclasses.
    r   c                     || _         d S r%   r   r'   r   s     r(   r)   zCalendar.__init__   s    (r*   c                     | j         dz  S rk   _firstweekdayr,   s    r(   getfirstweekdayzCalendar.getfirstweekday   s    !A%%r*   c                     || _         d S r%   r   r   s     r(   r   zCalendar.setfirstweekday   s    )r*   c              #   X   K   t          | j        | j        dz             D ]	}|dz  V  
dS )zt
        Return an iterator for one week of weekday numbers starting with the
        configured first one.
        re   N)r`   r   )r'   rF   s     r(   iterweekdayszCalendar.iterweekdays   sE      
 t($*;a*?@@ 	 	AA#IIII	 	r*   c              #   t   K   |                      ||          D ]\  }}}t          j        |||          V  dS )z
        Return an iterator for one month. The iterator will yield datetime.date
        values and will always iterate through complete weeks, so it will yield
        dates outside the specified month.
        N)itermonthdays3rA   rB   )r'   rp   r   ymds         r(   itermonthdateszCalendar.itermonthdates   sT       **477 	) 	)GAq!-1a((((((	) 	)r*   c              #      K   t          ||          \  }}|| j        z
  dz  }t          d|          E d{V  t          d|dz             E d{V  | j        |z
  |z
  dz  }t          d|          E d{V  dS )z
        Like itermonthdates(), but will yield day numbers. For days outside
        the specified month the day number is 0.
        re   r   Nr7   )r   r   r   r`   )r'   rp   r   r{   r|   days_before
days_afters          r(   itermonthdayszCalendar.itermonthdays   s      
 !u--ed//14![)))))))))EAI&&&&&&&&&'$.6!;
!Z(((((((((((r*   c              #   z   K   t          |                     ||          | j                  D ]\  }}||dz  fV  dS )z
        Like itermonthdates(), but will yield (day number, weekday number)
        tuples. For days outside the specified month the day number is 0.
        re   N)	enumerater   r   )r'   rp   r   rF   r   s        r(   itermonthdays2zCalendar.itermonthdays2   sU      
 d00u==t?PQQ 	 	DAqQU(NNNN	 	r*   c              #     K   t          ||          \  }}|| j        z
  dz  }| j        |z
  |z
  dz  }t          ||          \  }}t          ||          dz   }	t	          |	|z
  |	          D ]	}
|||
fV  
t	          d|dz             D ]	}
|||
fV  
t          ||          \  }}t	          d|dz             D ]	}
|||
fV  
dS )z
        Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
        used for dates outside of datetime.date range.
        re   r7   N)r   r   r   r   r`   r   )r'   rp   r   r{   r|   r   r   r   r   endr   s              r(   r   zCalendar.itermonthdays3   s     
 !u--ed//14'$.6!;
$&&11oo!s;,, 	 	AQ'MMMMq%!)$$ 	! 	!Aq.    $&&1q*q.)) 	 	AQ'MMMM	 	r*   c              #      K   t          |                     ||                    D ]\  }\  }}}|||| j        |z   dz  fV  dS )z
        Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
        Can be used for dates outside of datetime.date range.
        re   N)r   r   r   )r'   rp   r   rF   r   r   r   s          r(   itermonthdays4zCalendar.itermonthdays4   sh      
 &d&9&9$&F&FGG 	7 	7LAy1aQD-1Q666666	7 	7r*   c                     t          |                     ||                    fdt          dt                    d          D             S )z
        Return a matrix (list of lists) representing a month's calendar.
        Each row represents a week; week entries are datetime.date values.
        c                 *    g | ]}||d z            S re   r2   )rE   rF   datess     r(   rG   z/Calendar.monthdatescalendar.<locals>.<listcomp>   s%    @@@!q1u@@@r*   r   re   )listr   r`   len)r'   rp   r   r   s      @r(   monthdatescalendarzCalendar.monthdatescalendar   sN    
 T((u5566@@@@uQE

A'>'>@@@@r*   c                     t          |                     ||                    fdt          dt                    d          D             S )z
        Return a matrix representing a month's calendar.
        Each row represents a week; week entries are
        (day number, weekday number) tuples. Day numbers outside this month
        are zero.
        c                 *    g | ]}||d z            S r   r2   rE   rF   dayss     r(   rG   z/Calendar.monthdays2calendar.<locals>.<listcomp>   %    >>>a!e>>>r*   r   re   )r   r   r`   r   r'   rp   r   r   s      @r(   monthdays2calendarzCalendar.monthdays2calendar   sN     D''e4455>>>>eAs4yy!&<&<>>>>r*   c                     t          |                     ||                    fdt          dt                    d          D             S )z
        Return a matrix representing a month's calendar.
        Each row represents a week; days outside this month are zero.
        c                 *    g | ]}||d z            S r   r2   r   s     r(   rG   z.Calendar.monthdayscalendar.<locals>.<listcomp>   r   r*   r   re   )r   r   r`   r   r   s      @r(   monthdayscalendarzCalendar.monthdayscalendar   sN    
 D&&tU3344>>>>eAs4yy!&<&<>>>>r*      c                       fdt          t          t          dz             D             fdt          dt                              D             S )a'  
        Return the data for the specified year ready for formatting. The return
        value is a list of month rows. Each month row contains up to width months.
        Each month contains between 4 and 6 weeks and each week contains 1-7
        days. Days are datetime.date objects.
        c                 <    g | ]}                     |          S r2   )r   rE   rF   r'   rp   s     r(   rG   z.Calendar.yeardatescalendar.<locals>.<listcomp>  9     
 
 
 ##D!,,
 
 
r*   rH   c                 *    g | ]}||z            S r2   r2   rE   rF   monthswidths     r(   rG   z.Calendar.yeardatescalendar.<locals>.<listcomp>  &    IIIaq5y!IIIr*   r   r`   Januaryr   r'   rp   r   r   s   ```@r(   yeardatescalendarzCalendar.yeardatescalendar   s    
 
 
 
 
7GBJ//
 
 
 JIIII5CKK+G+GIIIIr*   c                       fdt          t          t          dz             D             fdt          dt                              D             S )z
        Return the data for the specified year ready for formatting (similar to
        yeardatescalendar()). Entries in the week lists are
        (day number, weekday number) tuples. Day numbers outside this month are
        zero.
        c                 <    g | ]}                     |          S r2   )r   r   s     r(   rG   z.Calendar.yeardays2calendar.<locals>.<listcomp>  r   r*   rH   c                 *    g | ]}||z            S r2   r2   r   s     r(   rG   z.Calendar.yeardays2calendar.<locals>.<listcomp>  r   r*   r   r   r   s   ```@r(   yeardays2calendarzCalendar.yeardays2calendar  r   r*   c                       fdt          t          t          dz             D             fdt          dt                              D             S )z
        Return the data for the specified year ready for formatting (similar to
        yeardatescalendar()). Entries in the week lists are day numbers.
        Day numbers outside this month are zero.
        c                 <    g | ]}                     |          S r2   )r   r   s     r(   rG   z-Calendar.yeardayscalendar.<locals>.<listcomp>   s9     
 
 
 ""4++
 
 
r*   rH   c                 *    g | ]}||z            S r2   r2   r   s     r(   rG   z-Calendar.yeardayscalendar.<locals>.<listcomp>$  r   r*   r   r   r   s   ```@r(   yeardayscalendarzCalendar.yeardayscalendar  ss    
 
 
 
 
7GBJ//
 
 
 JIIII5CKK+G+GIIIIr*   N)r   r   )r/   r0   r1   __doc__r)   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r2   r*   r(   r   r      s7        
) ) ) )& & &* * * 8O_==L  ) ) )
) 
) 
)    $7 7 7A A A? ? ?? ? ?J J J JJ J J J
J 
J 
J 
J 
J 
Jr*   r   c                   X    e Zd ZdZd Zd Zd Zd Zd ZddZ	dd
Z
ddZddZddZdS )r   zr
    Subclass of Calendar that outputs a calendar as a simple plain text
    similar to the UNIX program cal.
    c                 P    t          |                     ||          d           dS )z3
        Print a single week (no newline).
        rJ   r   N)print
formatweekr'   theweekr   s      r(   prweekzTextCalendar.prweek-  s+     	doogu--2666666r*   c                 H    |dk    rd}nd|z  }|                     |          S )z*
        Returns a formatted day.
        r   rJ   z%2icenter)r'   rw   r
   r   ss        r(   	formatdayzTextCalendar.formatday3  s-     !88AAAxxr*   c                 J     d                      fd|D                       S )zA
        Returns a single week in a string (no newline).
         c              3   L   K   | ]\  }}                     ||          V  d S r%   r   )rE   r   wdr'   r   s      r(   	<genexpr>z*TextCalendar.formatweek.<locals>.<genexpr>A  s7      LL!Rq"e44LLLLLLr*   joinr   s   ` `r(   r   zTextCalendar.formatweek=  s0     xxLLLLLGLLLLLLr*   c                 r    |dk    rt           }nt          }||         d|                             |          S )z4
        Returns a formatted week day name.
        	   N)r   r   r   )r'   rw   r   namess       r(   formatweekdayzTextCalendar.formatweekdayC  s:     A::EEESz&5&!((///r*   c                 n     d                      fd                                 D                       S )z-
        Return a header for a week.
        r   c              3   D   K   | ]}                     |          V  d S r%   r   )rE   rF   r'   r   s     r(   r   z0TextCalendar.formatweekheader.<locals>.<genexpr>Q  s3      RR**1e44RRRRRRr*   r   r   )r'   r   s   ``r(   formatweekheaderzTextCalendar.formatweekheaderM  s<     xxRRRRRd>O>O>Q>QRRRRRRr*   Tc                 X    t           |         }|r|d|}|                    |          S )z0
        Return a formatted month name.
        r   )r   r   )r'   theyearthemonthr   withyearr   s         r(   formatmonthnamezTextCalendar.formatmonthnameS  s6     x  	'11gg&Axxr*   r   c                 T    t          |                     ||||          d           dS )z+
        Print a month's calendar.
        rJ   r   N)r   formatmonth)r'   r   r   wls        r(   r   zTextCalendar.prmonth\  s1     	dw!Q77R@@@@@@r*   c                    t          d|          }t          d|          }|                     ||d|dz   z  dz
            }|                                }|d|z  z  }||                     |                                          z  }|d|z  z  }|                     ||          D ]5}||                     ||                                          z  }|d|z  z  }6|S )z@
        Return a month's calendar string (multi-line).
        r8   r7   re   
)maxr   rstripr   r   r   )r'   r   r   r   r   r   weeks          r(   r   zTextCalendar.formatmonthb  s     1II1II  (AQK!ODDHHJJ	TAX	T""1%%,,...	TAX++GX>> 	 	Dq))00222AMAAr*   r8   r7      r   c           	          t          d|          }t          d|          }t          d|          }|dz   dz  dz
  g }|j        } |t                                        |z  ||dz
  z  z                                                         |d|z                                  |          t                               |                    D ]\  }}	t          ||z  dz   t          ||dz   z  dz   d                    }
 |d|z              fd|
D             } |t          ||                                                      |d|z             fd|
D             } |t          ||                                                      |d|z             t          d |	D                       }t          |          D ]}g }|	D ]Z}|t          |          k    r|                    d	           +|                                         ||         |                     [ |t          ||                                                      |d|z             d	                    |          S )
zC
        Returns a year's calendar as a multi-line string.
        r8   r7   re   r   r^   c              3   H   K   | ]}                     |d           V  dS )FN)r   )rE   kcolwidthr'   r   s     r(   r   z*TextCalendar.formatyear.<locals>.<genexpr>  sK       & & ))'1hFF & & & & & &r*   c              3      K   | ]}V  d S r%   r2   )rE   r   headers     r(   r   z*TextCalendar.formatyear.<locals>.<genexpr>  s#      ..!v......r*   c              3   4   K   | ]}t          |          V  d S r%   )r   )rE   cals     r(   r   z*TextCalendar.formatyear.<locals>.<genexpr>  s(      11cS111111r*   rJ   )r   appendreprr   r   r   r   r   r`   minformatstringr   r   r   )r'   r   r   r   cr   varF   rowr   r   headersheightjweeksr   r   r   s   ``               @@r(   
formatyearzTextCalendar.formatyearr  s    1II1II1IIEQ;?H	$w--

xz!QqS'1
2
2
9
9
;
;<<<	$q&			&&q))!$"8"8!"D"DEE 	 	HQ1Q3q5#a1gai"4"455FAd1fIII& & & & & &$& & &EAl5(A..5577888Ad1fIII....v...GAl7Ha007799:::Ad1fIII11S11111F6]]   A ACCHH}}R((((T__SVQ%?%?@@@@,uh2299;;<<<$( wwqzzr*   c           	      V    t          |                     |||||          d           dS )zPrint a year's calendar.rJ   r   N)r   r  )r'   r   r   r   r  r   s         r(   pryearzTextCalendar.pryear  s/    doogq!Q22;;;;;;r*   NT)r   r   )r8   r7   r   r   )r   r   r   r   )r/   r0   r1   r   r   r   r   r   r   r   r   r   r  r  r2   r*   r(   r   r   '  s         
7 7 7  M M M0 0 0S S S   A A A A    # # # #J< < < < < <r*   r   c                   j    e Zd ZdZg dZeZdZdZdZdZ	dZ
d Zd Zd Zd	 ZddZddZddZddZdS )r   z4
    This calendar returns complete HTML pages.
    )montuewedthufrisatsunnodayr   rp   c                 F    |dk    r
d| j         z  S d| j        |         |fz  S )z/
        Return a day as a table cell.
        r   z<td class="%s">&nbsp;</td>z<td class="%s">%d</td>)cssclass_noday
cssclasses)r'   rw   r
   s      r(   r   zHTMLCalendar.formatday  s2     !88/$2EEE+tw/G.MMMr*   c                 P     d                      fd|D                       }d|z  S )z8
        Return a complete week as a table row.
        rJ   c              3   J   K   | ]\  }}                     ||          V  d S r%   r   )rE   r   r   r'   s      r(   r   z*HTMLCalendar.formatweek.<locals>.<genexpr>  s5      AAgq"DNN1b))AAAAAAr*   <tr>%s</tr>r   )r'   r   r   s   `  r(   r   zHTMLCalendar.formatweek  s6     GGAAAAAAAAAq  r*   c                 @    d| j         |         dt          |         dS )z:
        Return a weekday name as a table header.
        z<th class="">z</th>)cssclasses_weekday_headr   )r'   rw   s     r(   r   zHTMLCalendar.formatweekday  s+     
 (---x}}}> 	>r*   c                 t     d                      fd                                 D                       }d|z  S )z<
        Return a header for a week as a table row.
        rJ   c              3   B   K   | ]}                     |          V  d S r%   r   )rE   rF   r'   s     r(   r   z0HTMLCalendar.formatweekheader.<locals>.<genexpr>  s1      GGaD&&q))GGGGGGr*   r  r   )r'   r   s   ` r(   r   zHTMLCalendar.formatweekheader  sB     GGGGGG43D3D3F3FGGGGGq  r*   Tc                 h    |rt           |         d|}ndt           |         z  }d| j        d|dS )z5
        Return a month name as a table row.
        r   z%sz<tr><th colspan="7" class="r   z
</th></tr>)r   cssclass_month_head)r'   r   r   r   r   s        r(   r   zHTMLCalendar.formatmonthname  sQ      	,%h///9AAz(++A$$$aaa) 	)r*   c                    g }|j         } |d| j        z              |d            ||                     |||                      |d            ||                                             |d           |                     ||          D ]+} ||                     |                      |d           , |d            |d           d                    |          S )z6
        Return a formatted month as a table.
        =<table border="0" cellpadding="0" cellspacing="0" class="%s">r   r   </table>rJ   )r   cssclass_monthr   r   r   r   r   )r'   r   r   r   r  r  r   s          r(   r   zHTMLCalendar.formatmonth  s    H	
I! 	" 	" 	"	$	$

w8

D
DEEE	$	$


!
!"""	$++GX>> 	 	DAdood##$$$AdGGGG	*	$wwqzzr*   r   c           	         g }|j         }t          |d          } |d| j        z              |d            |d|| j        |fz             t	          t
          t
          dz   |          D ]u}t	          |t          ||z   d                    } |d           |D ]9} |d            ||                     ||d	
                      |d           : |d           v |d           d                    |          S )z?
        Return a formatted year as a table of tables.
        r7   r'  r   z,<tr><th colspan="%d" class="%s">%s</th></tr>rH   r^   z<tr>z<td>Fr(  z</td>z</tr>r)  rJ   )	r   r   cssclass_yearcssclass_year_headr`   r   r  r   r   )r'   r   r   r  r  rF   r   r   s           r(   r  zHTMLCalendar.formatyear  s<    HE1	
I

 	 	 		$	
84*G<5 5 	6 	6 	6w
E22 	 	A1c!E'2..//FAfIII  &			$""7A">>???'



AgJJJJ	*wwqzzr*   calendar.cssNc                    |t          j                    }g }|j        } |d|z              |d            |d            |d            |d|z             | |d|z              |d|z              |d	            |d
            ||                     ||                      |d            |d           d                    |                              |d          S )zB
        Return a formatted year as a complete HTML page.
        Nz$<?xml version="1.0" encoding="%s"?>
zn<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
z<html>
z<head>
zC<meta http-equiv="Content-Type" content="text/html; charset=%s" />
z4<link rel="stylesheet" type="text/css" href="%s" />
z<title>Calendar for %d</title>
z</head>
z<body>
z</body>
z</html>
rJ   xmlcharrefreplace)sysgetdefaultencodingr   r  r   encode)r'   r   r   cssencodingr  r  s          r(   formatyearpagezHTMLCalendar.formatyearpage  s     -//HH	
1H
<===	
{|||	*	*	
PS[
[\\\?AEKLLL	
,w
6777	+	*	$//'5
)
)***	+	+wwqzz  +>???r*   r  r   )r   r.  N)r/   r0   r1   r   r  r!  r  r%  r*  r-  r,  r   r   r   r   r   r   r  r6  r2   r*   r(   r   r     s         
 CBBJ ) N " N   MN N N! ! !> > >! ! !	) 	) 	) 	)   (   0@ @ @ @ @ @r*   r   c                        e Zd Zd Zd Zd ZdS )different_localec                 "    || _         d | _        d S r%   )locale	oldlocale)r'   r:  s     r(   r)   zdifferent_locale.__init__%  s    r*   c                     t          j        t           j        d           | _        t          j        t           j        | j                   d S r%   )_locale	setlocaleLC_TIMEr;  r:  r,   s    r(   	__enter__zdifferent_locale.__enter__)  s5     *7?DAA'/4;77777r*   c                 `    | j         d S t          j        t          j        | j                    d S r%   )r;  r=  r>  r?  )r'   argss     r(   __exit__zdifferent_locale.__exit__-  s,    >!F'/4>:::::r*   N)r/   r0   r1   r)   r@  rC  r2   r*   r(   r8  r8  $  sA          8 8 8; ; ; ; ;r*   r8  c                      t          j        t           j        d           } | dk    rFt          d          5  t          j        t           j        d           } d d d            n# 1 swxY w Y   | S )NCrJ   )r=  r>  r?  r8  r:  s    r(   _get_default_localerG  3  s    w55F}}b!! 	> 	> &w==F	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> Ms    A!!A%(A%c                   6     e Zd ZdZddZ fdZd	 fd	Z xZS )
r   
    This class can be passed a locale name in the constructor and will return
    month and weekday names in the specified locale.
    r   Nc                 j    t                               | |           |t                      }|| _        d S r%   )r   r)   rG  r:  r'   r   r:  s      r(   r)   zLocaleTextCalendar.__init__C  3    dL111>(**Fr*   c                     t          | j                  5  t                                          ||          cd d d            S # 1 swxY w Y   d S r%   r8  r:  superr   )r'   rw   r   	__class__s      r(   r   z LocaleTextCalendar.formatweekdayI  s    dk** 	5 	577((e44	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   "AA	A	Tc                     t          | j                  5  t                                          ||||          cd d d            S # 1 swxY w Y   d S r%   r8  r:  rO  r   )r'   r   r   r   r   rP  s        r(   r   z"LocaleTextCalendar.formatmonthnameM  s    dk** 	O 	O77**7HeXNN	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	Os   $AAAr   Nr  r/   r0   r1   r   r)   r   r   __classcell__rP  s   @r(   r   r   =  s~         
   5 5 5 5 5O O O O O O O O O Or*   r   c                   6     e Zd ZdZddZ fdZd	 fd	Z xZS )
r   rI  r   Nc                 j    t                               | |           |t                      }|| _        d S r%   )r   r)   rG  r:  rK  s      r(   r)   zLocaleHTMLCalendar.__init__W  rL  r*   c                     t          | j                  5  t                                          |          cd d d            S # 1 swxY w Y   d S r%   rN  )r'   rw   rP  s     r(   r   z LocaleHTMLCalendar.formatweekday]  s    dk** 	. 	.77((--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   !AAATc                     t          | j                  5  t                                          |||          cd d d            S # 1 swxY w Y   d S r%   rR  )r'   r   r   r   rP  s       r(   r   z"LocaleHTMLCalendar.formatmonthnamea  s    dk** 	H 	H77**7HhGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs   #AA
A
rS  r  rT  rV  s   @r(   r   r   R  s~            . . . . .H H H H H H H H H Hr*   r   c                 n    t           | cxk    rt          k    sn t          |           | t          _        d S r%   )r   r"   r   r  r   r   s    r(   r   r   j  s:    \++++V++++!,///!ANNNr*      r   c                 B    t          t          | ||                     dS )z1Prints multi-column formatting for year calendarsN)r   r  colsr   spacings      r(   rO   rO   ~  s"    	,tXw
/
/00000r*   c                 P    |dz  }|                     fd| D                       S )zEReturns a string formatted from n strings, centered within n columns.r   c              3   B   K   | ]}|                               V  d S r%   r   )rE   r  r   s     r(   r   zformatstring.<locals>.<genexpr>  s/      99q**999999r*   r   r^  s    ` r(   r  r    s3    sNG<<9999D999999r*   i  c                     | dd         \  }}}}}}t          j        ||d                                          t          z
  |z   dz
  }|dz  |z   }|dz  |z   }	|	dz  |z   }
|
S )zBUnrelated but handy function to calculate Unix timestamp from GMT.Nr   r7      <   )rA   rB   	toordinal
_EPOCH_ORD)tuplerp   r   rw   hourminutesecondr   hoursminutessecondss              r(   r   r     sx    -22A2Y*D%dFF=ua((2244zACG!KDGdNEBhGbj6!GNr*   c                    dd l }|                                }|                    d          }|                    d          }|                    ddt          dd           |                    d	d
t          dd           |                    ddt          dd           |                    ddt          dd           |                    dddd           |                    ddd d           |                    ddd d           |                    d d!d"d#d$%           |                    d&d't          d()           |                    d*d't          d+)           |                    | dd                    }|j        r0|j        s)|                    d,           t          j
        d           |j        |j        f}|j        d-k    r|j        rt          |.          }nt                      }|j        }|t          j                    }t          ||j        /          }	t          j        j        j        }
|j        : |
 |j        t,          j                                        j        fi |	           d S |j         |
 |j        |j        fi |	           d S |                    d0           t          j
        d           d S |j        rt5          |.          }nt7                      }t          |j        |j        1          }	|j        |j        |	d2<   |j        |	d3<   |j        0 |j         t,          j                                        j        fi |	}n4|j         |j         |j        fi |	}n |j!        |j        |j        fi |	}t          j        j        }
|j        r0|"                    |j                  }t          j        j        j        }
 |
|           d S )4Nr   ztext only argumentszhtml only argumentsz-wz--widthr8   z width of date column (default 2))typedefaulthelpz-lz--linesr7   z)number of lines for each week (default 1)z-sz	--spacingr   z"spacing between months (default 6)z-mz--monthsr   zmonths per row (default 3)z-cz--cssr.  zCSS to use for page)rq  rr  z-Lz--localez.locale to be used from month and weekday namesz-ez
--encodingzencoding to use for outputz-tz--typetext)rs  htmlzoutput type (text or html))rq  choicesrr  rp   ?zyear number (1-9999))nargsrp  rr  r   zmonth number (1-12, text only)z/if --locale is specified --encoding is requiredrt  rF  )r5  r4  zincorrect number of arguments)r   r   r  r   )#argparseArgumentParseradd_argument_groupadd_argumentint
parse_argsr:  r5  errorr1  exitrp  r   r   r2  dictr4  stdoutbufferwriterp   r6  rA   rB   todayr   r   r   r   linesr`  r   r  r   r3  )rB  rx  parser	textgroup	htmlgroupoptionsr:  r   r5  optdictr  results               r(   mainr    sw   OOO$$&&F))*?@@I))*?@@Ii!/    
 i!8    
 k!1    
 j!)    
 g"    
 j=    
 l)    
 h )	     #    
 -     QRR))G~ g. FGGG^W--F|v> 	!$F333CC..C#-//Hgk:::
!'<E$#$X]%8%8%:%:%?KK7KKLLLLL]"E$#$W\==W==>>>>>LL8999HQKKKKK> 	!$F333CC..C'-888= "?GCL">GCL<#S^HM$7$7$9$9$>JJ'JJFF]"#S^GL<<G<<FF$S_W\7=LLGLLF
  	,]]7#344FJ%+Efr*   __main__)Jr   r1  rA   r:  r=  	itertoolsr   __all__
ValueErrorr~  r   r   r   rz   ry   r=   rc   r   r   r   r   r`   r   r   r   r   r    r!   r"   r   r	   r
   r   r   r   r   objectr   r   r   r8  rG  r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r   	_colwidth_spacingrO   r  EPOCHrB   rf  rg  r   r  r/   argvr2   r*   r(   <module>r     sO  7 7 


           ! ! ! 	@ @ @ @ @
 @ @ @X X X X X* X X X  	<;;       &       ( >$>$ d##
d##
 DI588 @)XvxB B B
G G G5 5 5  ? ? ?    NJ NJ NJ NJ NJv NJ NJ NJbr< r< r< r< r<8 r< r< r<jE@ E@ E@ E@ E@8 E@ E@ E@P; ; ; ; ; ; ; ;  O O O O O O O O*H H H H H H H H( LNN " " "
 #	
|

)	<	 	 $X 1 1 1 1
 !*8 : : : : 	X]5!Q''1133
  e e eP zDNNNNN r*   