Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix calendar CLI when locale set via env var but not --locale
  • Loading branch information
hugovk committed Feb 28, 2025
commit 659597e42a3befc25b85c1a9d53ea584426d3b40
10 changes: 8 additions & 2 deletions Lib/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def formatmonthname(self, theyear, themonth, withyear=True):
return super().formatmonthname(theyear, themonth, withyear)


class _CLIDemoCalendar(LocaleTextCalendar):
class _CLIDemoCalendar(TextCalendar):
def __init__(self, highlight_day=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.highlight_day = highlight_day
Expand Down Expand Up @@ -752,6 +752,12 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
return ''.join(v)


class _CLIDemoLocaleCalendar(LocaleTextCalendar, _CLIDemoCalendar):
def __init__(self, highlight_day=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.highlight_day = highlight_day


# Support for old module level interface
c = TextCalendar()

Expand Down Expand Up @@ -893,7 +899,7 @@ def main(args=None):
write(cal.formatyearpage(options.year, **optdict))
else:
if options.locale:
cal = _CLIDemoCalendar(highlight_day=today, locale=locale)
cal = _CLIDemoLocaleCalendar(highlight_day=today, locale=locale)
else:
cal = _CLIDemoCalendar(highlight_day=today)
cal.setfirstweekday(options.first_weekday)
Expand Down