MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __init__

Method __init__

tools/python-3.11.9-amd64/Lib/_strptime.py:173–217  ·  view source on GitHub ↗

Create keys/values. Order of execution is important for dependency reasons.

(self, locale_time=None)

Source from the content-addressed store, hash-verified

171 """Handle conversion from format directives to regexes."""
172
173 def __init__(self, locale_time=None):
174 """Create keys/values.
175
176 Order of execution is important for dependency reasons.
177
178 """
179 if locale_time:
180 self.locale_time = locale_time
181 else:
182 self.locale_time = LocaleTime()
183 base = super()
184 base.__init__({
185 # The " [1-9]" part of the regex is to make %c from ANSI C work
186 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",
187 'f': r"(?P<f>[0-9]{1,6})",
188 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)",
189 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])",
190 'G': r"(?P<G>\d\d\d\d)",
191 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])",
192 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])",
193 'M': r"(?P<M>[0-5]\d|\d)",
194 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)",
195 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)",
196 'w': r"(?P<w>[0-6])",
197 'u': r"(?P<u>[1-7])",
198 'V': r"(?P<V>5[0-3]|0[1-9]|[1-4]\d|\d)",
199 # W is set below by using 'U'
200 'y': r"(?P<y>\d\d)",
201 #XXX: Does 'Y' need to worry about having less or more than
202 # 4 digits?
203 'Y': r"(?P<Y>\d\d\d\d)",
204 'z': r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d(\.\d{1,6})?)?|(?-i:Z))",
205 'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),
206 'a': self.__seqToRE(self.locale_time.a_weekday, 'a'),
207 'B': self.__seqToRE(self.locale_time.f_month[1:], 'B'),
208 'b': self.__seqToRE(self.locale_time.a_month[1:], 'b'),
209 'p': self.__seqToRE(self.locale_time.am_pm, 'p'),
210 'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone
211 for tz in tz_names),
212 'Z'),
213 '%': '%'})
214 base.__setitem__('W', base.__getitem__('U').replace('U', 'W'))
215 base.__setitem__('c', self.pattern(self.locale_time.LC_date_time))
216 base.__setitem__('x', self.pattern(self.locale_time.LC_date))
217 base.__setitem__('X', self.pattern(self.locale_time.LC_time))
218
219 def __seqToRE(self, to_convert, directive):
220 """Convert a list to a regex string for matching a directive.

Callers

nothing calls this directly

Calls 6

__seqToREMethod · 0.95
patternMethod · 0.95
LocaleTimeClass · 0.85
__setitem__Method · 0.45
replaceMethod · 0.45
__getitem__Method · 0.45

Tested by

no test coverage detected