f`H ddlZddlZddlZddlmZgdZeZGddeZ GddeZ dZ d Z gd Z Gd d ZGd dZedZedZedZedZed\ZZZZZZZdZdZdZdZdZ dZ!dZ"Gdde#Z$Gdde$Z%Gdd e$Z&Gd!d"Z'd#Z(Gd$d%e%Z)Gd&d'e&Z*e%Z+e+j,Z-d(Z.e+j/Z0e+j1Z1e+j2Z3e+j4Z5e+j6Z6e+j7Z8e+j9Z:e+j;Ze=e>fd+Z?e=e>fd,Z@d-ZAejBeAddCZDd.ZEd/ZFeGd0kreFejHdSdS)1N)repeat)IllegalMonthErrorIllegalWeekdayErrorsetfirstweekday firstweekdayisleapleapdaysweekday monthrange monthcalendarprmonthmonthprcalcalendartimegm month_name month_abbrday_nameday_abbrCalendar TextCalendar HTMLCalendarLocaleTextCalendarLocaleHTMLCalendar weekheaderMONDAYTUESDAY WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYceZdZdZdZdS)rc||_dSNr)selfrs //opt/alt/python311/lib64/python3.11/calendar.py__init__zIllegalMonthError.__init__s  cd|jzS)Nz!bad month number %r; must be 1-12r&r's r(__str__zIllegalMonthError.__str__s2TZ??r*N__name__ __module__ __qualname__r)r-r*r(rrs7@@@@@r*rceZdZdZdZdS)rc||_dSr%r )r'r s r(r)zIllegalWeekdayError.__init__"s  r*cd|jzS)Nz7bad weekday number %r; must be 0 (Monday) to 6 (Sunday)r5r,s r(r-zIllegalWeekdayError.__str__$sH4<WWr*Nr.r2r*r(rr!s7XXXXXr*r) rr9r9r;r9r9r;r9r;r9cxeZdZdedDZedddZdZdZdS) _localized_monthcJg|] }tjd|dzdj!Sir7datetimedatestrftime.0is r( z_localized_month.6s-GGGx}T1Q3**3GGGr* rcdS)Nr2)xs r(z_localized_month.7sr*c||_dSr%formatr'rOs r(r)z_localized_month.__init__9  r*cj|}t|trfd|DS|jS)Nc0g|]}|jSr2rNrEfr's r(rGz0_localized_month.__getitem__..?#222qAAdkNN222r*)_months isinstanceslicerOr'rFfuncss` r( __getitem__z_localized_month.__getitem__<sL Q a   &2222E222 25%% %r*cdS)N r2r,s r(__len__z_localized_month.__len__Csrr*N) r/r0r1rangerWinsertr)r\r_r2r*r(r=r=4srGGUU2YYGGGG NN1ll###&&&r*r=cJeZdZdedDZdZdZdZdS)_localized_daycJg|] }tjdd|dzj!Sr?r@rDs r(rGz_localized_day.Js- D D DaX]4AaC ( ( 1 D D Dr*c||_dSr%rNrPs r(r)z_localized_day.__init__LrQr*cj|}t|trfd|DS|jS)Nc0g|]}|jSr2rNrTs r(rGz._localized_day.__getitem__..RrVr*)_daysrXrYrOrZs` r(r\z_localized_day.__getitem__OsL 1  a   &2222E222 25%% %r*cdSNrer2r,s r(r_z_localized_day.__len__Vsqr*N)r/r0r1r`rir)r\r_r2r*r(rcrcGs_ E D5588 D D DE&&&r*rcz%Az%az%Bz%brec: |dzdko|dzdkp|dzdkS)Nrdr2)years r(rrfs-? !8q= AdSjAo@qAr*c^ |dz}|dz}|dz|dzz |dz|dzz z |dz|dzz zS)Nr7rmrnror2)y1y2s r(r r ksO!GB!GB EBEMb#gC/ 0BGb#g4E FFr*c tj|cxkrtjks nd|dzz}tj|||S)Niro)rAMINYEARMAXYEARrBr )rprdays r(r r ssXL  t 7 7 7 7x'7 7 7 7 7dSj  =uc * * 2 2 4 44r*c d|cxkrdksnt|t||d}t||tkot |z}||fSNr7rH)rr mdaysFebruaryr)rprday1ndayss r(r r zsm         &&& 4 " "D %LEX->&,, ?E ;r*cRt||tkot|zSr%)rzr{rrprs r( _monthlenrs! <5H,= >>r*c*|dkr|dz dfS||dz fSryr2rs r( _prevmonthrs' zzAvrzU1W}r*c*|dkr|dzdfS||dzfS)NrHr7r2rs r( _nextmonthrs' {{AvqyU1W}r*ceZdZ ddZdZdZeeeZdZdZ dZ dZ d Z d Z d Zd Zd ZddZddZddZdS)rrc||_dSr%rr'rs r(r)zCalendar.__init__s(r*c|jdzSrk _firstweekdayr,s r(getfirstweekdayzCalendar.getfirstweekdays!A%%r*c||_dSr%rrs r(rzCalendar.setfirstweekdays)r*c#ZK t|j|jdzD] }|dzV dSrk)r`r)r'rFs r( iterweekdayszCalendar.iterweekdayssJ t($*;a*?@@  AA#IIII  r*c#vK |||D]\}}}tj|||VdSr%)itermonthdays3rArB)r'rprymds r(itermonthdateszCalendar.itermonthdatessY **477 ) )GAq!-1a(( ( ( ( ( ) )r*c#K t||\}}||jz dz}td|Ed{Vtd|dzEd{V|j|z |z dz}td|Ed{VdS)Nrerr7)r rrr`)r'rprr|r} days_before days_afters r( itermonthdayszCalendar.itermonthdayss !u-- ed//14 ![)))))))))EAI&&&&&&&&&'$.6!; !Z(((((((((((r*c#|K t||||jD]\}}||dzfVdSrk) enumeraterr)r'rprrFrs r(itermonthdays2zCalendar.itermonthdays2sZ d00u==t?PQQ  DAqQU(NNNN  r*c#K t||\}}||jz dz}|j|z |z dz}t||\}}t||dz} t | |z | D] } ||| fV t d|dzD] } ||| fV t ||\}}t d|dzD] } ||| fV dS)Nrer7)r rrrr`r) r'rprr|r}rrrrendrs r(rzCalendar.itermonthdays3s !u-- ed//14 '$.6!; $&&11oo!s;,,  AQ'MMMMq%!)$$ ! !Aq. $&&1q*q.))  AQ'MMMM  r*c#K t|||D]\}\}}}||||j|zdzfVdSrk)rrr)r'rprrFrrrs r(itermonthdays4zCalendar.itermonthdays4sm &d&9&9$&F&FGG 7 7LAy1aQD-1Q66 6 6 6 6 7 7r*c t|||fdtdtdDS)Nc*g|]}||dzSrer2)rErFdatess r(rGz/Calendar.monthdatescalendar..s%@@@!q1u@@@r*rre)listrr`len)r'rprrs @r(monthdatescalendarzCalendar.monthdatescalendarsS T((u5566@@@@uQE A'>'>@@@@r*c t|||fdtdtdDS)Nc*g|]}||dzSrr2rErFdayss r(rGz/Calendar.monthdays2calendar..%>>>a!e>>>r*rre)rrr`rr'rprrs @r(monthdays2calendarzCalendar.monthdays2calendarsS D''e4455>>>>eAs4yy!&<&<>>>>r*c t|||fdtdtdDS)Nc*g|]}||dzSrr2rs r(rGz.Calendar.monthdayscalendar..rr*rre)rrr`rrs @r(monthdayscalendarzCalendar.monthdayscalendarsS D&&tU3344>>>>eAs4yy!&<&<>>>>r*c fdtttdzDfdtdtDS)Nc<g|]}|Sr2)rrErFr'rps r(rGz.Calendar.yeardatescalendar..9     # #D! , ,   r*rHc*g|]}||zSr2r2rErFmonthswidths r(rGz.Calendar.yeardatescalendar.. &IIIaq5y!IIIr*rr`Januaryrr'rprrs```@r(yeardatescalendarzCalendar.yeardatescalendarx      7GBJ//   JIIII5CKK+G+GIIIIr*c fdtttdzDfdtdtDS)Nc<g|]}|Sr2)rrs r(rGz.Calendar.yeardays2calendar..rr*rHc*g|]}||zSr2r2rs r(rGz.Calendar.yeardays2calendar..rr*rrrs```@r(yeardays2calendarzCalendar.yeardays2calendar rr*c fdtttdzDfdtdtDS)Nc<g|]}|Sr2)rrs r(rGz-Calendar.yeardayscalendar.. s9     " "4 + +   r*rHc*g|]}||zSr2r2rs r(rGz-Calendar.yeardayscalendar..$rr*rrrs```@r(yeardayscalendarzCalendar.yeardayscalendarsx      7GBJ//   JIIII5CKK+G+GIIIIr*N)rr)r/r0r1r)rrpropertyrrrrrrrrrrrrrr2r*r(rrs2 ))))&&&***8O_==L))) ) ) )$777AAA?????? J J J J J J J J J J J J J Jr*rcVeZdZ dZdZdZdZdZddZdd Z dd Z ddZ ddZ dS)rcR t|||ddSNrJ)r)print formatweekr'theweekrs r(prweekzTextCalendar.prweek-s0  doogu--2666666r*cJ |dkrd}nd|z}||S)NrrJz%2icenter)r'rwr rss r( formatdayzTextCalendar.formatday3s2  !88AA Axxr*cL dfd|DS)N c3LK|]\}}||VdSr%r)rErwdr'rs r( z*TextCalendar.formatweek..As7LL!Rq"e44LLLLLLr*joinrs` `r(rzTextCalendar.formatweek=s5 xxLLLLLGLLLLLLr*ct |dkrt}nt}||d||S)N )rrr)r'rwrnamess r( formatweekdayzTextCalendar.formatweekdayCs?  A::EEESz&5&!((///r*cp dfdDS)Nrc3DK|]}|VdSr%r)rErFr'rs r(rz0TextCalendar.formatweekheader..Qs3RR**1e44RRRRRRr*rr)r'rs``r(formatweekheaderzTextCalendar.formatweekheaderMsA xxRRRRRd>O>O>Q>QRRRRRRr*TcZ t|}|r|d|}||S)Nr)rr)r'theyearthemonthrwithyearrs r(formatmonthnamezTextCalendar.formatmonthnameSs;  x   '11gg&Axxr*rcV t|||||ddSr)r formatmonth)r'rrwls r(r zTextCalendar.prmonth\s6  dw!Q77R@@@@@@r*c td|}td|}|||d|dzzdz }|}|d|zz }|||z }|d|zz }|||D]5}||||z }|d|zz }6|S)Nr8r7re )maxrrstriprrr)r'rrrrrweeks r(rzTextCalendar.formatmonthbs  1II 1II  (AQK!O D D HHJJ TAX  T " "1 % % , , . .. TAX ++GX>>  D q))0022 2A MAAr*r8r7rc  td|}td|}td|}|dzdzdz g}|j}|t|z||dz zz|d|z|t |D]\}} t||zdzt||dzzdzd} |d|zfd| D} |t| ||d|zfd| D} |t| ||d|ztd| D} t| D]}g}| D]Z}|t|kr|d +| |||[|t|||d|zd |S) Nr8r7rerr^c3HK|]}|dVdS)FN)r)rEkcolwidthr'rs r(rz*TextCalendar.formatyear..sK&&))'1hFF&&&&&&r*c3K|]}VdSr%r2)rErheaders r(rz*TextCalendar.formatyear..s#..!v......r*c34K|]}t|VdSr%)r)rEcals r(rz*TextCalendar.formatyear..s(11cS111111r*rJ)rappendreprrrrrrr`min formatstringrrr)r'rrrcrvarFrowrrheadersheightjweeksrrrs`` @@r( formatyearzTextCalendar.formatyearrs  1II 1II 1IIEQ;?  H $w--  xz!QqS'1 2 2 9 9 ; ;<<< $q& &&q))!$"8"8!"D"DEE  HQ1Q3q5#a1gai"4"455F Ad1fIII&&&&&&$&&&E Al5(A..5577 8 8 8 Ad1fIII....v...G Al7Ha007799 : : : Ad1fIII11S11111F6]]  AACCHH}} R(((( T__SVQ%?%?@@@@,uh2299;;<<<$(  wwqzzr*c X t||||||ddSr)rr )r'rrrrrs r(pryearzTextCalendar.pryears2& doogq!Q22;;;;;;r*NT)rr)r8r7rr)rrrr) r/r0r1rrrrrrr rr rr2r*r(rr's 777 MMM 000SSS AAAA  ####J<<<<< z%d)cssclass_noday cssclasses)r'rwr s r(rzHTMLCalendar.formatdays7  !88/$2EE E+tw/G.MM Mr*cR dfd|D}d|zS)NrJc3JK|]\}}||VdSr%r)rErrr's r(rz*HTMLCalendar.formatweek..s5AAgq"DNN1b))AAAAAAr* %sr)r'rrs` r(rzHTMLCalendar.formatweeks;  GGAAAAAAA A Aq  r*c@d|j|dt|dS)Nz z)cssclasses_weekday_headr)r'rws r(rzHTMLCalendar.formatweekdays.   ( - - -x}}}> >r*cv dfdD}d|zS)NrJc3BK|]}|VdSr%r)rErFr's r(rz0HTMLCalendar.formatweekheader..s1GGaD&&q))GGGGGGr*rr)r'rs` r(rzHTMLCalendar.formatweekheadersG  GGGGGG43D3D3F3FGGG G Gq  r*Tcj |rt|d|}ndt|z}d|jd|dS)Nrz%szrrrJ)rcssclass_monthrrrrr)r'rrrrrrs r(rzHTMLCalendar.formatmonths   H  I   ! " " " $ $  w8  D DEEE $ $   ! !""" $++GX>>  D Adood## $ $ $ AdGGGG *  $wwqzzr*rc  g}|j}t|d}|d|jz|d|d||j|fzt t t dz|D]u}t |t ||zd}|d|D]9}|d||||d |d :|d v|d d|S)Nr7r'rz,%srHr^zzFr(zzr)rJ) rr cssclass_yearcssclass_year_headr`rrrr)r'rrrrrFrrs r(r zHTMLCalendar.formatyearsA   HE1   I       $  8 4*G<5 5 6 6 6w E22  A1c!E'2..//F AfIII  & $""7A">>???' AgJJJJ * wwqzzr* calendar.cssNc |tj}g}|j}|d|z|d|d|d|d|z||d|z|d|z|d|d |||||d |d d ||d S)Nz$ zn z z zC z4 zCalendar for %d z z z z rJxmlcharrefreplace)sysgetdefaultencodingrr rencode)r'rrcssencodingrrs r(formatyearpagezHTMLCalendar.formatyearpage s%   -//H  H  1H <===  {||| *  *   PS[ [\\\ ? AEK L L L  ,w 6777 + *  $//'5 ) )*** + +wwqzz  +>???r*rr)rr.N)r/r0r1rr!rr%r*r-r,rrrrrrr r6r2r*r(rrs CBBJ)N"N MNNN!!!>>>!!! ) ) ) )(0@@@@@@r*rc eZdZdZdZdZdS)different_localec"||_d|_dSr%)locale oldlocale)r'r:s r(r)zdifferent_locale.__init__%s r*ctjtjd|_tjtj|jdSr%)_locale setlocaleLC_TIMEr;r:r,s r( __enter__zdifferent_locale.__enter__)s5 *7?DAA'/4;77777r*c`|jdStjtj|jdSr%)r;r=r>r?)r'argss r(__exit__zdifferent_locale.__exit__-s, > ! F'/4>:::::r*N)r/r0r1r)r@rCr2r*r(r8r8$sA888;;;;;r*r8ctjtjd}|dkrFtd5tjtjd}dddn #1swxYwY|S)NCrJ)r=r>r?r8r:s r(_get_default_localerG3s  w 5 5F }} b ! ! > >&w==F > > > > > > > > > > > > > > > Ms A!!A%(A%c4eZdZ ddZfdZdfd ZxZS) rrNcjt|||t}||_dSr%)rr)rGr:r'rr:s r(r)zLocaleTextCalendar.__init__C3dL111 >(**F r*ct|j5t||cdddS#1swxYwYdSr%r8r:superr)r'rwr __class__s r(rz LocaleTextCalendar.formatweekdayIs dk * * 5 577((e44 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s"AA  A Tct|j5t||||cdddS#1swxYwYdSr%r8r:rNr)r'rrrrrOs r(rz"LocaleTextCalendar.formatmonthnameMs dk * * O O77**7HeXNN O O O O O O O O O O O O O O O O O Os$AA A rNrr/r0r1r)rr __classcell__rOs@r(rr=sy  55555OOOOOOOOOOr*rc4eZdZ ddZfdZdfd ZxZS) rrNcjt|||t}||_dSr%)rr)rGr:rJs r(r)zLocaleHTMLCalendar.__init__WrKr*ct|j5t|cdddS#1swxYwYdSr%rM)r'rwrOs r(rz LocaleHTMLCalendar.formatweekday]s dk * * . .77((-- . . . . . . . . . . . . . . . . . .s!AA ATct|j5t|||cdddS#1swxYwYdSr%rQ)r'rrrrOs r(rz"LocaleHTMLCalendar.formatmonthnameas dk * * H H77**7HhGG H H H H H H H H H H H H H H H H H Hs#AA  A rRrrSrUs@r(rrRsy .....HHHHHHHHHHr*rcnt|cxkr tksnt||t_dSr%)rr"rrrrs r(rrjs: \ + + + +V + + + +!,///!ANNNr*rcD tt|||dSr%)rrcolsrspacings r(rOrO~s%; ,tXw / /00000r*cR |dz}|fd|DS)Nrc3BK|]}|VdSr%r)rErrs r(rzformatstring..s/99q**999999r*rr]s ` r(rrs6O sNG <<9999D999 9 99r*ic |dd\}}}}}}tj||dtz |zdz }|dz|z}|dz|z} | dz|z} | S)Nrr7<)rArB toordinal _EPOCH_ORD) tuplerprrwhourminutesecondrhoursminutessecondss r(rrs{L-22A2Y*D%dFF =ua ( ( 2 2 4 4z AC G! KD GdNEBhGbj6!G Nr*cddl}|}|d}|d}|ddtdd|d d td d |d dtdd|ddtdd|dddd|dddd|dddd|d d!d"d#d$%|d&d'td()|d*d'td+)||d d}|jr0|js)|d,tj d |j|jf}|j d-kr|jrt|.}nt}|j}|tj}t||j/} tjjj} |j:| |jt,jjfi| dS|j| |j|jfi| dS|d0tj d dS|jrt5|.}nt7}t|j|j1} |j|j| d2<|j| d3<|j0|j t,jjfi| } n4|j|j |jfi| } n|j!|j|jfi| } tjj} |jr0| "|j} tjjj} | | dS)4Nrztext only argumentszhtml only argumentsz-wz--widthr8z width of date column (default 2))typedefaulthelpz-lz--linesr7z)number of lines for each week (default 1)z-sz --spacingrz"spacing between months (default 6)z-mz--monthsrzmonths per row (default 3)z-cz--cssr.zCSS to use for page)rprqz-Lz--localez)locale to use for month and weekday namesz-ez --encodingzencoding to use for outputz-tz--typetext)rrhtmlzoutput type (text or html))rpchoicesrqrp?z year number)nargsrorqrzmonth number (1-12, text only)z/if --locale is specified --encoding is requiredrsrF)r5r4zincorrect number of arguments)rrrr)#argparseArgumentParseradd_argument_group add_argumentint parse_argsr:r5errorr1exitrorrr2dictr4stdoutbufferwriterpr6rArBtodayrrrrlinesr_rr rr3) rBrwparser textgroup htmlgroupoptionsr:rr5optdictrresults r(mainrswOOO  $ $ & &F))*?@@I))*?@@I  i ! /  i ! 8  k ! 1  j ! )  g "   j 8   l )   h )       - QRR))G~g. FGGG  ^W- -F|v > !$F333CC..C#  -//Hgk::: !' <  E$#$X]%8%8%:%:%?KK7KK L L L L L ] " E$#$W\==W== > > > > > LL8 9 9 9 HQKKKKK > !$F333CC..C'-888 = "?GCL">GCL < #S^HM$7$7$9$9$>JJ'JJFF ] "#S^GL<rsJ7  ! ! ! @@@@@ @@@XXXXX*XXX   <;;&( >$   >$   d # #  d # # DI588@)XvxBBB GGG555???NJNJNJNJNJvNJNJNJbr<r<r<r<r<8r<r<r