grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|jÿ_ã@sò ddlZddlZddlZddlmZgd¢ZeZGdd„deƒZ Gdd„deƒZ dZ d Z gd ¢Z Gd d „d ƒZGd d„dƒZedƒZedƒZedƒZedƒZedƒ\ZZZZZZZdd„Zdd„Zdd„Zdd„Zdd„Z dd„Z!d d!„Z"Gd"d#„d#e#ƒZ$Gd$d%„d%e$ƒZ%Gd&d'„d'e$ƒZ&Gd(d)„d)ƒZ'Gd*d+„d+e%ƒZ(Gd,d-„d-e&ƒZ)e%ƒZ*e*j+Z,d.d/„Z-e*j.Z/e*j0Z0e*j1Z2e*j3Z4e*j5Z5e*j6Z7e*j8Z9e*j:Z;d0Ze6ó z_localized_month.é rcCódS)NÚr')Úxr'r'r(Ú7sz_localized_month.cCr#r$©Úformat©r&rJr'r'r(r)9r*z_localized_month.__init__có0ˆj|}t|tƒr‡fdd„|DƒS|ˆjƒS)Ncóg|]}|ˆjƒ‘qSr'rI©r@Úfr,r'r(rB?óz0_localized_month.__getitem__..)Ú_monthsÚ isinstanceÚslicerJ©r&rAZfuncsr'r,r(Ú __getitem__<ó   z_localized_month.__getitem__cCrE)Né r'r,r'r'r(Ú__len__Cóz_localized_month.__len__N) r/r0r1ÚrangerQÚinsertr)rUrXr'r'r'r(r94s  r9c@s6eZdZdd„edƒDƒZdd„Zdd„Zdd „Zd S) Ú_localized_daycCs g|] }t dd|d¡j‘qSr:r;r?r'r'r(rBJrCz_localized_day.écCr#r$rIrKr'r'r(r)Lr*z_localized_day.__init__crL)NcrMr'rIrNr,r'r(rBRrPz._localized_day.__getitem__..)Ú_daysrRrSrJrTr'r,r(rUOrVz_localized_day.__getitem__cCrE©Nr]r'r,r'r'r(rXVrYz_localized_day.__len__N)r/r0r1rZr^r)rUrXr'r'r'r(r\Gs  r\z%Az%az%Bz%br]cCs& |ddko|ddkp|ddkS)Nérédé�r')Úyearr'r'r(rfs$rcCsB |d8}|d8}|d|d|d|d|d|dS)Nr4r`rarbr')Zy1Zy2r'r'r(rks0rcCs: tj|kr tjksnd|d}t |||¡ ¡S)NiÐrb)r<ZMINYEARZMAXYEARr=r )rcr Údayr'r'r(r ss r cCsR d|krdkst|ƒ‚t|ƒ‚t||dƒ}t||tko#t|ƒ}||fS©Nr4rD)rr ÚmdaysÚFebruaryr)rcr Úday1Úndaysr'r'r(r zsÿ r cCst||tko t|ƒSr$)rfrgr©rcr r'r'r(Ú _monthlen„srkcCs |dkr |ddfS||dfSrer'rjr'r'r(Ú _prevmonthˆó  rlcCs |dkr |ddfS||dfS)NrDr4r'rjr'r'r(Ú _nextmonth�rmrnc@s˜eZdZ d"dd„Zdd„Zdd„ZeeeƒZdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zd#dd„Zd#dd„Zd#dd „Zd!S)$rrcCr#r$©r©r&rr'r'r(r)œr*zCalendar.__init__cCs |jdSr_©Z _firstweekdayr,r'r'r(ÚgetfirstweekdayŸr*zCalendar.getfirstweekdaycCr#r$rqrpr'r'r(r¢r*zCalendar.setfirstweekdayccs*� t|j|jdƒD]}|dVq dSr_)rZr)r&rAr'r'r(Ú iterweekdays§s € ÿzCalendar.iterweekdaysccs0� | ||¡D] \}}}t |||¡VqdSr$)Úitermonthdays3r<r=)r&rcr ÚyÚmÚdr'r'r(Úitermonthdates¯s €ÿzCalendar.itermonthdatesccsj� t||ƒ\}}||jd}td|ƒEdHtd|dƒEdH|j||d}td|ƒEdHdS)Nr]rr4)r rrrZ)r&rcr rhriÚ days_beforeÚ days_afterr'r'r(Ú itermonthdays¸s€zCalendar.itermonthdaysccs4� t| ||¡|jƒD] \}}||dfVq dSr_)Ú enumerater{r)r&rcr rArwr'r'r(Úitermonthdays2Äs €ÿzCalendar.itermonthdays2c csÀ� t||ƒ\}}||jd}|j||d}t||ƒ\}}t||ƒd} t| || ƒD]} ||| fVq.td|dƒD]} ||| fVq>t||ƒ\}}td|dƒD]} ||| fVqUdS)Nr]r4)r rrlrkrZrn) r&rcr rhriryrzrurvÚendrwr'r'r(rtÌs€ÿzCalendar.itermonthdays3ccs@� t| ||¡ƒD]\}\}}}||||j|dfVq dSr_)r|rtr)r&rcr rArurvrwr'r'r(Úitermonthdays4Þs €ÿzCalendar.itermonthdays4có0 t| ||¡ƒ‰‡fdd„tdtˆƒdƒDƒS)Ncóg|] }ˆ||d…‘qS©r]r'r?©Zdatesr'r(rBìóz/Calendar.monthdatescalendar..rr])ÚlistrxrZÚlen©r&rcr r'rƒr(ÚmonthdatescalendaræózCalendar.monthdatescalendarcr€)Ncr�r‚r'r?©Údaysr'r(rBör„z/Calendar.monthdays2calendar..rr])r…r}rZr†r‡r'rŠr(Úmonthdays2calendarîszCalendar.monthdays2calendarcr€)Ncr�r‚r'r?rŠr'r(rBþr„z.Calendar.monthdayscalendar..rr])r…r{rZr†r‡r'rŠr(Úmonthdayscalendarør‰zCalendar.monthdayscalendarécó@ ‡‡fdd„tttdƒDƒ‰‡‡fdd„tdtˆƒˆƒDƒS)Ncóg|]}ˆ ˆ|¡‘qSr')rˆr?©r&rcr'r(rBó ÿÿz.Calendar.yeardatescalendar..rDcóg|] }ˆ||ˆ…‘qSr'r'r?©ÚmonthsÚwidthr'r(rB r„r©rZÚJanuaryr†©r&rcr–r'©r•r&r–rcr(Úyeardatescalendaró   þ zCalendar.yeardatescalendarcr�)Ncr�r')rŒr?r‘r'r(rBr’z.Calendar.yeardays2calendar..rDcr“r'r'r?r”r'r(rBr„rr—r™r'ršr(Úyeardays2calendar rœzCalendar.yeardays2calendarcr�)Ncr�r')r�r?r‘r'r(rB r’z-Calendar.yeardayscalendar..rDcr“r'r'r?r”r'r(rB$r„rr—r™r'ršr(Úyeardayscalendars   þ zCalendar.yeardayscalendarN)r©rŽ)r/r0r1r)rrrÚpropertyrrsrxr{r}rtrrˆrŒr�r›r�ržr'r'r'r(r–s$       rc@sheZdZ dd„Zdd„Zdd„Zdd„Zd d „Zdd d „Zddd„Z ddd„Z ddd„Z ddd„Z dS) rcCs t| ||¡dd�dS©NrF)r~)ÚprintÚ formatweek©r&Útheweekr–r'r'r(Úprweek-szTextCalendar.prweekcCs" |dkrd}nd|}| |¡S)NrrFz%2i©Úcenter)r&rdr r–Úsr'r'r(Ú formatday3s  zTextCalendar.formatdaycs d ‡‡fdd„|Dƒ¡S)Nú c3s"�|] \}}ˆ ||ˆ¡VqdSr$©rª©r@rwZwd©r&r–r'r(Ú As€ z*TextCalendar.formatweek..©Újoinr¤r'r®r(r£=szTextCalendar.formatweekcCs* |dkrt}nt}||d|… |¡S)Né )rrr¨)r&rdr–Únamesr'r'r(Ú formatweekdayCs zTextCalendar.formatweekdaycs d ‡‡fdd„ˆ ¡Dƒ¡S)Nr«c3s�|] }ˆ |ˆ¡VqdSr$©r´r?r®r'r(r¯Qs€z0TextCalendar.formatweekheader..©r±rsr®r'r®r(ÚformatweekheaderMszTextCalendar.formatweekheaderTcCs$ t|}|r d||f}| |¡S)Nz%s %r)rr¨)r&ÚtheyearÚthemonthr–Úwithyearr©r'r'r(ÚformatmonthnameSs   zTextCalendar.formatmonthnamercCs t| ||||¡dd�dSr¡)r¢Ú formatmonth)r&r¸r¹ÚwÚlr'r'r(r \szTextCalendar.prmonthcCs˜ td|ƒ}td|ƒ}| ||d|dd¡}| ¡}|d|7}|| |¡ ¡7}|d|7}| ||¡D]}|| ||¡ ¡7}|d|7}q7|S)Nr5r4r]Ú )Úmaxr»Úrstripr·rŒr£)r&r¸r¹r½r¾r©Úweekr'r'r(r¼bs    zTextCalendar.formatmonthr5r4érŽc s® td|ƒ}td|ƒ}td|ƒ}|ddd‰g}|j}|tˆƒ ˆ|||d¡ ¡ƒ|d|ƒˆ |¡‰tˆ ˆ|¡ƒD]Ž\}} t||dt ||dddƒƒ} |d|ƒ‡‡‡fdd„| Dƒ} |t | ˆ|ƒ ¡ƒ|d|ƒ‡fdd„| Dƒ} |t | ˆ|ƒ ¡ƒ|d|ƒtd d„| Dƒƒ} t| ƒD]0}g}| D]}|t |ƒkr´| d ¡q¦| ˆ  |||¡¡q¦|t |ˆ|ƒ ¡ƒ|d|ƒq qCd   |¡S) Nr5r4r]r¿rWc3s �|] }ˆ ˆ|ˆd¡VqdS)FN)r»©r@Úk)Úcolwidthr&r¸r'r(r¯ƒs€ÿz*TextCalendar.formatyear..c3s�|]}ˆVqdSr$r'rÄ)Úheaderr'r(r¯‡s€css�|]}t|ƒVqdSr$)r†)r@Úcalr'r'r(r¯‹s€rF)rÀÚappendÚreprr¨rÁr·r|r�rZÚminÚ formatstringr†r£r±)r&r¸r½r¾ÚcrvÚvÚarAÚrowr•r³ZheadersZheightÚjZweeksrÈr')rÆrÇr&r¸r(Ú formatyearrs@   &  $ ÿ     ø zTextCalendar.formatyearcCs t| |||||¡dd�dSr¡)r¢rÒ)r&r¸r½r¾rÍrvr'r'r(Úpryear—szTextCalendar.pryearN©T)rr)r5r4rÃrŽ)rrrÃrŽ) r/r0r1r¦rªr£r´r·r»r r¼rÒrÓr'r'r'r(r's    %rc@sveZdZ gd¢ZeZdZdZdZdZdZ dd„Z dd„Z d d „Z d d „Z ddd„Zddd„Zddd„Zddd„ZdS)r)ZmonZtueZwedZthuZfriZsatZsunZnodayr rccCs& |dkr d|jSd|j||fS)Nrz z%d)Úcssclass_nodayÚ cssclasses)r&rdr r'r'r(rª¶s zHTMLCalendar.formatdaycs" d ‡fdd„|Dƒ¡}d|S)NrFc3s �|] \}}ˆ ||¡VqdSr$r¬r­r,r'r(r¯Äs€z*HTMLCalendar.formatweek..ú %sr°)r&r¥r©r'r,r(r£ÀszHTMLCalendar.formatweekcCs d|j|t|fS)Nz%s)Úcssclasses_weekday_headr©r&rdr'r'r(r´ÇsÿzHTMLCalendar.formatweekdaycs& d ‡fdd„ˆ ¡Dƒ¡}d|S)NrFc3s�|]}ˆ |¡VqdSr$rµr?r,r'r(r¯Òó€z0HTMLCalendar.formatweekheader..r×r¶)r&r©r'r,r(r·ÎszHTMLCalendar.formatweekheaderTcCs2 |r dt||f}ndt|}d|j|fS)Nz%s %sz%sz+%s)rÚcssclass_month_head)r&r¸r¹rºr©r'r'r(r»Õs ÿzHTMLCalendar.formatmonthnamecCs” g}|j}|d|jƒ|dƒ||j|||d�ƒ|dƒ|| ¡ƒ|dƒ| ||¡D] }|| |¡ƒ|dƒq/|dƒ|dƒd |¡S)Nú=r¿©rºú
rF)rÉÚcssclass_monthr»r·rŒr£r±)r&r¸r¹rºrÎrÏrÂr'r'r(r¼às"ÿ   zHTMLCalendar.formatmonthrŽcCsº g}|j}t|dƒ}|d|jƒ|dƒ|d||j|fƒtttd|ƒD]+}t|t||dƒƒ}|dƒ|D]}|dƒ||j||d d �ƒ|d ƒq:|d ƒq(|d ƒd |¡S)Nr4rÜr¿z,%srDrWzzFrÝzzrÞrF) rÉrÀÚ cssclass_yearÚcssclass_year_headrZr˜rËr¼r±)r&r¸r–rÎrÏrAr•rvr'r'r(rÒôs* ÿÿ   zHTMLCalendar.formatyearú calendar.cssNcCs® |dur t ¡}g}|j}|d|ƒ|dƒ|dƒ|dƒ|d|ƒ|dur0|d|ƒ|d|ƒ|dƒ|d ƒ|| ||¡ƒ|d ƒ|d ƒd  |¡ |d ¡S)Nz$ zn z z zC z4 zCalendar for %d z z z z rFÚxmlcharrefreplace)ÚsysÚgetdefaultencodingrÉrÒr±Úencode)r&r¸r–ÚcssÚencodingrÎrÏr'r'r(Úformatyearpage s&    zHTMLCalendar.formatyearpagerÔrŸ)rŽrâN)r/r0r1rÖrØrÕrÛrßráràrªr£r´r·r»r¼rÒrér'r'r'r(rœs"   rc@s$eZdZdd„Zdd„Zdd„ZdS)Údifferent_localecCr#r$©Úlocale)r&rìr'r'r(r)%r*zdifferent_locale.__init__cCs"t tj¡|_t tj|j¡dSr$)Ú_localeZ getlocaleÚLC_TIMEÚ oldlocaleÚ setlocalerìr,r'r'r(Ú __enter__(szdifferent_locale.__enter__cGst tj|j¡dSr$)rírðrîrï)r&Úargsr'r'r(Ú__exit__,szdifferent_locale.__exit__N)r/r0r1r)rñrór'r'r'r(rê$s rêcó6eZdZ d dd„Z‡fdd„Zd ‡fdd „ Z‡ZS) rrNcCó&t ||¡|durt ¡}||_dSr$)rr)ríÚgetdefaultlocalerì©r&rrìr'r'r(r)8ó  zLocaleTextCalendar.__init__cs<t|jƒ�tƒ ||¡WdƒS1swYdSr$©rêrìÚsuperr´)r&rdr–©Ú __class__r'r(r´>s  $ÿz LocaleTextCalendar.formatweekdayTcs@t|jƒ�tƒ ||||¡WdƒS1swYdSr$©rêrìrúr»)r&r¸r¹r–rºrûr'r(r»Bs $ÿz"LocaleTextCalendar.formatmonthname©rNrÔ©r/r0r1r)r´r»Ú __classcell__r'r'rûr(r0s   rcrô) rrNcCrõr$)rr)rírörìr÷r'r'r(r)NrøzLocaleHTMLCalendar.__init__cs:t|jƒ�tƒ |¡WdƒS1swYdSr$rùrÙrûr'r(r´Ts  $ÿz LocaleHTMLCalendar.formatweekdayTcs>t|jƒ�tƒ |||¡WdƒS1swYdSr$rý)r&r¸r¹rºrûr'r(r»Xs $ÿz"LocaleHTMLCalendar.formatmonthnamerþrÔrÿr'r'rûr(rGs   rcCs.t|kr tkst|ƒ‚t|ƒ‚|t_dSr$)rr!rrÍrror'r'r(ras ÿ rérÃcCs tt|||ƒƒdSr$)r¢rÌ©ZcolsrÆÚspacingr'r'r(rJusrJcs" |d9}| ‡fdd„|Dƒ¡S)Nr«c3s�|]}| ˆ¡VqdSr$r§)r@rÍ©rÆr'r(r¯}rÚzformatstring..r°rr'rr(rÌzsrÌi²c Cs` |dd…\}}}}}}t ||d¡ ¡t|d}|d|}|d|} | d|} | S)NrÃr4éé<)r<r=Ú toordinalÚ _EPOCH_ORD) Útuplercr rdZhourZminuteÚsecondr‹ZhoursZminutesZsecondsr'r'r(r„s   rc Cs¶ddl}| ¡}| d¡}| d¡}|jddtddd�|jd d td d d�|jd dtddd�|jddtddd�|jddddd�|jddddd�|jddddd�|jd d!d"d#d$d%�|jd&d'td(d)�|jd*d'td+d)�| |d d…¡}|jrŠ|jsŠ| d,¡t   d ¡|j|jf}|j d-krí|jržt |d.�}nt ƒ}|j}|dur¬t  ¡}t||jd/�} t jjj} |jdurÎ| |jtj ¡jfi| ¤ŽƒdS|jdurá| |j|jfi| ¤ŽƒdS| d0¡t   d ¡dS|jröt|d.�}ntƒ}t|j|jd1�} |jdu�r|j| d2<|j| d3<|jdu�r%|j tj ¡jfi| ¤Ž} n|jdu�r6|j |jfi| ¤Ž} n |j!|j|jfi| ¤Ž} t jj} |j�rU|  "|j¡} t jjj} | | ƒdS)4Nrztext only argumentszhtml only argumentsz-wz--widthr5z width of date column (default 2))ÚtypeÚdefaultÚhelpz-lz--linesr4z)number of lines for each week (default 1)z-sz --spacingrÃz"spacing between months (default 6)z-mz--monthsrŽzmonths per row (default 3)z-cz--cssrâzCSS to use for page)r r z-Lz--localez.locale to be used from month and weekday namesz-ez --encodingzencoding to use for outputz-tz--typeÚtext)rÚhtmlzoutput type (text or html))r Úchoicesr rcú?zyear number (1-9999))Únargsr r r zmonth number (1-12, text only)z/if --locale is specified --encoding is requiredrrë)rèrçzincorrect number of arguments)r½r¾rÍrv)#ÚargparseÚArgumentParserZadd_argument_groupÚ add_argumentÚintÚ parse_argsrìrèÚerrorräÚexitr rrråÚdictrçÚstdoutÚbufferÚwritercrér<r=Ztodayr rrr–Úlinesrr•rÒr¼ræ) ròrÚparserZ textgroupZ htmlgroupZoptionsrìrÈrèZoptdictrÚresultr'r'r(ÚmainŽs¸  ýýýýýýýüýý        "           r!Ú__main__)Hrär<rìríÚ itertoolsrÚ__all__Ú ValueErrorrrrr˜rgrfr9r\rrrrrZrrrrrr r!rrr r rkrlrnÚobjectrrrrêrrrÍrrrrr�r r¦r£rÂr·rr r¼r rÒrrÓrZ _colwidthZ_spacingrJrÌZEPOCHr=rrrr!r/Úargvr'r'r'r(Úsp   u   hÿ