Set all attributes. Order of methods called matters for dependency reasons. The locale language is set at the offset and then checked again before exiting. This is to make sure that the attributes were not set with a mix of information from more than one locale. T
(self)
| 85 | """ |
| 86 | |
| 87 | def __init__(self): |
| 88 | """Set all attributes. |
| 89 | |
| 90 | Order of methods called matters for dependency reasons. |
| 91 | |
| 92 | The locale language is set at the offset and then checked again before |
| 93 | exiting. This is to make sure that the attributes were not set with a |
| 94 | mix of information from more than one locale. This would most likely |
| 95 | happen when using threads where one thread calls a locale-dependent |
| 96 | function while another thread changes the locale while the function in |
| 97 | the other thread is still running. Proper coding would call for |
| 98 | locks to prevent changing the locale while locale-dependent code is |
| 99 | running. The check here is done in case someone does not think about |
| 100 | doing this. |
| 101 | |
| 102 | Only other possible issue is if someone changed the timezone and did |
| 103 | not call tz.tzset . That is an issue for the programmer, though, |
| 104 | since changing the timezone is worthless without that call. |
| 105 | |
| 106 | """ |
| 107 | self.lang = _getlang() |
| 108 | self.__calc_weekday() |
| 109 | self.__calc_month() |
| 110 | self.__calc_am_pm() |
| 111 | self.__calc_alt_digits() |
| 112 | self.__calc_timezone() |
| 113 | self.__calc_date_time() |
| 114 | if _getlang() != self.lang: |
| 115 | raise ValueError("locale changed during initialization") |
| 116 | if time.tzname != self.tzname or time.daylight != self.daylight: |
| 117 | raise ValueError("timezone changed during initialization") |
| 118 | |
| 119 | def __calc_weekday(self): |
| 120 | # Set self.a_weekday and self.f_weekday using the calendar |
nothing calls this directly
no test coverage detected