diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Recognizer.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Recognizer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c557256a0c9674364d8815f2d04d2d25fd81e05a Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Recognizer.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Token.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Token.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..41a8dd850bf8dcc68fb0b20d4ae4cc78a16ae845 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/__pycache__/Token.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/atn/__pycache__/ATNDeserializer.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/atn/__pycache__/ATNDeserializer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5e7ba41f3256b62350c256c67aa0e8f7bcff14e3 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/atn/__pycache__/ATNDeserializer.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/Errors.py b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/Errors.py new file mode 100644 index 0000000000000000000000000000000000000000..e78ac05911d3c9569441fe376ff7d6c686c05c95 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/Errors.py @@ -0,0 +1,172 @@ +# Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. +# Use of this file is governed by the BSD 3-clause license that +# can be found in the LICENSE.txt file in the project root. +# + +# need forward declaration +Token = None +Lexer = None +Parser = None +TokenStream = None +ATNConfigSet = None +ParserRulecontext = None +PredicateTransition = None +BufferedTokenStream = None + +class UnsupportedOperationException(Exception): + + def __init__(self, msg:str): + super().__init__(msg) + +class IllegalStateException(Exception): + + def __init__(self, msg:str): + super().__init__(msg) + +class CancellationException(IllegalStateException): + + def __init__(self, msg:str): + super().__init__(msg) + +# The root of the ANTLR exception hierarchy. In general, ANTLR tracks just +# 3 kinds of errors: prediction errors, failed predicate errors, and +# mismatched input errors. In each case, the parser knows where it is +# in the input, where it is in the ATN, the rule invocation stack, +# and what kind of problem occurred. + +from antlr4.InputStream import InputStream +from antlr4.ParserRuleContext import ParserRuleContext +from antlr4.Recognizer import Recognizer + +class RecognitionException(Exception): + + + def __init__(self, message:str=None, recognizer:Recognizer=None, input:InputStream=None, ctx:ParserRulecontext=None): + super().__init__(message) + self.message = message + self.recognizer = recognizer + self.input = input + self.ctx = ctx + # The current {@link Token} when an error occurred. Since not all streams + # support accessing symbols by index, we have to track the {@link Token} + # instance itself. + self.offendingToken = None + # Get the ATN state number the parser was in at the time the error + # occurred. For {@link NoViableAltException} and + # {@link LexerNoViableAltException} exceptions, this is the + # {@link DecisionState} number. For others, it is the state whose outgoing + # edge we couldn't match. + self.offendingState = -1 + if recognizer is not None: + self.offendingState = recognizer.state + + #

If the state number is not known, this method returns -1.

+ + # + # Gets the set of input symbols which could potentially follow the + # previously matched symbol at the time this exception was thrown. + # + #

If the set of expected tokens is not known and could not be computed, + # this method returns {@code null}.

+ # + # @return The set of token types that could potentially follow the current + # state in the ATN, or {@code null} if the information is not available. + #/ + def getExpectedTokens(self): + if self.recognizer is not None: + return self.recognizer.atn.getExpectedTokens(self.offendingState, self.ctx) + else: + return None + + +class LexerNoViableAltException(RecognitionException): + + def __init__(self, lexer:Lexer, input:InputStream, startIndex:int, deadEndConfigs:ATNConfigSet): + super().__init__(message=None, recognizer=lexer, input=input, ctx=None) + self.startIndex = startIndex + self.deadEndConfigs = deadEndConfigs + + def __str__(self): + symbol = "" + if self.startIndex >= 0 and self.startIndex < self.input.size: + symbol = self.input.getText(self.startIndex, self.startIndex) + # TODO symbol = Utils.escapeWhitespace(symbol, false); + return "LexerNoViableAltException('" + symbol + "')" + +# Indicates that the parser could not decide which of two or more paths +# to take based upon the remaining input. It tracks the starting token +# of the offending input and also knows where the parser was +# in the various paths when the error. Reported by reportNoViableAlternative() +# +class NoViableAltException(RecognitionException): + + def __init__(self, recognizer:Parser, input:TokenStream=None, startToken:Token=None, + offendingToken:Token=None, deadEndConfigs:ATNConfigSet=None, ctx:ParserRuleContext=None): + if ctx is None: + ctx = recognizer._ctx + if offendingToken is None: + offendingToken = recognizer.getCurrentToken() + if startToken is None: + startToken = recognizer.getCurrentToken() + if input is None: + input = recognizer.getInputStream() + super().__init__(recognizer=recognizer, input=input, ctx=ctx) + # Which configurations did we try at input.index() that couldn't match input.LT(1)?# + self.deadEndConfigs = deadEndConfigs + # The token object at the start index; the input stream might + # not be buffering tokens so get a reference to it. (At the + # time the error occurred, of course the stream needs to keep a + # buffer all of the tokens but later we might not have access to those.) + self.startToken = startToken + self.offendingToken = offendingToken + +# This signifies any kind of mismatched input exceptions such as +# when the current input does not match the expected token. +# +class InputMismatchException(RecognitionException): + + def __init__(self, recognizer:Parser): + super().__init__(recognizer=recognizer, input=recognizer.getInputStream(), ctx=recognizer._ctx) + self.offendingToken = recognizer.getCurrentToken() + + +# A semantic predicate failed during validation. Validation of predicates +# occurs when normally parsing the alternative just like matching a token. +# Disambiguating predicate evaluation occurs when we test a predicate during +# prediction. + +class FailedPredicateException(RecognitionException): + + def __init__(self, recognizer:Parser, predicate:str=None, message:str=None): + super().__init__(message=self.formatMessage(predicate,message), recognizer=recognizer, + input=recognizer.getInputStream(), ctx=recognizer._ctx) + s = recognizer._interp.atn.states[recognizer.state] + trans = s.transitions[0] + from antlr4.atn.Transition import PredicateTransition + if isinstance(trans, PredicateTransition): + self.ruleIndex = trans.ruleIndex + self.predicateIndex = trans.predIndex + else: + self.ruleIndex = 0 + self.predicateIndex = 0 + self.predicate = predicate + self.offendingToken = recognizer.getCurrentToken() + + def formatMessage(self, predicate:str, message:str): + if message is not None: + return message + else: + return "failed predicate: {" + predicate + "}?" + +class ParseCancellationException(CancellationException): + + pass + +del Token +del Lexer +del Parser +del TokenStream +del ATNConfigSet +del ParserRulecontext +del PredicateTransition +del BufferedTokenStream diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/ErrorStrategy.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/ErrorStrategy.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c5488184f1de46016024d01bb9f0b607be9dcbea Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/ErrorStrategy.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/Errors.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/Errors.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9a43b2d92f7ce836e54819333827500ae343a832 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/error/__pycache__/Errors.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/Chunk.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/Chunk.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8f9807899b669c2af794cec4592a308f6f287828 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/Chunk.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePattern.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePattern.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e148099fc4775e23310ffb3c0d790ccd22e54dc Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePattern.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePatternMatcher.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePatternMatcher.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db5ac55b1a26050031d5aed5b287d8e487a5e3d8 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/ParseTreePatternMatcher.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/__init__.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0726ef7c77a8ecc3500bd7b4242d5e0131bda502 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/antlr4/tree/__pycache__/__init__.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/INSTALLER b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/INSTALLER new file mode 100644 index 0000000000000000000000000000000000000000..a1b589e38a32041e49332e5e81c2d363dc418d68 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/LICENSE b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..033c86b7a40a331f281bd406e991ef1db597c208 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/LICENSE @@ -0,0 +1,13 @@ +Copyright 2016-2020 aio-libs collaboration. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/RECORD b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/RECORD new file mode 100644 index 0000000000000000000000000000000000000000..4cc3d6469171169dbeb253ebf6593dbb43b27dbf --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/RECORD @@ -0,0 +1,11 @@ +async_timeout-4.0.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +async_timeout-4.0.3.dist-info/LICENSE,sha256=4Y17uPUT4sRrtYXJS1hb0wcg3TzLId2weG9y0WZY-Sw,568 +async_timeout-4.0.3.dist-info/METADATA,sha256=WQVcnDIXQ2ntebcm-vYjhNLg_VMeTWw13_ReT-U36J4,4209 +async_timeout-4.0.3.dist-info/RECORD,, +async_timeout-4.0.3.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +async_timeout-4.0.3.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92 +async_timeout-4.0.3.dist-info/top_level.txt,sha256=9oM4e7Twq8iD_7_Q3Mz0E6GPIB6vJvRFo-UBwUQtBDU,14 +async_timeout-4.0.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1 +async_timeout/__init__.py,sha256=A0VOqDGQ3cCPFp0NZJKIbx_VRP1Y2xPtQOZebVIUB88,7242 +async_timeout/__pycache__/__init__.cpython-310.pyc,, +async_timeout/py.typed,sha256=tyozzRT1fziXETDxokmuyt6jhOmtjUbnVNJdZcG7ik0,12 diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/REQUESTED b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/REQUESTED new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/WHEEL b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/WHEEL new file mode 100644 index 0000000000000000000000000000000000000000..2c08da084599354e5b2dbccb3ab716165e63d1a0 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/WHEEL @@ -0,0 +1,5 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.41.1) +Root-Is-Purelib: true +Tag: py3-none-any + diff --git a/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/zip-safe b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/zip-safe new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/async_timeout-4.0.3.dist-info/zip-safe @@ -0,0 +1 @@ + diff --git a/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/INSTALLER b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/INSTALLER new file mode 100644 index 0000000000000000000000000000000000000000..a1b589e38a32041e49332e5e81c2d363dc418d68 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/LICENCE.rst b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/LICENCE.rst new file mode 100644 index 0000000000000000000000000000000000000000..82213c597d9f13e1ff95a500b6f9061cee200ca7 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/LICENCE.rst @@ -0,0 +1,23 @@ +This software is under the MIT Licence +====================================== + +Copyright (c) 2010 openpyxl + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/WHEEL b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/WHEEL new file mode 100644 index 0000000000000000000000000000000000000000..832be111324a83de65a3a27be4dcbdee7f5a6692 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/WHEEL @@ -0,0 +1,6 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.43.0) +Root-Is-Purelib: true +Tag: py2-none-any +Tag: py3-none-any + diff --git a/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/top_level.txt b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/top_level.txt new file mode 100644 index 0000000000000000000000000000000000000000..794cc3d380819835a6368b79423b997177aae40b --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/openpyxl-3.1.5.dist-info/top_level.txt @@ -0,0 +1 @@ +openpyxl diff --git a/evalkit_tf437/lib/python3.10/site-packages/pip-25.0.1.dist-info/top_level.txt b/evalkit_tf437/lib/python3.10/site-packages/pip-25.0.1.dist-info/top_level.txt new file mode 100644 index 0000000000000000000000000000000000000000..a1b589e38a32041e49332e5e81c2d363dc418d68 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/pip-25.0.1.dist-info/top_level.txt @@ -0,0 +1 @@ +pip diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/__init__.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a48f21878a2e190700bcce9693e0757f45249e8f Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/__init__.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/_file_info.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/_file_info.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f737fc611b5c198f8c3e3e3dada9a08621db0519 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/_file_info.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/datetime_helpers.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/datetime_helpers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3f5dca14f17ccfe8f38f27a7c8191f4981e8368 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/datetime_helpers.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/enums.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/enums.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4aa537260b518de37973a2c02f4f1255b52e16ef Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/enums.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/fields.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/fields.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c55c5a350d852fabb8ba746d3365adf52ca7b240 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/fields.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/message.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/message.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3136f9ce8f0912a5a8b4ee16aea5341c6ac856d2 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/message.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/modules.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/modules.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a0d342d9b17b0519862032b007f2aedaef955af5 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/modules.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/primitives.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/primitives.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..18f3a850d4175e0287c6efd23d2b786fc84e9083 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/primitives.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/utils.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85b02200ef07c3b078f5d31964eda3c4369b4ead Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/utils.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/version.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/version.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d5f26adff7f509c006729731542a80e1d859d4da Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/__pycache__/version.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/enums.py b/evalkit_tf437/lib/python3.10/site-packages/proto/enums.py new file mode 100644 index 0000000000000000000000000000000000000000..4073c2a3c677dfa67d76462df1b5e8eea59c751f --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/enums.py @@ -0,0 +1,163 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import enum + +from google.protobuf import descriptor_pb2 + +from proto import _file_info +from proto import _package_info +from proto.marshal.rules.enums import EnumRule + + +class ProtoEnumMeta(enum.EnumMeta): + """A metaclass for building and registering protobuf enums.""" + + def __new__(mcls, name, bases, attrs): + # Do not do any special behavior for `proto.Enum` itself. + if bases[0] == enum.IntEnum: + return super().__new__(mcls, name, bases, attrs) + + # Get the essential information about the proto package, and where + # this component belongs within the file. + package, marshal = _package_info.compile(name, attrs) + + # Determine the local path of this proto component within the file. + local_path = tuple(attrs.get("__qualname__", name).split(".")) + + # Sanity check: We get the wrong full name if a class is declared + # inside a function local scope; correct this. + if "" in local_path: + ix = local_path.index("") + local_path = local_path[: ix - 1] + local_path[ix + 1 :] + + # Determine the full name in protocol buffers. + full_name = ".".join((package,) + local_path).lstrip(".") + filename = _file_info._FileInfo.proto_file_name( + attrs.get("__module__", name.lower()) + ) + + # Retrieve any enum options. + # We expect something that looks like an EnumOptions message, + # either an actual instance or a dict-like representation. + pb_options = "_pb_options" + opts = attrs.pop(pb_options, {}) + # This is the only portable way to remove the _pb_options name + # from the enum attrs. + # In 3.7 onwards, we can define an _ignore_ attribute and do some + # mucking around with that. + if pb_options in attrs._member_names: + if isinstance(attrs._member_names, list): + idx = attrs._member_names.index(pb_options) + attrs._member_names.pop(idx) + else: # Python 3.11.0b3 + del attrs._member_names[pb_options] + + # Make the descriptor. + enum_desc = descriptor_pb2.EnumDescriptorProto( + name=name, + # Note: the superclass ctor removes the variants, so get them now. + # Note: proto3 requires that the first variant value be zero. + value=sorted( + ( + descriptor_pb2.EnumValueDescriptorProto(name=name, number=number) + # Minor hack to get all the enum variants out. + # Use the `_member_names` property to get only the enum members + # See https://github.com/googleapis/proto-plus-python/issues/490 + for name, number in attrs.items() + if name in attrs._member_names and isinstance(number, int) + ), + key=lambda v: v.number, + ), + options=opts, + ) + + file_info = _file_info._FileInfo.maybe_add_descriptor(filename, package) + if len(local_path) == 1: + file_info.descriptor.enum_type.add().MergeFrom(enum_desc) + else: + file_info.nested_enum[local_path] = enum_desc + + # Run the superclass constructor. + cls = super().__new__(mcls, name, bases, attrs) + + # We can't just add a "_meta" element to attrs because the Enum + # machinery doesn't know what to do with a non-int value. + # The pb is set later, in generate_file_pb + cls._meta = _EnumInfo(full_name=full_name, pb=None) + + file_info.enums[full_name] = cls + + # Register the enum with the marshal. + marshal.register(cls, EnumRule(cls)) + + # Generate the descriptor for the file if it is ready. + if file_info.ready(new_class=cls): + file_info.generate_file_pb(new_class=cls, fallback_salt=full_name) + + # Done; return the class. + return cls + + +class Enum(enum.IntEnum, metaclass=ProtoEnumMeta): + """A enum object that also builds a protobuf enum descriptor.""" + + def _comparable(self, other): + # Avoid 'isinstance' to prevent other IntEnums from matching + return type(other) in (type(self), int) + + def __hash__(self): + return hash(self.value) + + def __eq__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value == int(other) + + def __ne__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value != int(other) + + def __lt__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value < int(other) + + def __le__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value <= int(other) + + def __ge__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value >= int(other) + + def __gt__(self, other): + if not self._comparable(other): + return NotImplemented + + return self.value > int(other) + + +class _EnumInfo: + def __init__(self, *, full_name: str, pb): + self.full_name = full_name + self.pb = pb diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/fields.py b/evalkit_tf437/lib/python3.10/site-packages/proto/fields.py new file mode 100644 index 0000000000000000000000000000000000000000..6f5b6452161935c20f3cc8ef2f0e1aa121c51263 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/fields.py @@ -0,0 +1,165 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from enum import EnumMeta + +from google.protobuf import descriptor_pb2 +from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper + +from proto.primitives import ProtoType + + +class Field: + """A representation of a type of field in protocol buffers.""" + + # Fields are NOT repeated nor maps. + # The RepeatedField overrides this values. + repeated = False + + def __init__( + self, + proto_type, + *, + number: int, + message=None, + enum=None, + oneof: str = None, + json_name: str = None, + optional: bool = False + ): + # This class is not intended to stand entirely alone; + # data is augmented by the metaclass for Message. + self.mcls_data = None + self.parent = None + + # If the proto type sent is an object or a string, it is really + # a message or enum. + if not isinstance(proto_type, int): + # Note: We only support the "shortcut syntax" for enums + # when receiving the actual class. + if isinstance(proto_type, (EnumMeta, EnumTypeWrapper)): + enum = proto_type + proto_type = ProtoType.ENUM + else: + message = proto_type + proto_type = ProtoType.MESSAGE + + # Save the direct arguments. + self.number = number + self.proto_type = proto_type + self.message = message + self.enum = enum + self.json_name = json_name + self.optional = optional + self.oneof = oneof + + # Once the descriptor is accessed the first time, cache it. + # This is important because in rare cases the message or enum + # types are written later. + self._descriptor = None + + @property + def descriptor(self): + """Return the descriptor for the field.""" + if not self._descriptor: + # Resolve the message type, if any, to a string. + type_name = None + if isinstance(self.message, str): + if not self.message.startswith(self.package): + self.message = "{package}.{name}".format( + package=self.package, + name=self.message, + ) + type_name = self.message + elif self.message: + type_name = ( + self.message.DESCRIPTOR.full_name + if hasattr(self.message, "DESCRIPTOR") + else self.message._meta.full_name + ) + elif isinstance(self.enum, str): + if not self.enum.startswith(self.package): + self.enum = "{package}.{name}".format( + package=self.package, + name=self.enum, + ) + type_name = self.enum + elif self.enum: + type_name = ( + self.enum.DESCRIPTOR.full_name + if hasattr(self.enum, "DESCRIPTOR") + else self.enum._meta.full_name + ) + + # Set the descriptor. + self._descriptor = descriptor_pb2.FieldDescriptorProto( + name=self.name, + number=self.number, + label=3 if self.repeated else 1, + type=self.proto_type, + type_name=type_name, + json_name=self.json_name, + proto3_optional=self.optional, + ) + + # Return the descriptor. + return self._descriptor + + @property + def name(self) -> str: + """Return the name of the field.""" + return self.mcls_data["name"] + + @property + def package(self) -> str: + """Return the package of the field.""" + return self.mcls_data["package"] + + @property + def pb_type(self): + """Return the composite type of the field, or the primitive type if a primitive.""" + # For enums, return the Python enum. + if self.enum: + return self.enum + + # For primitive fields, we still want to know + # what the type is. + if not self.message: + return self.proto_type + + # Return the internal protobuf message. + if hasattr(self.message, "_meta"): + return self.message.pb() + return self.message + + +class RepeatedField(Field): + """A representation of a repeated field in protocol buffers.""" + + repeated = True + + +class MapField(Field): + """A representation of a map field in protocol buffers.""" + + def __init__(self, key_type, value_type, *, number: int, message=None, enum=None): + super().__init__(value_type, number=number, message=message, enum=enum) + self.map_key_type = key_type + + +__all__ = ( + "Field", + "MapField", + "RepeatedField", +) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__init__.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..621ea3695f931708b24e8d9dad4c6907d8947b15 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .marshal import Marshal + + +__all__ = ("Marshal",) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/__init__.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a8749ea60c36339fc52a876e890fcc6c367a4079 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/__init__.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/compat.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/compat.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f935f2026e0fe270c37e2a151fcd11a4e92f8bd4 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/__pycache__/compat.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__init__.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4b80a546c26a5cab35ea7eb02a781f3fd70f6d31 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__init__.py @@ -0,0 +1,24 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .maps import MapComposite +from .repeated import Repeated +from .repeated import RepeatedComposite + + +__all__ = ( + "MapComposite", + "Repeated", + "RepeatedComposite", +) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/__init__.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1ac289ea4ba8202c6e1a03854be3da28f68fc19d Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/__init__.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/maps.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/maps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f3b6df76fb0c84491ad3439a7ac9990e2150d5a1 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/maps.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/repeated.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/repeated.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c5e4014b36bf82b227347096a2b51efa9851ce6 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/__pycache__/repeated.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/maps.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/maps.py new file mode 100644 index 0000000000000000000000000000000000000000..3c4857161458291b3dc98c5a37d1f0bf4dae4dab --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/maps.py @@ -0,0 +1,82 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections + +from proto.utils import cached_property +from google.protobuf.message import Message + + +class MapComposite(collections.abc.MutableMapping): + """A view around a mutable sequence in protocol buffers. + + This implements the full Python MutableMapping interface, but all methods + modify the underlying field container directly. + """ + + @cached_property + def _pb_type(self): + """Return the protocol buffer type for this sequence.""" + # Huzzah, another hack. Still less bad than RepeatedComposite. + return type(self.pb.GetEntryClass()().value) + + def __init__(self, sequence, *, marshal): + """Initialize a wrapper around a protobuf map. + + Args: + sequence: A protocol buffers map. + marshal (~.MarshalRegistry): An instantiated marshal, used to + convert values going to and from this map. + """ + self._pb = sequence + self._marshal = marshal + + def __contains__(self, key): + # Protocol buffers is so permissive that querying for the existence + # of a key will in of itself create it. + # + # By taking a tuple of the keys and querying that, we avoid sending + # the lookup to protocol buffers and therefore avoid creating the key. + return key in tuple(self.keys()) + + def __getitem__(self, key): + # We handle raising KeyError ourselves, because otherwise protocol + # buffers will create the key if it does not exist. + if key not in self: + raise KeyError(key) + return self._marshal.to_python(self._pb_type, self.pb[key]) + + def __setitem__(self, key, value): + pb_value = self._marshal.to_proto(self._pb_type, value, strict=True) + # Directly setting a key is not allowed; however, protocol buffers + # is so permissive that querying for the existence of a key will in + # of itself create it. + # + # Therefore, we create a key that way (clearing any fields that may + # be set) and then merge in our values. + self.pb[key].Clear() + self.pb[key].MergeFrom(pb_value) + + def __delitem__(self, key): + self.pb.pop(key) + + def __len__(self): + return len(self.pb) + + def __iter__(self): + return iter(self.pb) + + @property + def pb(self): + return self._pb diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/repeated.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/repeated.py new file mode 100644 index 0000000000000000000000000000000000000000..a6560411cd71ac15a68f617ce7fe1c6e1e9cbabb --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/collections/repeated.py @@ -0,0 +1,189 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections +import copy +from typing import Iterable + +from proto.utils import cached_property + + +class Repeated(collections.abc.MutableSequence): + """A view around a mutable sequence in protocol buffers. + + This implements the full Python MutableSequence interface, but all methods + modify the underlying field container directly. + """ + + def __init__(self, sequence, *, marshal, proto_type=None): + """Initialize a wrapper around a protobuf repeated field. + + Args: + sequence: A protocol buffers repeated field. + marshal (~.MarshalRegistry): An instantiated marshal, used to + convert values going to and from this map. + """ + self._pb = sequence + self._marshal = marshal + self._proto_type = proto_type + + def __copy__(self): + """Copy this object and return the copy.""" + return type(self)(self.pb[:], marshal=self._marshal) + + def __delitem__(self, key): + """Delete the given item.""" + del self.pb[key] + + def __eq__(self, other): + if hasattr(other, "pb"): + return tuple(self.pb) == tuple(other.pb) + return tuple(self.pb) == tuple(other) if isinstance(other, Iterable) else False + + def __getitem__(self, key): + """Return the given item.""" + return self.pb[key] + + def __len__(self): + """Return the length of the sequence.""" + return len(self.pb) + + def __ne__(self, other): + return not self == other + + def __repr__(self): + return repr([*self]) + + def __setitem__(self, key, value): + self.pb[key] = value + + def insert(self, index: int, value): + """Insert ``value`` in the sequence before ``index``.""" + self.pb.insert(index, value) + + def sort(self, *, key: str = None, reverse: bool = False): + """Stable sort *IN PLACE*.""" + self.pb.sort(key=key, reverse=reverse) + + @property + def pb(self): + return self._pb + + +class RepeatedComposite(Repeated): + """A view around a mutable sequence of messages in protocol buffers. + + This implements the full Python MutableSequence interface, but all methods + modify the underlying field container directly. + """ + + @cached_property + def _pb_type(self): + """Return the protocol buffer type for this sequence.""" + # Provide the marshal-given proto_type, if any. + # Used for RepeatedComposite of Enum. + if self._proto_type is not None: + return self._proto_type + + # There is no public-interface mechanism to determine the type + # of what should go in the list (and the C implementation seems to + # have no exposed mechanism at all). + # + # If the list has members, use the existing list members to + # determine the type. + if len(self.pb) > 0: + return type(self.pb[0]) + + # We have no members in the list, so we get the type from the attributes. + if hasattr(self.pb, "_message_descriptor") and hasattr( + self.pb._message_descriptor, "_concrete_class" + ): + return self.pb._message_descriptor._concrete_class + + # Fallback logic in case attributes are not available + # In order to get the type, we create a throw-away copy and add a + # blank member to it. + canary = copy.deepcopy(self.pb).add() + return type(canary) + + def __eq__(self, other): + if super().__eq__(other): + return True + return ( + tuple([i for i in self]) == tuple(other) + if isinstance(other, Iterable) + else False + ) + + def __getitem__(self, key): + return self._marshal.to_python(self._pb_type, self.pb[key]) + + def __setitem__(self, key, value): + # The underlying protocol buffer does not define __setitem__, so we + # have to implement all the operations on our own. + + # If ``key`` is an integer, as in list[index] = value: + if isinstance(key, int): + if -len(self) <= key < len(self): + self.pop(key) # Delete the old item. + self.insert(key, value) # Insert the new item in its place. + else: + raise IndexError("list assignment index out of range") + + # If ``key`` is a slice object, as in list[start:stop:step] = [values]: + elif isinstance(key, slice): + start, stop, step = key.indices(len(self)) + + if not isinstance(value, collections.abc.Iterable): + raise TypeError("can only assign an iterable") + + if step == 1: # Is not an extended slice. + # Assign all the new values to the sliced part, replacing the + # old values, if any, and unconditionally inserting those + # values whose indices already exceed the slice length. + for index, item in enumerate(value): + if start + index < stop: + self.pop(start + index) + self.insert(start + index, item) + + # If there are less values than the length of the slice, remove + # the remaining elements so that the slice adapts to the + # newly provided values. + for _ in range(stop - start - len(value)): + self.pop(start + len(value)) + + else: # Is an extended slice. + indices = range(start, stop, step) + + if len(value) != len(indices): # XXX: Use PEP 572 on 3.8+ + raise ValueError( + f"attempt to assign sequence of size " + f"{len(value)} to extended slice of size " + f"{len(indices)}" + ) + + # Assign each value to its index, calling this function again + # with individual integer indexes that get processed above. + for index, item in zip(indices, value): + self[index] = item + + else: + raise TypeError( + f"list indices must be integers or slices, not {type(key).__name__}" + ) + + def insert(self, index: int, value): + """Insert ``value`` in the sequence before ``index``.""" + pb_value = self._marshal.to_proto(self._pb_type, value) + self.pb.insert(index, pb_value) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/compat.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/compat.py new file mode 100644 index 0000000000000000000000000000000000000000..b393acf5a447cc79913be8d3420e0bdc64c77382 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/compat.py @@ -0,0 +1,64 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file pulls in the container types from internal protocol buffers, +# and exports the types available. +# +# If the C extensions were not installed, then their container types will +# not be included. + +from google.protobuf.internal import containers + +# Import all message types to ensure that pyext types are recognized +# when upb types exist. Conda's protobuf defaults to pyext despite upb existing. +# See https://github.com/googleapis/proto-plus-python/issues/470 +try: + from google._upb import _message as _message_upb +except ImportError: + _message_upb = None + +try: + from google.protobuf.pyext import _message as _message_pyext +except ImportError: + _message_pyext = None + + +repeated_composite_types = (containers.RepeatedCompositeFieldContainer,) +repeated_scalar_types = (containers.RepeatedScalarFieldContainer,) +map_composite_types = (containers.MessageMap,) + +# In `proto/marshal.py`, for compatibility with protobuf 5.x, +# we'll use `map_composite_type_names` to check whether +# the name of the class of a protobuf type is +# `MessageMapContainer`, and, if `True`, return a MapComposite. +# See https://github.com/protocolbuffers/protobuf/issues/16596 +map_composite_type_names = ("MessageMapContainer",) + +for message in [_message_upb, _message_pyext]: + if message: + repeated_composite_types += (message.RepeatedCompositeContainer,) + repeated_scalar_types += (message.RepeatedScalarContainer,) + + try: + map_composite_types += (message.MessageMapContainer,) + except AttributeError: + # The `MessageMapContainer` attribute is not available in Protobuf 5.x+ + pass + +__all__ = ( + "repeated_composite_types", + "repeated_scalar_types", + "map_composite_types", + "map_composite_type_names", +) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/marshal.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/marshal.py new file mode 100644 index 0000000000000000000000000000000000000000..d278421a57975c7fd12e26e37cb5b83f1f7e222b --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/marshal.py @@ -0,0 +1,297 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import abc +import enum + +from google.protobuf import message +from google.protobuf import duration_pb2 +from google.protobuf import timestamp_pb2 +from google.protobuf import field_mask_pb2 +from google.protobuf import struct_pb2 +from google.protobuf import wrappers_pb2 + +from proto.marshal import compat +from proto.marshal.collections import MapComposite +from proto.marshal.collections import Repeated +from proto.marshal.collections import RepeatedComposite + +from proto.marshal.rules import bytes as pb_bytes +from proto.marshal.rules import stringy_numbers +from proto.marshal.rules import dates +from proto.marshal.rules import struct +from proto.marshal.rules import wrappers +from proto.marshal.rules import field_mask +from proto.primitives import ProtoType + + +class Rule(abc.ABC): + """Abstract class definition for marshal rules.""" + + @classmethod + def __subclasshook__(cls, C): + if hasattr(C, "to_python") and hasattr(C, "to_proto"): + return True + return NotImplemented + + +class BaseMarshal: + """The base class to translate between protobuf and Python classes. + + Protocol buffers defines many common types (e.g. Timestamp, Duration) + which also exist in the Python standard library. The marshal essentially + translates between these: it keeps a registry of common protocol buffers + and their Python representations, and translates back and forth. + + The protocol buffer class is always the "key" in this relationship; when + presenting a message, the declared field types are used to determine + whether a value should be transformed into another class. Similarly, + when accepting a Python value (when setting a field, for example), + the declared field type is still used. This means that, if appropriate, + multiple protocol buffer types may use the same Python type. + + The primary implementation of this is :class:`Marshal`, which should + usually be used instead of this class directly. + """ + + def __init__(self): + self._rules = {} + self._noop = NoopRule() + self.reset() + + def register(self, proto_type: type, rule: Rule = None): + """Register a rule against the given ``proto_type``. + + This function expects a ``proto_type`` (the descriptor class) and + a ``rule``; an object with a ``to_python`` and ``to_proto`` method. + Each method should return the appropriate Python or protocol buffer + type, and be idempotent (e.g. accept either type as input). + + This function can also be used as a decorator:: + + @marshal.register(timestamp_pb2.Timestamp) + class TimestampRule: + ... + + In this case, the class will be initialized for you with zero + arguments. + + Args: + proto_type (type): A protocol buffer message type. + rule: A marshal object + """ + # If a rule was provided, register it and be done. + if rule: + # Ensure the rule implements Rule. + if not isinstance(rule, Rule): + raise TypeError( + "Marshal rule instances must implement " + "`to_proto` and `to_python` methods." + ) + + # Register the rule. + self._rules[proto_type] = rule + return + + # Create an inner function that will register an instance of the + # marshal class to this object's registry, and return it. + def register_rule_class(rule_class: type): + # Ensure the rule class is a valid rule. + if not issubclass(rule_class, Rule): + raise TypeError( + "Marshal rule subclasses must implement " + "`to_proto` and `to_python` methods." + ) + + # Register the rule class. + self._rules[proto_type] = rule_class() + return rule_class + + return register_rule_class + + def reset(self): + """Reset the registry to its initial state.""" + self._rules.clear() + + # Register date and time wrappers. + self.register(timestamp_pb2.Timestamp, dates.TimestampRule()) + self.register(duration_pb2.Duration, dates.DurationRule()) + + # Register FieldMask wrappers. + self.register(field_mask_pb2.FieldMask, field_mask.FieldMaskRule()) + + # Register nullable primitive wrappers. + self.register(wrappers_pb2.BoolValue, wrappers.BoolValueRule()) + self.register(wrappers_pb2.BytesValue, wrappers.BytesValueRule()) + self.register(wrappers_pb2.DoubleValue, wrappers.DoubleValueRule()) + self.register(wrappers_pb2.FloatValue, wrappers.FloatValueRule()) + self.register(wrappers_pb2.Int32Value, wrappers.Int32ValueRule()) + self.register(wrappers_pb2.Int64Value, wrappers.Int64ValueRule()) + self.register(wrappers_pb2.StringValue, wrappers.StringValueRule()) + self.register(wrappers_pb2.UInt32Value, wrappers.UInt32ValueRule()) + self.register(wrappers_pb2.UInt64Value, wrappers.UInt64ValueRule()) + + # Register the google.protobuf.Struct wrappers. + # + # These are aware of the marshal that created them, because they + # create RepeatedComposite and MapComposite instances directly and + # need to pass the marshal to them. + self.register(struct_pb2.Value, struct.ValueRule(marshal=self)) + self.register(struct_pb2.ListValue, struct.ListValueRule(marshal=self)) + self.register(struct_pb2.Struct, struct.StructRule(marshal=self)) + + # Special case for bytes to allow base64 encode/decode + self.register(ProtoType.BYTES, pb_bytes.BytesRule()) + + # Special case for int64 from strings because of dict round trip. + # See https://github.com/protocolbuffers/protobuf/issues/2679 + for rule_class in stringy_numbers.STRINGY_NUMBER_RULES: + self.register(rule_class._proto_type, rule_class()) + + def get_rule(self, proto_type): + # Rules are needed to convert values between proto-plus and pb. + # Retrieve the rule for the specified proto type. + # The NoopRule will be used when a rule is not found. + rule = self._rules.get(proto_type, self._noop) + + # If we don't find a rule, also check under `_instances` + # in case there is a rule in another package. + # See https://github.com/googleapis/proto-plus-python/issues/349 + if rule == self._noop and hasattr(self, "_instances"): + for _, instance in self._instances.items(): + rule = instance._rules.get(proto_type, self._noop) + if rule != self._noop: + break + return rule + + def to_python(self, proto_type, value, *, absent: bool = None): + # Internal protobuf has its own special type for lists of values. + # Return a view around it that implements MutableSequence. + value_type = type(value) # Minor performance boost over isinstance + if value_type in compat.repeated_composite_types: + return RepeatedComposite(value, marshal=self) + if value_type in compat.repeated_scalar_types: + if isinstance(proto_type, type): + return RepeatedComposite(value, marshal=self, proto_type=proto_type) + else: + return Repeated(value, marshal=self) + + # Same thing for maps of messages. + # See https://github.com/protocolbuffers/protobuf/issues/16596 + # We need to look up the name of the type in compat.map_composite_type_names + # as class `MessageMapContainer` is no longer exposed + # This is done to avoid taking a breaking change in proto-plus. + if ( + value_type in compat.map_composite_types + or value_type.__name__ in compat.map_composite_type_names + ): + return MapComposite(value, marshal=self) + return self.get_rule(proto_type=proto_type).to_python(value, absent=absent) + + def to_proto(self, proto_type, value, *, strict: bool = False): + # The protos in google/protobuf/struct.proto are exceptional cases, + # because they can and should represent themselves as lists and dicts. + # These cases are handled in their rule classes. + if proto_type not in ( + struct_pb2.Value, + struct_pb2.ListValue, + struct_pb2.Struct, + ): + # For our repeated and map view objects, simply return the + # underlying pb. + if isinstance(value, (Repeated, MapComposite)): + return value.pb + + # Convert lists and tuples recursively. + if isinstance(value, (list, tuple)): + return type(value)(self.to_proto(proto_type, i) for i in value) + + # Convert dictionaries recursively when the proto type is a map. + # This is slightly more complicated than converting a list or tuple + # because we have to step through the magic that protocol buffers does. + # + # Essentially, a type of map will show up here as + # a FoosEntry with a `key` field, `value` field, and a `map_entry` + # annotation. We need to do the conversion based on the `value` + # field's type. + if isinstance(value, dict) and ( + proto_type.DESCRIPTOR.has_options + and proto_type.DESCRIPTOR.GetOptions().map_entry + ): + recursive_type = type(proto_type().value) + return {k: self.to_proto(recursive_type, v) for k, v in value.items()} + + pb_value = self.get_rule(proto_type=proto_type).to_proto(value) + + # Sanity check: If we are in strict mode, did we get the value we want? + if strict and not isinstance(pb_value, proto_type): + raise TypeError( + "Parameter must be instance of the same class; " + "expected {expected}, got {got}".format( + expected=proto_type.__name__, + got=pb_value.__class__.__name__, + ), + ) + # Return the final value. + return pb_value + + +class Marshal(BaseMarshal): + """The translator between protocol buffer and Python instances. + + The bulk of the implementation is in :class:`BaseMarshal`. This class + adds identity tracking: multiple instantiations of :class:`Marshal` with + the same name will provide the same instance. + """ + + _instances = {} + + def __new__(cls, *, name: str): + """Create a marshal instance. + + Args: + name (str): The name of the marshal. Instantiating multiple + marshals with the same ``name`` argument will provide the + same marshal each time. + """ + klass = cls._instances.get(name) + if klass is None: + klass = cls._instances[name] = super().__new__(cls) + + return klass + + def __init__(self, *, name: str): + """Instantiate a marshal. + + Args: + name (str): The name of the marshal. Instantiating multiple + marshals with the same ``name`` argument will provide the + same marshal each time. + """ + self._name = name + if not hasattr(self, "_rules"): + super().__init__() + + +class NoopRule: + """A catch-all rule that does nothing.""" + + def to_python(self, pb_value, *, absent: bool = None): + return pb_value + + def to_proto(self, value): + return value + + +__all__ = ("Marshal",) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__init__.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b0c7da3d7725b221298f8a38dadf11d4802dce0d --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/enums.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/enums.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..90d7e66f88affde6f3cb64c2c602d81daa5977ef Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/enums.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/field_mask.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/field_mask.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..69a91702eed3112adc7d523126e8dec608f62d1e Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/field_mask.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/message.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/message.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..09339c2d3c4e998b085a4bde39fa62adeadd2f60 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/message.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/stringy_numbers.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/stringy_numbers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..95631527e0c8739b2ea095e8d46888f432ef65e6 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/stringy_numbers.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/struct.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/struct.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7a9a912837e1598a243125757b93edffabb539d8 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/struct.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/wrappers.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/wrappers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c52273ab7bb2d0598b2daf363e66d270bfef9e13 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/wrappers.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/enums.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/enums.py new file mode 100644 index 0000000000000000000000000000000000000000..9cfc312764b6ab8ff38ebc12dd256d6b1434d6c2 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/enums.py @@ -0,0 +1,59 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Type +import enum +import warnings + + +class EnumRule: + """A marshal for converting between integer values and enum values.""" + + def __init__(self, enum_class: Type[enum.IntEnum]): + self._enum = enum_class + + def to_python(self, value, *, absent: bool = None): + if isinstance(value, int) and not isinstance(value, self._enum): + try: + # Coerce the int on the wire to the enum value. + return self._enum(value) + except ValueError: + # Since it is possible to add values to enums, we do + # not want to flatly error on this. + # + # However, it is useful to make some noise about it so + # the user realizes that an unexpected value came along. + warnings.warn( + "Unrecognized {name} enum value: {value}".format( + name=self._enum.__name__, + value=value, + ) + ) + return value + + def to_proto(self, value): + # Accept enum values and coerce to the pure integer. + # This is not strictly necessary (protocol buffers can take these + # objects as they subclass int) but nevertheless seems like the + # right thing to do. + if isinstance(value, self._enum): + return value.value + + # If a string is provided that matches an enum value, coerce it + # to the enum value. + if isinstance(value, str): + return self._enum[value].value + + # We got a pure integer; pass it on. + return value diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/message.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/message.py new file mode 100644 index 0000000000000000000000000000000000000000..479a2d95277631e7a659e5a1bfebd211fb1c22d7 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/message.py @@ -0,0 +1,52 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +class MessageRule: + """A marshal for converting between a descriptor and proto.Message.""" + + def __init__(self, descriptor: type, wrapper: type): + self._descriptor = descriptor + self._wrapper = wrapper + + def to_python(self, value, *, absent: bool = None): + if isinstance(value, self._descriptor): + return self._wrapper.wrap(value) + return value + + def to_proto(self, value): + if isinstance(value, self._wrapper): + return self._wrapper.pb(value) + if isinstance(value, dict) and not self.is_map: + # We need to use the wrapper's marshaling to handle + # potentially problematic nested messages. + try: + # Try the fast path first. + return self._descriptor(**value) + except (TypeError, ValueError) as ex: + # If we have a TypeError or Valueerror, + # try the slow path in case the error + # was: + # - an int64/string issue. + # - a missing key issue in case a key only exists with a `_` suffix. + # See related issue: https://github.com/googleapis/python-api-core/issues/227. + # - a missing key issue due to nested struct. See: b/321905145. + return self._wrapper(value)._pb + return value + + @property + def is_map(self): + """Return True if the descriptor is a map entry, False otherwise.""" + desc = self._descriptor.DESCRIPTOR + return desc.has_options and desc.GetOptions().map_entry diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/stringy_numbers.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/stringy_numbers.py new file mode 100644 index 0000000000000000000000000000000000000000..dae69e9c9121d9b71b2c98a2f2028ca2c9c7d66d --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/stringy_numbers.py @@ -0,0 +1,71 @@ +# Copyright (C) 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from proto.primitives import ProtoType + + +class StringyNumberRule: + """A marshal between certain numeric types and strings + + This is a necessary hack to allow round trip conversion + from messages to dicts back to messages. + + See https://github.com/protocolbuffers/protobuf/issues/2679 + and + https://developers.google.com/protocol-buffers/docs/proto3#json + for more details. + """ + + def to_python(self, value, *, absent: bool = None): + return value + + def to_proto(self, value): + if value is not None: + return self._python_type(value) + + return None + + +class Int64Rule(StringyNumberRule): + _python_type = int + _proto_type = ProtoType.INT64 + + +class UInt64Rule(StringyNumberRule): + _python_type = int + _proto_type = ProtoType.UINT64 + + +class SInt64Rule(StringyNumberRule): + _python_type = int + _proto_type = ProtoType.SINT64 + + +class Fixed64Rule(StringyNumberRule): + _python_type = int + _proto_type = ProtoType.FIXED64 + + +class SFixed64Rule(StringyNumberRule): + _python_type = int + _proto_type = ProtoType.SFIXED64 + + +STRINGY_NUMBER_RULES = [ + Int64Rule, + UInt64Rule, + SInt64Rule, + Fixed64Rule, + SFixed64Rule, +] diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/struct.py b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/struct.py new file mode 100644 index 0000000000000000000000000000000000000000..0e34587b26b19c06caa63bf469e26c3ef6bb9dda --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/marshal/rules/struct.py @@ -0,0 +1,143 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections.abc + +from google.protobuf import struct_pb2 + +from proto.marshal.collections import maps +from proto.marshal.collections import repeated + + +class ValueRule: + """A rule to marshal between google.protobuf.Value and Python values.""" + + def __init__(self, *, marshal): + self._marshal = marshal + + def to_python(self, value, *, absent: bool = None): + """Coerce the given value to the appropriate Python type. + + Note that both NullValue and absent fields return None. + In order to disambiguate between these two options, + use containment check, + E.g. + "value" in foo + which is True for NullValue and False for an absent value. + """ + kind = value.WhichOneof("kind") + if kind == "null_value" or absent: + return None + if kind == "bool_value": + return bool(value.bool_value) + if kind == "number_value": + return float(value.number_value) + if kind == "string_value": + return str(value.string_value) + if kind == "struct_value": + return self._marshal.to_python( + struct_pb2.Struct, + value.struct_value, + absent=False, + ) + if kind == "list_value": + return self._marshal.to_python( + struct_pb2.ListValue, + value.list_value, + absent=False, + ) + # If more variants are ever added, we want to fail loudly + # instead of tacitly returning None. + raise ValueError("Unexpected kind: %s" % kind) # pragma: NO COVER + + def to_proto(self, value) -> struct_pb2.Value: + """Return a protobuf Value object representing this value.""" + if isinstance(value, struct_pb2.Value): + return value + if value is None: + return struct_pb2.Value(null_value=0) + if isinstance(value, bool): + return struct_pb2.Value(bool_value=value) + if isinstance(value, (int, float)): + return struct_pb2.Value(number_value=float(value)) + if isinstance(value, str): + return struct_pb2.Value(string_value=value) + if isinstance(value, collections.abc.Sequence): + return struct_pb2.Value( + list_value=self._marshal.to_proto(struct_pb2.ListValue, value), + ) + if isinstance(value, collections.abc.Mapping): + return struct_pb2.Value( + struct_value=self._marshal.to_proto(struct_pb2.Struct, value), + ) + raise ValueError("Unable to coerce value: %r" % value) + + +class ListValueRule: + """A rule translating google.protobuf.ListValue and list-like objects.""" + + def __init__(self, *, marshal): + self._marshal = marshal + + def to_python(self, value, *, absent: bool = None): + """Coerce the given value to a Python sequence.""" + return ( + None + if absent + else repeated.RepeatedComposite(value.values, marshal=self._marshal) + ) + + def to_proto(self, value) -> struct_pb2.ListValue: + # We got a proto, or else something we sent originally. + # Preserve the instance we have. + if isinstance(value, struct_pb2.ListValue): + return value + if isinstance(value, repeated.RepeatedComposite): + return struct_pb2.ListValue(values=[v for v in value.pb]) + + # We got a list (or something list-like); convert it. + return struct_pb2.ListValue( + values=[self._marshal.to_proto(struct_pb2.Value, v) for v in value] + ) + + +class StructRule: + """A rule translating google.protobuf.Struct and dict-like objects.""" + + def __init__(self, *, marshal): + self._marshal = marshal + + def to_python(self, value, *, absent: bool = None): + """Coerce the given value to a Python mapping.""" + return ( + None if absent else maps.MapComposite(value.fields, marshal=self._marshal) + ) + + def to_proto(self, value) -> struct_pb2.Struct: + # We got a proto, or else something we sent originally. + # Preserve the instance we have. + if isinstance(value, struct_pb2.Struct): + return value + if isinstance(value, maps.MapComposite): + return struct_pb2.Struct( + fields={k: v for k, v in value.pb.items()}, + ) + + # We got a dict (or something dict-like); convert it. + answer = struct_pb2.Struct( + fields={ + k: self._marshal.to_proto(struct_pb2.Value, v) for k, v in value.items() + } + ) + return answer diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/message.py b/evalkit_tf437/lib/python3.10/site-packages/proto/message.py new file mode 100644 index 0000000000000000000000000000000000000000..989c1cd32a866806edfa1a3d579e3987a4717112 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/message.py @@ -0,0 +1,969 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections +import collections.abc +import copy +import re +from typing import List, Optional, Type +import warnings + +import google.protobuf +from google.protobuf import descriptor_pb2 +from google.protobuf import message +from google.protobuf.json_format import MessageToDict, MessageToJson, Parse + +from proto import _file_info +from proto import _package_info +from proto.fields import Field +from proto.fields import MapField +from proto.fields import RepeatedField +from proto.marshal import Marshal +from proto.primitives import ProtoType +from proto.utils import has_upb + + +PROTOBUF_VERSION = google.protobuf.__version__ + +_upb = has_upb() # Important to cache result here. + + +class MessageMeta(type): + """A metaclass for building and registering Message subclasses.""" + + def __new__(mcls, name, bases, attrs): + # Do not do any special behavior for Message itself. + if not bases: + return super().__new__(mcls, name, bases, attrs) + + # Get the essential information about the proto package, and where + # this component belongs within the file. + package, marshal = _package_info.compile(name, attrs) + + # Determine the local path of this proto component within the file. + local_path = tuple(attrs.get("__qualname__", name).split(".")) + + # Sanity check: We get the wrong full name if a class is declared + # inside a function local scope; correct this. + if "" in local_path: + ix = local_path.index("") + local_path = local_path[: ix - 1] + local_path[ix + 1 :] + + # Determine the full name in protocol buffers. + full_name = ".".join((package,) + local_path).lstrip(".") + + # Special case: Maps. Map fields are special; they are essentially + # shorthand for a nested message and a repeated field of that message. + # Decompose each map into its constituent form. + # https://developers.google.com/protocol-buffers/docs/proto3#maps + map_fields = {} + for key, field in attrs.items(): + if not isinstance(field, MapField): + continue + + # Determine the name of the entry message. + msg_name = "{pascal_key}Entry".format( + pascal_key=re.sub( + r"_\w", + lambda m: m.group()[1:].upper(), + key, + ).replace(key[0], key[0].upper(), 1), + ) + + # Create the "entry" message (with the key and value fields). + # + # Note: We instantiate an ordered dictionary here and then + # attach key and value in order to ensure that the fields are + # iterated in the correct order when the class is created. + # This is only an issue in Python 3.5, where the order is + # random (and the wrong order causes the pool to refuse to add + # the descriptor because reasons). + entry_attrs = collections.OrderedDict( + { + "__module__": attrs.get("__module__", None), + "__qualname__": "{prefix}.{name}".format( + prefix=attrs.get("__qualname__", name), + name=msg_name, + ), + "_pb_options": {"map_entry": True}, + } + ) + entry_attrs["key"] = Field(field.map_key_type, number=1) + entry_attrs["value"] = Field( + field.proto_type, + number=2, + enum=field.enum, + message=field.message, + ) + map_fields[msg_name] = MessageMeta(msg_name, (Message,), entry_attrs) + + # Create the repeated field for the entry message. + map_fields[key] = RepeatedField( + ProtoType.MESSAGE, + number=field.number, + message=map_fields[msg_name], + ) + + # Add the new entries to the attrs + attrs.update(map_fields) + + # Okay, now we deal with all the rest of the fields. + # Iterate over all the attributes and separate the fields into + # their own sequence. + fields = [] + new_attrs = {} + oneofs = collections.OrderedDict() + proto_imports = set() + index = 0 + for key, field in attrs.items(): + # Sanity check: If this is not a field, do nothing. + if not isinstance(field, Field): + # The field objects themselves should not be direct attributes. + new_attrs[key] = field + continue + + # Add data that the field requires that we do not take in the + # constructor because we can derive it from the metaclass. + # (The goal is to make the declaration syntax as nice as possible.) + field.mcls_data = { + "name": key, + "parent_name": full_name, + "index": index, + "package": package, + } + + # Add the field to the list of fields. + fields.append(field) + # If this field is part of a "oneof", ensure the oneof itself + # is represented. + if field.oneof: + # Keep a running tally of the index of each oneof, and assign + # that index to the field's descriptor. + oneofs.setdefault(field.oneof, len(oneofs)) + field.descriptor.oneof_index = oneofs[field.oneof] + + # If this field references a message, it may be from another + # proto file; ensure we know about the import (to faithfully + # construct our file descriptor proto). + if field.message and not isinstance(field.message, str): + field_msg = field.message + if hasattr(field_msg, "pb") and callable(field_msg.pb): + field_msg = field_msg.pb() + # Sanity check: The field's message may not yet be defined if + # it was a Message defined in the same file, and the file + # descriptor proto has not yet been generated. + # + # We do nothing in this situation; everything will be handled + # correctly when the file descriptor is created later. + if field_msg: + proto_imports.add(field_msg.DESCRIPTOR.file.name) + + # Same thing, but for enums. + elif field.enum and not isinstance(field.enum, str): + field_enum = ( + field.enum._meta.pb + if hasattr(field.enum, "_meta") + else field.enum.DESCRIPTOR + ) + + if field_enum: + proto_imports.add(field_enum.file.name) + + # Increment the field index counter. + index += 1 + + # As per descriptor.proto, all synthetic oneofs must be ordered after + # 'real' oneofs. + opt_attrs = {} + for field in fields: + if field.optional: + field.oneof = "_{}".format(field.name) + field.descriptor.oneof_index = oneofs[field.oneof] = len(oneofs) + opt_attrs[field.name] = field.name + + # Generating a metaclass dynamically provides class attributes that + # instances can't see. This provides idiomatically named constants + # that enable the following pattern to check for field presence: + # + # class MyMessage(proto.Message): + # field = proto.Field(proto.INT32, number=1, optional=True) + # + # m = MyMessage() + # MyMessage.field in m + if opt_attrs: + mcls = type("AttrsMeta", (mcls,), opt_attrs) + + # Determine the filename. + # We determine an appropriate proto filename based on the + # Python module. + filename = _file_info._FileInfo.proto_file_name( + new_attrs.get("__module__", name.lower()) + ) + + # Get or create the information about the file, including the + # descriptor to which the new message descriptor shall be added. + file_info = _file_info._FileInfo.maybe_add_descriptor(filename, package) + + # Ensure any imports that would be necessary are assigned to the file + # descriptor proto being created. + for proto_import in proto_imports: + if proto_import not in file_info.descriptor.dependency: + file_info.descriptor.dependency.append(proto_import) + + # Retrieve any message options. + opts = descriptor_pb2.MessageOptions(**new_attrs.pop("_pb_options", {})) + + # Create the underlying proto descriptor. + desc = descriptor_pb2.DescriptorProto( + name=name, + field=[i.descriptor for i in fields], + oneof_decl=[ + descriptor_pb2.OneofDescriptorProto(name=i) for i in oneofs.keys() + ], + options=opts, + ) + + # If any descriptors were nested under this one, they need to be + # attached as nested types here. + child_paths = [p for p in file_info.nested.keys() if local_path == p[:-1]] + for child_path in child_paths: + desc.nested_type.add().MergeFrom(file_info.nested.pop(child_path)) + + # Same thing, but for enums + child_paths = [p for p in file_info.nested_enum.keys() if local_path == p[:-1]] + for child_path in child_paths: + desc.enum_type.add().MergeFrom(file_info.nested_enum.pop(child_path)) + + # Add the descriptor to the file if it is a top-level descriptor, + # or to a "holding area" for nested messages otherwise. + if len(local_path) == 1: + file_info.descriptor.message_type.add().MergeFrom(desc) + else: + file_info.nested[local_path] = desc + + # Create the MessageInfo instance to be attached to this message. + new_attrs["_meta"] = _MessageInfo( + fields=fields, + full_name=full_name, + marshal=marshal, + options=opts, + package=package, + ) + + # Run the superclass constructor. + cls = super().__new__(mcls, name, bases, new_attrs) + + # The info class and fields need a reference to the class just created. + cls._meta.parent = cls + for field in cls._meta.fields.values(): + field.parent = cls + + # Add this message to the _FileInfo instance; this allows us to + # associate the descriptor with the message once the descriptor + # is generated. + file_info.messages[full_name] = cls + + # Generate the descriptor for the file if it is ready. + if file_info.ready(new_class=cls): + file_info.generate_file_pb(new_class=cls, fallback_salt=full_name) + + # Done; return the class. + return cls + + @classmethod + def __prepare__(mcls, name, bases, **kwargs): + return collections.OrderedDict() + + @property + def meta(cls): + return cls._meta + + def __dir__(self): + try: + names = set(dir(type)) + names.update( + ( + "meta", + "pb", + "wrap", + "serialize", + "deserialize", + "to_json", + "from_json", + "to_dict", + "copy_from", + ) + ) + desc = self.pb().DESCRIPTOR + names.update(t.name for t in desc.nested_types) + names.update(e.name for e in desc.enum_types) + + return names + except AttributeError: + return dir(type) + + def pb(cls, obj=None, *, coerce: bool = False): + """Return the underlying protobuf Message class or instance. + + Args: + obj: If provided, and an instance of ``cls``, return the + underlying protobuf instance. + coerce (bool): If provided, will attempt to coerce ``obj`` to + ``cls`` if it is not already an instance. + """ + if obj is None: + return cls.meta.pb + if not isinstance(obj, cls): + if coerce: + obj = cls(obj) + else: + raise TypeError( + "%r is not an instance of %s" + % ( + obj, + cls.__name__, + ) + ) + return obj._pb + + def wrap(cls, pb): + """Return a Message object that shallowly wraps the descriptor. + + Args: + pb: A protocol buffer object, such as would be returned by + :meth:`pb`. + """ + # Optimized fast path. + instance = cls.__new__(cls) + super(cls, instance).__setattr__("_pb", pb) + return instance + + def serialize(cls, instance) -> bytes: + """Return the serialized proto. + + Args: + instance: An instance of this message type, or something + compatible (accepted by the type's constructor). + + Returns: + bytes: The serialized representation of the protocol buffer. + """ + return cls.pb(instance, coerce=True).SerializeToString() + + def deserialize(cls, payload: bytes) -> "Message": + """Given a serialized proto, deserialize it into a Message instance. + + Args: + payload (bytes): The serialized proto. + + Returns: + ~.Message: An instance of the message class against which this + method was called. + """ + return cls.wrap(cls.pb().FromString(payload)) + + def _warn_if_including_default_value_fields_is_used_protobuf_5( + cls, including_default_value_fields: Optional[bool] + ) -> None: + """ + Warn Protobuf 5.x+ users that `including_default_value_fields` is deprecated if it is set. + + Args: + including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user. + """ + if ( + PROTOBUF_VERSION[0] not in ("3", "4") + and including_default_value_fields is not None + ): + warnings.warn( + """The argument `including_default_value_fields` has been removed from + Protobuf 5.x. Please use `always_print_fields_with_no_presence` instead. + """, + DeprecationWarning, + ) + + def _raise_if_print_fields_values_are_set_and_differ( + cls, + always_print_fields_with_no_presence: Optional[bool], + including_default_value_fields: Optional[bool], + ) -> None: + """ + Raise Exception if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set + and the values differ. + + Args: + always_print_fields_with_no_presence (Optional(bool)): The value of `always_print_fields_with_no_presence` set by the user. + including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user. + Returns: + None + Raises: + ValueError: if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set and + the values differ. + """ + if ( + always_print_fields_with_no_presence is not None + and including_default_value_fields is not None + and always_print_fields_with_no_presence != including_default_value_fields + ): + raise ValueError( + "Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match" + ) + + def _normalize_print_fields_without_presence( + cls, + always_print_fields_with_no_presence: Optional[bool], + including_default_value_fields: Optional[bool], + ) -> bool: + """ + Return true if fields with no presence should be included in the results. + By default, fields with no presence will be included in the results + when both `always_print_fields_with_no_presence` and + `including_default_value_fields` are not set + + Args: + always_print_fields_with_no_presence (Optional(bool)): The value of `always_print_fields_with_no_presence` set by the user. + including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user. + Returns: + None + Raises: + ValueError: if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set and + the values differ. + """ + + cls._warn_if_including_default_value_fields_is_used_protobuf_5( + including_default_value_fields + ) + cls._raise_if_print_fields_values_are_set_and_differ( + always_print_fields_with_no_presence, including_default_value_fields + ) + # Default to True if neither `always_print_fields_with_no_presence` or `including_default_value_fields` is set + return ( + ( + always_print_fields_with_no_presence is None + and including_default_value_fields is None + ) + or always_print_fields_with_no_presence + or including_default_value_fields + ) + + def to_json( + cls, + instance, + *, + use_integers_for_enums=True, + including_default_value_fields=None, + preserving_proto_field_name=False, + sort_keys=False, + indent=2, + float_precision=None, + always_print_fields_with_no_presence=None, + ) -> str: + """Given a message instance, serialize it to json + + Args: + instance: An instance of this message type, or something + compatible (accepted by the type's constructor). + use_integers_for_enums (Optional(bool)): An option that determines whether enum + values should be represented by strings (False) or integers (True). + Default is True. + including_default_value_fields (Optional(bool)): Deprecated. Use argument + `always_print_fields_with_no_presence` instead. An option that + determines whether the default field values should be included in the results. + This value must match `always_print_fields_with_no_presence`, + if both arguments are explicitly set. + preserving_proto_field_name (Optional(bool)): An option that + determines whether field name representations preserve + proto case (snake_case) or use lowerCamelCase. Default is False. + sort_keys (Optional(bool)): If True, then the output will be sorted by field names. + Default is False. + indent (Optional(int)): The JSON object will be pretty-printed with this indent level. + An indent level of 0 or negative will only insert newlines. + Pass None for the most compact representation without newlines. + float_precision (Optional(int)): If set, use this to specify float field valid digits. + Default is None. + always_print_fields_with_no_presence (Optional(bool)): If True, fields without + presence (implicit presence scalars, repeated fields, and map fields) will + always be serialized. Any field that supports presence is not affected by + this option (including singular message fields and oneof fields). + This value must match `including_default_value_fields`, + if both arguments are explicitly set. + Returns: + str: The json string representation of the protocol buffer. + """ + + print_fields = cls._normalize_print_fields_without_presence( + always_print_fields_with_no_presence, including_default_value_fields + ) + + if PROTOBUF_VERSION[0] in ("3", "4"): + return MessageToJson( + cls.pb(instance), + use_integers_for_enums=use_integers_for_enums, + including_default_value_fields=print_fields, + preserving_proto_field_name=preserving_proto_field_name, + sort_keys=sort_keys, + indent=indent, + float_precision=float_precision, + ) + else: + # The `including_default_value_fields` argument was removed from protobuf 5.x + # and replaced with `always_print_fields_with_no_presence` which very similar but has + # handles optional fields consistently by not affecting them. + # The old flag accidentally had inconsistent behavior between proto2 + # optional and proto3 optional fields. + return MessageToJson( + cls.pb(instance), + use_integers_for_enums=use_integers_for_enums, + always_print_fields_with_no_presence=print_fields, + preserving_proto_field_name=preserving_proto_field_name, + sort_keys=sort_keys, + indent=indent, + float_precision=float_precision, + ) + + def from_json(cls, payload, *, ignore_unknown_fields=False) -> "Message": + """Given a json string representing an instance, + parse it into a message. + + Args: + payload: A json string representing a message. + ignore_unknown_fields (Optional(bool)): If True, do not raise errors + for unknown fields. + + Returns: + ~.Message: An instance of the message class against which this + method was called. + """ + instance = cls() + Parse(payload, instance._pb, ignore_unknown_fields=ignore_unknown_fields) + return instance + + def to_dict( + cls, + instance, + *, + use_integers_for_enums=True, + preserving_proto_field_name=True, + including_default_value_fields=None, + float_precision=None, + always_print_fields_with_no_presence=None, + ) -> "Message": + """Given a message instance, return its representation as a python dict. + + Args: + instance: An instance of this message type, or something + compatible (accepted by the type's constructor). + use_integers_for_enums (Optional(bool)): An option that determines whether enum + values should be represented by strings (False) or integers (True). + Default is True. + preserving_proto_field_name (Optional(bool)): An option that + determines whether field name representations preserve + proto case (snake_case) or use lowerCamelCase. Default is True. + including_default_value_fields (Optional(bool)): Deprecated. Use argument + `always_print_fields_with_no_presence` instead. An option that + determines whether the default field values should be included in the results. + This value must match `always_print_fields_with_no_presence`, + if both arguments are explicitly set. + float_precision (Optional(int)): If set, use this to specify float field valid digits. + Default is None. + always_print_fields_with_no_presence (Optional(bool)): If True, fields without + presence (implicit presence scalars, repeated fields, and map fields) will + always be serialized. Any field that supports presence is not affected by + this option (including singular message fields and oneof fields). This value + must match `including_default_value_fields`, if both arguments are explicitly set. + + Returns: + dict: A representation of the protocol buffer using pythonic data structures. + Messages and map fields are represented as dicts, + repeated fields are represented as lists. + """ + + print_fields = cls._normalize_print_fields_without_presence( + always_print_fields_with_no_presence, including_default_value_fields + ) + + if PROTOBUF_VERSION[0] in ("3", "4"): + return MessageToDict( + cls.pb(instance), + including_default_value_fields=print_fields, + preserving_proto_field_name=preserving_proto_field_name, + use_integers_for_enums=use_integers_for_enums, + float_precision=float_precision, + ) + else: + # The `including_default_value_fields` argument was removed from protobuf 5.x + # and replaced with `always_print_fields_with_no_presence` which very similar but has + # handles optional fields consistently by not affecting them. + # The old flag accidentally had inconsistent behavior between proto2 + # optional and proto3 optional fields. + return MessageToDict( + cls.pb(instance), + always_print_fields_with_no_presence=print_fields, + preserving_proto_field_name=preserving_proto_field_name, + use_integers_for_enums=use_integers_for_enums, + float_precision=float_precision, + ) + + def copy_from(cls, instance, other): + """Equivalent for protobuf.Message.CopyFrom + + Args: + instance: An instance of this message type + other: (Union[dict, ~.Message): + A dictionary or message to reinitialize the values for this message. + """ + if isinstance(other, cls): + # Just want the underlying proto. + other = Message.pb(other) + elif isinstance(other, cls.pb()): + # Don't need to do anything. + pass + elif isinstance(other, collections.abc.Mapping): + # Coerce into a proto + other = cls._meta.pb(**other) + else: + raise TypeError( + "invalid argument type to copy to {}: {}".format( + cls.__name__, other.__class__.__name__ + ) + ) + + # Note: we can't just run self.__init__ because this may be a message field + # for a higher order proto; the memory layout for protos is NOT LIKE the + # python memory model. We cannot rely on just setting things by reference. + # Non-trivial complexity is (partially) hidden by the protobuf runtime. + cls.pb(instance).CopyFrom(other) + + +class Message(metaclass=MessageMeta): + """The abstract base class for a message. + + Args: + mapping (Union[dict, ~.Message]): A dictionary or message to be + used to determine the values for this message. + ignore_unknown_fields (Optional(bool)): If True, do not raise errors for + unknown fields. Only applied if `mapping` is a mapping type or there + are keyword parameters. + kwargs (dict): Keys and values corresponding to the fields of the + message. + """ + + def __init__( + self, + mapping=None, + *, + ignore_unknown_fields=False, + **kwargs, + ): + # We accept several things for `mapping`: + # * An instance of this class. + # * An instance of the underlying protobuf descriptor class. + # * A dict + # * Nothing (keyword arguments only). + if mapping is None: + if not kwargs: + # Special fast path for empty construction. + super().__setattr__("_pb", self._meta.pb()) + return + + mapping = kwargs + elif isinstance(mapping, self._meta.pb): + # Make a copy of the mapping. + # This is a constructor for a new object, so users will assume + # that it will not have side effects on the arguments being + # passed in. + # + # The `wrap` method on the metaclass is the public API for taking + # ownership of the passed in protobuf object. + mapping = copy.deepcopy(mapping) + if kwargs: + mapping.MergeFrom(self._meta.pb(**kwargs)) + + super().__setattr__("_pb", mapping) + return + elif isinstance(mapping, type(self)): + # Just use the above logic on mapping's underlying pb. + self.__init__(mapping=mapping._pb, **kwargs) + return + elif isinstance(mapping, collections.abc.Mapping): + # Can't have side effects on mapping. + mapping = copy.copy(mapping) + # kwargs entries take priority for duplicate keys. + mapping.update(kwargs) + else: + # Sanity check: Did we get something not a map? Error if so. + raise TypeError( + "Invalid constructor input for %s: %r" + % ( + self.__class__.__name__, + mapping, + ) + ) + + params = {} + # Update the mapping to address any values that need to be + # coerced. + marshal = self._meta.marshal + for key, value in mapping.items(): + (key, pb_type) = self._get_pb_type_from_key(key) + if pb_type is None: + if ignore_unknown_fields: + continue + + raise ValueError( + "Unknown field for {}: {}".format(self.__class__.__name__, key) + ) + + pb_value = marshal.to_proto(pb_type, value) + + if pb_value is not None: + params[key] = pb_value + + # Create the internal protocol buffer. + super().__setattr__("_pb", self._meta.pb(**params)) + + def _get_pb_type_from_key(self, key): + """Given a key, return the corresponding pb_type. + + Args: + key(str): The name of the field. + + Returns: + A tuple containing a key and pb_type. The pb_type will be + the composite type of the field, or the primitive type if a primitive. + If no corresponding field exists, return None. + """ + + pb_type = None + + try: + pb_type = self._meta.fields[key].pb_type + except KeyError: + # Underscores may be appended to field names + # that collide with python or proto-plus keywords. + # In case a key only exists with a `_` suffix, coerce the key + # to include the `_` suffix. It's not possible to + # natively define the same field with a trailing underscore in protobuf. + # See related issue + # https://github.com/googleapis/python-api-core/issues/227 + if f"{key}_" in self._meta.fields: + key = f"{key}_" + pb_type = self._meta.fields[key].pb_type + + return (key, pb_type) + + def __dir__(self): + desc = type(self).pb().DESCRIPTOR + names = {f_name for f_name in self._meta.fields.keys()} + names.update(m.name for m in desc.nested_types) + names.update(e.name for e in desc.enum_types) + names.update(dir(object())) + # Can't think of a better way of determining + # the special methods than manually listing them. + names.update( + ( + "__bool__", + "__contains__", + "__dict__", + "__getattr__", + "__getstate__", + "__module__", + "__setstate__", + "__weakref__", + ) + ) + + return names + + def __bool__(self): + """Return True if any field is truthy, False otherwise.""" + return any(k in self and getattr(self, k) for k in self._meta.fields.keys()) + + def __contains__(self, key): + """Return True if this field was set to something non-zero on the wire. + + In most cases, this method will return True when ``__getattr__`` + would return a truthy value and False when it would return a falsy + value, so explicitly calling this is not useful. + + The exception case is empty messages explicitly set on the wire, + which are falsy from ``__getattr__``. This method allows to + distinguish between an explicitly provided empty message and the + absence of that message, which is useful in some edge cases. + + The most common edge case is the use of ``google.protobuf.BoolValue`` + to get a boolean that distinguishes between ``False`` and ``None`` + (or the same for a string, int, etc.). This library transparently + handles that case for you, but this method remains available to + accommodate cases not automatically covered. + + Args: + key (str): The name of the field. + + Returns: + bool: Whether the field's value corresponds to a non-empty + wire serialization. + """ + pb_value = getattr(self._pb, key) + try: + # Protocol buffers "HasField" is unfriendly; it only works + # against composite, non-repeated fields, and raises ValueError + # against any repeated field or primitive. + # + # There is no good way to test whether it is valid to provide + # a field to this method, so sadly we are stuck with a + # somewhat inefficient try/except. + return self._pb.HasField(key) + except ValueError: + return bool(pb_value) + + def __delattr__(self, key): + """Delete the value on the given field. + + This is generally equivalent to setting a falsy value. + """ + self._pb.ClearField(key) + + def __eq__(self, other): + """Return True if the messages are equal, False otherwise.""" + # If these are the same type, use internal protobuf's equality check. + if isinstance(other, type(self)): + return self._pb == other._pb + + # If the other type is the target protobuf object, honor that also. + if isinstance(other, self._meta.pb): + return self._pb == other + + # Ask the other object. + return NotImplemented + + def __getattr__(self, key): + """Retrieve the given field's value. + + In protocol buffers, the presence of a field on a message is + sufficient for it to always be "present". + + For primitives, a value of the correct type will always be returned + (the "falsy" values in protocol buffers consistently match those + in Python). For repeated fields, the falsy value is always an empty + sequence. + + For messages, protocol buffers does distinguish between an empty + message and absence, but this distinction is subtle and rarely + relevant. Therefore, this method always returns an empty message + (following the official implementation). To check for message + presence, use ``key in self`` (in other words, ``__contains__``). + + .. note:: + + Some well-known protocol buffer types + (e.g. ``google.protobuf.Timestamp``) will be converted to + their Python equivalents. See the ``marshal`` module for + more details. + """ + (key, pb_type) = self._get_pb_type_from_key(key) + if pb_type is None: + raise AttributeError( + "Unknown field for {}: {}".format(self.__class__.__name__, key) + ) + pb_value = getattr(self._pb, key) + marshal = self._meta.marshal + return marshal.to_python(pb_type, pb_value, absent=key not in self) + + def __ne__(self, other): + """Return True if the messages are unequal, False otherwise.""" + return not self == other + + def __repr__(self): + return repr(self._pb) + + def __setattr__(self, key, value): + """Set the value on the given field. + + For well-known protocol buffer types which are marshalled, either + the protocol buffer object or the Python equivalent is accepted. + """ + if key[0] == "_": + return super().__setattr__(key, value) + marshal = self._meta.marshal + (key, pb_type) = self._get_pb_type_from_key(key) + if pb_type is None: + raise AttributeError( + "Unknown field for {}: {}".format(self.__class__.__name__, key) + ) + + pb_value = marshal.to_proto(pb_type, value) + + # Clear the existing field. + # This is the only way to successfully write nested falsy values, + # because otherwise MergeFrom will no-op on them. + self._pb.ClearField(key) + + # Merge in the value being set. + if pb_value is not None: + self._pb.MergeFrom(self._meta.pb(**{key: pb_value})) + + def __getstate__(self): + """Serialize for pickling.""" + return self._pb.SerializeToString() + + def __setstate__(self, value): + """Deserialization for pickling.""" + new_pb = self._meta.pb().FromString(value) + super().__setattr__("_pb", new_pb) + + +class _MessageInfo: + """Metadata about a message. + + Args: + fields (Tuple[~.fields.Field]): The fields declared on the message. + package (str): The proto package. + full_name (str): The full name of the message. + file_info (~._FileInfo): The file descriptor and messages for the + file containing this message. + marshal (~.Marshal): The marshal instance to which this message was + automatically registered. + options (~.descriptor_pb2.MessageOptions): Any options that were + set on the message. + """ + + def __init__( + self, + *, + fields: List[Field], + package: str, + full_name: str, + marshal: Marshal, + options: descriptor_pb2.MessageOptions, + ) -> None: + self.package = package + self.full_name = full_name + self.options = options + self.fields = collections.OrderedDict((i.name, i) for i in fields) + self.fields_by_number = collections.OrderedDict((i.number, i) for i in fields) + self.marshal = marshal + self._pb = None + + @property + def pb(self) -> Type[message.Message]: + """Return the protobuf message type for this descriptor. + + If a field on the message references another message which has not + loaded, then this method returns None. + """ + return self._pb + + +__all__ = ("Message",) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/modules.py b/evalkit_tf437/lib/python3.10/site-packages/proto/modules.py new file mode 100644 index 0000000000000000000000000000000000000000..45864a937c589242e12a694263e9e1e2f167c911 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/modules.py @@ -0,0 +1,50 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Set +import collections + + +_ProtoModule = collections.namedtuple( + "ProtoModule", + ["package", "marshal", "manifest"], +) + + +def define_module( + *, package: str, marshal: str = None, manifest: Set[str] = frozenset() +) -> _ProtoModule: + """Define a protocol buffers module. + + The settings defined here are used for all protobuf messages + declared in the module of the given name. + + Args: + package (str): The proto package name. + marshal (str): The name of the marshal to use. It is recommended + to use one marshal per Python library (e.g. package on PyPI). + manifest (Set[str]): A set of messages and enums to be created. Setting + this adds a slight efficiency in piecing together proto + descriptors under the hood. + """ + if not marshal: + marshal = package + return _ProtoModule( + package=package, + marshal=marshal, + manifest=frozenset(manifest), + ) + + +__all__ = ("define_module",) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/utils.py b/evalkit_tf437/lib/python3.10/site-packages/proto/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..ac3c471a2e8b5e2792175f4aa25220efba422264 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/utils.py @@ -0,0 +1,58 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools + + +def has_upb(): + try: + from google._upb import _message # pylint: disable=unused-import + + has_upb = True + except ImportError: + has_upb = False + return has_upb + + +def cached_property(fx): + """Make the callable into a cached property. + + Similar to @property, but the function will only be called once per + object. + + Args: + fx (Callable[]): The property function. + + Returns: + Callable[]: The wrapped function. + """ + + @functools.wraps(fx) + def inner(self): + # Sanity check: If there is no cache at all, create an empty cache. + if not hasattr(self, "_cached_values"): + object.__setattr__(self, "_cached_values", {}) + + # If and only if the function's result is not in the cache, + # run the function. + if fx.__name__ not in self._cached_values: + self._cached_values[fx.__name__] = fx(self) + + # Return the value from cache. + return self._cached_values[fx.__name__] + + return property(inner) + + +__all__ = ("cached_property",) diff --git a/evalkit_tf437/lib/python3.10/site-packages/proto/version.py b/evalkit_tf437/lib/python3.10/site-packages/proto/version.py new file mode 100644 index 0000000000000000000000000000000000000000..ab2f7680f17272c7799b27455fa289f9b7d1cc48 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/proto/version.py @@ -0,0 +1,15 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "1.25.0" diff --git a/evalkit_tf437/lib/python3.10/site-packages/regex/__init__.py b/evalkit_tf437/lib/python3.10/site-packages/regex/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..eb06564ab033a2b0b501f7f41efb169dacd1f801 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/regex/__init__.py @@ -0,0 +1,3 @@ +from .regex import * +from . import regex +__all__ = regex.__all__ diff --git a/evalkit_tf437/lib/python3.10/site-packages/regex/__pycache__/regex.cpython-310.pyc b/evalkit_tf437/lib/python3.10/site-packages/regex/__pycache__/regex.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3f8bd0cae20d56f8093ab4d65068ece81d4bf7d6 Binary files /dev/null and b/evalkit_tf437/lib/python3.10/site-packages/regex/__pycache__/regex.cpython-310.pyc differ diff --git a/evalkit_tf437/lib/python3.10/site-packages/regex/regex.py b/evalkit_tf437/lib/python3.10/site-packages/regex/regex.py new file mode 100644 index 0000000000000000000000000000000000000000..0fdb4da983c495d15db51e593ec880c8513ed55f --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/regex/regex.py @@ -0,0 +1,746 @@ +# +# Secret Labs' Regular Expression Engine +# +# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. +# +# This version of the SRE library can be redistributed under CNRI's +# Python 1.6 license. For any other use, please contact Secret Labs +# AB (info@pythonware.com). +# +# Portions of this engine have been developed in cooperation with +# CNRI. Hewlett-Packard provided funding for 1.6 integration and +# other compatibility work. +# +# 2010-01-16 mrab Python front-end re-written and extended + +r"""Support for regular expressions (RE). + +This module provides regular expression matching operations similar to those +found in Perl. It supports both 8-bit and Unicode strings; both the pattern and +the strings being processed can contain null bytes and characters outside the +US ASCII range. + +Regular expressions can contain both special and ordinary characters. Most +ordinary characters, like "A", "a", or "0", are the simplest regular +expressions; they simply match themselves. You can concatenate ordinary +characters, so last matches the string 'last'. + +There are a few differences between the old (legacy) behaviour and the new +(enhanced) behaviour, which are indicated by VERSION0 or VERSION1. + +The special characters are: + "." Matches any character except a newline. + "^" Matches the start of the string. + "$" Matches the end of the string or just before the + newline at the end of the string. + "*" Matches 0 or more (greedy) repetitions of the preceding + RE. Greedy means that it will match as many repetitions + as possible. + "+" Matches 1 or more (greedy) repetitions of the preceding + RE. + "?" Matches 0 or 1 (greedy) of the preceding RE. + *?,+?,?? Non-greedy versions of the previous three special + characters. + *+,++,?+ Possessive versions of the previous three special + characters. + {m,n} Matches from m to n repetitions of the preceding RE. + {m,n}? Non-greedy version of the above. + {m,n}+ Possessive version of the above. + {...} Fuzzy matching constraints. + "\\" Either escapes special characters or signals a special + sequence. + [...] Indicates a set of characters. A "^" as the first + character indicates a complementing set. + "|" A|B, creates an RE that will match either A or B. + (...) Matches the RE inside the parentheses. The contents are + captured and can be retrieved or matched later in the + string. + (?flags-flags) VERSION1: Sets/clears the flags for the remainder of + the group or pattern; VERSION0: Sets the flags for the + entire pattern. + (?:...) Non-capturing version of regular parentheses. + (?>...) Atomic non-capturing version of regular parentheses. + (?flags-flags:...) Non-capturing version of regular parentheses with local + flags. + (?P...) The substring matched by the group is accessible by + name. + (?...) The substring matched by the group is accessible by + name. + (?P=name) Matches the text matched earlier by the group named + name. + (?#...) A comment; ignored. + (?=...) Matches if ... matches next, but doesn't consume the + string. + (?!...) Matches if ... doesn't match next. + (?<=...) Matches if preceded by .... + (? Matches the text matched by the group named name. + \G Matches the empty string, but only at the position where + the search started. + \h Matches horizontal whitespace. + \K Keeps only what follows for the entire match. + \L Named list. The list is provided as a keyword argument. + \m Matches the empty string, but only at the start of a word. + \M Matches the empty string, but only at the end of a word. + \n Matches the newline character. + \N{name} Matches the named character. + \p{name=value} Matches the character if its property has the specified + value. + \P{name=value} Matches the character if its property hasn't the specified + value. + \r Matches the carriage-return character. + \s Matches any whitespace character; equivalent to + [ \t\n\r\f\v]. + \S Matches any non-whitespace character; equivalent to [^\s]. + \t Matches the tab character. + \uXXXX Matches the Unicode codepoint with 4-digit hex code XXXX. + \UXXXXXXXX Matches the Unicode codepoint with 8-digit hex code + XXXXXXXX. + \v Matches the vertical tab character. + \w Matches any alphanumeric character; equivalent to + [a-zA-Z0-9_] when matching a bytestring or a Unicode string + with the ASCII flag, or the whole range of Unicode + alphanumeric characters (letters plus digits plus + underscore) when matching a Unicode string. With LOCALE, it + will match the set [0-9_] plus characters defined as + letters for the current locale. + \W Matches the complement of \w; equivalent to [^\w]. + \xXX Matches the character with 2-digit hex code XX. + \X Matches a grapheme. + \Z Matches only at the end of the string. + \\ Matches a literal backslash. + +This module exports the following functions: + match Match a regular expression pattern at the beginning of a string. + fullmatch Match a regular expression pattern against all of a string. + search Search a string for the presence of a pattern. + sub Substitute occurrences of a pattern found in a string using a + template string. + subf Substitute occurrences of a pattern found in a string using a + format string. + subn Same as sub, but also return the number of substitutions made. + subfn Same as subf, but also return the number of substitutions made. + split Split a string by the occurrences of a pattern. VERSION1: will + split at zero-width match; VERSION0: won't split at zero-width + match. + splititer Return an iterator yielding the parts of a split string. + findall Find all occurrences of a pattern in a string. + finditer Return an iterator yielding a match object for each match. + compile Compile a pattern into a Pattern object. + purge Clear the regular expression cache. + escape Backslash all non-alphanumerics or special characters in a + string. + +Most of the functions support a concurrent parameter: if True, the GIL will be +released during matching, allowing other Python threads to run concurrently. If +the string changes during matching, the behaviour is undefined. This parameter +is not needed when working on the builtin (immutable) string classes. + +Some of the functions in this module take flags as optional parameters. Most of +these flags can also be set within an RE: + A a ASCII Make \w, \W, \b, \B, \d, and \D match the + corresponding ASCII character categories. Default + when matching a bytestring. + B b BESTMATCH Find the best fuzzy match (default is first). + D DEBUG Print the parsed pattern. + E e ENHANCEMATCH Attempt to improve the fit after finding the first + fuzzy match. + F f FULLCASE Use full case-folding when performing + case-insensitive matching in Unicode. + I i IGNORECASE Perform case-insensitive matching. + L L LOCALE Make \w, \W, \b, \B, \d, and \D dependent on the + current locale. (One byte per character only.) + M m MULTILINE "^" matches the beginning of lines (after a newline) + as well as the string. "$" matches the end of lines + (before a newline) as well as the end of the string. + P p POSIX Perform POSIX-standard matching (leftmost longest). + R r REVERSE Searches backwards. + S s DOTALL "." matches any character at all, including the + newline. + U u UNICODE Make \w, \W, \b, \B, \d, and \D dependent on the + Unicode locale. Default when matching a Unicode + string. + V0 V0 VERSION0 Turn on the old legacy behaviour. + V1 V1 VERSION1 Turn on the new enhanced behaviour. This flag + includes the FULLCASE flag. + W w WORD Make \b and \B work with default Unicode word breaks + and make ".", "^" and "$" work with Unicode line + breaks. + X x VERBOSE Ignore whitespace and comments for nicer looking REs. + +This module also defines an exception 'error'. + +""" + +# Public symbols. +__all__ = ["cache_all", "compile", "DEFAULT_VERSION", "escape", "findall", + "finditer", "fullmatch", "match", "purge", "search", "split", "splititer", + "sub", "subf", "subfn", "subn", "template", "Scanner", "A", "ASCII", "B", + "BESTMATCH", "D", "DEBUG", "E", "ENHANCEMATCH", "S", "DOTALL", "F", + "FULLCASE", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", "P", "POSIX", + "R", "REVERSE", "T", "TEMPLATE", "U", "UNICODE", "V0", "VERSION0", "V1", + "VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__", + "__doc__", "RegexFlag"] + +__version__ = "2.5.148" + +# -------------------------------------------------------------------- +# Public interface. + +def match(pattern, string, flags=0, pos=None, endpos=None, partial=False, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Try to apply the pattern at the start of the string, returning a match + object, or None if no match was found.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.match(string, pos, endpos, concurrent, partial, timeout) + +def fullmatch(pattern, string, flags=0, pos=None, endpos=None, partial=False, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Try to apply the pattern against all of the string, returning a match + object, or None if no match was found.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.fullmatch(string, pos, endpos, concurrent, partial, timeout) + +def search(pattern, string, flags=0, pos=None, endpos=None, partial=False, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Search through string looking for a match to the pattern, returning a + match object, or None if no match was found.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.search(string, pos, endpos, concurrent, partial, timeout) + +def sub(pattern, repl, string, count=0, flags=0, pos=None, endpos=None, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return the string obtained by replacing the leftmost (or rightmost with a + reverse pattern) non-overlapping occurrences of the pattern in string by the + replacement repl. repl can be either a string or a callable; if a string, + backslash escapes in it are processed; if a callable, it's passed the match + object and must return a replacement string to be used.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.sub(repl, string, count, pos, endpos, concurrent, timeout) + +def subf(pattern, format, string, count=0, flags=0, pos=None, endpos=None, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return the string obtained by replacing the leftmost (or rightmost with a + reverse pattern) non-overlapping occurrences of the pattern in string by the + replacement format. format can be either a string or a callable; if a string, + it's treated as a format string; if a callable, it's passed the match object + and must return a replacement string to be used.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.subf(format, string, count, pos, endpos, concurrent, timeout) + +def subn(pattern, repl, string, count=0, flags=0, pos=None, endpos=None, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return a 2-tuple containing (new_string, number). new_string is the string + obtained by replacing the leftmost (or rightmost with a reverse pattern) + non-overlapping occurrences of the pattern in the source string by the + replacement repl. number is the number of substitutions that were made. repl + can be either a string or a callable; if a string, backslash escapes in it + are processed; if a callable, it's passed the match object and must return a + replacement string to be used.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.subn(repl, string, count, pos, endpos, concurrent, timeout) + +def subfn(pattern, format, string, count=0, flags=0, pos=None, endpos=None, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return a 2-tuple containing (new_string, number). new_string is the string + obtained by replacing the leftmost (or rightmost with a reverse pattern) + non-overlapping occurrences of the pattern in the source string by the + replacement format. number is the number of substitutions that were made. format + can be either a string or a callable; if a string, it's treated as a format + string; if a callable, it's passed the match object and must return a + replacement string to be used.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.subfn(format, string, count, pos, endpos, concurrent, timeout) + +def split(pattern, string, maxsplit=0, flags=0, concurrent=None, timeout=None, + ignore_unused=False, **kwargs): + """Split the source string by the occurrences of the pattern, returning a + list containing the resulting substrings. If capturing parentheses are used + in pattern, then the text of all groups in the pattern are also returned as + part of the resulting list. If maxsplit is nonzero, at most maxsplit splits + occur, and the remainder of the string is returned as the final element of + the list.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.split(string, maxsplit, concurrent, timeout) + +def splititer(pattern, string, maxsplit=0, flags=0, concurrent=None, + timeout=None, ignore_unused=False, **kwargs): + "Return an iterator yielding the parts of a split string." + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.splititer(string, maxsplit, concurrent, timeout) + +def findall(pattern, string, flags=0, pos=None, endpos=None, overlapped=False, + concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return a list of all matches in the string. The matches may be overlapped + if overlapped is True. If one or more groups are present in the pattern, + return a list of groups; this will be a list of tuples if the pattern has + more than one group. Empty matches are included in the result.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.findall(string, pos, endpos, overlapped, concurrent, timeout) + +def finditer(pattern, string, flags=0, pos=None, endpos=None, overlapped=False, + partial=False, concurrent=None, timeout=None, ignore_unused=False, **kwargs): + """Return an iterator over all matches in the string. The matches may be + overlapped if overlapped is True. For each match, the iterator returns a + match object. Empty matches are included in the result.""" + pat = _compile(pattern, flags, ignore_unused, kwargs, True) + return pat.finditer(string, pos, endpos, overlapped, concurrent, partial, + timeout) + +def compile(pattern, flags=0, ignore_unused=False, cache_pattern=None, **kwargs): + "Compile a regular expression pattern, returning a pattern object." + if cache_pattern is None: + cache_pattern = _cache_all + return _compile(pattern, flags, ignore_unused, kwargs, cache_pattern) + +def purge(): + "Clear the regular expression cache" + _cache.clear() + _locale_sensitive.clear() + +# Whether to cache all patterns. +_cache_all = True + +def cache_all(value=True): + """Sets whether to cache all patterns, even those are compiled explicitly. + Passing None has no effect, but returns the current setting.""" + global _cache_all + + if value is None: + return _cache_all + + _cache_all = value + +def template(pattern, flags=0): + "Compile a template pattern, returning a pattern object." + return _compile(pattern, flags | TEMPLATE, False, {}, False) + +def escape(pattern, special_only=True, literal_spaces=False): + """Escape a string for use as a literal in a pattern. If special_only is + True, escape only special characters, else escape all non-alphanumeric + characters. If literal_spaces is True, don't escape spaces.""" + # Convert it to Unicode. + if isinstance(pattern, bytes): + p = pattern.decode("latin-1") + else: + p = pattern + + s = [] + if special_only: + for c in p: + if c == " " and literal_spaces: + s.append(c) + elif c in _METACHARS or c.isspace(): + s.append("\\") + s.append(c) + else: + s.append(c) + else: + for c in p: + if c == " " and literal_spaces: + s.append(c) + elif c in _ALNUM: + s.append(c) + else: + s.append("\\") + s.append(c) + + r = "".join(s) + # Convert it back to bytes if necessary. + if isinstance(pattern, bytes): + r = r.encode("latin-1") + + return r + +# -------------------------------------------------------------------- +# Internals. + +import regex._regex_core as _regex_core +import regex._regex as _regex +from threading import RLock as _RLock +from locale import getpreferredencoding as _getpreferredencoding +from regex._regex_core import * +from regex._regex_core import (_ALL_VERSIONS, _ALL_ENCODINGS, _FirstSetError, + _UnscopedFlagSet, _check_group_features, _compile_firstset, + _compile_replacement, _flatten_code, _fold_case, _get_required_string, + _parse_pattern, _shrink_cache) +from regex._regex_core import (ALNUM as _ALNUM, Info as _Info, OP as _OP, Source + as _Source, Fuzzy as _Fuzzy) + +# Version 0 is the old behaviour, compatible with the original 're' module. +# Version 1 is the new behaviour, which differs slightly. + +DEFAULT_VERSION = VERSION0 + +_METACHARS = frozenset("()[]{}?*+|^$\\.-#&~") + +_regex_core.DEFAULT_VERSION = DEFAULT_VERSION + +# Caches for the patterns and replacements. +_cache = {} +_cache_lock = _RLock() +_named_args = {} +_replacement_cache = {} +_locale_sensitive = {} + +# Maximum size of the cache. +_MAXCACHE = 500 +_MAXREPCACHE = 500 + +def _compile(pattern, flags, ignore_unused, kwargs, cache_it): + "Compiles a regular expression to a PatternObject." + + global DEFAULT_VERSION + try: + from regex import DEFAULT_VERSION + except ImportError: + pass + + # We won't bother to cache the pattern if we're debugging. + if (flags & DEBUG) != 0: + cache_it = False + + # What locale is this pattern using? + locale_key = (type(pattern), pattern) + if _locale_sensitive.get(locale_key, True) or (flags & LOCALE) != 0: + # This pattern is, or might be, locale-sensitive. + pattern_locale = _getpreferredencoding() + else: + # This pattern is definitely not locale-sensitive. + pattern_locale = None + + def complain_unused_args(): + if ignore_unused: + return + + # Complain about any unused keyword arguments, possibly resulting from a typo. + unused_kwargs = set(kwargs) - {k for k, v in args_needed} + if unused_kwargs: + any_one = next(iter(unused_kwargs)) + raise ValueError('unused keyword argument {!a}'.format(any_one)) + + if cache_it: + try: + # Do we know what keyword arguments are needed? + args_key = pattern, type(pattern), flags + args_needed = _named_args[args_key] + + # Are we being provided with its required keyword arguments? + args_supplied = set() + if args_needed: + for k, v in args_needed: + try: + args_supplied.add((k, frozenset(kwargs[k]))) + except KeyError: + raise error("missing named list: {!r}".format(k)) + + complain_unused_args() + + args_supplied = frozenset(args_supplied) + + # Have we already seen this regular expression and named list? + pattern_key = (pattern, type(pattern), flags, args_supplied, + DEFAULT_VERSION, pattern_locale) + return _cache[pattern_key] + except KeyError: + # It's a new pattern, or new named list for a known pattern. + pass + + # Guess the encoding from the class of the pattern string. + if isinstance(pattern, str): + guess_encoding = UNICODE + elif isinstance(pattern, bytes): + guess_encoding = ASCII + elif isinstance(pattern, Pattern): + if flags: + raise ValueError("cannot process flags argument with a compiled pattern") + + return pattern + else: + raise TypeError("first argument must be a string or compiled pattern") + + # Set the default version in the core code in case it has been changed. + _regex_core.DEFAULT_VERSION = DEFAULT_VERSION + + global_flags = flags + + while True: + caught_exception = None + try: + source = _Source(pattern) + info = _Info(global_flags, source.char_type, kwargs) + info.guess_encoding = guess_encoding + source.ignore_space = bool(info.flags & VERBOSE) + parsed = _parse_pattern(source, info) + break + except _UnscopedFlagSet: + # Remember the global flags for the next attempt. + global_flags = info.global_flags + except error as e: + caught_exception = e + + if caught_exception: + raise error(caught_exception.msg, caught_exception.pattern, + caught_exception.pos) + + if not source.at_end(): + raise error("unbalanced parenthesis", pattern, source.pos) + + # Check the global flags for conflicts. + version = (info.flags & _ALL_VERSIONS) or DEFAULT_VERSION + if version not in (0, VERSION0, VERSION1): + raise ValueError("VERSION0 and VERSION1 flags are mutually incompatible") + + if (info.flags & _ALL_ENCODINGS) not in (0, ASCII, LOCALE, UNICODE): + raise ValueError("ASCII, LOCALE and UNICODE flags are mutually incompatible") + + if isinstance(pattern, bytes) and (info.flags & UNICODE): + raise ValueError("cannot use UNICODE flag with a bytes pattern") + + if not (info.flags & _ALL_ENCODINGS): + if isinstance(pattern, str): + info.flags |= UNICODE + else: + info.flags |= ASCII + + reverse = bool(info.flags & REVERSE) + fuzzy = isinstance(parsed, _Fuzzy) + + # Remember whether this pattern as an inline locale flag. + _locale_sensitive[locale_key] = info.inline_locale + + # Fix the group references. + caught_exception = None + try: + parsed.fix_groups(pattern, reverse, False) + except error as e: + caught_exception = e + + if caught_exception: + raise error(caught_exception.msg, caught_exception.pattern, + caught_exception.pos) + + # Should we print the parsed pattern? + if flags & DEBUG: + parsed.dump(indent=0, reverse=reverse) + + # Optimise the parsed pattern. + parsed = parsed.optimise(info, reverse) + parsed = parsed.pack_characters(info) + + # Get the required string. + req_offset, req_chars, req_flags = _get_required_string(parsed, info.flags) + + # Build the named lists. + named_lists = {} + named_list_indexes = [None] * len(info.named_lists_used) + args_needed = set() + for key, index in info.named_lists_used.items(): + name, case_flags = key + values = frozenset(kwargs[name]) + if case_flags: + items = frozenset(_fold_case(info, v) for v in values) + else: + items = values + named_lists[name] = values + named_list_indexes[index] = items + args_needed.add((name, values)) + + complain_unused_args() + + # Check the features of the groups. + _check_group_features(info, parsed) + + # Compile the parsed pattern. The result is a list of tuples. + code = parsed.compile(reverse) + + # Is there a group call to the pattern as a whole? + key = (0, reverse, fuzzy) + ref = info.call_refs.get(key) + if ref is not None: + code = [(_OP.CALL_REF, ref)] + code + [(_OP.END, )] + + # Add the final 'success' opcode. + code += [(_OP.SUCCESS, )] + + # Compile the additional copies of the groups that we need. + for group, rev, fuz in info.additional_groups: + code += group.compile(rev, fuz) + + # Flatten the code into a list of ints. + code = _flatten_code(code) + + if not parsed.has_simple_start(): + # Get the first set, if possible. + try: + fs_code = _compile_firstset(info, parsed.get_firstset(reverse)) + fs_code = _flatten_code(fs_code) + code = fs_code + code + except _FirstSetError: + pass + + # The named capture groups. + index_group = dict((v, n) for n, v in info.group_index.items()) + + # Create the PatternObject. + # + # Local flags like IGNORECASE affect the code generation, but aren't needed + # by the PatternObject itself. Conversely, global flags like LOCALE _don't_ + # affect the code generation but _are_ needed by the PatternObject. + compiled_pattern = _regex.compile(pattern, info.flags | version, code, + info.group_index, index_group, named_lists, named_list_indexes, + req_offset, req_chars, req_flags, info.group_count) + + # Do we need to reduce the size of the cache? + if len(_cache) >= _MAXCACHE: + with _cache_lock: + _shrink_cache(_cache, _named_args, _locale_sensitive, _MAXCACHE) + + if cache_it: + if (info.flags & LOCALE) == 0: + pattern_locale = None + + args_needed = frozenset(args_needed) + + # Store this regular expression and named list. + pattern_key = (pattern, type(pattern), flags, args_needed, + DEFAULT_VERSION, pattern_locale) + _cache[pattern_key] = compiled_pattern + + # Store what keyword arguments are needed. + _named_args[args_key] = args_needed + + return compiled_pattern + +def _compile_replacement_helper(pattern, template): + "Compiles a replacement template." + # This function is called by the _regex module. + + # Have we seen this before? + key = pattern.pattern, pattern.flags, template + compiled = _replacement_cache.get(key) + if compiled is not None: + return compiled + + if len(_replacement_cache) >= _MAXREPCACHE: + _replacement_cache.clear() + + is_unicode = isinstance(template, str) + source = _Source(template) + if is_unicode: + def make_string(char_codes): + return "".join(chr(c) for c in char_codes) + else: + def make_string(char_codes): + return bytes(char_codes) + + compiled = [] + literal = [] + while True: + ch = source.get() + if not ch: + break + if ch == "\\": + # '_compile_replacement' will return either an int group reference + # or a string literal. It returns items (plural) in order to handle + # a 2-character literal (an invalid escape sequence). + is_group, items = _compile_replacement(source, pattern, is_unicode) + if is_group: + # It's a group, so first flush the literal. + if literal: + compiled.append(make_string(literal)) + literal = [] + compiled.extend(items) + else: + literal.extend(items) + else: + literal.append(ord(ch)) + + # Flush the literal. + if literal: + compiled.append(make_string(literal)) + + _replacement_cache[key] = compiled + + return compiled + +# We define Pattern here after all the support objects have been defined. +_pat = _compile('', 0, False, {}, False) +Pattern = type(_pat) +Match = type(_pat.match('')) +del _pat + +# Make Pattern public for typing annotations. +__all__.append("Pattern") +__all__.append("Match") + +# We'll define an alias for the 'compile' function so that the repr of a +# pattern object is eval-able. +Regex = compile + +# Register myself for pickling. +import copyreg as _copy_reg + +def _pickle(pattern): + return _regex.compile, pattern._pickled_data + +_copy_reg.pickle(Pattern, _pickle) diff --git a/evalkit_tf437/lib/python3.10/site-packages/regex/test_regex.py b/evalkit_tf437/lib/python3.10/site-packages/regex/test_regex.py new file mode 100644 index 0000000000000000000000000000000000000000..bce5a871164919ca910c2b02b9cfd3c58e5912b8 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/regex/test_regex.py @@ -0,0 +1,4488 @@ +from weakref import proxy +import copy +import pickle +import regex +import string +import sys +import unittest + +# String subclasses for issue 18468. +class StrSubclass(str): + def __getitem__(self, index): + return StrSubclass(super().__getitem__(index)) + +class BytesSubclass(bytes): + def __getitem__(self, index): + return BytesSubclass(super().__getitem__(index)) + +class RegexTests(unittest.TestCase): + PATTERN_CLASS = "" + FLAGS_WITH_COMPILED_PAT = "cannot process flags argument with a compiled pattern" + INVALID_GROUP_REF = "invalid group reference" + MISSING_GT = "missing >" + BAD_GROUP_NAME = "bad character in group name" + MISSING_GROUP_NAME = "missing group name" + MISSING_LT = "missing <" + UNKNOWN_GROUP_I = "unknown group" + UNKNOWN_GROUP = "unknown group" + BAD_ESCAPE = r"bad escape \(end of pattern\)" + BAD_OCTAL_ESCAPE = r"bad escape \\" + BAD_SET = "unterminated character set" + STR_PAT_ON_BYTES = "cannot use a string pattern on a bytes-like object" + BYTES_PAT_ON_STR = "cannot use a bytes pattern on a string-like object" + STR_PAT_BYTES_TEMPL = "expected str instance, bytes found" + BYTES_PAT_STR_TEMPL = "expected a bytes-like object, str found" + BYTES_PAT_UNI_FLAG = "cannot use UNICODE flag with a bytes pattern" + MIXED_FLAGS = "ASCII, LOCALE and UNICODE flags are mutually incompatible" + MISSING_RPAREN = "missing \\)" + TRAILING_CHARS = "unbalanced parenthesis" + BAD_CHAR_RANGE = "bad character range" + NOTHING_TO_REPEAT = "nothing to repeat" + MULTIPLE_REPEAT = "multiple repeat" + OPEN_GROUP = "cannot refer to an open group" + DUPLICATE_GROUP = "duplicate group" + CANT_TURN_OFF = "bad inline flags: cannot turn flags off" + UNDEF_CHAR_NAME = "undefined character name" + + def assertTypedEqual(self, actual, expect, msg=None): + self.assertEqual(actual, expect, msg) + + def recurse(actual, expect): + if isinstance(expect, (tuple, list)): + for x, y in zip(actual, expect): + recurse(x, y) + else: + self.assertIs(type(actual), type(expect), msg) + + recurse(actual, expect) + + def test_weakref(self): + s = 'QabbbcR' + x = regex.compile('ab+c') + y = proxy(x) + if x.findall('QabbbcR') != y.findall('QabbbcR'): + self.fail() + + def test_search_star_plus(self): + self.assertEqual(regex.search('a*', 'xxx').span(0), (0, 0)) + self.assertEqual(regex.search('x*', 'axx').span(), (0, 0)) + self.assertEqual(regex.search('x+', 'axx').span(0), (1, 3)) + self.assertEqual(regex.search('x+', 'axx').span(), (1, 3)) + self.assertEqual(regex.search('x', 'aaa'), None) + self.assertEqual(regex.match('a*', 'xxx').span(0), (0, 0)) + self.assertEqual(regex.match('a*', 'xxx').span(), (0, 0)) + self.assertEqual(regex.match('x*', 'xxxa').span(0), (0, 3)) + self.assertEqual(regex.match('x*', 'xxxa').span(), (0, 3)) + self.assertEqual(regex.match('a+', 'xxx'), None) + + def bump_num(self, matchobj): + int_value = int(matchobj[0]) + return str(int_value + 1) + + def test_basic_regex_sub(self): + self.assertEqual(regex.sub("(?i)b+", "x", "bbbb BBBB"), 'x x') + self.assertEqual(regex.sub(r'\d+', self.bump_num, '08.2 -2 23x99y'), + '9.3 -3 24x100y') + self.assertEqual(regex.sub(r'\d+', self.bump_num, '08.2 -2 23x99y', 3), + '9.3 -3 23x99y') + + self.assertEqual(regex.sub('.', lambda m: r"\n", 'x'), "\\n") + self.assertEqual(regex.sub('.', r"\n", 'x'), "\n") + + self.assertEqual(regex.sub('(?Px)', r'\g\g', 'xx'), 'xxxx') + self.assertEqual(regex.sub('(?Px)', r'\g\g<1>', 'xx'), 'xxxx') + self.assertEqual(regex.sub('(?Px)', r'\g\g', 'xx'), + 'xxxx') + self.assertEqual(regex.sub('(?Px)', r'\g<1>\g<1>', 'xx'), 'xxxx') + + self.assertEqual(regex.sub('a', r'\t\n\v\r\f\a\b', 'a'), "\t\n\v\r\f\a\b") + self.assertEqual(regex.sub('a', '\t\n\v\r\f\a', 'a'), "\t\n\v\r\f\a") + self.assertEqual(regex.sub('a', '\t\n\v\r\f\a', 'a'), chr(9) + chr(10) + + chr(11) + chr(13) + chr(12) + chr(7)) + + self.assertEqual(regex.sub(r'^\s*', 'X', 'test'), 'Xtest') + + self.assertEqual(regex.sub(r"x", r"\x0A", "x"), "\n") + self.assertEqual(regex.sub(r"x", r"\u000A", "x"), "\n") + self.assertEqual(regex.sub(r"x", r"\U0000000A", "x"), "\n") + self.assertEqual(regex.sub(r"x", r"\N{LATIN CAPITAL LETTER A}", + "x"), "A") + + self.assertEqual(regex.sub(br"x", br"\x0A", b"x"), b"\n") + + def test_bug_449964(self): + # Fails for group followed by other escape. + self.assertEqual(regex.sub(r'(?Px)', r'\g<1>\g<1>\b', 'xx'), + "xx\bxx\b") + + def test_bug_449000(self): + # Test for sub() on escaped characters. + self.assertEqual(regex.sub(r'\r\n', r'\n', 'abc\r\ndef\r\n'), + "abc\ndef\n") + self.assertEqual(regex.sub('\r\n', r'\n', 'abc\r\ndef\r\n'), + "abc\ndef\n") + self.assertEqual(regex.sub(r'\r\n', '\n', 'abc\r\ndef\r\n'), + "abc\ndef\n") + self.assertEqual(regex.sub('\r\n', '\n', 'abc\r\ndef\r\n'), + "abc\ndef\n") + + def test_bug_1661(self): + # Verify that flags do not get silently ignored with compiled patterns + pattern = regex.compile('.') + self.assertRaisesRegex(ValueError, self.FLAGS_WITH_COMPILED_PAT, + lambda: regex.match(pattern, 'A', regex.I)) + self.assertRaisesRegex(ValueError, self.FLAGS_WITH_COMPILED_PAT, + lambda: regex.search(pattern, 'A', regex.I)) + self.assertRaisesRegex(ValueError, self.FLAGS_WITH_COMPILED_PAT, + lambda: regex.findall(pattern, 'A', regex.I)) + self.assertRaisesRegex(ValueError, self.FLAGS_WITH_COMPILED_PAT, + lambda: regex.compile(pattern, regex.I)) + + def test_bug_3629(self): + # A regex that triggered a bug in the sre-code validator + self.assertEqual(repr(type(regex.compile("(?P)(?(quote))"))), + self.PATTERN_CLASS) + + def test_sub_template_numeric_escape(self): + # Bug 776311 and friends. + self.assertEqual(regex.sub('x', r'\0', 'x'), "\0") + self.assertEqual(regex.sub('x', r'\000', 'x'), "\000") + self.assertEqual(regex.sub('x', r'\001', 'x'), "\001") + self.assertEqual(regex.sub('x', r'\008', 'x'), "\0" + "8") + self.assertEqual(regex.sub('x', r'\009', 'x'), "\0" + "9") + self.assertEqual(regex.sub('x', r'\111', 'x'), "\111") + self.assertEqual(regex.sub('x', r'\117', 'x'), "\117") + + self.assertEqual(regex.sub('x', r'\1111', 'x'), "\1111") + self.assertEqual(regex.sub('x', r'\1111', 'x'), "\111" + "1") + + self.assertEqual(regex.sub('x', r'\00', 'x'), '\x00') + self.assertEqual(regex.sub('x', r'\07', 'x'), '\x07') + self.assertEqual(regex.sub('x', r'\08', 'x'), "\0" + "8") + self.assertEqual(regex.sub('x', r'\09', 'x'), "\0" + "9") + self.assertEqual(regex.sub('x', r'\0a', 'x'), "\0" + "a") + + self.assertEqual(regex.sub('x', r'\400', 'x'), "\u0100") + self.assertEqual(regex.sub('x', r'\777', 'x'), "\u01FF") + self.assertEqual(regex.sub(b'x', br'\400', b'x'), b"\x00") + self.assertEqual(regex.sub(b'x', br'\777', b'x'), b"\xFF") + + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\1', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\8', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\9', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\11', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\18', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\1a', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\90', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\99', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\118', 'x')) # r'\11' + '8' + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\11a', 'x')) + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\181', 'x')) # r'\18' + '1' + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.sub('x', r'\800', 'x')) # r'\80' + '0' + + # In Python 2.3 (etc), these loop endlessly in sre_parser.py. + self.assertEqual(regex.sub('(((((((((((x)))))))))))', r'\11', 'x'), + 'x') + self.assertEqual(regex.sub('((((((((((y))))))))))(.)', r'\118', 'xyz'), + 'xz8') + self.assertEqual(regex.sub('((((((((((y))))))))))(.)', r'\11a', 'xyz'), + 'xza') + + def test_qualified_re_sub(self): + self.assertEqual(regex.sub('a', 'b', 'aaaaa'), 'bbbbb') + self.assertEqual(regex.sub('a', 'b', 'aaaaa', 1), 'baaaa') + + def test_bug_114660(self): + self.assertEqual(regex.sub(r'(\S)\s+(\S)', r'\1 \2', 'hello there'), + 'hello there') + + def test_bug_462270(self): + # Test for empty sub() behaviour, see SF bug #462270 + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.sub('(?V0)x*', '-', 'abxd'), '-a-b--d-') + else: + self.assertEqual(regex.sub('(?V0)x*', '-', 'abxd'), '-a-b-d-') + self.assertEqual(regex.sub('(?V1)x*', '-', 'abxd'), '-a-b--d-') + self.assertEqual(regex.sub('x+', '-', 'abxd'), 'ab-d') + + def test_bug_14462(self): + # chr(255) is a valid identifier in Python 3. + group_name = '\xFF' + self.assertEqual(regex.search(r'(?P<' + group_name + '>a)', + 'abc').group(group_name), 'a') + + def test_symbolic_refs(self): + self.assertRaisesRegex(regex.error, self.MISSING_GT, lambda: + regex.sub('(?Px)', r'\gx)', r'\g<', 'xx')) + self.assertRaisesRegex(regex.error, self.MISSING_LT, lambda: + regex.sub('(?Px)', r'\g', 'xx')) + self.assertRaisesRegex(regex.error, self.BAD_GROUP_NAME, lambda: + regex.sub('(?Px)', r'\g', 'xx')) + self.assertRaisesRegex(regex.error, self.BAD_GROUP_NAME, lambda: + regex.sub('(?Px)', r'\g<1a1>', 'xx')) + self.assertRaisesRegex(IndexError, self.UNKNOWN_GROUP_I, lambda: + regex.sub('(?Px)', r'\g', 'xx')) + + # The new behaviour of unmatched but valid groups is to treat them like + # empty matches in the replacement template, like in Perl. + self.assertEqual(regex.sub('(?Px)|(?Py)', r'\g', 'xx'), '') + self.assertEqual(regex.sub('(?Px)|(?Py)', r'\2', 'xx'), '') + + # The old behaviour was to raise it as an IndexError. + self.assertRaisesRegex(regex.error, self.BAD_GROUP_NAME, lambda: + regex.sub('(?Px)', r'\g<-1>', 'xx')) + + def test_re_subn(self): + self.assertEqual(regex.subn("(?i)b+", "x", "bbbb BBBB"), ('x x', 2)) + self.assertEqual(regex.subn("b+", "x", "bbbb BBBB"), ('x BBBB', 1)) + self.assertEqual(regex.subn("b+", "x", "xyz"), ('xyz', 0)) + self.assertEqual(regex.subn("b*", "x", "xyz"), ('xxxyxzx', 4)) + self.assertEqual(regex.subn("b*", "x", "xyz", 2), ('xxxyz', 2)) + + def test_re_split(self): + self.assertEqual(regex.split(":", ":a:b::c"), ['', 'a', 'b', '', 'c']) + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split(":*", ":a:b::c"), ['', '', 'a', '', + 'b', '', 'c', '']) + self.assertEqual(regex.split("(:*)", ":a:b::c"), ['', ':', '', '', + 'a', ':', '', '', 'b', '::', '', '', 'c', '', '']) + self.assertEqual(regex.split("(?::*)", ":a:b::c"), ['', '', 'a', + '', 'b', '', 'c', '']) + self.assertEqual(regex.split("(:)*", ":a:b::c"), ['', ':', '', + None, 'a', ':', '', None, 'b', ':', '', None, 'c', None, '']) + else: + self.assertEqual(regex.split(":*", ":a:b::c"), ['', 'a', 'b', 'c']) + self.assertEqual(regex.split("(:*)", ":a:b::c"), ['', ':', 'a', + ':', 'b', '::', 'c']) + self.assertEqual(regex.split("(?::*)", ":a:b::c"), ['', 'a', 'b', + 'c']) + self.assertEqual(regex.split("(:)*", ":a:b::c"), ['', ':', 'a', + ':', 'b', ':', 'c']) + self.assertEqual(regex.split("([b:]+)", ":a:b::c"), ['', ':', 'a', + ':b::', 'c']) + self.assertEqual(regex.split("(b)|(:+)", ":a:b::c"), ['', None, ':', + 'a', None, ':', '', 'b', None, '', None, '::', 'c']) + self.assertEqual(regex.split("(?:b)|(?::+)", ":a:b::c"), ['', 'a', '', + '', 'c']) + + self.assertEqual(regex.split("x", "xaxbxc"), ['', 'a', 'b', 'c']) + self.assertEqual([m for m in regex.splititer("x", "xaxbxc")], ['', 'a', + 'b', 'c']) + + self.assertEqual(regex.split("(?r)x", "xaxbxc"), ['c', 'b', 'a', '']) + self.assertEqual([m for m in regex.splititer("(?r)x", "xaxbxc")], ['c', + 'b', 'a', '']) + + self.assertEqual(regex.split("(x)|(y)", "xaxbxc"), ['', 'x', None, 'a', + 'x', None, 'b', 'x', None, 'c']) + self.assertEqual([m for m in regex.splititer("(x)|(y)", "xaxbxc")], + ['', 'x', None, 'a', 'x', None, 'b', 'x', None, 'c']) + + self.assertEqual(regex.split("(?r)(x)|(y)", "xaxbxc"), ['c', 'x', None, + 'b', 'x', None, 'a', 'x', None, '']) + self.assertEqual([m for m in regex.splititer("(?r)(x)|(y)", "xaxbxc")], + ['c', 'x', None, 'b', 'x', None, 'a', 'x', None, '']) + + self.assertEqual(regex.split(r"(?V1)\b", "a b c"), ['', 'a', ' ', 'b', + ' ', 'c', '']) + self.assertEqual(regex.split(r"(?V1)\m", "a b c"), ['', 'a ', 'b ', + 'c']) + self.assertEqual(regex.split(r"(?V1)\M", "a b c"), ['a', ' b', ' c', + '']) + + def test_qualified_re_split(self): + self.assertEqual(regex.split(":", ":a:b::c", 2), ['', 'a', 'b::c']) + self.assertEqual(regex.split(':', 'a:b:c:d', 2), ['a', 'b', 'c:d']) + self.assertEqual(regex.split("(:)", ":a:b::c", 2), ['', ':', 'a', ':', + 'b::c']) + + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split("(:*)", ":a:b::c", 2), ['', ':', '', + '', 'a:b::c']) + else: + self.assertEqual(regex.split("(:*)", ":a:b::c", 2), ['', ':', 'a', + ':', 'b::c']) + + def test_re_findall(self): + self.assertEqual(regex.findall(":+", "abc"), []) + self.assertEqual(regex.findall(":+", "a:b::c:::d"), [':', '::', ':::']) + self.assertEqual(regex.findall("(:+)", "a:b::c:::d"), [':', '::', + ':::']) + self.assertEqual(regex.findall("(:)(:*)", "a:b::c:::d"), [(':', ''), + (':', ':'), (':', '::')]) + + self.assertEqual(regex.findall(r"\((?P.{0,5}?TEST)\)", + "(MY TEST)"), ["MY TEST"]) + self.assertEqual(regex.findall(r"\((?P.{0,3}?TEST)\)", + "(MY TEST)"), ["MY TEST"]) + self.assertEqual(regex.findall(r"\((?P.{0,3}?T)\)", "(MY T)"), + ["MY T"]) + + self.assertEqual(regex.findall(r"[^a]{2}[A-Z]", "\n S"), [' S']) + self.assertEqual(regex.findall(r"[^a]{2,3}[A-Z]", "\n S"), ['\n S']) + self.assertEqual(regex.findall(r"[^a]{2,3}[A-Z]", "\n S"), [' S']) + + self.assertEqual(regex.findall(r"X(Y[^Y]+?){1,2}( |Q)+DEF", + "XYABCYPPQ\nQ DEF"), [('YPPQ\n', ' ')]) + + self.assertEqual(regex.findall(r"(\nTest(\n+.+?){0,2}?)?\n+End", + "\nTest\nxyz\nxyz\nEnd"), [('\nTest\nxyz\nxyz', '\nxyz')]) + + def test_bug_117612(self): + self.assertEqual(regex.findall(r"(a|(b))", "aba"), [('a', ''), ('b', + 'b'), ('a', '')]) + + def test_re_match(self): + self.assertEqual(regex.match('a', 'a')[:], ('a',)) + self.assertEqual(regex.match('(a)', 'a')[:], ('a', 'a')) + self.assertEqual(regex.match(r'(a)', 'a')[0], 'a') + self.assertEqual(regex.match(r'(a)', 'a')[1], 'a') + self.assertEqual(regex.match(r'(a)', 'a').group(1, 1), ('a', 'a')) + + pat = regex.compile('((a)|(b))(c)?') + self.assertEqual(pat.match('a')[:], ('a', 'a', 'a', None, None)) + self.assertEqual(pat.match('b')[:], ('b', 'b', None, 'b', None)) + self.assertEqual(pat.match('ac')[:], ('ac', 'a', 'a', None, 'c')) + self.assertEqual(pat.match('bc')[:], ('bc', 'b', None, 'b', 'c')) + self.assertEqual(pat.match('bc')[:], ('bc', 'b', None, 'b', 'c')) + + # A single group. + m = regex.match('(a)', 'a') + self.assertEqual(m.group(), 'a') + self.assertEqual(m.group(0), 'a') + self.assertEqual(m.group(1), 'a') + self.assertEqual(m.group(1, 1), ('a', 'a')) + + pat = regex.compile('(?:(?Pa)|(?Pb))(?Pc)?') + self.assertEqual(pat.match('a').group(1, 2, 3), ('a', None, None)) + self.assertEqual(pat.match('b').group('a1', 'b2', 'c3'), (None, 'b', + None)) + self.assertEqual(pat.match('ac').group(1, 'b2', 3), ('a', None, 'c')) + + def test_re_groupref_exists(self): + self.assertEqual(regex.match(r'^(\()?([^()]+)(?(1)\))$', '(a)')[:], + ('(a)', '(', 'a')) + self.assertEqual(regex.match(r'^(\()?([^()]+)(?(1)\))$', 'a')[:], ('a', + None, 'a')) + self.assertEqual(regex.match(r'^(\()?([^()]+)(?(1)\))$', 'a)'), None) + self.assertEqual(regex.match(r'^(\()?([^()]+)(?(1)\))$', '(a'), None) + self.assertEqual(regex.match('^(?:(a)|c)((?(1)b|d))$', 'ab')[:], ('ab', + 'a', 'b')) + self.assertEqual(regex.match('^(?:(a)|c)((?(1)b|d))$', 'cd')[:], ('cd', + None, 'd')) + self.assertEqual(regex.match('^(?:(a)|c)((?(1)|d))$', 'cd')[:], ('cd', + None, 'd')) + self.assertEqual(regex.match('^(?:(a)|c)((?(1)|d))$', 'a')[:], ('a', + 'a', '')) + + # Tests for bug #1177831: exercise groups other than the first group. + p = regex.compile('(?Pa)(?Pb)?((?(g2)c|d))') + self.assertEqual(p.match('abc')[:], ('abc', 'a', 'b', 'c')) + self.assertEqual(p.match('ad')[:], ('ad', 'a', None, 'd')) + self.assertEqual(p.match('abd'), None) + self.assertEqual(p.match('ac'), None) + + def test_re_groupref(self): + self.assertEqual(regex.match(r'^(\|)?([^()]+)\1$', '|a|')[:], ('|a|', + '|', 'a')) + self.assertEqual(regex.match(r'^(\|)?([^()]+)\1?$', 'a')[:], ('a', + None, 'a')) + self.assertEqual(regex.match(r'^(\|)?([^()]+)\1$', 'a|'), None) + self.assertEqual(regex.match(r'^(\|)?([^()]+)\1$', '|a'), None) + self.assertEqual(regex.match(r'^(?:(a)|c)(\1)$', 'aa')[:], ('aa', 'a', + 'a')) + self.assertEqual(regex.match(r'^(?:(a)|c)(\1)?$', 'c')[:], ('c', None, + None)) + + self.assertEqual(regex.findall(r"(?i)(.{1,40}?),(.{1,40}?)(?:;)+(.{1,80}).{1,40}?\3(\ |;)+(.{1,80}?)\1", + "TEST, BEST; LEST ; Lest 123 Test, Best"), [('TEST', ' BEST', + ' LEST', ' ', '123 ')]) + + def test_groupdict(self): + self.assertEqual(regex.match('(?Pfirst) (?Psecond)', + 'first second').groupdict(), {'first': 'first', 'second': 'second'}) + + def test_expand(self): + self.assertEqual(regex.match("(?Pfirst) (?Psecond)", + "first second").expand(r"\2 \1 \g \g"), + 'second first second first') + + def test_repeat_minmax(self): + self.assertEqual(regex.match(r"^(\w){1}$", "abc"), None) + self.assertEqual(regex.match(r"^(\w){1}?$", "abc"), None) + self.assertEqual(regex.match(r"^(\w){1,2}$", "abc"), None) + self.assertEqual(regex.match(r"^(\w){1,2}?$", "abc"), None) + + self.assertEqual(regex.match(r"^(\w){3}$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){1,3}$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){1,4}$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){3,4}?$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){3}?$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){1,3}?$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){1,4}?$", "abc")[1], 'c') + self.assertEqual(regex.match(r"^(\w){3,4}?$", "abc")[1], 'c') + + self.assertEqual(regex.match("^x{1}$", "xxx"), None) + self.assertEqual(regex.match("^x{1}?$", "xxx"), None) + self.assertEqual(regex.match("^x{1,2}$", "xxx"), None) + self.assertEqual(regex.match("^x{1,2}?$", "xxx"), None) + + self.assertEqual(regex.match("^x{1}", "xxx")[0], 'x') + self.assertEqual(regex.match("^x{1}?", "xxx")[0], 'x') + self.assertEqual(regex.match("^x{0,1}", "xxx")[0], 'x') + self.assertEqual(regex.match("^x{0,1}?", "xxx")[0], '') + + self.assertEqual(bool(regex.match("^x{3}$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{1,3}$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{1,4}$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{3,4}?$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{3}?$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{1,3}?$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{1,4}?$", "xxx")), True) + self.assertEqual(bool(regex.match("^x{3,4}?$", "xxx")), True) + + self.assertEqual(regex.match("^x{}$", "xxx"), None) + self.assertEqual(bool(regex.match("^x{}$", "x{}")), True) + + def test_getattr(self): + self.assertEqual(regex.compile("(?i)(a)(b)").pattern, '(?i)(a)(b)') + self.assertEqual(regex.compile("(?i)(a)(b)").flags, regex.I | regex.U | + regex.DEFAULT_VERSION) + self.assertEqual(regex.compile(b"(?i)(a)(b)").flags, regex.A | regex.I + | regex.DEFAULT_VERSION) + self.assertEqual(regex.compile("(?i)(a)(b)").groups, 2) + self.assertEqual(regex.compile("(?i)(a)(b)").groupindex, {}) + + self.assertEqual(regex.compile("(?i)(?Pa)(?Pb)").groupindex, + {'first': 1, 'other': 2}) + + self.assertEqual(regex.match("(a)", "a").pos, 0) + self.assertEqual(regex.match("(a)", "a").endpos, 1) + + self.assertEqual(regex.search("b(c)", "abcdef").pos, 0) + self.assertEqual(regex.search("b(c)", "abcdef").endpos, 6) + self.assertEqual(regex.search("b(c)", "abcdef").span(), (1, 3)) + self.assertEqual(regex.search("b(c)", "abcdef").span(1), (2, 3)) + + self.assertEqual(regex.match("(a)", "a").string, 'a') + self.assertEqual(regex.match("(a)", "a").regs, ((0, 1), (0, 1))) + self.assertEqual(repr(type(regex.match("(a)", "a").re)), + self.PATTERN_CLASS) + + # Issue 14260. + p = regex.compile(r'abc(?Pdef)') + p.groupindex["n"] = 0 + self.assertEqual(p.groupindex["n"], 1) + + def test_special_escapes(self): + self.assertEqual(regex.search(r"\b(b.)\b", "abcd abc bcd bx")[1], 'bx') + self.assertEqual(regex.search(r"\B(b.)\B", "abc bcd bc abxd")[1], 'bx') + self.assertEqual(regex.search(br"\b(b.)\b", b"abcd abc bcd bx", + regex.LOCALE)[1], b'bx') + self.assertEqual(regex.search(br"\B(b.)\B", b"abc bcd bc abxd", + regex.LOCALE)[1], b'bx') + self.assertEqual(regex.search(r"\b(b.)\b", "abcd abc bcd bx", + regex.UNICODE)[1], 'bx') + self.assertEqual(regex.search(r"\B(b.)\B", "abc bcd bc abxd", + regex.UNICODE)[1], 'bx') + + self.assertEqual(regex.search(r"^abc$", "\nabc\n", regex.M)[0], 'abc') + self.assertEqual(regex.search(r"^\Aabc\Z$", "abc", regex.M)[0], 'abc') + self.assertEqual(regex.search(r"^\Aabc\Z$", "\nabc\n", regex.M), None) + + self.assertEqual(regex.search(br"\b(b.)\b", b"abcd abc bcd bx")[1], + b'bx') + self.assertEqual(regex.search(br"\B(b.)\B", b"abc bcd bc abxd")[1], + b'bx') + self.assertEqual(regex.search(br"^abc$", b"\nabc\n", regex.M)[0], + b'abc') + self.assertEqual(regex.search(br"^\Aabc\Z$", b"abc", regex.M)[0], + b'abc') + self.assertEqual(regex.search(br"^\Aabc\Z$", b"\nabc\n", regex.M), + None) + + self.assertEqual(regex.search(r"\d\D\w\W\s\S", "1aa! a")[0], '1aa! a') + self.assertEqual(regex.search(br"\d\D\w\W\s\S", b"1aa! a", + regex.LOCALE)[0], b'1aa! a') + self.assertEqual(regex.search(r"\d\D\w\W\s\S", "1aa! a", + regex.UNICODE)[0], '1aa! a') + + def test_bigcharset(self): + self.assertEqual(regex.match(r"([\u2222\u2223])", "\u2222")[1], + '\u2222') + self.assertEqual(regex.match(r"([\u2222\u2223])", "\u2222", + regex.UNICODE)[1], '\u2222') + self.assertEqual("".join(regex.findall(".", + "e\xe8\xe9\xea\xeb\u0113\u011b\u0117", flags=regex.UNICODE)), + 'e\xe8\xe9\xea\xeb\u0113\u011b\u0117') + self.assertEqual("".join(regex.findall(r"[e\xe8\xe9\xea\xeb\u0113\u011b\u0117]", + "e\xe8\xe9\xea\xeb\u0113\u011b\u0117", flags=regex.UNICODE)), + 'e\xe8\xe9\xea\xeb\u0113\u011b\u0117') + self.assertEqual("".join(regex.findall(r"e|\xe8|\xe9|\xea|\xeb|\u0113|\u011b|\u0117", + "e\xe8\xe9\xea\xeb\u0113\u011b\u0117", flags=regex.UNICODE)), + 'e\xe8\xe9\xea\xeb\u0113\u011b\u0117') + + def test_anyall(self): + self.assertEqual(regex.match("a.b", "a\nb", regex.DOTALL)[0], "a\nb") + self.assertEqual(regex.match("a.*b", "a\n\nb", regex.DOTALL)[0], + "a\n\nb") + + def test_non_consuming(self): + self.assertEqual(regex.match(r"(a(?=\s[^a]))", "a b")[1], 'a') + self.assertEqual(regex.match(r"(a(?=\s[^a]*))", "a b")[1], 'a') + self.assertEqual(regex.match(r"(a(?=\s[abc]))", "a b")[1], 'a') + self.assertEqual(regex.match(r"(a(?=\s[abc]*))", "a bc")[1], 'a') + self.assertEqual(regex.match(r"(a)(?=\s\1)", "a a")[1], 'a') + self.assertEqual(regex.match(r"(a)(?=\s\1*)", "a aa")[1], 'a') + self.assertEqual(regex.match(r"(a)(?=\s(abc|a))", "a a")[1], 'a') + + self.assertEqual(regex.match(r"(a(?!\s[^a]))", "a a")[1], 'a') + self.assertEqual(regex.match(r"(a(?!\s[abc]))", "a d")[1], 'a') + self.assertEqual(regex.match(r"(a)(?!\s\1)", "a b")[1], 'a') + self.assertEqual(regex.match(r"(a)(?!\s(abc|a))", "a b")[1], 'a') + + def test_ignore_case(self): + self.assertEqual(regex.match("abc", "ABC", regex.I)[0], 'ABC') + self.assertEqual(regex.match(b"abc", b"ABC", regex.I)[0], b'ABC') + + self.assertEqual(regex.match(r"(a\s[^a]*)", "a bb", regex.I)[1], + 'a bb') + self.assertEqual(regex.match(r"(a\s[abc])", "a b", regex.I)[1], 'a b') + self.assertEqual(regex.match(r"(a\s[abc]*)", "a bb", regex.I)[1], + 'a bb') + self.assertEqual(regex.match(r"((a)\s\2)", "a a", regex.I)[1], 'a a') + self.assertEqual(regex.match(r"((a)\s\2*)", "a aa", regex.I)[1], + 'a aa') + self.assertEqual(regex.match(r"((a)\s(abc|a))", "a a", regex.I)[1], + 'a a') + self.assertEqual(regex.match(r"((a)\s(abc|a)*)", "a aa", regex.I)[1], + 'a aa') + + # Issue 3511. + self.assertEqual(regex.match(r"[Z-a]", "_").span(), (0, 1)) + self.assertEqual(regex.match(r"(?i)[Z-a]", "_").span(), (0, 1)) + + self.assertEqual(bool(regex.match(r"(?i)nao", "nAo")), True) + self.assertEqual(bool(regex.match(r"(?i)n\xE3o", "n\xC3o")), True) + self.assertEqual(bool(regex.match(r"(?i)n\xE3o", "N\xC3O")), True) + self.assertEqual(bool(regex.match(r"(?i)s", "\u017F")), True) + + def test_case_folding(self): + self.assertEqual(regex.search(r"(?fi)ss", "SS").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)SS", "ss").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)SS", + "\N{LATIN SMALL LETTER SHARP S}").span(), (0, 1)) + self.assertEqual(regex.search(r"(?fi)\N{LATIN SMALL LETTER SHARP S}", + "SS").span(), (0, 2)) + + self.assertEqual(regex.search(r"(?fi)\N{LATIN SMALL LIGATURE ST}", + "ST").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)ST", + "\N{LATIN SMALL LIGATURE ST}").span(), (0, 1)) + self.assertEqual(regex.search(r"(?fi)ST", + "\N{LATIN SMALL LIGATURE LONG S T}").span(), (0, 1)) + + self.assertEqual(regex.search(r"(?fi)SST", + "\N{LATIN SMALL LETTER SHARP S}t").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)SST", + "s\N{LATIN SMALL LIGATURE LONG S T}").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)SST", + "s\N{LATIN SMALL LIGATURE ST}").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)\N{LATIN SMALL LIGATURE ST}", + "SST").span(), (1, 3)) + self.assertEqual(regex.search(r"(?fi)SST", + "s\N{LATIN SMALL LIGATURE ST}").span(), (0, 2)) + + self.assertEqual(regex.search(r"(?fi)FFI", + "\N{LATIN SMALL LIGATURE FFI}").span(), (0, 1)) + self.assertEqual(regex.search(r"(?fi)FFI", + "\N{LATIN SMALL LIGATURE FF}i").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)FFI", + "f\N{LATIN SMALL LIGATURE FI}").span(), (0, 2)) + self.assertEqual(regex.search(r"(?fi)\N{LATIN SMALL LIGATURE FFI}", + "FFI").span(), (0, 3)) + self.assertEqual(regex.search(r"(?fi)\N{LATIN SMALL LIGATURE FF}i", + "FFI").span(), (0, 3)) + self.assertEqual(regex.search(r"(?fi)f\N{LATIN SMALL LIGATURE FI}", + "FFI").span(), (0, 3)) + + sigma = "\u03A3\u03C3\u03C2" + for ch1 in sigma: + for ch2 in sigma: + if not regex.match(r"(?fi)" + ch1, ch2): + self.fail() + + self.assertEqual(bool(regex.search(r"(?iV1)ff", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)ff", "\uFB01\uFB00")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)fi", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)fi", "\uFB01\uFB00")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)fffi", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)f\uFB03", + "\uFB00\uFB01")), True) + self.assertEqual(bool(regex.search(r"(?iV1)ff", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)fi", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)fffi", "\uFB00\uFB01")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)f\uFB03", + "\uFB00\uFB01")), True) + self.assertEqual(bool(regex.search(r"(?iV1)f\uFB01", "\uFB00i")), + True) + self.assertEqual(bool(regex.search(r"(?iV1)f\uFB01", "\uFB00i")), + True) + + self.assertEqual(regex.findall(r"(?iV0)\m(?:word){e<=3}\M(?ne", "affine", + options=["\N{LATIN SMALL LIGATURE FFI}"]).span(), (0, 6)) + self.assertEqual(regex.search(r"(?fi)a\Lne", + "a\N{LATIN SMALL LIGATURE FFI}ne", options=["ffi"]).span(), (0, 4)) + + def test_category(self): + self.assertEqual(regex.match(r"(\s)", " ")[1], ' ') + + def test_not_literal(self): + self.assertEqual(regex.search(r"\s([^a])", " b")[1], 'b') + self.assertEqual(regex.search(r"\s([^a]*)", " bb")[1], 'bb') + + def test_search_coverage(self): + self.assertEqual(regex.search(r"\s(b)", " b")[1], 'b') + self.assertEqual(regex.search(r"a\s", "a ")[0], 'a ') + + def test_re_escape(self): + p = "" + self.assertEqual(regex.escape(p), p) + for i in range(0, 256): + p += chr(i) + self.assertEqual(bool(regex.match(regex.escape(chr(i)), chr(i))), + True) + self.assertEqual(regex.match(regex.escape(chr(i)), chr(i)).span(), + (0, 1)) + + pat = regex.compile(regex.escape(p)) + self.assertEqual(pat.match(p).span(), (0, 256)) + + def test_re_escape_byte(self): + p = b"" + self.assertEqual(regex.escape(p), p) + for i in range(0, 256): + b = bytes([i]) + p += b + self.assertEqual(bool(regex.match(regex.escape(b), b)), True) + self.assertEqual(regex.match(regex.escape(b), b).span(), (0, 1)) + + pat = regex.compile(regex.escape(p)) + self.assertEqual(pat.match(p).span(), (0, 256)) + + def test_constants(self): + if regex.I != regex.IGNORECASE: + self.fail() + if regex.L != regex.LOCALE: + self.fail() + if regex.M != regex.MULTILINE: + self.fail() + if regex.S != regex.DOTALL: + self.fail() + if regex.X != regex.VERBOSE: + self.fail() + + def test_flags(self): + for flag in [regex.I, regex.M, regex.X, regex.S, regex.L]: + self.assertEqual(repr(type(regex.compile('^pattern$', flag))), + self.PATTERN_CLASS) + + def test_sre_character_literals(self): + for i in [0, 8, 16, 32, 64, 127, 128, 255]: + self.assertEqual(bool(regex.match(r"\%03o" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"\%03o0" % i, chr(i) + "0")), + True) + self.assertEqual(bool(regex.match(r"\%03o8" % i, chr(i) + "8")), + True) + self.assertEqual(bool(regex.match(r"\x%02x" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"\x%02x0" % i, chr(i) + "0")), + True) + self.assertEqual(bool(regex.match(r"\x%02xz" % i, chr(i) + "z")), + True) + + self.assertRaisesRegex(regex.error, self.INVALID_GROUP_REF, lambda: + regex.match(r"\911", "")) + + def test_sre_character_class_literals(self): + for i in [0, 8, 16, 32, 64, 127, 128, 255]: + self.assertEqual(bool(regex.match(r"[\%03o]" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"[\%03o0]" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"[\%03o8]" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"[\x%02x]" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"[\x%02x0]" % i, chr(i))), True) + self.assertEqual(bool(regex.match(r"[\x%02xz]" % i, chr(i))), True) + + self.assertRaisesRegex(regex.error, self.BAD_OCTAL_ESCAPE, lambda: + regex.match(r"[\911]", "")) + + def test_bug_113254(self): + self.assertEqual(regex.match(r'(a)|(b)', 'b').start(1), -1) + self.assertEqual(regex.match(r'(a)|(b)', 'b').end(1), -1) + self.assertEqual(regex.match(r'(a)|(b)', 'b').span(1), (-1, -1)) + + def test_bug_527371(self): + # Bug described in patches 527371/672491. + self.assertEqual(regex.match(r'(a)?a','a').lastindex, None) + self.assertEqual(regex.match(r'(a)(b)?b','ab').lastindex, 1) + self.assertEqual(regex.match(r'(?Pa)(?Pb)?b','ab').lastgroup, + 'a') + self.assertEqual(regex.match("(?Pa(b))", "ab").lastgroup, 'a') + self.assertEqual(regex.match("((a))", "a").lastindex, 1) + + def test_bug_545855(self): + # Bug 545855 -- This pattern failed to cause a compile error as it + # should, instead provoking a TypeError. + self.assertRaisesRegex(regex.error, self.BAD_SET, lambda: + regex.compile('foo[a-')) + + def test_bug_418626(self): + # Bugs 418626 at al. -- Testing Greg Chapman's addition of op code + # SRE_OP_MIN_REPEAT_ONE for eliminating recursion on simple uses of + # pattern '*?' on a long string. + self.assertEqual(regex.match('.*?c', 10000 * 'ab' + 'cd').end(0), + 20001) + self.assertEqual(regex.match('.*?cd', 5000 * 'ab' + 'c' + 5000 * 'ab' + + 'cde').end(0), 20003) + self.assertEqual(regex.match('.*?cd', 20000 * 'abc' + 'de').end(0), + 60001) + # Non-simple '*?' still used to hit the recursion limit, before the + # non-recursive scheme was implemented. + self.assertEqual(regex.search('(a|b)*?c', 10000 * 'ab' + 'cd').end(0), + 20001) + + def test_bug_612074(self): + pat = "[" + regex.escape("\u2039") + "]" + self.assertEqual(regex.compile(pat) and 1, 1) + + def test_stack_overflow(self): + # Nasty cases that used to overflow the straightforward recursive + # implementation of repeated groups. + self.assertEqual(regex.match('(x)*', 50000 * 'x')[1], 'x') + self.assertEqual(regex.match('(x)*y', 50000 * 'x' + 'y')[1], 'x') + self.assertEqual(regex.match('(x)*?y', 50000 * 'x' + 'y')[1], 'x') + + def test_scanner(self): + def s_ident(scanner, token): return token + def s_operator(scanner, token): return "op%s" % token + def s_float(scanner, token): return float(token) + def s_int(scanner, token): return int(token) + + scanner = regex.Scanner([(r"[a-zA-Z_]\w*", s_ident), (r"\d+\.\d*", + s_float), (r"\d+", s_int), (r"=|\+|-|\*|/", s_operator), (r"\s+", + None), ]) + + self.assertEqual(repr(type(scanner.scanner.scanner("").pattern)), + self.PATTERN_CLASS) + + self.assertEqual(scanner.scan("sum = 3*foo + 312.50 + bar"), (['sum', + 'op=', 3, 'op*', 'foo', 'op+', 312.5, 'op+', 'bar'], '')) + + def test_bug_448951(self): + # Bug 448951 (similar to 429357, but with single char match). + # (Also test greedy matches.) + for op in '', '?', '*': + self.assertEqual(regex.match(r'((.%s):)?z' % op, 'z')[:], ('z', + None, None)) + self.assertEqual(regex.match(r'((.%s):)?z' % op, 'a:z')[:], ('a:z', + 'a:', 'a')) + + def test_bug_725106(self): + # Capturing groups in alternatives in repeats. + self.assertEqual(regex.match('^((a)|b)*', 'abc')[:], ('ab', 'b', 'a')) + self.assertEqual(regex.match('^(([ab])|c)*', 'abc')[:], ('abc', 'c', + 'b')) + self.assertEqual(regex.match('^((d)|[ab])*', 'abc')[:], ('ab', 'b', + None)) + self.assertEqual(regex.match('^((a)c|[ab])*', 'abc')[:], ('ab', 'b', + None)) + self.assertEqual(regex.match('^((a)|b)*?c', 'abc')[:], ('abc', 'b', + 'a')) + self.assertEqual(regex.match('^(([ab])|c)*?d', 'abcd')[:], ('abcd', + 'c', 'b')) + self.assertEqual(regex.match('^((d)|[ab])*?c', 'abc')[:], ('abc', 'b', + None)) + self.assertEqual(regex.match('^((a)c|[ab])*?c', 'abc')[:], ('abc', 'b', + None)) + + def test_bug_725149(self): + # Mark_stack_base restoring before restoring marks. + self.assertEqual(regex.match('(a)(?:(?=(b)*)c)*', 'abb')[:], ('a', 'a', + None)) + self.assertEqual(regex.match('(a)((?!(b)*))*', 'abb')[:], ('a', 'a', + None, None)) + + def test_bug_764548(self): + # Bug 764548, regex.compile() barfs on str/unicode subclasses. + class my_unicode(str): pass + pat = regex.compile(my_unicode("abc")) + self.assertEqual(pat.match("xyz"), None) + + def test_finditer(self): + it = regex.finditer(r":+", "a:b::c:::d") + self.assertEqual([item[0] for item in it], [':', '::', ':::']) + + def test_bug_926075(self): + if regex.compile('bug_926075') is regex.compile(b'bug_926075'): + self.fail() + + def test_bug_931848(self): + pattern = "[\u002E\u3002\uFF0E\uFF61]" + self.assertEqual(regex.compile(pattern).split("a.b.c"), ['a', 'b', + 'c']) + + def test_bug_581080(self): + it = regex.finditer(r"\s", "a b") + self.assertEqual(next(it).span(), (1, 2)) + self.assertRaises(StopIteration, lambda: next(it)) + + scanner = regex.compile(r"\s").scanner("a b") + self.assertEqual(scanner.search().span(), (1, 2)) + self.assertEqual(scanner.search(), None) + + def test_bug_817234(self): + it = regex.finditer(r".*", "asdf") + self.assertEqual(next(it).span(), (0, 4)) + self.assertEqual(next(it).span(), (4, 4)) + self.assertRaises(StopIteration, lambda: next(it)) + + def test_empty_array(self): + # SF buf 1647541. + import array + for typecode in 'bBuhHiIlLfd': + a = array.array(typecode) + self.assertEqual(regex.compile(b"bla").match(a), None) + self.assertEqual(regex.compile(b"").match(a)[1 : ], ()) + + def test_inline_flags(self): + # Bug #1700. + upper_char = chr(0x1ea0) # Latin Capital Letter A with Dot Below + lower_char = chr(0x1ea1) # Latin Small Letter A with Dot Below + + p = regex.compile(upper_char, regex.I | regex.U) + self.assertEqual(bool(p.match(lower_char)), True) + + p = regex.compile(lower_char, regex.I | regex.U) + self.assertEqual(bool(p.match(upper_char)), True) + + p = regex.compile('(?i)' + upper_char, regex.U) + self.assertEqual(bool(p.match(lower_char)), True) + + p = regex.compile('(?i)' + lower_char, regex.U) + self.assertEqual(bool(p.match(upper_char)), True) + + p = regex.compile('(?iu)' + upper_char) + self.assertEqual(bool(p.match(lower_char)), True) + + p = regex.compile('(?iu)' + lower_char) + self.assertEqual(bool(p.match(upper_char)), True) + + # Changed to positional flags in regex 2023.12.23. + self.assertEqual(bool(regex.match(r"(?i)a", "A")), True) + self.assertEqual(regex.match(r"a(?i)", "A"), None) + + def test_dollar_matches_twice(self): + # $ matches the end of string, and just before the terminating \n. + pattern = regex.compile('$') + self.assertEqual(pattern.sub('#', 'a\nb\n'), 'a\nb#\n#') + self.assertEqual(pattern.sub('#', 'a\nb\nc'), 'a\nb\nc#') + self.assertEqual(pattern.sub('#', '\n'), '#\n#') + + pattern = regex.compile('$', regex.MULTILINE) + self.assertEqual(pattern.sub('#', 'a\nb\n' ), 'a#\nb#\n#') + self.assertEqual(pattern.sub('#', 'a\nb\nc'), 'a#\nb#\nc#') + self.assertEqual(pattern.sub('#', '\n'), '#\n#') + + def test_bytes_str_mixing(self): + # Mixing str and bytes is disallowed. + pat = regex.compile('.') + bpat = regex.compile(b'.') + self.assertRaisesRegex(TypeError, self.STR_PAT_ON_BYTES, lambda: + pat.match(b'b')) + self.assertRaisesRegex(TypeError, self.BYTES_PAT_ON_STR, lambda: + bpat.match('b')) + self.assertRaisesRegex(TypeError, self.STR_PAT_BYTES_TEMPL, lambda: + pat.sub(b'b', 'c')) + self.assertRaisesRegex(TypeError, self.STR_PAT_ON_BYTES, lambda: + pat.sub('b', b'c')) + self.assertRaisesRegex(TypeError, self.STR_PAT_ON_BYTES, lambda: + pat.sub(b'b', b'c')) + self.assertRaisesRegex(TypeError, self.BYTES_PAT_ON_STR, lambda: + bpat.sub(b'b', 'c')) + self.assertRaisesRegex(TypeError, self.BYTES_PAT_STR_TEMPL, lambda: + bpat.sub('b', b'c')) + self.assertRaisesRegex(TypeError, self.BYTES_PAT_ON_STR, lambda: + bpat.sub('b', 'c')) + + self.assertRaisesRegex(ValueError, self.BYTES_PAT_UNI_FLAG, lambda: + regex.compile(br'\w', regex.UNICODE)) + self.assertRaisesRegex(ValueError, self.BYTES_PAT_UNI_FLAG, lambda: + regex.compile(br'(?u)\w')) + self.assertRaisesRegex(ValueError, self.MIXED_FLAGS, lambda: + regex.compile(r'\w', regex.UNICODE | regex.ASCII)) + self.assertRaisesRegex(ValueError, self.MIXED_FLAGS, lambda: + regex.compile(r'(?u)\w', regex.ASCII)) + self.assertRaisesRegex(ValueError, self.MIXED_FLAGS, lambda: + regex.compile(r'(?a)\w', regex.UNICODE)) + self.assertRaisesRegex(ValueError, self.MIXED_FLAGS, lambda: + regex.compile(r'(?au)\w')) + + def test_ascii_and_unicode_flag(self): + # String patterns. + for flags in (0, regex.UNICODE): + pat = regex.compile('\xc0', flags | regex.IGNORECASE) + self.assertEqual(bool(pat.match('\xe0')), True) + pat = regex.compile(r'\w', flags) + self.assertEqual(bool(pat.match('\xe0')), True) + + pat = regex.compile('\xc0', regex.ASCII | regex.IGNORECASE) + self.assertEqual(pat.match('\xe0'), None) + pat = regex.compile('(?a)\xc0', regex.IGNORECASE) + self.assertEqual(pat.match('\xe0'), None) + pat = regex.compile(r'\w', regex.ASCII) + self.assertEqual(pat.match('\xe0'), None) + pat = regex.compile(r'(?a)\w') + self.assertEqual(pat.match('\xe0'), None) + + # Bytes patterns. + for flags in (0, regex.ASCII): + pat = regex.compile(b'\xc0', flags | regex.IGNORECASE) + self.assertEqual(pat.match(b'\xe0'), None) + pat = regex.compile(br'\w') + self.assertEqual(pat.match(b'\xe0'), None) + + self.assertRaisesRegex(ValueError, self.MIXED_FLAGS, lambda: + regex.compile(r'(?au)\w')) + + def test_subscripting_match(self): + m = regex.match(r'(?\w)', 'xy') + if not m: + self.fail("Failed: expected match but returned None") + elif not m or m[0] != m.group(0) or m[1] != m.group(1): + self.fail("Failed") + if not m: + self.fail("Failed: expected match but returned None") + elif m[:] != ('x', 'x'): + self.fail("Failed: expected \"('x', 'x')\" but got {} instead".format(ascii(m[:]))) + + def test_new_named_groups(self): + m0 = regex.match(r'(?P\w)', 'x') + m1 = regex.match(r'(?\w)', 'x') + if not (m0 and m1 and m0[:] == m1[:]): + self.fail("Failed") + + def test_properties(self): + self.assertEqual(regex.match(b'(?ai)\xC0', b'\xE0'), None) + self.assertEqual(regex.match(br'(?ai)\xC0', b'\xE0'), None) + self.assertEqual(regex.match(br'(?a)\w', b'\xE0'), None) + self.assertEqual(bool(regex.match(r'\w', '\xE0')), True) + + # Dropped the following test. It's not possible to determine what the + # correct result should be in the general case. +# self.assertEqual(bool(regex.match(br'(?L)\w', b'\xE0')), +# b'\xE0'.isalnum()) + + self.assertEqual(bool(regex.match(br'(?L)\d', b'0')), True) + self.assertEqual(bool(regex.match(br'(?L)\s', b' ')), True) + self.assertEqual(bool(regex.match(br'(?L)\w', b'a')), True) + self.assertEqual(regex.match(br'(?L)\d', b'?'), None) + self.assertEqual(regex.match(br'(?L)\s', b'?'), None) + self.assertEqual(regex.match(br'(?L)\w', b'?'), None) + + self.assertEqual(regex.match(br'(?L)\D', b'0'), None) + self.assertEqual(regex.match(br'(?L)\S', b' '), None) + self.assertEqual(regex.match(br'(?L)\W', b'a'), None) + self.assertEqual(bool(regex.match(br'(?L)\D', b'?')), True) + self.assertEqual(bool(regex.match(br'(?L)\S', b'?')), True) + self.assertEqual(bool(regex.match(br'(?L)\W', b'?')), True) + + self.assertEqual(bool(regex.match(r'\p{Cyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'(?i)\p{Cyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{IsCyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{Script=Cyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{InCyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{Block=Cyrillic}', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:Cyrillic:]]', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:IsCyrillic:]]', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:Script=Cyrillic:]]', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:InCyrillic:]]', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:Block=Cyrillic:]]', + '\N{CYRILLIC CAPITAL LETTER A}')), True) + + self.assertEqual(bool(regex.match(r'\P{Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\P{IsCyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\P{Script=Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\P{InCyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\P{Block=Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{^Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{^IsCyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{^Script=Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{^InCyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'\p{^Block=Cyrillic}', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:^Cyrillic:]]', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:^IsCyrillic:]]', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:^Script=Cyrillic:]]', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:^InCyrillic:]]', + '\N{LATIN CAPITAL LETTER A}')), True) + self.assertEqual(bool(regex.match(r'[[:^Block=Cyrillic:]]', + '\N{LATIN CAPITAL LETTER A}')), True) + + self.assertEqual(bool(regex.match(r'\d', '0')), True) + self.assertEqual(bool(regex.match(r'\s', ' ')), True) + self.assertEqual(bool(regex.match(r'\w', 'A')), True) + self.assertEqual(regex.match(r"\d", "?"), None) + self.assertEqual(regex.match(r"\s", "?"), None) + self.assertEqual(regex.match(r"\w", "?"), None) + self.assertEqual(regex.match(r"\D", "0"), None) + self.assertEqual(regex.match(r"\S", " "), None) + self.assertEqual(regex.match(r"\W", "A"), None) + self.assertEqual(bool(regex.match(r'\D', '?')), True) + self.assertEqual(bool(regex.match(r'\S', '?')), True) + self.assertEqual(bool(regex.match(r'\W', '?')), True) + + self.assertEqual(bool(regex.match(r'\p{L}', 'A')), True) + self.assertEqual(bool(regex.match(r'\p{L}', 'a')), True) + self.assertEqual(bool(regex.match(r'\p{Lu}', 'A')), True) + self.assertEqual(bool(regex.match(r'\p{Ll}', 'a')), True) + + self.assertEqual(bool(regex.match(r'(?i)a', 'a')), True) + self.assertEqual(bool(regex.match(r'(?i)a', 'A')), True) + + self.assertEqual(bool(regex.match(r'\w', '0')), True) + self.assertEqual(bool(regex.match(r'\w', 'a')), True) + self.assertEqual(bool(regex.match(r'\w', '_')), True) + + self.assertEqual(regex.match(r"\X", "\xE0").span(), (0, 1)) + self.assertEqual(regex.match(r"\X", "a\u0300").span(), (0, 2)) + self.assertEqual(regex.findall(r"\X", + "a\xE0a\u0300e\xE9e\u0301"), ['a', '\xe0', 'a\u0300', 'e', + '\xe9', 'e\u0301']) + self.assertEqual(regex.findall(r"\X{3}", + "a\xE0a\u0300e\xE9e\u0301"), ['a\xe0a\u0300', 'e\xe9e\u0301']) + self.assertEqual(regex.findall(r"\X", "\r\r\n\u0301A\u0301"), + ['\r', '\r\n', '\u0301', 'A\u0301']) + + self.assertEqual(bool(regex.match(r'\p{Ll}', 'a')), True) + + chars_u = "-09AZaz_\u0393\u03b3" + chars_b = b"-09AZaz_" + word_set = set("Ll Lm Lo Lt Lu Mc Me Mn Nd Nl No Pc".split()) + + tests = [ + (r"\w", chars_u, "09AZaz_\u0393\u03b3"), + (r"[[:word:]]", chars_u, "09AZaz_\u0393\u03b3"), + (r"\W", chars_u, "-"), + (r"[[:^word:]]", chars_u, "-"), + (r"\d", chars_u, "09"), + (r"[[:digit:]]", chars_u, "09"), + (r"\D", chars_u, "-AZaz_\u0393\u03b3"), + (r"[[:^digit:]]", chars_u, "-AZaz_\u0393\u03b3"), + (r"[[:alpha:]]", chars_u, "AZaz\u0393\u03b3"), + (r"[[:^alpha:]]", chars_u, "-09_"), + (r"[[:alnum:]]", chars_u, "09AZaz\u0393\u03b3"), + (r"[[:^alnum:]]", chars_u, "-_"), + (r"[[:xdigit:]]", chars_u, "09Aa"), + (r"[[:^xdigit:]]", chars_u, "-Zz_\u0393\u03b3"), + (r"\p{InBasicLatin}", "a\xE1", "a"), + (r"\P{InBasicLatin}", "a\xE1", "\xE1"), + (r"(?i)\p{InBasicLatin}", "a\xE1", "a"), + (r"(?i)\P{InBasicLatin}", "a\xE1", "\xE1"), + + (br"(?L)\w", chars_b, b"09AZaz_"), + (br"(?L)[[:word:]]", chars_b, b"09AZaz_"), + (br"(?L)\W", chars_b, b"-"), + (br"(?L)[[:^word:]]", chars_b, b"-"), + (br"(?L)\d", chars_b, b"09"), + (br"(?L)[[:digit:]]", chars_b, b"09"), + (br"(?L)\D", chars_b, b"-AZaz_"), + (br"(?L)[[:^digit:]]", chars_b, b"-AZaz_"), + (br"(?L)[[:alpha:]]", chars_b, b"AZaz"), + (br"(?L)[[:^alpha:]]", chars_b, b"-09_"), + (br"(?L)[[:alnum:]]", chars_b, b"09AZaz"), + (br"(?L)[[:^alnum:]]", chars_b, b"-_"), + (br"(?L)[[:xdigit:]]", chars_b, b"09Aa"), + (br"(?L)[[:^xdigit:]]", chars_b, b"-Zz_"), + + (br"(?a)\w", chars_b, b"09AZaz_"), + (br"(?a)[[:word:]]", chars_b, b"09AZaz_"), + (br"(?a)\W", chars_b, b"-"), + (br"(?a)[[:^word:]]", chars_b, b"-"), + (br"(?a)\d", chars_b, b"09"), + (br"(?a)[[:digit:]]", chars_b, b"09"), + (br"(?a)\D", chars_b, b"-AZaz_"), + (br"(?a)[[:^digit:]]", chars_b, b"-AZaz_"), + (br"(?a)[[:alpha:]]", chars_b, b"AZaz"), + (br"(?a)[[:^alpha:]]", chars_b, b"-09_"), + (br"(?a)[[:alnum:]]", chars_b, b"09AZaz"), + (br"(?a)[[:^alnum:]]", chars_b, b"-_"), + (br"(?a)[[:xdigit:]]", chars_b, b"09Aa"), + (br"(?a)[[:^xdigit:]]", chars_b, b"-Zz_"), + ] + for pattern, chars, expected in tests: + try: + if chars[ : 0].join(regex.findall(pattern, chars)) != expected: + self.fail("Failed: {}".format(pattern)) + except Exception as e: + self.fail("Failed: {} raised {}".format(pattern, ascii(e))) + + self.assertEqual(bool(regex.match(r"\p{NumericValue=0}", "0")), + True) + self.assertEqual(bool(regex.match(r"\p{NumericValue=1/2}", + "\N{VULGAR FRACTION ONE HALF}")), True) + self.assertEqual(bool(regex.match(r"\p{NumericValue=0.5}", + "\N{VULGAR FRACTION ONE HALF}")), True) + + def test_word_class(self): + self.assertEqual(regex.findall(r"\w+", + " \u0939\u093f\u0928\u094d\u0926\u0940,"), + ['\u0939\u093f\u0928\u094d\u0926\u0940']) + self.assertEqual(regex.findall(r"\W+", + " \u0939\u093f\u0928\u094d\u0926\u0940,"), [' ', ',']) + self.assertEqual(regex.split(r"(?V1)\b", + " \u0939\u093f\u0928\u094d\u0926\u0940,"), [' ', + '\u0939\u093f\u0928\u094d\u0926\u0940', ',']) + self.assertEqual(regex.split(r"(?V1)\B", + " \u0939\u093f\u0928\u094d\u0926\u0940,"), ['', ' \u0939', + '\u093f', '\u0928', '\u094d', '\u0926', '\u0940,', '']) + + def test_search_anchor(self): + self.assertEqual(regex.findall(r"\G\w{2}", "abcd ef"), ['ab', 'cd']) + + def test_search_reverse(self): + self.assertEqual(regex.findall(r"(?r).", "abc"), ['c', 'b', 'a']) + self.assertEqual(regex.findall(r"(?r).", "abc", overlapped=True), ['c', + 'b', 'a']) + self.assertEqual(regex.findall(r"(?r)..", "abcde"), ['de', 'bc']) + self.assertEqual(regex.findall(r"(?r)..", "abcde", overlapped=True), + ['de', 'cd', 'bc', 'ab']) + self.assertEqual(regex.findall(r"(?r)(.)(-)(.)", "a-b-c", + overlapped=True), [("b", "-", "c"), ("a", "-", "b")]) + + self.assertEqual([m[0] for m in regex.finditer(r"(?r).", "abc")], ['c', + 'b', 'a']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)..", "abcde", + overlapped=True)], ['de', 'cd', 'bc', 'ab']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r).", "abc")], ['c', + 'b', 'a']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)..", "abcde", + overlapped=True)], ['de', 'cd', 'bc', 'ab']) + + self.assertEqual(regex.findall(r"^|\w+", "foo bar"), ['', 'foo', + 'bar']) + self.assertEqual(regex.findall(r"(?V1)^|\w+", "foo bar"), ['', 'foo', + 'bar']) + self.assertEqual(regex.findall(r"(?r)^|\w+", "foo bar"), ['bar', 'foo', + '']) + self.assertEqual(regex.findall(r"(?rV1)^|\w+", "foo bar"), ['bar', + 'foo', '']) + + self.assertEqual([m[0] for m in regex.finditer(r"^|\w+", "foo bar")], + ['', 'foo', 'bar']) + self.assertEqual([m[0] for m in regex.finditer(r"(?V1)^|\w+", + "foo bar")], ['', 'foo', 'bar']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)^|\w+", + "foo bar")], ['bar', 'foo', '']) + self.assertEqual([m[0] for m in regex.finditer(r"(?rV1)^|\w+", + "foo bar")], ['bar', 'foo', '']) + + self.assertEqual(regex.findall(r"\G\w{2}", "abcd ef"), ['ab', 'cd']) + self.assertEqual(regex.findall(r".{2}(?<=\G.*)", "abcd"), ['ab', 'cd']) + self.assertEqual(regex.findall(r"(?r)\G\w{2}", "abcd ef"), []) + self.assertEqual(regex.findall(r"(?r)\w{2}\G", "abcd ef"), ['ef']) + + self.assertEqual(regex.findall(r"q*", "qqwe"), ['qq', '', '', '']) + self.assertEqual(regex.findall(r"(?V1)q*", "qqwe"), ['qq', '', '', '']) + self.assertEqual(regex.findall(r"(?r)q*", "qqwe"), ['', '', 'qq', '']) + self.assertEqual(regex.findall(r"(?rV1)q*", "qqwe"), ['', '', 'qq', + '']) + + self.assertEqual(regex.findall(".", "abcd", pos=1, endpos=3), ['b', + 'c']) + self.assertEqual(regex.findall(".", "abcd", pos=1, endpos=-1), ['b', + 'c']) + self.assertEqual([m[0] for m in regex.finditer(".", "abcd", pos=1, + endpos=3)], ['b', 'c']) + self.assertEqual([m[0] for m in regex.finditer(".", "abcd", pos=1, + endpos=-1)], ['b', 'c']) + + self.assertEqual([m[0] for m in regex.finditer("(?r).", "abcd", pos=1, + endpos=3)], ['c', 'b']) + self.assertEqual([m[0] for m in regex.finditer("(?r).", "abcd", pos=1, + endpos=-1)], ['c', 'b']) + self.assertEqual(regex.findall("(?r).", "abcd", pos=1, endpos=3), ['c', + 'b']) + self.assertEqual(regex.findall("(?r).", "abcd", pos=1, endpos=-1), + ['c', 'b']) + + self.assertEqual(regex.findall(r"[ab]", "aB", regex.I), ['a', 'B']) + self.assertEqual(regex.findall(r"(?r)[ab]", "aB", regex.I), ['B', 'a']) + + self.assertEqual(regex.findall(r"(?r).{2}", "abc"), ['bc']) + self.assertEqual(regex.findall(r"(?r).{2}", "abc", overlapped=True), + ['bc', 'ab']) + self.assertEqual(regex.findall(r"(\w+) (\w+)", + "first second third fourth fifth"), [('first', 'second'), ('third', + 'fourth')]) + self.assertEqual(regex.findall(r"(?r)(\w+) (\w+)", + "first second third fourth fifth"), [('fourth', 'fifth'), ('second', + 'third')]) + + self.assertEqual([m[0] for m in regex.finditer(r"(?r).{2}", "abc")], + ['bc']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r).{2}", "abc", + overlapped=True)], ['bc', 'ab']) + self.assertEqual([m[0] for m in regex.finditer(r"(\w+) (\w+)", + "first second third fourth fifth")], ['first second', + 'third fourth']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)(\w+) (\w+)", + "first second third fourth fifth")], ['fourth fifth', + 'second third']) + + self.assertEqual(regex.search("abcdef", "abcdef").span(), (0, 6)) + self.assertEqual(regex.search("(?r)abcdef", "abcdef").span(), (0, 6)) + self.assertEqual(regex.search("(?i)abcdef", "ABCDEF").span(), (0, 6)) + self.assertEqual(regex.search("(?ir)abcdef", "ABCDEF").span(), (0, 6)) + + self.assertEqual(regex.sub(r"(.)", r"\1", "abc"), 'abc') + self.assertEqual(regex.sub(r"(?r)(.)", r"\1", "abc"), 'abc') + + def test_atomic(self): + # Issue 433030. + self.assertEqual(regex.search(r"(?>a*)a", "aa"), None) + + def test_possessive(self): + # Single-character non-possessive. + self.assertEqual(regex.search(r"a?a", "a").span(), (0, 1)) + self.assertEqual(regex.search(r"a*a", "aaa").span(), (0, 3)) + self.assertEqual(regex.search(r"a+a", "aaa").span(), (0, 3)) + self.assertEqual(regex.search(r"a{1,3}a", "aaa").span(), (0, 3)) + + # Multiple-character non-possessive. + self.assertEqual(regex.search(r"(?:ab)?ab", "ab").span(), (0, 2)) + self.assertEqual(regex.search(r"(?:ab)*ab", "ababab").span(), (0, 6)) + self.assertEqual(regex.search(r"(?:ab)+ab", "ababab").span(), (0, 6)) + self.assertEqual(regex.search(r"(?:ab){1,3}ab", "ababab").span(), (0, + 6)) + + # Single-character possessive. + self.assertEqual(regex.search(r"a?+a", "a"), None) + self.assertEqual(regex.search(r"a*+a", "aaa"), None) + self.assertEqual(regex.search(r"a++a", "aaa"), None) + self.assertEqual(regex.search(r"a{1,3}+a", "aaa"), None) + + # Multiple-character possessive. + self.assertEqual(regex.search(r"(?:ab)?+ab", "ab"), None) + self.assertEqual(regex.search(r"(?:ab)*+ab", "ababab"), None) + self.assertEqual(regex.search(r"(?:ab)++ab", "ababab"), None) + self.assertEqual(regex.search(r"(?:ab){1,3}+ab", "ababab"), None) + + def test_zerowidth(self): + # Issue 3262. + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split(r"\b", "a b"), ['', 'a', ' ', 'b', + '']) + else: + self.assertEqual(regex.split(r"\b", "a b"), ['a b']) + self.assertEqual(regex.split(r"(?V1)\b", "a b"), ['', 'a', ' ', 'b', + '']) + + # Issue 1647489. + self.assertEqual(regex.findall(r"^|\w+", "foo bar"), ['', 'foo', + 'bar']) + self.assertEqual([m[0] for m in regex.finditer(r"^|\w+", "foo bar")], + ['', 'foo', 'bar']) + self.assertEqual(regex.findall(r"(?r)^|\w+", "foo bar"), ['bar', + 'foo', '']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)^|\w+", + "foo bar")], ['bar', 'foo', '']) + self.assertEqual(regex.findall(r"(?V1)^|\w+", "foo bar"), ['', 'foo', + 'bar']) + self.assertEqual([m[0] for m in regex.finditer(r"(?V1)^|\w+", + "foo bar")], ['', 'foo', 'bar']) + self.assertEqual(regex.findall(r"(?rV1)^|\w+", "foo bar"), ['bar', + 'foo', '']) + self.assertEqual([m[0] for m in regex.finditer(r"(?rV1)^|\w+", + "foo bar")], ['bar', 'foo', '']) + + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split("", "xaxbxc"), ['', 'x', 'a', 'x', + 'b', 'x', 'c', '']) + self.assertEqual([m for m in regex.splititer("", "xaxbxc")], ['', + 'x', 'a', 'x', 'b', 'x', 'c', '']) + else: + self.assertEqual(regex.split("", "xaxbxc"), ['xaxbxc']) + self.assertEqual([m for m in regex.splititer("", "xaxbxc")], + ['xaxbxc']) + + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split("(?r)", "xaxbxc"), ['', 'c', 'x', 'b', + 'x', 'a', 'x', '']) + self.assertEqual([m for m in regex.splititer("(?r)", "xaxbxc")], + ['', 'c', 'x', 'b', 'x', 'a', 'x', '']) + else: + self.assertEqual(regex.split("(?r)", "xaxbxc"), ['xaxbxc']) + self.assertEqual([m for m in regex.splititer("(?r)", "xaxbxc")], + ['xaxbxc']) + + self.assertEqual(regex.split("(?V1)", "xaxbxc"), ['', 'x', 'a', 'x', + 'b', 'x', 'c', '']) + self.assertEqual([m for m in regex.splititer("(?V1)", "xaxbxc")], ['', + 'x', 'a', 'x', 'b', 'x', 'c', '']) + + self.assertEqual(regex.split("(?rV1)", "xaxbxc"), ['', 'c', 'x', 'b', + 'x', 'a', 'x', '']) + self.assertEqual([m for m in regex.splititer("(?rV1)", "xaxbxc")], ['', + 'c', 'x', 'b', 'x', 'a', 'x', '']) + + def test_scoped_and_inline_flags(self): + # Issues 433028, 433024, 433027. + self.assertEqual(regex.search(r"(?i)Ab", "ab").span(), (0, 2)) + self.assertEqual(regex.search(r"(?i:A)b", "ab").span(), (0, 2)) + # Changed to positional flags in regex 2023.12.23. + self.assertEqual(regex.search(r"A(?i)b", "ab"), None) + + self.assertEqual(regex.search(r"(?V0)Ab", "ab"), None) + self.assertEqual(regex.search(r"(?V1)Ab", "ab"), None) + self.assertEqual(regex.search(r"(?-i)Ab", "ab", flags=regex.I), None) + self.assertEqual(regex.search(r"(?-i:A)b", "ab", flags=regex.I), None) + self.assertEqual(regex.search(r"A(?-i)b", "ab", flags=regex.I).span(), + (0, 2)) + + def test_repeated_repeats(self): + # Issue 2537. + self.assertEqual(regex.search(r"(?:a+)+", "aaa").span(), (0, 3)) + self.assertEqual(regex.search(r"(?:(?:ab)+c)+", "abcabc").span(), (0, + 6)) + + # Hg issue 286. + self.assertEqual(regex.search(r"(?:a+){2,}", "aaa").span(), (0, 3)) + + def test_lookbehind(self): + self.assertEqual(regex.search(r"123(?<=a\d+)", "a123").span(), (1, 4)) + self.assertEqual(regex.search(r"123(?<=a\d+)", "b123"), None) + self.assertEqual(regex.search(r"123(?= (3, 7, 0): + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "xy"), + 'y-x-') + else: + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "xy"), + 'y-x') + self.assertEqual(regex.sub(r"(?V1)(x)?(y)?", r"\2-\1", "xy"), 'y-x-') + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "x"), '-x-') + else: + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "x"), '-x') + self.assertEqual(regex.sub(r"(?V1)(x)?(y)?", r"\2-\1", "x"), '-x-') + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "y"), 'y--') + else: + self.assertEqual(regex.sub(r"(?V0)(x)?(y)?", r"\2-\1", "y"), 'y-') + self.assertEqual(regex.sub(r"(?V1)(x)?(y)?", r"\2-\1", "y"), 'y--') + + def test_bug_10328 (self): + # Issue 10328. + pat = regex.compile(r'(?mV0)(?P[ \t]+\r*$)|(?P(?<=[^\n])\Z)') + if sys.version_info >= (3, 7, 0): + self.assertEqual(pat.subn(lambda m: '<' + m.lastgroup + '>', + 'foobar '), ('foobar', 2)) + else: + self.assertEqual(pat.subn(lambda m: '<' + m.lastgroup + '>', + 'foobar '), ('foobar', 1)) + self.assertEqual([m.group() for m in pat.finditer('foobar ')], [' ', + '']) + pat = regex.compile(r'(?mV1)(?P[ \t]+\r*$)|(?P(?<=[^\n])\Z)') + self.assertEqual(pat.subn(lambda m: '<' + m.lastgroup + '>', + 'foobar '), ('foobar', 2)) + self.assertEqual([m.group() for m in pat.finditer('foobar ')], [' ', + '']) + + def test_overlapped(self): + self.assertEqual(regex.findall(r"..", "abcde"), ['ab', 'cd']) + self.assertEqual(regex.findall(r"..", "abcde", overlapped=True), ['ab', + 'bc', 'cd', 'de']) + self.assertEqual(regex.findall(r"(?r)..", "abcde"), ['de', 'bc']) + self.assertEqual(regex.findall(r"(?r)..", "abcde", overlapped=True), + ['de', 'cd', 'bc', 'ab']) + self.assertEqual(regex.findall(r"(.)(-)(.)", "a-b-c", overlapped=True), + [("a", "-", "b"), ("b", "-", "c")]) + + self.assertEqual([m[0] for m in regex.finditer(r"..", "abcde")], ['ab', + 'cd']) + self.assertEqual([m[0] for m in regex.finditer(r"..", "abcde", + overlapped=True)], ['ab', 'bc', 'cd', 'de']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)..", "abcde")], + ['de', 'bc']) + self.assertEqual([m[0] for m in regex.finditer(r"(?r)..", "abcde", + overlapped=True)], ['de', 'cd', 'bc', 'ab']) + + self.assertEqual([m.groups() for m in regex.finditer(r"(.)(-)(.)", + "a-b-c", overlapped=True)], [("a", "-", "b"), ("b", "-", "c")]) + self.assertEqual([m.groups() for m in regex.finditer(r"(?r)(.)(-)(.)", + "a-b-c", overlapped=True)], [("b", "-", "c"), ("a", "-", "b")]) + + def test_splititer(self): + self.assertEqual(regex.split(r",", "a,b,,c,"), ['a', 'b', '', 'c', '']) + self.assertEqual([m for m in regex.splititer(r",", "a,b,,c,")], ['a', + 'b', '', 'c', '']) + + def test_grapheme(self): + self.assertEqual(regex.match(r"\X", "\xE0").span(), (0, 1)) + self.assertEqual(regex.match(r"\X", "a\u0300").span(), (0, 2)) + + self.assertEqual(regex.findall(r"\X", + "a\xE0a\u0300e\xE9e\u0301"), ['a', '\xe0', 'a\u0300', 'e', + '\xe9', 'e\u0301']) + self.assertEqual(regex.findall(r"\X{3}", + "a\xE0a\u0300e\xE9e\u0301"), ['a\xe0a\u0300', 'e\xe9e\u0301']) + self.assertEqual(regex.findall(r"\X", "\r\r\n\u0301A\u0301"), + ['\r', '\r\n', '\u0301', 'A\u0301']) + + def test_word_boundary(self): + text = 'The quick ("brown") fox can\'t jump 32.3 feet, right?' + self.assertEqual(regex.split(r'(?V1)\b', text), ['', 'The', ' ', + 'quick', ' ("', 'brown', '") ', 'fox', ' ', 'can', "'", 't', + ' ', 'jump', ' ', '32', '.', '3', ' ', 'feet', ', ', + 'right', '?']) + self.assertEqual(regex.split(r'(?V1w)\b', text), ['', 'The', ' ', + 'quick', ' ', '(', '"', 'brown', '"', ')', ' ', 'fox', ' ', + "can't", ' ', 'jump', ' ', '32.3', ' ', 'feet', ',', ' ', + 'right', '?', '']) + + text = "The fox" + self.assertEqual(regex.split(r'(?V1)\b', text), ['', 'The', ' ', + 'fox', '']) + self.assertEqual(regex.split(r'(?V1w)\b', text), ['', 'The', ' ', + 'fox', '']) + + text = "can't aujourd'hui l'objectif" + self.assertEqual(regex.split(r'(?V1)\b', text), ['', 'can', "'", + 't', ' ', 'aujourd', "'", 'hui', ' ', 'l', "'", 'objectif', + '']) + self.assertEqual(regex.split(r'(?V1w)\b', text), ['', "can't", ' ', + "aujourd'hui", ' ', "l'objectif", '']) + + def test_line_boundary(self): + self.assertEqual(regex.findall(r".+", "Line 1\nLine 2\n"), ["Line 1", + "Line 2"]) + self.assertEqual(regex.findall(r".+", "Line 1\rLine 2\r"), + ["Line 1\rLine 2\r"]) + self.assertEqual(regex.findall(r".+", "Line 1\r\nLine 2\r\n"), + ["Line 1\r", "Line 2\r"]) + self.assertEqual(regex.findall(r"(?w).+", "Line 1\nLine 2\n"), + ["Line 1", "Line 2"]) + self.assertEqual(regex.findall(r"(?w).+", "Line 1\rLine 2\r"), + ["Line 1", "Line 2"]) + self.assertEqual(regex.findall(r"(?w).+", "Line 1\r\nLine 2\r\n"), + ["Line 1", "Line 2"]) + + self.assertEqual(regex.search(r"^abc", "abc").start(), 0) + self.assertEqual(regex.search(r"^abc", "\nabc"), None) + self.assertEqual(regex.search(r"^abc", "\rabc"), None) + self.assertEqual(regex.search(r"(?w)^abc", "abc").start(), 0) + self.assertEqual(regex.search(r"(?w)^abc", "\nabc"), None) + self.assertEqual(regex.search(r"(?w)^abc", "\rabc"), None) + + self.assertEqual(regex.search(r"abc$", "abc").start(), 0) + self.assertEqual(regex.search(r"abc$", "abc\n").start(), 0) + self.assertEqual(regex.search(r"abc$", "abc\r"), None) + self.assertEqual(regex.search(r"(?w)abc$", "abc").start(), 0) + self.assertEqual(regex.search(r"(?w)abc$", "abc\n").start(), 0) + self.assertEqual(regex.search(r"(?w)abc$", "abc\r").start(), 0) + + self.assertEqual(regex.search(r"(?m)^abc", "abc").start(), 0) + self.assertEqual(regex.search(r"(?m)^abc", "\nabc").start(), 1) + self.assertEqual(regex.search(r"(?m)^abc", "\rabc"), None) + self.assertEqual(regex.search(r"(?mw)^abc", "abc").start(), 0) + self.assertEqual(regex.search(r"(?mw)^abc", "\nabc").start(), 1) + self.assertEqual(regex.search(r"(?mw)^abc", "\rabc").start(), 1) + + self.assertEqual(regex.search(r"(?m)abc$", "abc").start(), 0) + self.assertEqual(regex.search(r"(?m)abc$", "abc\n").start(), 0) + self.assertEqual(regex.search(r"(?m)abc$", "abc\r"), None) + self.assertEqual(regex.search(r"(?mw)abc$", "abc").start(), 0) + self.assertEqual(regex.search(r"(?mw)abc$", "abc\n").start(), 0) + self.assertEqual(regex.search(r"(?mw)abc$", "abc\r").start(), 0) + + def test_branch_reset(self): + self.assertEqual(regex.match(r"(?:(a)|(b))(c)", "ac").groups(), ('a', + None, 'c')) + self.assertEqual(regex.match(r"(?:(a)|(b))(c)", "bc").groups(), (None, + 'b', 'c')) + self.assertEqual(regex.match(r"(?:(?a)|(?b))(?c)", + "ac").groups(), ('a', None, 'c')) + self.assertEqual(regex.match(r"(?:(?a)|(?b))(?c)", + "bc").groups(), (None, 'b', 'c')) + + self.assertEqual(regex.match(r"(?a)(?:(?b)|(?c))(?d)", + "abd").groups(), ('a', 'b', None, 'd')) + self.assertEqual(regex.match(r"(?a)(?:(?b)|(?c))(?d)", + "acd").groups(), ('a', None, 'c', 'd')) + self.assertEqual(regex.match(r"(a)(?:(b)|(c))(d)", "abd").groups(), + ('a', 'b', None, 'd')) + + self.assertEqual(regex.match(r"(a)(?:(b)|(c))(d)", "acd").groups(), + ('a', None, 'c', 'd')) + self.assertEqual(regex.match(r"(a)(?|(b)|(b))(d)", "abd").groups(), + ('a', 'b', 'd')) + self.assertEqual(regex.match(r"(?|(?a)|(?b))(c)", "ac").groups(), + ('a', None, 'c')) + self.assertEqual(regex.match(r"(?|(?a)|(?b))(c)", "bc").groups(), + (None, 'b', 'c')) + self.assertEqual(regex.match(r"(?|(?a)|(?b))(c)", "ac").groups(), + ('a', 'c')) + + self.assertEqual(regex.match(r"(?|(?a)|(?b))(c)", "bc").groups(), + ('b', 'c')) + + self.assertEqual(regex.match(r"(?|(?a)(?b)|(?c)(?d))(e)", + "abe").groups(), ('a', 'b', 'e')) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(?c)(?d))(e)", + "cde").groups(), ('d', 'c', 'e')) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(?c)(d))(e)", + "abe").groups(), ('a', 'b', 'e')) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(?c)(d))(e)", + "cde").groups(), ('d', 'c', 'e')) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(d))(e)", + "abe").groups(), ('a', 'b', 'e')) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(d))(e)", + "cde").groups(), ('c', 'd', 'e')) + + # Hg issue 87: Allow duplicate names of groups + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(?d))(e)", + "abe").groups(), ("a", "b", "e")) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(?d))(e)", + "abe").capturesdict(), {"a": ["a"], "b": ["b"]}) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(?d))(e)", + "cde").groups(), ("d", None, "e")) + self.assertEqual(regex.match(r"(?|(?a)(?b)|(c)(?d))(e)", + "cde").capturesdict(), {"a": ["c", "d"], "b": []}) + + def test_set(self): + self.assertEqual(regex.match(r"[a]", "a").span(), (0, 1)) + self.assertEqual(regex.match(r"(?i)[a]", "A").span(), (0, 1)) + self.assertEqual(regex.match(r"[a-b]", r"a").span(), (0, 1)) + self.assertEqual(regex.match(r"(?i)[a-b]", r"A").span(), (0, 1)) + + self.assertEqual(regex.sub(r"(?V0)([][])", r"-", "a[b]c"), "a-b-c") + + self.assertEqual(regex.findall(r"[\p{Alpha}]", "a0"), ["a"]) + self.assertEqual(regex.findall(r"(?i)[\p{Alpha}]", "A0"), ["A"]) + + self.assertEqual(regex.findall(r"[a\p{Alpha}]", "ab0"), ["a", "b"]) + self.assertEqual(regex.findall(r"[a\P{Alpha}]", "ab0"), ["a", "0"]) + self.assertEqual(regex.findall(r"(?i)[a\p{Alpha}]", "ab0"), ["a", + "b"]) + self.assertEqual(regex.findall(r"(?i)[a\P{Alpha}]", "ab0"), ["a", + "0"]) + + self.assertEqual(regex.findall(r"[a-b\p{Alpha}]", "abC0"), ["a", + "b", "C"]) + self.assertEqual(regex.findall(r"(?i)[a-b\p{Alpha}]", "AbC0"), ["A", + "b", "C"]) + + self.assertEqual(regex.findall(r"[\p{Alpha}]", "a0"), ["a"]) + self.assertEqual(regex.findall(r"[\P{Alpha}]", "a0"), ["0"]) + self.assertEqual(regex.findall(r"[^\p{Alpha}]", "a0"), ["0"]) + self.assertEqual(regex.findall(r"[^\P{Alpha}]", "a0"), ["a"]) + + self.assertEqual("".join(regex.findall(r"[^\d-h]", "a^b12c-h")), + 'a^bc') + self.assertEqual("".join(regex.findall(r"[^\dh]", "a^b12c-h")), + 'a^bc-') + self.assertEqual("".join(regex.findall(r"[^h\s\db]", "a^b 12c-h")), + 'a^c-') + self.assertEqual("".join(regex.findall(r"[^b\w]", "a b")), ' ') + self.assertEqual("".join(regex.findall(r"[^b\S]", "a b")), ' ') + self.assertEqual("".join(regex.findall(r"[^8\d]", "a 1b2")), 'a b') + + all_chars = "".join(chr(c) for c in range(0x100)) + self.assertEqual(len(regex.findall(r"\p{ASCII}", all_chars)), 128) + self.assertEqual(len(regex.findall(r"\p{Letter}", all_chars)), + 117) + self.assertEqual(len(regex.findall(r"\p{Digit}", all_chars)), 10) + + # Set operators + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}&&\p{Letter}]", + all_chars)), 52) + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}&&\p{Alnum}&&\p{Letter}]", + all_chars)), 52) + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}&&\p{Alnum}&&\p{Digit}]", + all_chars)), 10) + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}&&\p{Cc}]", + all_chars)), 33) + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}&&\p{Graph}]", + all_chars)), 94) + self.assertEqual(len(regex.findall(r"(?V1)[\p{ASCII}--\p{Cc}]", + all_chars)), 95) + self.assertEqual(len(regex.findall(r"[\p{Letter}\p{Digit}]", + all_chars)), 127) + self.assertEqual(len(regex.findall(r"(?V1)[\p{Letter}||\p{Digit}]", + all_chars)), 127) + self.assertEqual(len(regex.findall(r"\p{HexDigit}", all_chars)), + 22) + self.assertEqual(len(regex.findall(r"(?V1)[\p{HexDigit}~~\p{Digit}]", + all_chars)), 12) + self.assertEqual(len(regex.findall(r"(?V1)[\p{Digit}~~\p{HexDigit}]", + all_chars)), 12) + + self.assertEqual(repr(type(regex.compile(r"(?V0)([][-])"))), + self.PATTERN_CLASS) + self.assertEqual(regex.findall(r"(?V1)[[a-z]--[aei]]", "abc"), ["b", + "c"]) + self.assertEqual(regex.findall(r"(?iV1)[[a-z]--[aei]]", "abc"), ["b", + "c"]) + self.assertEqual(regex.findall(r"(?V1)[\w--a]","abc"), ["b", "c"]) + self.assertEqual(regex.findall(r"(?iV1)[\w--a]","abc"), ["b", "c"]) + + def test_various(self): + tests = [ + # Test ?P< and ?P= extensions. + ('(?Pa)', '', '', regex.error, self.BAD_GROUP_NAME), # Begins with a digit. + ('(?Pa)', '', '', regex.error, self.BAD_GROUP_NAME), # Begins with an illegal char. + ('(?Pa)', '', '', regex.error, self.BAD_GROUP_NAME), # Begins with an illegal char. + + # Same tests, for the ?P= form. + ('(?Pa)(?P=foo_123', 'aa', '', regex.error, + self.MISSING_RPAREN), + ('(?Pa)(?P=1)', 'aa', '1', ascii('a')), + ('(?Pa)(?P=0)', 'aa', '', regex.error, + self.BAD_GROUP_NAME), + ('(?Pa)(?P=-1)', 'aa', '', regex.error, + self.BAD_GROUP_NAME), + ('(?Pa)(?P=!)', 'aa', '', regex.error, + self.BAD_GROUP_NAME), + ('(?Pa)(?P=foo_124)', 'aa', '', regex.error, + self.UNKNOWN_GROUP), # Backref to undefined group. + + ('(?Pa)', 'a', '1', ascii('a')), + ('(?Pa)(?P=foo_123)', 'aa', '1', ascii('a')), + + # Mal-formed \g in pattern treated as literal for compatibility. + (r'(?a)\ga)\g<1>', 'aa', '1', ascii('a')), + (r'(?a)\g', 'aa', '', ascii(None)), + (r'(?a)\g', 'aa', '', regex.error, + self.UNKNOWN_GROUP), # Backref to undefined group. + + ('(?a)', 'a', '1', ascii('a')), + (r'(?a)\g', 'aa', '1', ascii('a')), + + # Test octal escapes. + ('\\1', 'a', '', regex.error, self.INVALID_GROUP_REF), # Backreference. + ('[\\1]', '\1', '0', "'\\x01'"), # Character. + ('\\09', chr(0) + '9', '0', ascii(chr(0) + '9')), + ('\\141', 'a', '0', ascii('a')), + ('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', + '0,11', ascii(('abcdefghijklk9', 'k'))), + + # Test \0 is handled everywhere. + (r'\0', '\0', '0', ascii('\0')), + (r'[\0a]', '\0', '0', ascii('\0')), + (r'[a\0]', '\0', '0', ascii('\0')), + (r'[^a\0]', '\0', '', ascii(None)), + + # Test various letter escapes. + (r'\a[\b]\f\n\r\t\v', '\a\b\f\n\r\t\v', '0', + ascii('\a\b\f\n\r\t\v')), + (r'[\a][\b][\f][\n][\r][\t][\v]', '\a\b\f\n\r\t\v', '0', + ascii('\a\b\f\n\r\t\v')), + (r'\xff', '\377', '0', ascii(chr(255))), + + # New \x semantics. + (r'\x00ffffffffffffff', '\377', '', ascii(None)), + (r'\x00f', '\017', '', ascii(None)), + (r'\x00fe', '\376', '', ascii(None)), + + (r'\x00ff', '\377', '', ascii(None)), + (r'\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', '0', ascii('\t\n\v\r\f\ag')), + ('\t\n\v\r\f\a\\g', '\t\n\v\r\f\ag', '0', ascii('\t\n\v\r\f\ag')), + (r'\t\n\v\r\f\a', '\t\n\v\r\f\a', '0', ascii(chr(9) + chr(10) + + chr(11) + chr(13) + chr(12) + chr(7))), + (r'[\t][\n][\v][\r][\f][\b]', '\t\n\v\r\f\b', '0', + ascii('\t\n\v\r\f\b')), + + (r"^\w+=(\\[\000-\277]|[^\n\\])*", + "SRC=eval.c g.c blah blah blah \\\\\n\tapes.c", '0', + ascii("SRC=eval.c g.c blah blah blah \\\\")), + + # Test that . only matches \n in DOTALL mode. + ('a.b', 'acb', '0', ascii('acb')), + ('a.b', 'a\nb', '', ascii(None)), + ('a.*b', 'acc\nccb', '', ascii(None)), + ('a.{4,5}b', 'acc\nccb', '', ascii(None)), + ('a.b', 'a\rb', '0', ascii('a\rb')), + # Changed to positional flags in regex 2023.12.23. + ('a.b(?s)', 'a\nb', '', ascii(None)), + ('(?s)a.b', 'a\nb', '0', ascii('a\nb')), + ('a.*(?s)b', 'acc\nccb', '', ascii(None)), + ('(?s)a.*b', 'acc\nccb', '0', ascii('acc\nccb')), + ('(?s)a.{4,5}b', 'acc\nccb', '0', ascii('acc\nccb')), + + (')', '', '', regex.error, self.TRAILING_CHARS), # Unmatched right bracket. + ('', '', '0', "''"), # Empty pattern. + ('abc', 'abc', '0', ascii('abc')), + ('abc', 'xbc', '', ascii(None)), + ('abc', 'axc', '', ascii(None)), + ('abc', 'abx', '', ascii(None)), + ('abc', 'xabcy', '0', ascii('abc')), + ('abc', 'ababc', '0', ascii('abc')), + ('ab*c', 'abc', '0', ascii('abc')), + ('ab*bc', 'abc', '0', ascii('abc')), + + ('ab*bc', 'abbc', '0', ascii('abbc')), + ('ab*bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab+bc', 'abbc', '0', ascii('abbc')), + ('ab+bc', 'abc', '', ascii(None)), + ('ab+bc', 'abq', '', ascii(None)), + ('ab+bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab?bc', 'abbc', '0', ascii('abbc')), + ('ab?bc', 'abc', '0', ascii('abc')), + ('ab?bc', 'abbbbc', '', ascii(None)), + ('ab?c', 'abc', '0', ascii('abc')), + + ('^abc$', 'abc', '0', ascii('abc')), + ('^abc$', 'abcc', '', ascii(None)), + ('^abc', 'abcc', '0', ascii('abc')), + ('^abc$', 'aabc', '', ascii(None)), + ('abc$', 'aabc', '0', ascii('abc')), + ('^', 'abc', '0', ascii('')), + ('$', 'abc', '0', ascii('')), + ('a.c', 'abc', '0', ascii('abc')), + ('a.c', 'axc', '0', ascii('axc')), + ('a.*c', 'axyzc', '0', ascii('axyzc')), + + ('a.*c', 'axyzd', '', ascii(None)), + ('a[bc]d', 'abc', '', ascii(None)), + ('a[bc]d', 'abd', '0', ascii('abd')), + ('a[b-d]e', 'abd', '', ascii(None)), + ('a[b-d]e', 'ace', '0', ascii('ace')), + ('a[b-d]', 'aac', '0', ascii('ac')), + ('a[-b]', 'a-', '0', ascii('a-')), + ('a[\\-b]', 'a-', '0', ascii('a-')), + ('a[b-]', 'a-', '0', ascii('a-')), + ('a[]b', '-', '', regex.error, self.BAD_SET), + + ('a[', '-', '', regex.error, self.BAD_SET), + ('a\\', '-', '', regex.error, self.BAD_ESCAPE), + ('abc)', '-', '', regex.error, self.TRAILING_CHARS), + ('(abc', '-', '', regex.error, self.MISSING_RPAREN), + ('a]', 'a]', '0', ascii('a]')), + ('a[]]b', 'a]b', '0', ascii('a]b')), + ('a[]]b', 'a]b', '0', ascii('a]b')), + ('a[^bc]d', 'aed', '0', ascii('aed')), + ('a[^bc]d', 'abd', '', ascii(None)), + ('a[^-b]c', 'adc', '0', ascii('adc')), + + ('a[^-b]c', 'a-c', '', ascii(None)), + ('a[^]b]c', 'a]c', '', ascii(None)), + ('a[^]b]c', 'adc', '0', ascii('adc')), + ('\\ba\\b', 'a-', '0', ascii('a')), + ('\\ba\\b', '-a', '0', ascii('a')), + ('\\ba\\b', '-a-', '0', ascii('a')), + ('\\by\\b', 'xy', '', ascii(None)), + ('\\by\\b', 'yz', '', ascii(None)), + ('\\by\\b', 'xyz', '', ascii(None)), + ('x\\b', 'xyz', '', ascii(None)), + + ('x\\B', 'xyz', '0', ascii('x')), + ('\\Bz', 'xyz', '0', ascii('z')), + ('z\\B', 'xyz', '', ascii(None)), + ('\\Bx', 'xyz', '', ascii(None)), + ('\\Ba\\B', 'a-', '', ascii(None)), + ('\\Ba\\B', '-a', '', ascii(None)), + ('\\Ba\\B', '-a-', '', ascii(None)), + ('\\By\\B', 'xy', '', ascii(None)), + ('\\By\\B', 'yz', '', ascii(None)), + ('\\By\\b', 'xy', '0', ascii('y')), + + ('\\by\\B', 'yz', '0', ascii('y')), + ('\\By\\B', 'xyz', '0', ascii('y')), + ('ab|cd', 'abc', '0', ascii('ab')), + ('ab|cd', 'abcd', '0', ascii('ab')), + ('()ef', 'def', '0,1', ascii(('ef', ''))), + ('$b', 'b', '', ascii(None)), + ('a\\(b', 'a(b', '', ascii(('a(b',))), + ('a\\(*b', 'ab', '0', ascii('ab')), + ('a\\(*b', 'a((b', '0', ascii('a((b')), + ('a\\\\b', 'a\\b', '0', ascii('a\\b')), + + ('((a))', 'abc', '0,1,2', ascii(('a', 'a', 'a'))), + ('(a)b(c)', 'abc', '0,1,2', ascii(('abc', 'a', 'c'))), + ('a+b+c', 'aabbabc', '0', ascii('abc')), + ('(a+|b)*', 'ab', '0,1', ascii(('ab', 'b'))), + ('(a+|b)+', 'ab', '0,1', ascii(('ab', 'b'))), + ('(a+|b)?', 'ab', '0,1', ascii(('a', 'a'))), + (')(', '-', '', regex.error, self.TRAILING_CHARS), + ('[^ab]*', 'cde', '0', ascii('cde')), + ('abc', '', '', ascii(None)), + ('a*', '', '0', ascii('')), + + ('a|b|c|d|e', 'e', '0', ascii('e')), + ('(a|b|c|d|e)f', 'ef', '0,1', ascii(('ef', 'e'))), + ('abcd*efg', 'abcdefg', '0', ascii('abcdefg')), + ('ab*', 'xabyabbbz', '0', ascii('ab')), + ('ab*', 'xayabbbz', '0', ascii('a')), + ('(ab|cd)e', 'abcde', '0,1', ascii(('cde', 'cd'))), + ('[abhgefdc]ij', 'hij', '0', ascii('hij')), + ('^(ab|cd)e', 'abcde', '', ascii(None)), + ('(abc|)ef', 'abcdef', '0,1', ascii(('ef', ''))), + ('(a|b)c*d', 'abcd', '0,1', ascii(('bcd', 'b'))), + + ('(ab|ab*)bc', 'abc', '0,1', ascii(('abc', 'a'))), + ('a([bc]*)c*', 'abc', '0,1', ascii(('abc', 'bc'))), + ('a([bc]*)(c*d)', 'abcd', '0,1,2', ascii(('abcd', 'bc', 'd'))), + ('a([bc]+)(c*d)', 'abcd', '0,1,2', ascii(('abcd', 'bc', 'd'))), + ('a([bc]*)(c+d)', 'abcd', '0,1,2', ascii(('abcd', 'b', 'cd'))), + ('a[bcd]*dcdcde', 'adcdcde', '0', ascii('adcdcde')), + ('a[bcd]+dcdcde', 'adcdcde', '', ascii(None)), + ('(ab|a)b*c', 'abc', '0,1', ascii(('abc', 'ab'))), + ('((a)(b)c)(d)', 'abcd', '1,2,3,4', ascii(('abc', 'a', 'b', 'd'))), + ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', '0', ascii('alpha')), + + ('^a(bc+|b[eh])g|.h$', 'abh', '0,1', ascii(('bh', None))), + ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', '0,1,2', ascii(('effgz', + 'effgz', None))), + ('(bc+d$|ef*g.|h?i(j|k))', 'ij', '0,1,2', ascii(('ij', 'ij', + 'j'))), + ('(bc+d$|ef*g.|h?i(j|k))', 'effg', '', ascii(None)), + ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', '', ascii(None)), + ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', '0,1,2', ascii(('effgz', + 'effgz', None))), + ('(((((((((a)))))))))', 'a', '0', ascii('a')), + ('multiple words of text', 'uh-uh', '', ascii(None)), + ('multiple words', 'multiple words, yeah', '0', + ascii('multiple words')), + ('(.*)c(.*)', 'abcde', '0,1,2', ascii(('abcde', 'ab', 'de'))), + + ('\\((.*), (.*)\\)', '(a, b)', '2,1', ascii(('b', 'a'))), + ('[k]', 'ab', '', ascii(None)), + ('a[-]?c', 'ac', '0', ascii('ac')), + ('(abc)\\1', 'abcabc', '1', ascii('abc')), + ('([a-c]*)\\1', 'abcabc', '1', ascii('abc')), + ('^(.+)?B', 'AB', '1', ascii('A')), + ('(a+).\\1$', 'aaaaa', '0,1', ascii(('aaaaa', 'aa'))), + ('^(a+).\\1$', 'aaaa', '', ascii(None)), + ('(abc)\\1', 'abcabc', '0,1', ascii(('abcabc', 'abc'))), + ('([a-c]+)\\1', 'abcabc', '0,1', ascii(('abcabc', 'abc'))), + + ('(a)\\1', 'aa', '0,1', ascii(('aa', 'a'))), + ('(a+)\\1', 'aa', '0,1', ascii(('aa', 'a'))), + ('(a+)+\\1', 'aa', '0,1', ascii(('aa', 'a'))), + ('(a).+\\1', 'aba', '0,1', ascii(('aba', 'a'))), + ('(a)ba*\\1', 'aba', '0,1', ascii(('aba', 'a'))), + ('(aa|a)a\\1$', 'aaa', '0,1', ascii(('aaa', 'a'))), + ('(a|aa)a\\1$', 'aaa', '0,1', ascii(('aaa', 'a'))), + ('(a+)a\\1$', 'aaa', '0,1', ascii(('aaa', 'a'))), + ('([abc]*)\\1', 'abcabc', '0,1', ascii(('abcabc', 'abc'))), + ('(a)(b)c|ab', 'ab', '0,1,2', ascii(('ab', None, None))), + + ('(a)+x', 'aaax', '0,1', ascii(('aaax', 'a'))), + ('([ac])+x', 'aacx', '0,1', ascii(('aacx', 'c'))), + ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', '0,1', + ascii(('d:msgs/tdir/sub1/', 'tdir/'))), + ('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', + '0,1,2,3', ascii(('track1.title:TBlah blah blah', 'track1', + 'title', 'Blah blah blah'))), + ('([^N]*N)+', 'abNNxyzN', '0,1', ascii(('abNNxyzN', 'xyzN'))), + ('([^N]*N)+', 'abNNxyz', '0,1', ascii(('abNN', 'N'))), + ('([abc]*)x', 'abcx', '0,1', ascii(('abcx', 'abc'))), + ('([abc]*)x', 'abc', '', ascii(None)), + ('([xyz]*)x', 'abcx', '0,1', ascii(('x', ''))), + ('(a)+b|aac', 'aac', '0,1', ascii(('aac', None))), + + # Test symbolic groups. + ('(?Paaa)a', 'aaaa', '', regex.error, self.BAD_GROUP_NAME), + ('(?Paaa)a', 'aaaa', '0,id', ascii(('aaaa', 'aaa'))), + ('(?Paa)(?P=id)', 'aaaa', '0,id', ascii(('aaaa', 'aa'))), + ('(?Paa)(?P=xd)', 'aaaa', '', regex.error, self.UNKNOWN_GROUP), + + # Character properties. + (r"\g", "g", '0', ascii('g')), + (r"\g<1>", "g", '', regex.error, self.INVALID_GROUP_REF), + (r"(.)\g<1>", "gg", '0', ascii('gg')), + (r"(.)\g<1>", "gg", '', ascii(('gg', 'g'))), + (r"\N", "N", '0', ascii('N')), + (r"\N{LATIN SMALL LETTER A}", "a", '0', ascii('a')), + (r"\p", "p", '0', ascii('p')), + (r"\p{Ll}", "a", '0', ascii('a')), + (r"\P", "P", '0', ascii('P')), + (r"\P{Lu}", "p", '0', ascii('p')), + + # All tests from Perl. + ('abc', 'abc', '0', ascii('abc')), + ('abc', 'xbc', '', ascii(None)), + ('abc', 'axc', '', ascii(None)), + ('abc', 'abx', '', ascii(None)), + ('abc', 'xabcy', '0', ascii('abc')), + ('abc', 'ababc', '0', ascii('abc')), + + ('ab*c', 'abc', '0', ascii('abc')), + ('ab*bc', 'abc', '0', ascii('abc')), + ('ab*bc', 'abbc', '0', ascii('abbc')), + ('ab*bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab{0,}bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab+bc', 'abbc', '0', ascii('abbc')), + ('ab+bc', 'abc', '', ascii(None)), + ('ab+bc', 'abq', '', ascii(None)), + ('ab{1,}bc', 'abq', '', ascii(None)), + ('ab+bc', 'abbbbc', '0', ascii('abbbbc')), + + ('ab{1,}bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab{1,3}bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab{3,4}bc', 'abbbbc', '0', ascii('abbbbc')), + ('ab{4,5}bc', 'abbbbc', '', ascii(None)), + ('ab?bc', 'abbc', '0', ascii('abbc')), + ('ab?bc', 'abc', '0', ascii('abc')), + ('ab{0,1}bc', 'abc', '0', ascii('abc')), + ('ab?bc', 'abbbbc', '', ascii(None)), + ('ab?c', 'abc', '0', ascii('abc')), + ('ab{0,1}c', 'abc', '0', ascii('abc')), + + ('^abc$', 'abc', '0', ascii('abc')), + ('^abc$', 'abcc', '', ascii(None)), + ('^abc', 'abcc', '0', ascii('abc')), + ('^abc$', 'aabc', '', ascii(None)), + ('abc$', 'aabc', '0', ascii('abc')), + ('^', 'abc', '0', ascii('')), + ('$', 'abc', '0', ascii('')), + ('a.c', 'abc', '0', ascii('abc')), + ('a.c', 'axc', '0', ascii('axc')), + ('a.*c', 'axyzc', '0', ascii('axyzc')), + + ('a.*c', 'axyzd', '', ascii(None)), + ('a[bc]d', 'abc', '', ascii(None)), + ('a[bc]d', 'abd', '0', ascii('abd')), + ('a[b-d]e', 'abd', '', ascii(None)), + ('a[b-d]e', 'ace', '0', ascii('ace')), + ('a[b-d]', 'aac', '0', ascii('ac')), + ('a[-b]', 'a-', '0', ascii('a-')), + ('a[b-]', 'a-', '0', ascii('a-')), + ('a[b-a]', '-', '', regex.error, self.BAD_CHAR_RANGE), + ('a[]b', '-', '', regex.error, self.BAD_SET), + + ('a[', '-', '', regex.error, self.BAD_SET), + ('a]', 'a]', '0', ascii('a]')), + ('a[]]b', 'a]b', '0', ascii('a]b')), + ('a[^bc]d', 'aed', '0', ascii('aed')), + ('a[^bc]d', 'abd', '', ascii(None)), + ('a[^-b]c', 'adc', '0', ascii('adc')), + ('a[^-b]c', 'a-c', '', ascii(None)), + ('a[^]b]c', 'a]c', '', ascii(None)), + ('a[^]b]c', 'adc', '0', ascii('adc')), + ('ab|cd', 'abc', '0', ascii('ab')), + + ('ab|cd', 'abcd', '0', ascii('ab')), + ('()ef', 'def', '0,1', ascii(('ef', ''))), + ('*a', '-', '', regex.error, self.NOTHING_TO_REPEAT), + ('(*)b', '-', '', regex.error, self.NOTHING_TO_REPEAT), + ('$b', 'b', '', ascii(None)), + ('a\\', '-', '', regex.error, self.BAD_ESCAPE), + ('a\\(b', 'a(b', '', ascii(('a(b',))), + ('a\\(*b', 'ab', '0', ascii('ab')), + ('a\\(*b', 'a((b', '0', ascii('a((b')), + ('a\\\\b', 'a\\b', '0', ascii('a\\b')), + + ('abc)', '-', '', regex.error, self.TRAILING_CHARS), + ('(abc', '-', '', regex.error, self.MISSING_RPAREN), + ('((a))', 'abc', '0,1,2', ascii(('a', 'a', 'a'))), + ('(a)b(c)', 'abc', '0,1,2', ascii(('abc', 'a', 'c'))), + ('a+b+c', 'aabbabc', '0', ascii('abc')), + ('a{1,}b{1,}c', 'aabbabc', '0', ascii('abc')), + ('a**', '-', '', regex.error, self.MULTIPLE_REPEAT), + ('a.+?c', 'abcabc', '0', ascii('abc')), + ('(a+|b)*', 'ab', '0,1', ascii(('ab', 'b'))), + ('(a+|b){0,}', 'ab', '0,1', ascii(('ab', 'b'))), + + ('(a+|b)+', 'ab', '0,1', ascii(('ab', 'b'))), + ('(a+|b){1,}', 'ab', '0,1', ascii(('ab', 'b'))), + ('(a+|b)?', 'ab', '0,1', ascii(('a', 'a'))), + ('(a+|b){0,1}', 'ab', '0,1', ascii(('a', 'a'))), + (')(', '-', '', regex.error, self.TRAILING_CHARS), + ('[^ab]*', 'cde', '0', ascii('cde')), + ('abc', '', '', ascii(None)), + ('a*', '', '0', ascii('')), + ('([abc])*d', 'abbbcd', '0,1', ascii(('abbbcd', 'c'))), + ('([abc])*bcd', 'abcd', '0,1', ascii(('abcd', 'a'))), + + ('a|b|c|d|e', 'e', '0', ascii('e')), + ('(a|b|c|d|e)f', 'ef', '0,1', ascii(('ef', 'e'))), + ('abcd*efg', 'abcdefg', '0', ascii('abcdefg')), + ('ab*', 'xabyabbbz', '0', ascii('ab')), + ('ab*', 'xayabbbz', '0', ascii('a')), + ('(ab|cd)e', 'abcde', '0,1', ascii(('cde', 'cd'))), + ('[abhgefdc]ij', 'hij', '0', ascii('hij')), + ('^(ab|cd)e', 'abcde', '', ascii(None)), + ('(abc|)ef', 'abcdef', '0,1', ascii(('ef', ''))), + ('(a|b)c*d', 'abcd', '0,1', ascii(('bcd', 'b'))), + + ('(ab|ab*)bc', 'abc', '0,1', ascii(('abc', 'a'))), + ('a([bc]*)c*', 'abc', '0,1', ascii(('abc', 'bc'))), + ('a([bc]*)(c*d)', 'abcd', '0,1,2', ascii(('abcd', 'bc', 'd'))), + ('a([bc]+)(c*d)', 'abcd', '0,1,2', ascii(('abcd', 'bc', 'd'))), + ('a([bc]*)(c+d)', 'abcd', '0,1,2', ascii(('abcd', 'b', 'cd'))), + ('a[bcd]*dcdcde', 'adcdcde', '0', ascii('adcdcde')), + ('a[bcd]+dcdcde', 'adcdcde', '', ascii(None)), + ('(ab|a)b*c', 'abc', '0,1', ascii(('abc', 'ab'))), + ('((a)(b)c)(d)', 'abcd', '1,2,3,4', ascii(('abc', 'a', 'b', 'd'))), + ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', '0', ascii('alpha')), + + ('^a(bc+|b[eh])g|.h$', 'abh', '0,1', ascii(('bh', None))), + ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', '0,1,2', ascii(('effgz', + 'effgz', None))), + ('(bc+d$|ef*g.|h?i(j|k))', 'ij', '0,1,2', ascii(('ij', 'ij', + 'j'))), + ('(bc+d$|ef*g.|h?i(j|k))', 'effg', '', ascii(None)), + ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', '', ascii(None)), + ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', '0,1,2', ascii(('effgz', + 'effgz', None))), + ('((((((((((a))))))))))', 'a', '10', ascii('a')), + ('((((((((((a))))))))))\\10', 'aa', '0', ascii('aa')), + + # Python does not have the same rules for \\41 so this is a syntax error + # ('((((((((((a))))))))))\\41', 'aa', '', ascii(None)), + # ('((((((((((a))))))))))\\41', 'a!', '0', ascii('a!')), + ('((((((((((a))))))))))\\41', '', '', regex.error, + self.INVALID_GROUP_REF), + ('(?i)((((((((((a))))))))))\\41', '', '', regex.error, + self.INVALID_GROUP_REF), + + ('(((((((((a)))))))))', 'a', '0', ascii('a')), + ('multiple words of text', 'uh-uh', '', ascii(None)), + ('multiple words', 'multiple words, yeah', '0', + ascii('multiple words')), + ('(.*)c(.*)', 'abcde', '0,1,2', ascii(('abcde', 'ab', 'de'))), + ('\\((.*), (.*)\\)', '(a, b)', '2,1', ascii(('b', 'a'))), + ('[k]', 'ab', '', ascii(None)), + ('a[-]?c', 'ac', '0', ascii('ac')), + ('(abc)\\1', 'abcabc', '1', ascii('abc')), + ('([a-c]*)\\1', 'abcabc', '1', ascii('abc')), + ('(?i)abc', 'ABC', '0', ascii('ABC')), + + ('(?i)abc', 'XBC', '', ascii(None)), + ('(?i)abc', 'AXC', '', ascii(None)), + ('(?i)abc', 'ABX', '', ascii(None)), + ('(?i)abc', 'XABCY', '0', ascii('ABC')), + ('(?i)abc', 'ABABC', '0', ascii('ABC')), + ('(?i)ab*c', 'ABC', '0', ascii('ABC')), + ('(?i)ab*bc', 'ABC', '0', ascii('ABC')), + ('(?i)ab*bc', 'ABBC', '0', ascii('ABBC')), + ('(?i)ab*?bc', 'ABBBBC', '0', ascii('ABBBBC')), + ('(?i)ab{0,}?bc', 'ABBBBC', '0', ascii('ABBBBC')), + + ('(?i)ab+?bc', 'ABBC', '0', ascii('ABBC')), + ('(?i)ab+bc', 'ABC', '', ascii(None)), + ('(?i)ab+bc', 'ABQ', '', ascii(None)), + ('(?i)ab{1,}bc', 'ABQ', '', ascii(None)), + ('(?i)ab+bc', 'ABBBBC', '0', ascii('ABBBBC')), + ('(?i)ab{1,}?bc', 'ABBBBC', '0', ascii('ABBBBC')), + ('(?i)ab{1,3}?bc', 'ABBBBC', '0', ascii('ABBBBC')), + ('(?i)ab{3,4}?bc', 'ABBBBC', '0', ascii('ABBBBC')), + ('(?i)ab{4,5}?bc', 'ABBBBC', '', ascii(None)), + ('(?i)ab??bc', 'ABBC', '0', ascii('ABBC')), + + ('(?i)ab??bc', 'ABC', '0', ascii('ABC')), + ('(?i)ab{0,1}?bc', 'ABC', '0', ascii('ABC')), + ('(?i)ab??bc', 'ABBBBC', '', ascii(None)), + ('(?i)ab??c', 'ABC', '0', ascii('ABC')), + ('(?i)ab{0,1}?c', 'ABC', '0', ascii('ABC')), + ('(?i)^abc$', 'ABC', '0', ascii('ABC')), + ('(?i)^abc$', 'ABCC', '', ascii(None)), + ('(?i)^abc', 'ABCC', '0', ascii('ABC')), + ('(?i)^abc$', 'AABC', '', ascii(None)), + ('(?i)abc$', 'AABC', '0', ascii('ABC')), + + ('(?i)^', 'ABC', '0', ascii('')), + ('(?i)$', 'ABC', '0', ascii('')), + ('(?i)a.c', 'ABC', '0', ascii('ABC')), + ('(?i)a.c', 'AXC', '0', ascii('AXC')), + ('(?i)a.*?c', 'AXYZC', '0', ascii('AXYZC')), + ('(?i)a.*c', 'AXYZD', '', ascii(None)), + ('(?i)a[bc]d', 'ABC', '', ascii(None)), + ('(?i)a[bc]d', 'ABD', '0', ascii('ABD')), + ('(?i)a[b-d]e', 'ABD', '', ascii(None)), + ('(?i)a[b-d]e', 'ACE', '0', ascii('ACE')), + + ('(?i)a[b-d]', 'AAC', '0', ascii('AC')), + ('(?i)a[-b]', 'A-', '0', ascii('A-')), + ('(?i)a[b-]', 'A-', '0', ascii('A-')), + ('(?i)a[b-a]', '-', '', regex.error, self.BAD_CHAR_RANGE), + ('(?i)a[]b', '-', '', regex.error, self.BAD_SET), + ('(?i)a[', '-', '', regex.error, self.BAD_SET), + ('(?i)a]', 'A]', '0', ascii('A]')), + ('(?i)a[]]b', 'A]B', '0', ascii('A]B')), + ('(?i)a[^bc]d', 'AED', '0', ascii('AED')), + ('(?i)a[^bc]d', 'ABD', '', ascii(None)), + + ('(?i)a[^-b]c', 'ADC', '0', ascii('ADC')), + ('(?i)a[^-b]c', 'A-C', '', ascii(None)), + ('(?i)a[^]b]c', 'A]C', '', ascii(None)), + ('(?i)a[^]b]c', 'ADC', '0', ascii('ADC')), + ('(?i)ab|cd', 'ABC', '0', ascii('AB')), + ('(?i)ab|cd', 'ABCD', '0', ascii('AB')), + ('(?i)()ef', 'DEF', '0,1', ascii(('EF', ''))), + ('(?i)*a', '-', '', regex.error, self.NOTHING_TO_REPEAT), + ('(?i)(*)b', '-', '', regex.error, self.NOTHING_TO_REPEAT), + ('(?i)$b', 'B', '', ascii(None)), + + ('(?i)a\\', '-', '', regex.error, self.BAD_ESCAPE), + ('(?i)a\\(b', 'A(B', '', ascii(('A(B',))), + ('(?i)a\\(*b', 'AB', '0', ascii('AB')), + ('(?i)a\\(*b', 'A((B', '0', ascii('A((B')), + ('(?i)a\\\\b', 'A\\B', '0', ascii('A\\B')), + ('(?i)abc)', '-', '', regex.error, self.TRAILING_CHARS), + ('(?i)(abc', '-', '', regex.error, self.MISSING_RPAREN), + ('(?i)((a))', 'ABC', '0,1,2', ascii(('A', 'A', 'A'))), + ('(?i)(a)b(c)', 'ABC', '0,1,2', ascii(('ABC', 'A', 'C'))), + ('(?i)a+b+c', 'AABBABC', '0', ascii('ABC')), + + ('(?i)a{1,}b{1,}c', 'AABBABC', '0', ascii('ABC')), + ('(?i)a**', '-', '', regex.error, self.MULTIPLE_REPEAT), + ('(?i)a.+?c', 'ABCABC', '0', ascii('ABC')), + ('(?i)a.*?c', 'ABCABC', '0', ascii('ABC')), + ('(?i)a.{0,5}?c', 'ABCABC', '0', ascii('ABC')), + ('(?i)(a+|b)*', 'AB', '0,1', ascii(('AB', 'B'))), + ('(?i)(a+|b){0,}', 'AB', '0,1', ascii(('AB', 'B'))), + ('(?i)(a+|b)+', 'AB', '0,1', ascii(('AB', 'B'))), + ('(?i)(a+|b){1,}', 'AB', '0,1', ascii(('AB', 'B'))), + ('(?i)(a+|b)?', 'AB', '0,1', ascii(('A', 'A'))), + + ('(?i)(a+|b){0,1}', 'AB', '0,1', ascii(('A', 'A'))), + ('(?i)(a+|b){0,1}?', 'AB', '0,1', ascii(('', None))), + ('(?i))(', '-', '', regex.error, self.TRAILING_CHARS), + ('(?i)[^ab]*', 'CDE', '0', ascii('CDE')), + ('(?i)abc', '', '', ascii(None)), + ('(?i)a*', '', '0', ascii('')), + ('(?i)([abc])*d', 'ABBBCD', '0,1', ascii(('ABBBCD', 'C'))), + ('(?i)([abc])*bcd', 'ABCD', '0,1', ascii(('ABCD', 'A'))), + ('(?i)a|b|c|d|e', 'E', '0', ascii('E')), + ('(?i)(a|b|c|d|e)f', 'EF', '0,1', ascii(('EF', 'E'))), + + ('(?i)abcd*efg', 'ABCDEFG', '0', ascii('ABCDEFG')), + ('(?i)ab*', 'XABYABBBZ', '0', ascii('AB')), + ('(?i)ab*', 'XAYABBBZ', '0', ascii('A')), + ('(?i)(ab|cd)e', 'ABCDE', '0,1', ascii(('CDE', 'CD'))), + ('(?i)[abhgefdc]ij', 'HIJ', '0', ascii('HIJ')), + ('(?i)^(ab|cd)e', 'ABCDE', '', ascii(None)), + ('(?i)(abc|)ef', 'ABCDEF', '0,1', ascii(('EF', ''))), + ('(?i)(a|b)c*d', 'ABCD', '0,1', ascii(('BCD', 'B'))), + ('(?i)(ab|ab*)bc', 'ABC', '0,1', ascii(('ABC', 'A'))), + ('(?i)a([bc]*)c*', 'ABC', '0,1', ascii(('ABC', 'BC'))), + + ('(?i)a([bc]*)(c*d)', 'ABCD', '0,1,2', ascii(('ABCD', 'BC', 'D'))), + ('(?i)a([bc]+)(c*d)', 'ABCD', '0,1,2', ascii(('ABCD', 'BC', 'D'))), + ('(?i)a([bc]*)(c+d)', 'ABCD', '0,1,2', ascii(('ABCD', 'B', 'CD'))), + ('(?i)a[bcd]*dcdcde', 'ADCDCDE', '0', ascii('ADCDCDE')), + ('(?i)a[bcd]+dcdcde', 'ADCDCDE', '', ascii(None)), + ('(?i)(ab|a)b*c', 'ABC', '0,1', ascii(('ABC', 'AB'))), + ('(?i)((a)(b)c)(d)', 'ABCD', '1,2,3,4', ascii(('ABC', 'A', 'B', + 'D'))), + ('(?i)[a-zA-Z_][a-zA-Z0-9_]*', 'ALPHA', '0', ascii('ALPHA')), + ('(?i)^a(bc+|b[eh])g|.h$', 'ABH', '0,1', ascii(('BH', None))), + ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFGZ', '0,1,2', ascii(('EFFGZ', + 'EFFGZ', None))), + + ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'IJ', '0,1,2', ascii(('IJ', 'IJ', + 'J'))), + ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFG', '', ascii(None)), + ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'BCDD', '', ascii(None)), + ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'REFFGZ', '0,1,2', ascii(('EFFGZ', + 'EFFGZ', None))), + ('(?i)((((((((((a))))))))))', 'A', '10', ascii('A')), + ('(?i)((((((((((a))))))))))\\10', 'AA', '0', ascii('AA')), + #('(?i)((((((((((a))))))))))\\41', 'AA', '', ascii(None)), + #('(?i)((((((((((a))))))))))\\41', 'A!', '0', ascii('A!')), + ('(?i)(((((((((a)))))))))', 'A', '0', ascii('A')), + ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))', 'A', '1', + ascii('A')), + ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))', 'C', '1', + ascii('C')), + ('(?i)multiple words of text', 'UH-UH', '', ascii(None)), + + ('(?i)multiple words', 'MULTIPLE WORDS, YEAH', '0', + ascii('MULTIPLE WORDS')), + ('(?i)(.*)c(.*)', 'ABCDE', '0,1,2', ascii(('ABCDE', 'AB', 'DE'))), + ('(?i)\\((.*), (.*)\\)', '(A, B)', '2,1', ascii(('B', 'A'))), + ('(?i)[k]', 'AB', '', ascii(None)), + # ('(?i)abcd', 'ABCD', SUCCEED, 'found+"-"+\\found+"-"+\\\\found', ascii(ABCD-$&-\\ABCD)), + # ('(?i)a(bc)d', 'ABCD', SUCCEED, 'g1+"-"+\\g1+"-"+\\\\g1', ascii(BC-$1-\\BC)), + ('(?i)a[-]?c', 'AC', '0', ascii('AC')), + ('(?i)(abc)\\1', 'ABCABC', '1', ascii('ABC')), + ('(?i)([a-c]*)\\1', 'ABCABC', '1', ascii('ABC')), + ('a(?!b).', 'abad', '0', ascii('ad')), + ('a(?=d).', 'abad', '0', ascii('ad')), + ('a(?=c|d).', 'abad', '0', ascii('ad')), + + ('a(?:b|c|d)(.)', 'ace', '1', ascii('e')), + ('a(?:b|c|d)*(.)', 'ace', '1', ascii('e')), + ('a(?:b|c|d)+?(.)', 'ace', '1', ascii('e')), + ('a(?:b|(c|e){1,2}?|d)+?(.)', 'ace', '1,2', ascii(('c', 'e'))), + + # Lookbehind: split by : but not if it is escaped by -. + ('(?]*?b', 'a>b', '', ascii(None)), + # Bug 490573: minimizing repeat problem. + (r'^a*?$', 'foo', '', ascii(None)), + # Bug 470582: nested groups problem. + (r'^((a)c)?(ab)$', 'ab', '1,2,3', ascii((None, None, 'ab'))), + # Another minimizing repeat problem (capturing groups in assertions). + ('^([ab]*?)(?=(b)?)c', 'abc', '1,2', ascii(('ab', None))), + ('^([ab]*?)(?!(b))c', 'abc', '1,2', ascii(('ab', None))), + ('^([ab]*?)(?(.){0,2})d", "abcd").captures(1), + ['b', 'c']) + self.assertEqual(regex.search(r"(.)+", "a").captures(1), ['a']) + + def test_guards(self): + m = regex.search(r"(X.*?Y\s*){3}(X\s*)+AB:", + "XY\nX Y\nX Y\nXY\nXX AB:") + self.assertEqual(m.span(0, 1, 2), ((3, 21), (12, 15), (16, 18))) + + m = regex.search(r"(X.*?Y\s*){3,}(X\s*)+AB:", + "XY\nX Y\nX Y\nXY\nXX AB:") + self.assertEqual(m.span(0, 1, 2), ((0, 21), (12, 15), (16, 18))) + + m = regex.search(r'\d{4}(\s*\w)?\W*((?!\d)\w){2}', "9999XX") + self.assertEqual(m.span(0, 1, 2), ((0, 6), (-1, -1), (5, 6))) + + m = regex.search(r'A\s*?.*?(\n+.*?\s*?){0,2}\(X', 'A\n1\nS\n1 (X') + self.assertEqual(m.span(0, 1), ((0, 10), (5, 8))) + + m = regex.search(r'Derde\s*:', 'aaaaaa:\nDerde:') + self.assertEqual(m.span(), (8, 14)) + m = regex.search(r'Derde\s*:', 'aaaaa:\nDerde:') + self.assertEqual(m.span(), (7, 13)) + + def test_turkic(self): + # Turkish has dotted and dotless I/i. + pairs = "I=i;I=\u0131;i=\u0130" + + all_chars = set() + matching = set() + for pair in pairs.split(";"): + ch1, ch2 = pair.split("=") + all_chars.update((ch1, ch2)) + matching.add((ch1, ch1)) + matching.add((ch1, ch2)) + matching.add((ch2, ch1)) + matching.add((ch2, ch2)) + + for ch1 in all_chars: + for ch2 in all_chars: + m = regex.match(r"(?i)\A" + ch1 + r"\Z", ch2) + if m: + if (ch1, ch2) not in matching: + self.fail("{} matching {}".format(ascii(ch1), + ascii(ch2))) + else: + if (ch1, ch2) in matching: + self.fail("{} not matching {}".format(ascii(ch1), + ascii(ch2))) + + def test_named_lists(self): + options = ["one", "two", "three"] + self.assertEqual(regex.match(r"333\L444", "333one444", + bar=options).group(), "333one444") + self.assertEqual(regex.match(r"(?i)333\L444", "333TWO444", + bar=options).group(), "333TWO444") + self.assertEqual(regex.match(r"333\L444", "333four444", + bar=options), None) + + options = [b"one", b"two", b"three"] + self.assertEqual(regex.match(br"333\L444", b"333one444", + bar=options).group(), b"333one444") + self.assertEqual(regex.match(br"(?i)333\L444", b"333TWO444", + bar=options).group(), b"333TWO444") + self.assertEqual(regex.match(br"333\L444", b"333four444", + bar=options), None) + + self.assertEqual(repr(type(regex.compile(r"3\L4\L+5", + bar=["one", "two", "three"]))), self.PATTERN_CLASS) + + self.assertEqual(regex.findall(r"^\L", "solid QWERT", + options=set(['good', 'brilliant', '+s\\ol[i}d'])), []) + self.assertEqual(regex.findall(r"^\L", "+solid QWERT", + options=set(['good', 'brilliant', '+solid'])), ['+solid']) + + options = ["STRASSE"] + self.assertEqual(regex.match(r"(?fi)\L", + "stra\N{LATIN SMALL LETTER SHARP S}e", words=options).span(), (0, + 6)) + + options = ["STRASSE", "stress"] + self.assertEqual(regex.match(r"(?fi)\L", + "stra\N{LATIN SMALL LETTER SHARP S}e", words=options).span(), (0, + 6)) + + options = ["stra\N{LATIN SMALL LETTER SHARP S}e"] + self.assertEqual(regex.match(r"(?fi)\L", "STRASSE", + words=options).span(), (0, 7)) + + options = ["kit"] + self.assertEqual(regex.search(r"(?i)\L", "SKITS", + words=options).span(), (1, 4)) + self.assertEqual(regex.search(r"(?i)\L", + "SK\N{LATIN CAPITAL LETTER I WITH DOT ABOVE}TS", + words=options).span(), (1, 4)) + + self.assertEqual(regex.search(r"(?fi)\b(\w+) +\1\b", + " stra\N{LATIN SMALL LETTER SHARP S}e STRASSE ").span(), (1, 15)) + self.assertEqual(regex.search(r"(?fi)\b(\w+) +\1\b", + " STRASSE stra\N{LATIN SMALL LETTER SHARP S}e ").span(), (1, 15)) + + self.assertEqual(regex.search(r"^\L$", "", options=[]).span(), + (0, 0)) + + def test_fuzzy(self): + # Some tests borrowed from TRE library tests. + self.assertEqual(repr(type(regex.compile('(fou){s,e<=1}'))), + self.PATTERN_CLASS) + self.assertEqual(repr(type(regex.compile('(fuu){s}'))), + self.PATTERN_CLASS) + self.assertEqual(repr(type(regex.compile('(fuu){s,e}'))), + self.PATTERN_CLASS) + self.assertEqual(repr(type(regex.compile('(anaconda){1i+1d<1,s<=1}'))), + self.PATTERN_CLASS) + self.assertEqual(repr(type(regex.compile('(anaconda){1i+1d<1,s<=1,e<=10}'))), + self.PATTERN_CLASS) + self.assertEqual(repr(type(regex.compile('(anaconda){s<=1,e<=1,1i+1d<1}'))), + self.PATTERN_CLASS) + + text = 'molasses anaconda foo bar baz smith anderson ' + self.assertEqual(regex.search('(znacnda){s<=1,e<=3,1i+1d<1}', text), + None) + self.assertEqual(regex.search('(znacnda){s<=1,e<=3,1i+1d<2}', + text).span(0, 1), ((9, 17), (9, 17))) + self.assertEqual(regex.search('(ananda){1i+1d<2}', text), None) + self.assertEqual(regex.search(r"(?:\bznacnda){e<=2}", text)[0], + "anaconda") + self.assertEqual(regex.search(r"(?:\bnacnda){e<=2}", text)[0], + "anaconda") + + text = 'anaconda foo bar baz smith anderson' + self.assertEqual(regex.search('(fuu){i<=3,d<=3,e<=5}', text).span(0, + 1), ((0, 0), (0, 0))) + self.assertEqual(regex.search('(?b)(fuu){i<=3,d<=3,e<=5}', + text).span(0, 1), ((9, 10), (9, 10))) + self.assertEqual(regex.search('(fuu){i<=2,d<=2,e<=5}', text).span(0, + 1), ((7, 10), (7, 10))) + self.assertEqual(regex.search('(?e)(fuu){i<=2,d<=2,e<=5}', + text).span(0, 1), ((9, 10), (9, 10))) + self.assertEqual(regex.search('(fuu){i<=3,d<=3,e}', text).span(0, 1), + ((0, 0), (0, 0))) + self.assertEqual(regex.search('(?b)(fuu){i<=3,d<=3,e}', text).span(0, + 1), ((9, 10), (9, 10))) + + self.assertEqual(repr(type(regex.compile('(approximate){s<=3,1i+1d<3}'))), + self.PATTERN_CLASS) + + # No cost limit. + self.assertEqual(regex.search('(foobar){e}', + 'xirefoabralfobarxie').span(0, 1), ((0, 6), (0, 6))) + self.assertEqual(regex.search('(?e)(foobar){e}', + 'xirefoabralfobarxie').span(0, 1), ((0, 3), (0, 3))) + self.assertEqual(regex.search('(?b)(foobar){e}', + 'xirefoabralfobarxie').span(0, 1), ((11, 16), (11, 16))) + + # At most two errors. + self.assertEqual(regex.search('(foobar){e<=2}', + 'xirefoabrzlfd').span(0, 1), ((4, 9), (4, 9))) + self.assertEqual(regex.search('(foobar){e<=2}', 'xirefoabzlfd'), None) + + # At most two inserts or substitutions and max two errors total. + self.assertEqual(regex.search('(foobar){i<=2,s<=2,e<=2}', + 'oobargoobaploowap').span(0, 1), ((5, 11), (5, 11))) + + # Find best whole word match for "foobar". + self.assertEqual(regex.search('\\b(foobar){e}\\b', 'zfoobarz').span(0, + 1), ((0, 8), (0, 8))) + self.assertEqual(regex.search('\\b(foobar){e}\\b', + 'boing zfoobarz goobar woop').span(0, 1), ((0, 6), (0, 6))) + self.assertEqual(regex.search('(?b)\\b(foobar){e}\\b', + 'boing zfoobarz goobar woop').span(0, 1), ((15, 21), (15, 21))) + + # Match whole string, allow only 1 error. + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foobar').span(0, 1), + ((0, 6), (0, 6))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'xfoobar').span(0, + 1), ((0, 7), (0, 7))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foobarx').span(0, + 1), ((0, 7), (0, 7))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'fooxbar').span(0, + 1), ((0, 7), (0, 7))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foxbar').span(0, 1), + ((0, 6), (0, 6))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'xoobar').span(0, 1), + ((0, 6), (0, 6))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foobax').span(0, 1), + ((0, 6), (0, 6))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'oobar').span(0, 1), + ((0, 5), (0, 5))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'fobar').span(0, 1), + ((0, 5), (0, 5))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'fooba').span(0, 1), + ((0, 5), (0, 5))) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'xfoobarx'), None) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foobarxx'), None) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'xxfoobar'), None) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'xfoxbar'), None) + self.assertEqual(regex.search('^(foobar){e<=1}$', 'foxbarx'), None) + + # At most one insert, two deletes, and three substitutions. + # Additionally, deletes cost two and substitutes one, and total + # cost must be less than 4. + self.assertEqual(regex.search('(foobar){i<=1,d<=2,s<=3,2d+1s<4}', + '3oifaowefbaoraofuiebofasebfaobfaorfeoaro').span(0, 1), ((6, 13), (6, + 13))) + self.assertEqual(regex.search('(?b)(foobar){i<=1,d<=2,s<=3,2d+1s<4}', + '3oifaowefbaoraofuiebofasebfaobfaorfeoaro').span(0, 1), ((34, 39), + (34, 39))) + + # Partially fuzzy matches. + self.assertEqual(regex.search('foo(bar){e<=1}zap', 'foobarzap').span(0, + 1), ((0, 9), (3, 6))) + self.assertEqual(regex.search('foo(bar){e<=1}zap', 'fobarzap'), None) + self.assertEqual(regex.search('foo(bar){e<=1}zap', 'foobrzap').span(0, + 1), ((0, 8), (3, 5))) + + text = ('www.cnn.com 64.236.16.20\nwww.slashdot.org 66.35.250.150\n' + 'For useful information, use www.slashdot.org\nthis is demo data!\n') + self.assertEqual(regex.search(r'(?s)^.*(dot.org){e}.*$', text).span(0, + 1), ((0, 120), (120, 120))) + self.assertEqual(regex.search(r'(?es)^.*(dot.org){e}.*$', text).span(0, + 1), ((0, 120), (93, 100))) + self.assertEqual(regex.search(r'^.*(dot.org){e}.*$', text).span(0, 1), + ((0, 119), (24, 101))) + + # Behaviour is unexpected, but arguably not wrong. It first finds the + # best match, then the best in what follows, etc. + self.assertEqual(regex.findall(r"\b\L{e<=1}\b", + " book cot dog desk ", words="cat dog".split()), ["cot", "dog"]) + self.assertEqual(regex.findall(r"\b\L{e<=1}\b", + " book dog cot desk ", words="cat dog".split()), [" dog", "cot"]) + self.assertEqual(regex.findall(r"(?e)\b\L{e<=1}\b", + " book dog cot desk ", words="cat dog".split()), ["dog", "cot"]) + self.assertEqual(regex.findall(r"(?r)\b\L{e<=1}\b", + " book cot dog desk ", words="cat dog".split()), ["dog ", "cot"]) + self.assertEqual(regex.findall(r"(?er)\b\L{e<=1}\b", + " book cot dog desk ", words="cat dog".split()), ["dog", "cot"]) + self.assertEqual(regex.findall(r"(?r)\b\L{e<=1}\b", + " book dog cot desk ", words="cat dog".split()), ["cot", "dog"]) + self.assertEqual(regex.findall(br"\b\L{e<=1}\b", + b" book cot dog desk ", words=b"cat dog".split()), [b"cot", b"dog"]) + self.assertEqual(regex.findall(br"\b\L{e<=1}\b", + b" book dog cot desk ", words=b"cat dog".split()), [b" dog", b"cot"]) + self.assertEqual(regex.findall(br"(?e)\b\L{e<=1}\b", + b" book dog cot desk ", words=b"cat dog".split()), [b"dog", b"cot"]) + self.assertEqual(regex.findall(br"(?r)\b\L{e<=1}\b", + b" book cot dog desk ", words=b"cat dog".split()), [b"dog ", b"cot"]) + self.assertEqual(regex.findall(br"(?er)\b\L{e<=1}\b", + b" book cot dog desk ", words=b"cat dog".split()), [b"dog", b"cot"]) + self.assertEqual(regex.findall(br"(?r)\b\L{e<=1}\b", + b" book dog cot desk ", words=b"cat dog".split()), [b"cot", b"dog"]) + + self.assertEqual(regex.search(r"(\w+) (\1{e<=1})", "foo fou").groups(), + ("foo", "fou")) + self.assertEqual(regex.search(r"(?r)(\2{e<=1}) (\w+)", + "foo fou").groups(), ("foo", "fou")) + self.assertEqual(regex.search(br"(\w+) (\1{e<=1})", + b"foo fou").groups(), (b"foo", b"fou")) + + self.assertEqual(regex.findall(r"(?:(?:QR)+){e}", "abcde"), ["abcde", + ""]) + self.assertEqual(regex.findall(r"(?:Q+){e}", "abc"), ["abc", ""]) + + # Hg issue 41: = for fuzzy matches + self.assertEqual(regex.match(r"(?:service detection){0[^()]+)|(?R))*\)", "(ab(cd)ef)")[ + : ], ("(ab(cd)ef)", "ef")) + self.assertEqual(regex.search(r"\(((?>[^()]+)|(?R))*\)", + "(ab(cd)ef)").captures(1), ["ab", "cd", "(cd)", "ef"]) + + self.assertEqual(regex.search(r"(?r)\(((?R)|(?>[^()]+))*\)", + "(ab(cd)ef)")[ : ], ("(ab(cd)ef)", "ab")) + self.assertEqual(regex.search(r"(?r)\(((?R)|(?>[^()]+))*\)", + "(ab(cd)ef)").captures(1), ["ef", "cd", "(cd)", "ab"]) + + self.assertEqual(regex.search(r"\(([^()]+|(?R))*\)", + "some text (a(b(c)d)e) more text")[ : ], ("(a(b(c)d)e)", "e")) + + self.assertEqual(regex.search(r"(?r)\(((?R)|[^()]+)*\)", + "some text (a(b(c)d)e) more text")[ : ], ("(a(b(c)d)e)", "a")) + + self.assertEqual(regex.search(r"(foo(\(((?:(?>[^()]+)|(?2))*)\)))", + "foo(bar(baz)+baz(bop))")[ : ], ("foo(bar(baz)+baz(bop))", + "foo(bar(baz)+baz(bop))", "(bar(baz)+baz(bop))", + "bar(baz)+baz(bop)")) + + self.assertEqual(regex.search(r"(?r)(foo(\(((?:(?2)|(?>[^()]+))*)\)))", + "foo(bar(baz)+baz(bop))")[ : ], ("foo(bar(baz)+baz(bop))", + "foo(bar(baz)+baz(bop))", "(bar(baz)+baz(bop))", + "bar(baz)+baz(bop)")) + + rgx = regex.compile(r"""^\s*(<\s*([a-zA-Z:]+)(?:\s*[a-zA-Z:]*\s*=\s*(?:'[^']*'|"[^"]*"))*\s*(/\s*)?>(?:[^<>]*|(?1))*(?(3)|<\s*/\s*\2\s*>))\s*$""") + self.assertEqual(bool(rgx.search('')), True) + self.assertEqual(bool(rgx.search('')), False) + self.assertEqual(bool(rgx.search('')), True) + self.assertEqual(bool(rgx.search('')), False) + self.assertEqual(bool(rgx.search('')), False) + + self.assertEqual(bool(rgx.search('')), False) + self.assertEqual(bool(rgx.search('')), True) + self.assertEqual(bool(rgx.search('< fooo / >')), True) + # The next regex should and does match. Perl 5.14 agrees. + #self.assertEqual(bool(rgx.search('foo')), False) + self.assertEqual(bool(rgx.search('foo')), False) + + self.assertEqual(bool(rgx.search('foo')), True) + self.assertEqual(bool(rgx.search('foo')), True) + self.assertEqual(bool(rgx.search('')), True) + + def test_copy(self): + # PatternObjects are immutable, therefore there's no need to clone them. + r = regex.compile("a") + self.assertTrue(copy.copy(r) is r) + self.assertTrue(copy.deepcopy(r) is r) + + # MatchObjects are normally mutable because the target string can be + # detached. However, after the target string has been detached, a + # MatchObject becomes immutable, so there's no need to clone it. + m = r.match("a") + self.assertTrue(copy.copy(m) is not m) + self.assertTrue(copy.deepcopy(m) is not m) + + self.assertTrue(m.string is not None) + m2 = copy.copy(m) + m2.detach_string() + self.assertTrue(m.string is not None) + self.assertTrue(m2.string is None) + + # The following behaviour matches that of the re module. + it = regex.finditer(".", "ab") + it2 = copy.copy(it) + self.assertEqual(next(it).group(), "a") + self.assertEqual(next(it2).group(), "b") + + # The following behaviour matches that of the re module. + it = regex.finditer(".", "ab") + it2 = copy.deepcopy(it) + self.assertEqual(next(it).group(), "a") + self.assertEqual(next(it2).group(), "b") + + # The following behaviour is designed to match that of copying 'finditer'. + it = regex.splititer(" ", "a b") + it2 = copy.copy(it) + self.assertEqual(next(it), "a") + self.assertEqual(next(it2), "b") + + # The following behaviour is designed to match that of copying 'finditer'. + it = regex.splititer(" ", "a b") + it2 = copy.deepcopy(it) + self.assertEqual(next(it), "a") + self.assertEqual(next(it2), "b") + + def test_format(self): + self.assertEqual(regex.subf(r"(\w+) (\w+)", "{0} => {2} {1}", + "foo bar"), "foo bar => bar foo") + self.assertEqual(regex.subf(r"(?\w+) (?\w+)", + "{word2} {word1}", "foo bar"), "bar foo") + + self.assertEqual(regex.subfn(r"(\w+) (\w+)", "{0} => {2} {1}", + "foo bar"), ("foo bar => bar foo", 1)) + self.assertEqual(regex.subfn(r"(?\w+) (?\w+)", + "{word2} {word1}", "foo bar"), ("bar foo", 1)) + + self.assertEqual(regex.match(r"(\w+) (\w+)", + "foo bar").expandf("{0} => {2} {1}"), "foo bar => bar foo") + + def test_fullmatch(self): + self.assertEqual(bool(regex.fullmatch(r"abc", "abc")), True) + self.assertEqual(bool(regex.fullmatch(r"abc", "abcx")), False) + self.assertEqual(bool(regex.fullmatch(r"abc", "abcx", endpos=3)), True) + + self.assertEqual(bool(regex.fullmatch(r"abc", "xabc", pos=1)), True) + self.assertEqual(bool(regex.fullmatch(r"abc", "xabcy", pos=1)), False) + self.assertEqual(bool(regex.fullmatch(r"abc", "xabcy", pos=1, + endpos=4)), True) + + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "abc")), True) + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "abcx")), False) + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "abcx", endpos=3)), + True) + + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "xabc", pos=1)), + True) + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "xabcy", pos=1)), + False) + self.assertEqual(bool(regex.fullmatch(r"(?r)abc", "xabcy", pos=1, + endpos=4)), True) + + def test_issue_18468(self): + self.assertTypedEqual(regex.sub('y', 'a', 'xyz'), 'xaz') + self.assertTypedEqual(regex.sub('y', StrSubclass('a'), + StrSubclass('xyz')), 'xaz') + self.assertTypedEqual(regex.sub(b'y', b'a', b'xyz'), b'xaz') + self.assertTypedEqual(regex.sub(b'y', BytesSubclass(b'a'), + BytesSubclass(b'xyz')), b'xaz') + self.assertTypedEqual(regex.sub(b'y', bytearray(b'a'), + bytearray(b'xyz')), b'xaz') + self.assertTypedEqual(regex.sub(b'y', memoryview(b'a'), + memoryview(b'xyz')), b'xaz') + + for string in ":a:b::c", StrSubclass(":a:b::c"): + self.assertTypedEqual(regex.split(":", string), ['', 'a', 'b', '', + 'c']) + if sys.version_info >= (3, 7, 0): + self.assertTypedEqual(regex.split(":*", string), ['', '', 'a', + '', 'b', '', 'c', '']) + self.assertTypedEqual(regex.split("(:*)", string), ['', ':', + '', '', 'a', ':', '', '', 'b', '::', '', '', 'c', '', '']) + else: + self.assertTypedEqual(regex.split(":*", string), ['', 'a', 'b', + 'c']) + self.assertTypedEqual(regex.split("(:*)", string), ['', ':', + 'a', ':', 'b', '::', 'c']) + + for string in (b":a:b::c", BytesSubclass(b":a:b::c"), + bytearray(b":a:b::c"), memoryview(b":a:b::c")): + self.assertTypedEqual(regex.split(b":", string), [b'', b'a', b'b', + b'', b'c']) + if sys.version_info >= (3, 7, 0): + self.assertTypedEqual(regex.split(b":*", string), [b'', b'', + b'a', b'', b'b', b'', b'c', b'']) + self.assertTypedEqual(regex.split(b"(:*)", string), [b'', b':', + b'', b'', b'a', b':', b'', b'', b'b', b'::', b'', b'', b'c', + b'', b'']) + else: + self.assertTypedEqual(regex.split(b":*", string), [b'', b'a', + b'b', b'c']) + self.assertTypedEqual(regex.split(b"(:*)", string), [b'', b':', + b'a', b':', b'b', b'::', b'c']) + + for string in "a:b::c:::d", StrSubclass("a:b::c:::d"): + self.assertTypedEqual(regex.findall(":+", string), [":", "::", + ":::"]) + self.assertTypedEqual(regex.findall("(:+)", string), [":", "::", + ":::"]) + self.assertTypedEqual(regex.findall("(:)(:*)", string), [(":", ""), + (":", ":"), (":", "::")]) + + for string in (b"a:b::c:::d", BytesSubclass(b"a:b::c:::d"), + bytearray(b"a:b::c:::d"), memoryview(b"a:b::c:::d")): + self.assertTypedEqual(regex.findall(b":+", string), [b":", b"::", + b":::"]) + self.assertTypedEqual(regex.findall(b"(:+)", string), [b":", b"::", + b":::"]) + self.assertTypedEqual(regex.findall(b"(:)(:*)", string), [(b":", + b""), (b":", b":"), (b":", b"::")]) + + for string in 'a', StrSubclass('a'): + self.assertEqual(regex.match('a', string).groups(), ()) + self.assertEqual(regex.match('(a)', string).groups(), ('a',)) + self.assertEqual(regex.match('(a)', string).group(0), 'a') + self.assertEqual(regex.match('(a)', string).group(1), 'a') + self.assertEqual(regex.match('(a)', string).group(1, 1), ('a', + 'a')) + + for string in (b'a', BytesSubclass(b'a'), bytearray(b'a'), + memoryview(b'a')): + self.assertEqual(regex.match(b'a', string).groups(), ()) + self.assertEqual(regex.match(b'(a)', string).groups(), (b'a',)) + self.assertEqual(regex.match(b'(a)', string).group(0), b'a') + self.assertEqual(regex.match(b'(a)', string).group(1), b'a') + self.assertEqual(regex.match(b'(a)', string).group(1, 1), (b'a', + b'a')) + + def test_partial(self): + self.assertEqual(regex.match('ab', 'a', partial=True).partial, True) + self.assertEqual(regex.match('ab', 'a', partial=True).span(), (0, 1)) + self.assertEqual(regex.match(r'cats', 'cat', partial=True).partial, + True) + self.assertEqual(regex.match(r'cats', 'cat', partial=True).span(), (0, + 3)) + self.assertEqual(regex.match(r'cats', 'catch', partial=True), None) + self.assertEqual(regex.match(r'abc\w{3}', 'abcdef', + partial=True).partial, False) + self.assertEqual(regex.match(r'abc\w{3}', 'abcdef', + partial=True).span(), (0, 6)) + self.assertEqual(regex.match(r'abc\w{3}', 'abcde', + partial=True).partial, True) + self.assertEqual(regex.match(r'abc\w{3}', 'abcde', + partial=True).span(), (0, 5)) + + self.assertEqual(regex.match(r'\d{4}$', '1234', partial=True).partial, + False) + + self.assertEqual(regex.match(r'\L', 'post', partial=True, + words=['post']).partial, False) + self.assertEqual(regex.match(r'\L', 'post', partial=True, + words=['post']).span(), (0, 4)) + self.assertEqual(regex.match(r'\L', 'pos', partial=True, + words=['post']).partial, True) + self.assertEqual(regex.match(r'\L', 'pos', partial=True, + words=['post']).span(), (0, 3)) + + self.assertEqual(regex.match(r'(?fi)\L', 'POST', partial=True, + words=['po\uFB06']).partial, False) + self.assertEqual(regex.match(r'(?fi)\L', 'POST', partial=True, + words=['po\uFB06']).span(), (0, 4)) + self.assertEqual(regex.match(r'(?fi)\L', 'POS', partial=True, + words=['po\uFB06']).partial, True) + self.assertEqual(regex.match(r'(?fi)\L', 'POS', partial=True, + words=['po\uFB06']).span(), (0, 3)) + self.assertEqual(regex.match(r'(?fi)\L', 'po\uFB06', + partial=True, words=['POS']), None) + + self.assertEqual(regex.match(r'[a-z]*4R$', 'a', partial=True).span(), + (0, 1)) + self.assertEqual(regex.match(r'[a-z]*4R$', 'ab', partial=True).span(), + (0, 2)) + self.assertEqual(regex.match(r'[a-z]*4R$', 'ab4', partial=True).span(), + (0, 3)) + self.assertEqual(regex.match(r'[a-z]*4R$', 'a4', partial=True).span(), + (0, 2)) + self.assertEqual(regex.match(r'[a-z]*4R$', 'a4R', partial=True).span(), + (0, 3)) + self.assertEqual(regex.match(r'[a-z]*4R$', '4a', partial=True), None) + self.assertEqual(regex.match(r'[a-z]*4R$', 'a44', partial=True), None) + + def test_hg_bugs(self): + # Hg issue 28: regex.compile("(?>b)") causes "TypeError: 'Character' + # object is not subscriptable" + self.assertEqual(bool(regex.compile("(?>b)", flags=regex.V1)), True) + + # Hg issue 29: regex.compile("^((?>\w+)|(?>\s+))*$") causes + # "TypeError: 'GreedyRepeat' object is not iterable" + self.assertEqual(bool(regex.compile(r"^((?>\w+)|(?>\s+))*$", + flags=regex.V1)), True) + + # Hg issue 31: atomic and normal groups in recursive patterns + self.assertEqual(regex.findall(r"\((?:(?>[^()]+)|(?R))*\)", + "a(bcd(e)f)g(h)"), ['(bcd(e)f)', '(h)']) + self.assertEqual(regex.findall(r"\((?:(?:[^()]+)|(?R))*\)", + "a(bcd(e)f)g(h)"), ['(bcd(e)f)', '(h)']) + self.assertEqual(regex.findall(r"\((?:(?>[^()]+)|(?R))*\)", + "a(b(cd)e)f)g)h"), ['(b(cd)e)']) + self.assertEqual(regex.findall(r"\((?:(?>[^()]+)|(?R))*\)", + "a(bc(d(e)f)gh"), ['(d(e)f)']) + self.assertEqual(regex.findall(r"(?r)\((?:(?>[^()]+)|(?R))*\)", + "a(bc(d(e)f)gh"), ['(d(e)f)']) + self.assertEqual([m.group() for m in + regex.finditer(r"\((?:[^()]*+|(?0))*\)", "a(b(c(de)fg)h")], + ['(c(de)fg)']) + + # Hg issue 32: regex.search("a(bc)d", "abcd", regex.I|regex.V1) returns + # None + self.assertEqual(regex.search("a(bc)d", "abcd", regex.I | + regex.V1).group(0), "abcd") + + # Hg issue 33: regex.search("([\da-f:]+)$", "E", regex.I|regex.V1) + # returns None + self.assertEqual(regex.search(r"([\da-f:]+)$", "E", regex.I | + regex.V1).group(0), "E") + self.assertEqual(regex.search(r"([\da-f:]+)$", "e", regex.I | + regex.V1).group(0), "e") + + # Hg issue 34: regex.search("^(?=ab(de))(abd)(e)", "abde").groups() + # returns (None, 'abd', 'e') instead of ('de', 'abd', 'e') + self.assertEqual(regex.search("^(?=ab(de))(abd)(e)", "abde").groups(), + ('de', 'abd', 'e')) + + # Hg issue 35: regex.compile("\ ", regex.X) causes "_regex_core.error: + # bad escape" + self.assertEqual(bool(regex.match(r"\ ", " ", flags=regex.X)), True) + + # Hg issue 36: regex.search("^(a|)\1{2}b", "b") returns None + self.assertEqual(regex.search(r"^(a|)\1{2}b", "b").group(0, 1), ('b', + '')) + + # Hg issue 37: regex.search("^(a){0,0}", "abc").group(0,1) returns + # ('a', 'a') instead of ('', None) + self.assertEqual(regex.search("^(a){0,0}", "abc").group(0, 1), ('', + None)) + + # Hg issue 38: regex.search("(?>.*/)b", "a/b") returns None + self.assertEqual(regex.search("(?>.*/)b", "a/b").group(0), "a/b") + + # Hg issue 39: regex.search("((?i)blah)\\s+\\1", "blah BLAH") doesn't + # return None + # Changed to positional flags in regex 2023.12.23. + self.assertEqual(regex.search(r"((?i)blah)\s+\1", "blah BLAH"), None) + + # Hg issue 40: regex.search("(\()?[^()]+(?(1)\)|)", "(abcd").group(0) + # returns "bcd" instead of "abcd" + self.assertEqual(regex.search(r"(\()?[^()]+(?(1)\)|)", + "(abcd").group(0), "abcd") + + # Hg issue 42: regex.search("(a*)*", "a", flags=regex.V1).span(1) + # returns (0, 1) instead of (1, 1) + self.assertEqual(regex.search("(a*)*", "a").span(1), (1, 1)) + self.assertEqual(regex.search("(a*)*", "aa").span(1), (2, 2)) + self.assertEqual(regex.search("(a*)*", "aaa").span(1), (3, 3)) + + # Hg issue 43: regex.compile("a(?#xxx)*") causes "_regex_core.error: + # nothing to repeat" + self.assertEqual(regex.search("a(?#xxx)*", "aaa").group(), "aaa") + + # Hg issue 44: regex.compile("(?=abc){3}abc") causes + # "_regex_core.error: nothing to repeat" + self.assertEqual(regex.search("(?=abc){3}abc", "abcabcabc").span(), (0, + 3)) + + # Hg issue 45: regex.compile("^(?:a(?:(?:))+)+") causes + # "_regex_core.error: nothing to repeat" + self.assertEqual(regex.search("^(?:a(?:(?:))+)+", "a").span(), (0, 1)) + self.assertEqual(regex.search("^(?:a(?:(?:))+)+", "aa").span(), (0, 2)) + + # Hg issue 46: regex.compile("a(?x: b c )d") causes + # "_regex_core.error: missing )" + self.assertEqual(regex.search("a(?x: b c )d", "abcd").group(0), "abcd") + + # Hg issue 47: regex.compile("a#comment\n*", flags=regex.X) causes + # "_regex_core.error: nothing to repeat" + self.assertEqual(regex.search("a#comment\n*", "aaa", + flags=regex.X).group(0), "aaa") + + # Hg issue 48: regex.search("(a(?(1)\\1)){4}", "a"*10, + # flags=regex.V1).group(0,1) returns ('aaaaa', 'a') instead of ('aaaaaaaaaa', 'aaaa') + self.assertEqual(regex.search(r"(?V1)(a(?(1)\1)){1}", + "aaaaaaaaaa").span(0, 1), ((0, 1), (0, 1))) + self.assertEqual(regex.search(r"(?V1)(a(?(1)\1)){2}", + "aaaaaaaaaa").span(0, 1), ((0, 3), (1, 3))) + self.assertEqual(regex.search(r"(?V1)(a(?(1)\1)){3}", + "aaaaaaaaaa").span(0, 1), ((0, 6), (3, 6))) + self.assertEqual(regex.search(r"(?V1)(a(?(1)\1)){4}", + "aaaaaaaaaa").span(0, 1), ((0, 10), (6, 10))) + + # Hg issue 49: regex.search("(a)(?<=b(?1))", "baz", regex.V1) returns + # None incorrectly + self.assertEqual(regex.search("(?V1)(a)(?<=b(?1))", "baz").group(0), + "a") + + # Hg issue 50: not all keywords are found by named list with + # overlapping keywords when full Unicode casefolding is required + self.assertEqual(regex.findall(r'(?fi)\L', + 'POST, Post, post, po\u017Ft, po\uFB06, and po\uFB05', + keywords=['post','pos']), ['POST', 'Post', 'post', 'po\u017Ft', + 'po\uFB06', 'po\uFB05']) + self.assertEqual(regex.findall(r'(?fi)pos|post', + 'POST, Post, post, po\u017Ft, po\uFB06, and po\uFB05'), ['POS', + 'Pos', 'pos', 'po\u017F', 'po\uFB06', 'po\uFB05']) + self.assertEqual(regex.findall(r'(?fi)post|pos', + 'POST, Post, post, po\u017Ft, po\uFB06, and po\uFB05'), ['POST', + 'Post', 'post', 'po\u017Ft', 'po\uFB06', 'po\uFB05']) + self.assertEqual(regex.findall(r'(?fi)post|another', + 'POST, Post, post, po\u017Ft, po\uFB06, and po\uFB05'), ['POST', + 'Post', 'post', 'po\u017Ft', 'po\uFB06', 'po\uFB05']) + + # Hg issue 51: regex.search("((a)(?1)|(?2))", "a", flags=regex.V1) + # returns None incorrectly + self.assertEqual(regex.search("(?V1)((a)(?1)|(?2))", "a").group(0, 1, + 2), ('a', 'a', None)) + + # Hg issue 52: regex.search("(\\1xx|){6}", "xx", + # flags=regex.V1).span(0,1) returns incorrect value + self.assertEqual(regex.search(r"(?V1)(\1xx|){6}", "xx").span(0, 1), + ((0, 2), (2, 2))) + + # Hg issue 53: regex.search("(a|)+", "a") causes MemoryError + self.assertEqual(regex.search("(a|)+", "a").group(0, 1), ("a", "")) + + # Hg issue 54: regex.search("(a|)*\\d", "a"*80) causes MemoryError + self.assertEqual(regex.search(r"(a|)*\d", "a" * 80), None) + + # Hg issue 55: regex.search("^(?:a?b?)*$", "ac") take a very long time. + self.assertEqual(regex.search("^(?:a?b?)*$", "ac"), None) + + # Hg issue 58: bad named character escape sequences like "\\N{1}" + # treats as "N" + self.assertRaisesRegex(regex.error, self.UNDEF_CHAR_NAME, lambda: + regex.compile("\\N{1}")) + + # Hg issue 59: regex.search("\\Z", "a\na\n") returns None incorrectly + self.assertEqual(regex.search("\\Z", "a\na\n").span(0), (4, 4)) + + # Hg issue 60: regex.search("(q1|.)*(q2|.)*(x(a|bc)*y){2,}", "xayxay") + # returns None incorrectly + self.assertEqual(regex.search("(q1|.)*(q2|.)*(x(a|bc)*y){2,}", + "xayxay").group(0), "xayxay") + + # Hg issue 61: regex.search("[^a]", "A", regex.I).group(0) returns '' + # incorrectly + self.assertEqual(regex.search("(?i)[^a]", "A"), None) + + # Hg issue 63: regex.search("[[:ascii:]]", "\N{KELVIN SIGN}", + # flags=regex.I|regex.V1) doesn't return None + self.assertEqual(regex.search("(?i)[[:ascii:]]", "\N{KELVIN SIGN}"), + None) + + # Hg issue 66: regex.search("((a|b(?1)c){3,5})", "baaaaca", + # flags=regex.V1).groups() returns ('baaaac', 'baaaac') instead of ('aaaa', 'a') + self.assertEqual(regex.search("((a|b(?1)c){3,5})", "baaaaca").group(0, + 1, 2), ('aaaa', 'aaaa', 'a')) + + # Hg issue 71: non-greedy quantifier in lookbehind + self.assertEqual(regex.findall(r"(?<=:\S+ )\w+", ":9 abc :10 def"), + ['abc', 'def']) + self.assertEqual(regex.findall(r"(?<=:\S* )\w+", ":9 abc :10 def"), + ['abc', 'def']) + self.assertEqual(regex.findall(r"(?<=:\S+? )\w+", ":9 abc :10 def"), + ['abc', 'def']) + self.assertEqual(regex.findall(r"(?<=:\S*? )\w+", ":9 abc :10 def"), + ['abc', 'def']) + + # Hg issue 73: conditional patterns + self.assertEqual(regex.search(r"(?:fe)?male", "female").group(), + "female") + self.assertEqual([m.group() for m in + regex.finditer(r"(fe)?male: h(?(1)(er)|(is)) (\w+)", + "female: her dog; male: his cat. asdsasda")], ['female: her dog', + 'male: his cat']) + + # Hg issue 78: "Captures" doesn't work for recursive calls + self.assertEqual(regex.search(r'(?\((?:[^()]++|(?&rec))*\))', + 'aaa(((1+0)+1)+1)bbb').captures('rec'), ['(1+0)', '((1+0)+1)', + '(((1+0)+1)+1)']) + + # Hg issue 80: Escape characters throws an exception + self.assertRaisesRegex(regex.error, self.BAD_ESCAPE, lambda: + regex.sub('x', '\\', 'x'), ) + + # Hg issue 82: error range does not work + fz = "(CAGCCTCCCATTTCAGAATATACATCC){1a(?b))', "ab").spans("x"), [(1, + 2), (0, 2)]) + + # Hg issue 91: match.expand is extremely slow + # Check that the replacement cache works. + self.assertEqual(regex.sub(r'(-)', lambda m: m.expand(r'x'), 'a-b-c'), + 'axbxc') + + # Hg issue 94: Python crashes when executing regex updates + # pattern.findall + rx = regex.compile(r'\bt(est){i<2}', flags=regex.V1) + self.assertEqual(rx.search("Some text"), None) + self.assertEqual(rx.findall("Some text"), []) + + # Hg issue 95: 'pos' for regex.error + self.assertRaisesRegex(regex.error, self.MULTIPLE_REPEAT, lambda: + regex.compile(r'.???')) + + # Hg issue 97: behaviour of regex.escape's special_only is wrong + # + # Hg issue 244: Make `special_only=True` the default in + # `regex.escape()` + self.assertEqual(regex.escape('foo!?', special_only=False), 'foo\\!\\?') + self.assertEqual(regex.escape('foo!?', special_only=True), 'foo!\\?') + self.assertEqual(regex.escape('foo!?'), 'foo!\\?') + + self.assertEqual(regex.escape(b'foo!?', special_only=False), b'foo\\!\\?') + self.assertEqual(regex.escape(b'foo!?', special_only=True), + b'foo!\\?') + self.assertEqual(regex.escape(b'foo!?'), b'foo!\\?') + + # Hg issue 100: strange results from regex.search + self.assertEqual(regex.search('^([^z]*(?:WWWi|W))?$', + 'WWWi').groups(), ('WWWi', )) + self.assertEqual(regex.search('^([^z]*(?:WWWi|w))?$', + 'WWWi').groups(), ('WWWi', )) + self.assertEqual(regex.search('^([^z]*?(?:WWWi|W))?$', + 'WWWi').groups(), ('WWWi', )) + + # Hg issue 101: findall() broken (seems like memory corruption) + pat = regex.compile(r'xxx', flags=regex.FULLCASE | regex.UNICODE) + self.assertEqual([x.group() for x in pat.finditer('yxxx')], ['xxx']) + self.assertEqual(pat.findall('yxxx'), ['xxx']) + + raw = 'yxxx' + self.assertEqual([x.group() for x in pat.finditer(raw)], ['xxx']) + self.assertEqual(pat.findall(raw), ['xxx']) + + pat = regex.compile(r'xxx', flags=regex.FULLCASE | regex.IGNORECASE | + regex.UNICODE) + self.assertEqual([x.group() for x in pat.finditer('yxxx')], ['xxx']) + self.assertEqual(pat.findall('yxxx'), ['xxx']) + + raw = 'yxxx' + self.assertEqual([x.group() for x in pat.finditer(raw)], ['xxx']) + self.assertEqual(pat.findall(raw), ['xxx']) + + # Hg issue 106: * operator not working correctly with sub() + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.sub('(?V0).*', 'x', 'test'), 'xx') + else: + self.assertEqual(regex.sub('(?V0).*', 'x', 'test'), 'x') + self.assertEqual(regex.sub('(?V1).*', 'x', 'test'), 'xx') + + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.sub('(?V0).*?', '|', 'test'), '|||||||||') + else: + self.assertEqual(regex.sub('(?V0).*?', '|', 'test'), '|t|e|s|t|') + self.assertEqual(regex.sub('(?V1).*?', '|', 'test'), '|||||||||') + + # Hg issue 112: re: OK, but regex: SystemError + self.assertEqual(regex.sub(r'^(@)\n(?!.*?@)(.*)', + r'\1\n==========\n\2', '@\n', flags=regex.DOTALL), '@\n==========\n') + + # Hg issue 109: Edit distance of fuzzy match + self.assertEqual(regex.match(r'(?:cats|cat){e<=1}', + 'caz').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.match(r'(?e)(?:cats|cat){e<=1}', + 'caz').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.match(r'(?b)(?:cats|cat){e<=1}', + 'caz').fuzzy_counts, (1, 0, 0)) + + self.assertEqual(regex.match(r'(?:cat){e<=1}', 'caz').fuzzy_counts, + (1, 0, 0)) + self.assertEqual(regex.match(r'(?e)(?:cat){e<=1}', + 'caz').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.match(r'(?b)(?:cat){e<=1}', + 'caz').fuzzy_counts, (1, 0, 0)) + + self.assertEqual(regex.match(r'(?:cats){e<=2}', 'c ats').fuzzy_counts, + (1, 1, 0)) + self.assertEqual(regex.match(r'(?e)(?:cats){e<=2}', + 'c ats').fuzzy_counts, (0, 1, 0)) + self.assertEqual(regex.match(r'(?b)(?:cats){e<=2}', + 'c ats').fuzzy_counts, (0, 1, 0)) + + self.assertEqual(regex.match(r'(?:cats){e<=2}', + 'c a ts').fuzzy_counts, (0, 2, 0)) + self.assertEqual(regex.match(r'(?e)(?:cats){e<=2}', + 'c a ts').fuzzy_counts, (0, 2, 0)) + self.assertEqual(regex.match(r'(?b)(?:cats){e<=2}', + 'c a ts').fuzzy_counts, (0, 2, 0)) + + self.assertEqual(regex.match(r'(?:cats){e<=1}', 'c ats').fuzzy_counts, + (0, 1, 0)) + self.assertEqual(regex.match(r'(?e)(?:cats){e<=1}', + 'c ats').fuzzy_counts, (0, 1, 0)) + self.assertEqual(regex.match(r'(?b)(?:cats){e<=1}', + 'c ats').fuzzy_counts, (0, 1, 0)) + + # Hg issue 115: Infinite loop when processing backreferences + self.assertEqual(regex.findall(r'\bof ([a-z]+) of \1\b', + 'To make use of one of these modules'), []) + + # Hg issue 125: Reference to entire match (\g<0>) in + # Pattern.sub() doesn't work as of 2014.09.22 release. + self.assertEqual(regex.sub(r'x', r'\g<0>', 'x'), 'x') + + # Unreported issue: no such builtin as 'ascii' in Python 2. + self.assertEqual(bool(regex.match(r'a', 'a', regex.DEBUG)), True) + + # Hg issue 131: nested sets behaviour + self.assertEqual(regex.findall(r'(?V1)[[b-e]--cd]', 'abcdef'), ['b', + 'e']) + self.assertEqual(regex.findall(r'(?V1)[b-e--cd]', 'abcdef'), ['b', + 'e']) + self.assertEqual(regex.findall(r'(?V1)[[bcde]--cd]', 'abcdef'), ['b', + 'e']) + self.assertEqual(regex.findall(r'(?V1)[bcde--cd]', 'abcdef'), ['b', + 'e']) + + # Hg issue 132: index out of range on null property \p{} + self.assertRaisesRegex(regex.error, '^unknown property at position 4$', + lambda: regex.compile(r'\p{}')) + + # Issue 23692. + self.assertEqual(regex.match('(?:()|(?(1)()|z)){2}(?(2)a|z)', + 'a').group(0, 1, 2), ('a', '', '')) + self.assertEqual(regex.match('(?:()|(?(1)()|z)){0,2}(?(2)a|z)', + 'a').group(0, 1, 2), ('a', '', '')) + + # Hg issue 137: Posix character class :punct: does not seem to be + # supported. + + # Posix compatibility as recommended here: + # http://www.unicode.org/reports/tr18/#Compatibility_Properties + + # Posix in Unicode. + chars = ''.join(chr(c) for c in range(0x10000)) + + self.assertEqual(ascii(''.join(regex.findall(r'''[[:alnum:]]+''', + chars))), ascii(''.join(regex.findall(r'''[\p{Alpha}\p{PosixDigit}]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:alpha:]]+''', + chars))), ascii(''.join(regex.findall(r'''\p{Alpha}+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:ascii:]]+''', + chars))), ascii(''.join(regex.findall(r'''[\p{InBasicLatin}]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:blank:]]+''', + chars))), ascii(''.join(regex.findall(r'''[\p{gc=Space_Separator}\t]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:cntrl:]]+''', + chars))), ascii(''.join(regex.findall(r'''\p{gc=Control}+''', chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:digit:]]+''', + chars))), ascii(''.join(regex.findall(r'''[0-9]+''', chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:graph:]]+''', + chars))), ascii(''.join(regex.findall(r'''[^\p{Space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:lower:]]+''', + chars))), ascii(''.join(regex.findall(r'''\p{Lower}+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:print:]]+''', + chars))), ascii(''.join(regex.findall(r'''(?V1)[\p{Graph}\p{Blank}--\p{Cntrl}]+''', chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:punct:]]+''', + chars))), + ascii(''.join(regex.findall(r'''(?V1)[\p{gc=Punctuation}\p{gc=Symbol}--\p{Alpha}]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:space:]]+''', + chars))), ascii(''.join(regex.findall(r'''\p{Whitespace}+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:upper:]]+''', + chars))), ascii(''.join(regex.findall(r'''\p{Upper}+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:word:]]+''', + chars))), ascii(''.join(regex.findall(r'''[\p{Alpha}\p{gc=Mark}\p{Digit}\p{gc=Connector_Punctuation}\p{Join_Control}]+''', + chars)))) + self.assertEqual(ascii(''.join(regex.findall(r'''[[:xdigit:]]+''', + chars))), ascii(''.join(regex.findall(r'''[0-9A-Fa-f]+''', + chars)))) + + # Posix in ASCII. + chars = bytes(range(0x100)) + + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:alnum:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[\p{Alpha}\p{PosixDigit}]+''', + chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:alpha:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)\p{Alpha}+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:ascii:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[\x00-\x7F]+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:blank:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[\p{gc=Space_Separator}\t]+''', + chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:cntrl:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)\p{gc=Control}+''', + chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:digit:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[0-9]+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:graph:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[^\p{Space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:lower:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)\p{Lower}+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:print:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?aV1)[\p{Graph}\p{Blank}--\p{Cntrl}]+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:punct:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?aV1)[\p{gc=Punctuation}\p{gc=Symbol}--\p{Alpha}]+''', + chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:space:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)\p{Whitespace}+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:upper:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)\p{Upper}+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:word:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[\p{Alpha}\p{gc=Mark}\p{Digit}\p{gc=Connector_Punctuation}\p{Join_Control}]+''', chars)))) + self.assertEqual(ascii(b''.join(regex.findall(br'''(?a)[[:xdigit:]]+''', + chars))), ascii(b''.join(regex.findall(br'''(?a)[0-9A-Fa-f]+''', chars)))) + + # Hg issue 138: grapheme anchored search not working properly. + self.assertEqual(ascii(regex.search(r'\X$', 'ab\u2103').group()), + ascii('\u2103')) + + # Hg issue 139: Regular expression with multiple wildcards where first + # should match empty string does not always work. + self.assertEqual(regex.search("([^L]*)([^R]*R)", "LtR").groups(), ('', + 'LtR')) + + # Hg issue 140: Replace with REVERSE and groups has unexpected + # behavior. + self.assertEqual(regex.sub(r'(.)', r'x\1y', 'ab'), 'xayxby') + self.assertEqual(regex.sub(r'(?r)(.)', r'x\1y', 'ab'), 'xayxby') + self.assertEqual(regex.subf(r'(.)', 'x{1}y', 'ab'), 'xayxby') + self.assertEqual(regex.subf(r'(?r)(.)', 'x{1}y', 'ab'), 'xayxby') + + # Hg issue 141: Crash on a certain partial match. + self.assertEqual(regex.fullmatch('(a)*abc', 'ab', + partial=True).span(), (0, 2)) + self.assertEqual(regex.fullmatch('(a)*abc', 'ab', + partial=True).partial, True) + + # Hg issue 143: Partial matches have incorrect span if prefix is '.' + # wildcard. + self.assertEqual(regex.search('OXRG', 'OOGOX', partial=True).span(), + (3, 5)) + self.assertEqual(regex.search('.XRG', 'OOGOX', partial=True).span(), + (3, 5)) + self.assertEqual(regex.search('.{1,3}XRG', 'OOGOX', + partial=True).span(), (1, 5)) + + # Hg issue 144: Latest version problem with matching 'R|R'. + self.assertEqual(regex.match('R|R', 'R').span(), (0, 1)) + + # Hg issue 146: Forced-fail (?!) works improperly in conditional. + self.assertEqual(regex.match(r'(.)(?(1)(?!))', 'xy'), None) + + # Groups cleared after failure. + self.assertEqual(regex.findall(r'(y)?(\d)(?(1)\b\B)', 'ax1y2z3b'), + [('', '1'), ('', '2'), ('', '3')]) + self.assertEqual(regex.findall(r'(y)?+(\d)(?(1)\b\B)', 'ax1y2z3b'), + [('', '1'), ('', '2'), ('', '3')]) + + # Hg issue 147: Fuzzy match can return match points beyond buffer end. + self.assertEqual([m.span() for m in regex.finditer(r'(?i)(?:error){e}', + 'regex failure')], [(0, 5), (5, 10), (10, 13), (13, 13)]) + self.assertEqual([m.span() for m in + regex.finditer(r'(?fi)(?:error){e}', 'regex failure')], [(0, 5), (5, + 10), (10, 13), (13, 13)]) + + # Hg issue 150: Have an option for POSIX-compatible longest match of + # alternates. + self.assertEqual(regex.search(r'(?p)\d+(\w(\d*)?|[eE]([+-]\d+))', + '10b12')[0], '10b12') + self.assertEqual(regex.search(r'(?p)\d+(\w(\d*)?|[eE]([+-]\d+))', + '10E+12')[0], '10E+12') + + self.assertEqual(regex.search(r'(?p)(\w|ae|oe|ue|ss)', 'ae')[0], 'ae') + self.assertEqual(regex.search(r'(?p)one(self)?(selfsufficient)?', + 'oneselfsufficient')[0], 'oneselfsufficient') + + # Hg issue 151: Request: \K. + self.assertEqual(regex.search(r'(ab\Kcd)', 'abcd').group(0, 1), ('cd', + 'abcd')) + self.assertEqual(regex.findall(r'\w\w\K\w\w', 'abcdefgh'), ['cd', + 'gh']) + self.assertEqual(regex.findall(r'(\w\w\K\w\w)', 'abcdefgh'), ['abcd', + 'efgh']) + + self.assertEqual(regex.search(r'(?r)(ab\Kcd)', 'abcd').group(0, 1), + ('ab', 'abcd')) + self.assertEqual(regex.findall(r'(?r)\w\w\K\w\w', 'abcdefgh'), ['ef', + 'ab']) + self.assertEqual(regex.findall(r'(?r)(\w\w\K\w\w)', 'abcdefgh'), + ['efgh', 'abcd']) + + # Hg issue 152: Request: Request: (?(DEFINE)...). + self.assertEqual(regex.search(r'(?(DEFINE)(?\d+)(?\w+))(?&quant) (?&item)', + '5 elephants')[0], '5 elephants') + + self.assertEqual(regex.search(r'(?&routine)(?(DEFINE)(?.))', 'a').group('routine'), None) + self.assertEqual(regex.search(r'(?&routine)(?(DEFINE)(?.))', 'a').captures('routine'), ['a']) + + # Hg issue 153: Request: (*SKIP). + self.assertEqual(regex.search(r'12(*FAIL)|3', '123')[0], '3') + self.assertEqual(regex.search(r'(?r)12(*FAIL)|3', '123')[0], '3') + + self.assertEqual(regex.search(r'\d+(*PRUNE)\d', '123'), None) + self.assertEqual(regex.search(r'\d+(?=(*PRUNE))\d', '123')[0], '123') + self.assertEqual(regex.search(r'\d+(*PRUNE)bcd|[3d]', '123bcd')[0], + '123bcd') + self.assertEqual(regex.search(r'\d+(*PRUNE)bcd|[3d]', '123zzd')[0], + 'd') + self.assertEqual(regex.search(r'\d+?(*PRUNE)bcd|[3d]', '123bcd')[0], + '3bcd') + self.assertEqual(regex.search(r'\d+?(*PRUNE)bcd|[3d]', '123zzd')[0], + 'd') + self.assertEqual(regex.search(r'\d++(?<=3(*PRUNE))zzd|[4d]$', + '123zzd')[0], '123zzd') + self.assertEqual(regex.search(r'\d++(?<=3(*PRUNE))zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'\d++(?<=(*PRUNE)3)zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'\d++(?<=2(*PRUNE)3)zzd|[3d]$', + '124zzd')[0], 'd') + + self.assertEqual(regex.search(r'(?r)\d(*PRUNE)\d+', '123'), None) + self.assertEqual(regex.search(r'(?r)\d(?<=(*PRUNE))\d+', '123')[0], + '123') + self.assertEqual(regex.search(r'(?r)\d+(*PRUNE)bcd|[3d]', + '123bcd')[0], '123bcd') + self.assertEqual(regex.search(r'(?r)\d+(*PRUNE)bcd|[3d]', + '123zzd')[0], 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=3(*PRUNE))zzd|[4d]$', + '123zzd')[0], '123zzd') + self.assertEqual(regex.search(r'(?r)\d++(?<=3(*PRUNE))zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=(*PRUNE)3)zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=2(*PRUNE)3)zzd|[3d]$', + '124zzd')[0], 'd') + + self.assertEqual(regex.search(r'\d+(*SKIP)bcd|[3d]', '123bcd')[0], + '123bcd') + self.assertEqual(regex.search(r'\d+(*SKIP)bcd|[3d]', '123zzd')[0], + 'd') + self.assertEqual(regex.search(r'\d+?(*SKIP)bcd|[3d]', '123bcd')[0], + '3bcd') + self.assertEqual(regex.search(r'\d+?(*SKIP)bcd|[3d]', '123zzd')[0], + 'd') + self.assertEqual(regex.search(r'\d++(?<=3(*SKIP))zzd|[4d]$', + '123zzd')[0], '123zzd') + self.assertEqual(regex.search(r'\d++(?<=3(*SKIP))zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'\d++(?<=(*SKIP)3)zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'\d++(?<=2(*SKIP)3)zzd|[3d]$', + '124zzd')[0], 'd') + + self.assertEqual(regex.search(r'(?r)\d+(*SKIP)bcd|[3d]', '123bcd')[0], + '123bcd') + self.assertEqual(regex.search(r'(?r)\d+(*SKIP)bcd|[3d]', '123zzd')[0], + 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=3(*SKIP))zzd|[4d]$', + '123zzd')[0], '123zzd') + self.assertEqual(regex.search(r'(?r)\d++(?<=3(*SKIP))zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=(*SKIP)3)zzd|[4d]$', + '124zzd')[0], 'd') + self.assertEqual(regex.search(r'(?r)\d++(?<=2(*SKIP)3)zzd|[3d]$', + '124zzd')[0], 'd') + + # Hg issue 154: Segmentation fault 11 when working with an atomic group + text = """June 30, December 31, 2013 2012 +some words follow: +more words and numbers 1,234,567 9,876,542 +more words and numbers 1,234,567 9,876,542""" + self.assertEqual(len(regex.findall(r'(?2014|2013 ?2012)', text)), 1) + + # Hg issue 156: regression on atomic grouping + self.assertEqual(regex.match('1(?>2)', '12').span(), (0, 2)) + + # Hg issue 157: regression: segfault on complex lookaround + self.assertEqual(regex.match(r'(?V1w)(?=(?=[^A-Z]*+[A-Z])(?=[^a-z]*+[a-z]))(?=\D*+\d)(?=\p{Alphanumeric}*+\P{Alphanumeric})\A(?s:.){8,255}+\Z', + 'AAaa11!!')[0], 'AAaa11!!') + + # Hg issue 158: Group issue with (?(DEFINE)...) + TEST_REGEX = regex.compile(r'''(?smx) +(?(DEFINE) + (? + ^,[^,]+, + ) +) + +# Group 2 is defined on this line +^,([^,]+), + +(?:(?!(?&subcat)[\r\n]+(?&subcat)).)+ +''') + + TEST_DATA = ''' +,Cat 1, +,Brand 1, +some +thing +,Brand 2, +other +things +,Cat 2, +,Brand, +Some +thing +''' + + self.assertEqual([m.span(1, 2) for m in + TEST_REGEX.finditer(TEST_DATA)], [((-1, -1), (2, 7)), ((-1, -1), (54, + 59))]) + + # Hg issue 161: Unexpected fuzzy match results + self.assertEqual(regex.search('(abcdefgh){e}', + '******abcdefghijklmnopqrtuvwxyz', regex.BESTMATCH).span(), (6, 14)) + self.assertEqual(regex.search('(abcdefghi){e}', + '******abcdefghijklmnopqrtuvwxyz', regex.BESTMATCH).span(), (6, 15)) + + # Hg issue 163: allow lookarounds in conditionals. + self.assertEqual(regex.match(r'(?:(?=\d)\d+\b|\w+)', '123abc').span(), + (0, 6)) + self.assertEqual(regex.match(r'(?(?=\d)\d+\b|\w+)', '123abc'), None) + self.assertEqual(regex.search(r'(?(?<=love\s)you|(?<=hate\s)her)', + "I love you").span(), (7, 10)) + self.assertEqual(regex.findall(r'(?(?<=love\s)you|(?<=hate\s)her)', + "I love you but I don't hate her either"), ['you', 'her']) + + # Hg issue 180: bug of POSIX matching. + self.assertEqual(regex.search(r'(?p)a*(.*?)', 'aaabbb').group(0, 1), + ('aaabbb', 'bbb')) + self.assertEqual(regex.search(r'(?p)a*(.*)', 'aaabbb').group(0, 1), + ('aaabbb', 'bbb')) + self.assertEqual(regex.sub(r'(?p)a*(.*?)', r'\1', 'aaabbb'), 'bbb') + self.assertEqual(regex.sub(r'(?p)a*(.*)', r'\1', 'aaabbb'), 'bbb') + + # Hg issue 192: Named lists reverse matching doesn't work with + # IGNORECASE and V1 + self.assertEqual(regex.match(r'(?irV0)\L', '21', kw=['1']).span(), + (1, 2)) + self.assertEqual(regex.match(r'(?irV1)\L', '21', kw=['1']).span(), + (1, 2)) + + # Hg issue 193: Alternation and .REVERSE flag. + self.assertEqual(regex.search('a|b', '111a222').span(), (3, 4)) + self.assertEqual(regex.search('(?r)a|b', '111a222').span(), (3, 4)) + + # Hg issue 194: .FULLCASE and Backreference + self.assertEqual(regex.search(r'(?if)<(CLI)><\1>', + '').span(), (0, 10)) + self.assertEqual(regex.search(r'(?if)<(CLI)><\1>', + '').span(), (0, 10)) + self.assertEqual(regex.search(r'(?ifr)<\1><(CLI)>', + '').span(), (0, 10)) + + # Hg issue 195: Pickle (or otherwise serial) the compiled regex + r = regex.compile(r'\L', options=['foo', 'bar']) + p = pickle.dumps(r) + r = pickle.loads(p) + self.assertEqual(r.match('foo').span(), (0, 3)) + + # Hg issue 196: Fuzzy matching on repeated regex not working as + # expected + self.assertEqual(regex.match('(x{6}){e<=1}', 'xxxxxx', + flags=regex.BESTMATCH).span(), (0, 6)) + self.assertEqual(regex.match('(x{6}){e<=1}', 'xxxxx', + flags=regex.BESTMATCH).span(), (0, 5)) + self.assertEqual(regex.match('(x{6}){e<=1}', 'x', + flags=regex.BESTMATCH), None) + self.assertEqual(regex.match('(?r)(x{6}){e<=1}', 'xxxxxx', + flags=regex.BESTMATCH).span(), (0, 6)) + self.assertEqual(regex.match('(?r)(x{6}){e<=1}', 'xxxxx', + flags=regex.BESTMATCH).span(), (0, 5)) + self.assertEqual(regex.match('(?r)(x{6}){e<=1}', 'x', + flags=regex.BESTMATCH), None) + + # Hg issue 197: ValueError in regex.compile + self.assertRaises(regex.error, lambda: + regex.compile(b'00000\\0\\00\\^\50\\00\\U05000000')) + + # Hg issue 198: ValueError in regex.compile + self.assertRaises(regex.error, lambda: regex.compile(b"{e', '22', aa=['121', + '22'])), True) + self.assertEqual(bool(regex.search(r'(?ri)\L', '22', aa=['121', + '22'])), True) + self.assertEqual(bool(regex.search(r'(?fi)\L', '22', aa=['121', + '22'])), True) + self.assertEqual(bool(regex.search(r'(?fri)\L', '22', aa=['121', + '22'])), True) + + # Hg issue 208: Named list, (?ri) flags, Backreference + self.assertEqual(regex.search(r'(?r)\1dog..(?<=(\L))$', 'ccdogcc', + aa=['bcb', 'cc']). span(), (0, 7)) + self.assertEqual(regex.search(r'(?ir)\1dog..(?<=(\L))$', + 'ccdogcc', aa=['bcb', 'cc']). span(), (0, 7)) + + # Hg issue 210: Fuzzy matching and Backreference + self.assertEqual(regex.search(r'(2)(?:\1{5}){e<=1}', + '3222212').span(), (1, 7)) + self.assertEqual(regex.search(r'(\d)(?:\1{5}){e<=1}', + '3222212').span(), (1, 7)) + + # Hg issue 211: Segmentation fault with recursive matches and atomic + # groups + self.assertEqual(regex.match(r'''\A(?P(?>\((?&whole)\)|[+\-]))\Z''', + '((-))').span(), (0, 5)) + self.assertEqual(regex.match(r'''\A(?P(?>\((?&whole)\)|[+\-]))\Z''', + '((-)+)'), None) + + # Hg issue 212: Unexpected matching difference with .*? between re and + # regex + self.assertEqual(regex.match(r"x.*? (.).*\1(.*)\1", + 'x |y| z|').span(), (0, 9)) + self.assertEqual(regex.match(r"\.sr (.*?) (.)(.*)\2(.*)\2(.*)", + r'.sr h |||').span(), (0, 35)) + + # Hg issue 213: Segmentation Fault + a = '"\\xF9\\x80\\xAEqdz\\x95L\\xA7\\x89[\\xFE \\x91)\\xF9]\\xDB\'\\x99\\x09=\\x00\\xFD\\x98\\x22\\xDD\\xF1\\xB6\\xC3 Z\\xB6gv\\xA5x\\x93P\\xE1r\\x14\\x8Cv\\x0C\\xC0w\\x15r\\xFFc%" ' + py_regex_pattern = r'''(?P((?>(?"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``)))) (?P((?>(?"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``))))''' + self.assertEqual(bool(regex.search(py_regex_pattern, a)), False) + + # Hg Issue 216: Invalid match when using negative lookbehind and pipe + self.assertEqual(bool(regex.match('foo(?<=foo)', 'foo')), True) + self.assertEqual(bool(regex.match('foo(?.*\!\w*\:.*)|(?P.*))', + '!')), False) + + # Hg issue 220: Misbehavior of group capture with OR operand + self.assertEqual(regex.match(r'\w*(ea)\w*|\w*e(?!a)\w*', + 'easier').groups(), ('ea', )) + + # Hg issue 225: BESTMATCH in fuzzy match not working + self.assertEqual(regex.search('(^1234$){i,d}', '12234', + regex.BESTMATCH).span(), (0, 5)) + self.assertEqual(regex.search('(^1234$){i,d}', '12234', + regex.BESTMATCH).fuzzy_counts, (0, 1, 0)) + + self.assertEqual(regex.search('(^1234$){s,i,d}', '12234', + regex.BESTMATCH).span(), (0, 5)) + self.assertEqual(regex.search('(^1234$){s,i,d}', '12234', + regex.BESTMATCH).fuzzy_counts, (0, 1, 0)) + + # Hg issue 226: Error matching at start of string + self.assertEqual(regex.search('(^123$){s,i,d}', 'xxxxxxxx123', + regex.BESTMATCH).span(), (0, 11)) + self.assertEqual(regex.search('(^123$){s,i,d}', 'xxxxxxxx123', + regex.BESTMATCH).fuzzy_counts, (0, 8, 0)) + + # Hg issue 227: Incorrect behavior for ? operator with UNICODE + + # IGNORECASE + self.assertEqual(regex.search(r'a?yz', 'xxxxyz', flags=regex.FULLCASE | + regex.IGNORECASE).span(), (4, 6)) + + # Hg issue 230: Is it a bug of (?(DEFINE)...) + self.assertEqual(regex.findall(r'(?:(?![a-d]).)+', 'abcdefgh'), + ['efgh']) + self.assertEqual(regex.findall(r'''(?(DEFINE)(?P(?:(?![a-d]).)))(?&mydef)+''', + 'abcdefgh'), ['efgh']) + + # Hg issue 238: Not fully re backward compatible + self.assertEqual(regex.findall(r'((\w{1,3})(\.{2,10})){1,3}', + '"Erm....yes. T..T...Thank you for that."'), [('Erm....', 'Erm', + '....'), ('T...', 'T', '...')]) + self.assertEqual(regex.findall(r'((\w{1,3})(\.{2,10})){3}', + '"Erm....yes. T..T...Thank you for that."'), []) + self.assertEqual(regex.findall(r'((\w{1,3})(\.{2,10})){2}', + '"Erm....yes. T..T...Thank you for that."'), [('T...', 'T', '...')]) + self.assertEqual(regex.findall(r'((\w{1,3})(\.{2,10})){1}', + '"Erm....yes. T..T...Thank you for that."'), [('Erm....', 'Erm', + '....'), ('T..', 'T', '..'), ('T...', 'T', '...')]) + + # Hg issue 247: Unexpected result with fuzzy matching and lookahead + # expression + self.assertEqual(regex.search(r'(?:ESTONIA(?!\w)){e<=1}', + 'ESTONIAN WORKERS').group(), 'ESTONIAN') + self.assertEqual(regex.search(r'(?:ESTONIA(?=\W)){e<=1}', + 'ESTONIAN WORKERS').group(), 'ESTONIAN') + + self.assertEqual(regex.search(r'(?:(?.))(?&func)', + 'abc').groups(), (None, )) + self.assertEqual(regex.search(r'(?(DEFINE)(?.))(?&func)', + 'abc').groupdict(), {'func': None}) + self.assertEqual(regex.search(r'(?(DEFINE)(?.))(?&func)', + 'abc').capturesdict(), {'func': ['a']}) + + self.assertEqual(regex.search(r'(?(DEFINE)(?.))(?=(?&func))', + 'abc').groups(), (None, )) + self.assertEqual(regex.search(r'(?(DEFINE)(?.))(?=(?&func))', + 'abc').groupdict(), {'func': None}) + self.assertEqual(regex.search(r'(?(DEFINE)(?.))(?=(?&func))', + 'abc').capturesdict(), {'func': ['a']}) + + self.assertEqual(regex.search(r'(?(DEFINE)(?.)).(?<=(?&func))', + 'abc').groups(), (None, )) + self.assertEqual(regex.search(r'(?(DEFINE)(?.)).(?<=(?&func))', + 'abc').groupdict(), {'func': None}) + self.assertEqual(regex.search(r'(?(DEFINE)(?.)).(?<=(?&func))', + 'abc').capturesdict(), {'func': ['a']}) + + # Hg issue 271: Comment logic different between Re and Regex + self.assertEqual(bool(regex.match(r'ab(?#comment\))cd', 'abcd')), True) + + # Hg issue 276: Partial Matches yield incorrect matches and bounds + self.assertEqual(regex.search(r'[a-z]+ [a-z]*?:', 'foo bar', + partial=True).span(), (0, 7)) + self.assertEqual(regex.search(r'(?r):[a-z]*? [a-z]+', 'foo bar', + partial=True).span(), (0, 7)) + + # Hg issue 291: Include Script Extensions as a supported Unicode property + self.assertEqual(bool(regex.match(r'(?u)\p{Script:Beng}', + '\u09EF')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{Script:Bengali}', + '\u09EF')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{Script_Extensions:Bengali}', + '\u09EF')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{Script_Extensions:Beng}', + '\u09EF')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{Script_Extensions:Cakm}', + '\u09EF')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{Script_Extensions:Sylo}', + '\u09EF')), True) + + # Hg issue #293: scx (Script Extensions) property currently matches + # incorrectly + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Latin}', 'P')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Ahom}', 'P')), False) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Common}', '4')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Caucasian_Albanian}', '4')), + False) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Arabic}', '\u062A')), True) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Balinese}', '\u062A')), + False) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Devanagari}', '\u091C')), + True) + self.assertEqual(bool(regex.match(r'(?u)\p{scx:Batak}', '\u091C')), False) + + # Hg issue 296: Group references are not taken into account when group is reporting the last match + self.assertEqual(regex.fullmatch('(?P.)*(?&x)', 'abc').captures('x'), + ['a', 'b', 'c']) + self.assertEqual(regex.fullmatch('(?P.)*(?&x)', 'abc').group('x'), + 'b') + + self.assertEqual(regex.fullmatch('(?P.)(?P.)(?P.)', + 'abc').captures('x'), ['a', 'b', 'c']) + self.assertEqual(regex.fullmatch('(?P.)(?P.)(?P.)', + 'abc').group('x'), 'c') + + # Hg issue 299: Partial gives misleading results with "open ended" regexp + self.assertEqual(regex.match('(?:ab)*', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)*', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)*?', '', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)*+', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)*+', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)+', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)+', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)+?', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)++', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?:ab)++', 'abab', partial=True).partial, + False) + + self.assertEqual(regex.match('(?r)(?:ab)*', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)*', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)*?', '', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)*+', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)*+', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)+', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)+', 'abab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)+?', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)++', 'ab', partial=True).partial, + False) + self.assertEqual(regex.match('(?r)(?:ab)++', 'abab', partial=True).partial, + False) + + self.assertEqual(regex.match('a*', '', partial=True).partial, False) + self.assertEqual(regex.match('a*?', '', partial=True).partial, False) + self.assertEqual(regex.match('a*+', '', partial=True).partial, False) + self.assertEqual(regex.match('a+', '', partial=True).partial, True) + self.assertEqual(regex.match('a+?', '', partial=True).partial, True) + self.assertEqual(regex.match('a++', '', partial=True).partial, True) + self.assertEqual(regex.match('a+', 'a', partial=True).partial, False) + self.assertEqual(regex.match('a+?', 'a', partial=True).partial, False) + self.assertEqual(regex.match('a++', 'a', partial=True).partial, False) + + self.assertEqual(regex.match('(?r)a*', '', partial=True).partial, False) + self.assertEqual(regex.match('(?r)a*?', '', partial=True).partial, False) + self.assertEqual(regex.match('(?r)a*+', '', partial=True).partial, False) + self.assertEqual(regex.match('(?r)a+', '', partial=True).partial, True) + self.assertEqual(regex.match('(?r)a+?', '', partial=True).partial, True) + self.assertEqual(regex.match('(?r)a++', '', partial=True).partial, True) + self.assertEqual(regex.match('(?r)a+', 'a', partial=True).partial, False) + self.assertEqual(regex.match('(?r)a+?', 'a', partial=True).partial, False) + self.assertEqual(regex.match('(?r)a++', 'a', partial=True).partial, False) + + self.assertEqual(regex.match(r"(?:\s*\w+'*)+", 'whatever', partial=True).partial, + False) + + # Hg issue 300: segmentation fault + pattern = ('(?PGGCGTCACACTTTGCTATGCCATAGCAT[AG]TTTATCCATAAGA' + 'TTAGCGGATCCTACCTGACGCTTTTTATCGCAACTCTCTACTGTTTCTCCATAACAGAACATATTGA' + 'CTATCCGGTATTACCCGGCATGACAGGAGTAAAA){e<=1}' + '(?P[ACGT]{1059}){e<=2}' + '(?PTAATCGTCTTGTTTGATACACAAGGGTCGCATCTGCGGCCCTTTTGCTTTTTTAAG' + 'TTGTAAGGATATGCCATTCTAGA){e<=0}' + '(?P[ACGT]{18}){e<=0}' + '(?PAGATCGG[CT]AGAGCGTCGTGTAGGGAAAGAGTGTGG){e<=1}') + + text = ('GCACGGCGTCACACTTTGCTATGCCATAGCATATTTATCCATAAGATTAGCGGATCCTACC' + 'TGACGCTTTTTATCGCAACTCTCTACTGTTTCTCCATAACAGAACATATTGACTATCCGGTATTACC' + 'CGGCATGACAGGAGTAAAAATGGCTATCGACGAAAACAAACAGAAAGCGTTGGCGGCAGCACTGGGC' + 'CAGATTGAGAAACAATTTGGTAAAGGCTCCATCATGCGCCTGGGTGAAGACCGTTCCATGGATGTGG' + 'AAACCATCTCTACCGGTTCGCTTTCACTGGATATCGCGCTTGGGGCAGGTGGTCTGCCGATGGGCCG' + 'TATCGTCGAAATCTACGGACCGGAATCTTCCGGTAAAACCACGCTGACGCTGCAGGTGATCGCCGCA' + 'GCGCAGCGTGAAGGTAAAACCTGTGCGTTTATCGATGCTGAACACGCGCTGGACCCAATCTACGCAC' + 'GTAAACTGGGCGTCGATATCGACAACCTGCTGTGCTCCCAGCCGGACACCGGCGAGCAGGCACTGGA' + 'AATCTGTGACGCCCTGGCGCGTTCTGGCGCAGTAGACGTTATCGTCGTTGACTCCGTGGCGGCACTG' + 'ACGCCGAAAGCGGAAATCGAAGGCGAAATCGGCGACTCTCATATGGGCCTTGCGGCACGTATGATGA' + 'GCCAGGCGATGCGTAAGCTGGCGGGTAACCTGAAGCAGTCCAACACGCTGCTGATCTTCATCAACCC' + 'CATCCGTATGAAAATTGGTGTGATGTTCGGCAACCCGGAAACCACTTACCGGTGGTAACGCGCTGAA' + 'ATTCTACGCCTCTGTTCGTCTCGACATCCGTTAAATCGGCGCGGTGAAAGAGGGCGAAAACGTGGTG' + 'GGTAGCGAAACCCGCGTGAAAGTGGTGAAGAACAAAATCGCTGCGCCGTTTAAACAGGCTGAATTCC' + 'AGATCCTCTACGGCGAAGGTATCAACTTCTACCCCGAACTGGTTGACCTGGGCGTAAAAGAGAAGCT' + 'GATCGAGAAAGCAGGCGCGTGGTACAGCTACAAAGGTGAGAAGATCGGTCAGGGTAAAGCGAATGCG' + 'ACTGCCTGGCTGAAATTTAACCCGGAAACCGCGAAAGAGATCGAGTGAAAAGTACGTGAGTTGCTGC' + 'TGAGCAACCCGAACTCAACGCCGGATTTCTCTGTAGATGATAGCGAAGGCGTAGCAGAAACTAACGA' + 'AGATTTTTAATCGTCTTGTTTGATACACAAGGGTCGCATCTGCGGCCCTTTTGCTTTTTTAAGTTGT' + 'AAGGATATGCCATTCTAGACAGTTAACACACCAACAAAGATCGGTAGAGCGTCGTGTAGGGAAAGAG' + 'TGTGGTACC') + + m = regex.search(pattern, text, flags=regex.BESTMATCH) + self.assertEqual(m.fuzzy_counts, (0, 1, 0)) + self.assertEqual(m.fuzzy_changes, ([], [1206], [])) + + # Hg issue 306: Fuzzy match parameters not respecting quantifier scope + self.assertEqual(regex.search(r'(?e)(dogf(((oo){e<1})|((00){e<1}))d){e<2}', + 'dogfood').fuzzy_counts, (0, 0, 0)) + self.assertEqual(regex.search(r'(?e)(dogf(((oo){e<1})|((00){e<1}))d){e<2}', + 'dogfoot').fuzzy_counts, (1, 0, 0)) + + # Hg issue 312: \X not matching graphemes with zero-width-joins + self.assertEqual(regex.findall(r'\X', + '\U0001F468\u200D\U0001F469\u200D\U0001F467\u200D\U0001F466'), + ['\U0001F468\u200D\U0001F469\u200D\U0001F467\u200D\U0001F466']) + + # Hg issue 320: Abnormal performance + self.assertEqual(bool(regex.search(r'(?=a)a', 'a')), True) + self.assertEqual(bool(regex.search(r'(?!b)a', 'a')), True) + + # Hg issue 327: .fullmatch() causes MemoryError + self.assertEqual(regex.fullmatch(r'((\d)*?)*?', '123').span(), (0, 3)) + + # Hg issue 329: Wrong group matches when question mark quantifier is used within a look behind + self.assertEqual(regex.search(r'''(?(DEFINE)(?(?THIS_SHOULD_NOT_MATCHx?)|(?right))).*(?<=(?&mydef).*)''', + 'x right').capturesdict(), {'mydef': ['right'], 'wrong': [], 'right': + ['right']}) + + # Hg issue 338: specifying allowed characters when fuzzy-matching + self.assertEqual(bool(regex.match(r'(?:cat){e<=1:[u]}', 'cut')), True) + self.assertEqual(bool(regex.match(r'(?:cat){e<=1:u}', 'cut')), True) + + # Hg issue 353: fuzzy changes negative indexes + self.assertEqual(regex.search(r'(?be)(AGTGTTCCCCGCGCCAGCGGGGATAAACCG){s<=5,i<=5,d<=5,s+i+d<=10}', + 'TTCCCCGCGCCAGCGGGGATAAACCG').fuzzy_changes, ([], [], [0, 1, 3, 5])) + + # Git issue 364: Contradictory values in fuzzy_counts and fuzzy_changes + self.assertEqual(regex.match(r'(?:bc){e}', 'c').fuzzy_counts, (1, 0, + 1)) + self.assertEqual(regex.match(r'(?:bc){e}', 'c').fuzzy_changes, ([0], + [], [1])) + self.assertEqual(regex.match(r'(?e)(?:bc){e}', 'c').fuzzy_counts, (0, + 0, 1)) + self.assertEqual(regex.match(r'(?e)(?:bc){e}', 'c').fuzzy_changes, + ([], [], [0])) + self.assertEqual(regex.match(r'(?b)(?:bc){e}', 'c').fuzzy_counts, (0, + 0, 1)) + self.assertEqual(regex.match(r'(?b)(?:bc){e}', 'c').fuzzy_changes, + ([], [], [0])) + + # Git issue 370: Confusions about Fuzzy matching behavior + self.assertEqual(regex.match('(?e)(?:^(\\$ )?\\d{1,3}(,\\d{3})*(\\.\\d{2})$){e}', + '$ 10,112.111.12').fuzzy_counts, (6, 0, 5)) + self.assertEqual(regex.match('(?e)(?:^(\\$ )?\\d{1,3}(,\\d{3})*(\\.\\d{2})$){s<=1}', + '$ 10,112.111.12').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.match('(?e)(?:^(\\$ )?\\d{1,3}(,\\d{3})*(\\.\\d{2})$){s<=1,i<=1,d<=1}', + '$ 10,112.111.12').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.match('(?e)(?:^(\\$ )?\\d{1,3}(,\\d{3})*(\\.\\d{2})$){s<=3}', + '$ 10,1a2.111.12').fuzzy_counts, (2, 0, 0)) + self.assertEqual(regex.match('(?e)(?:^(\\$ )?\\d{1,3}(,\\d{3})*(\\.\\d{2})$){s<=2}', + '$ 10,1a2.111.12').fuzzy_counts, (2, 0, 0)) + + self.assertEqual(regex.fullmatch(r'(?e)(?:0?,0(?:,0)?){s<=1,d<=1}', + ',0;0').fuzzy_counts, (1, 0, 0)) + self.assertEqual(regex.fullmatch(r'(?e)(?:0??,0(?:,0)?){s<=1,d<=1}', + ',0;0').fuzzy_counts, (1, 0, 0)) + + # Git issue 371: Specifying character set when fuzzy-matching allows characters not in the set + self.assertEqual(regex.search(r"\b(?e)(?:\d{6,20}){i<=5:[\-\\\/]}\b", + "cat dog starting at 00:01132.000. hello world"), None) + + # Git issue 385: Comments in expressions + self.assertEqual(bool(regex.compile('(?#)')), True) + self.assertEqual(bool(regex.compile('(?x)(?#)')), True) + + # Git issue 394: Unexpected behaviour in fuzzy matching with limited character set with IGNORECASE flag + self.assertEqual(regex.findall(r'(\d+){i<=2:[ab]}', '123X4Y5'), + ['123', '4', '5']) + self.assertEqual(regex.findall(r'(?i)(\d+){i<=2:[ab]}', '123X4Y5'), + ['123', '4', '5']) + + # Git issue 403: Fuzzy matching with wrong distance (unnecessary substitutions) + self.assertEqual(regex.match(r'^(test){e<=5}$', 'terstin', + flags=regex.B).fuzzy_counts, (0, 3, 0)) + + # Git issue 408: regex fails with a quantified backreference but succeeds with repeated backref + self.assertEqual(bool(regex.match(r"(?:(x*)\1\1\1)*x$", "x" * 5)), True) + self.assertEqual(bool(regex.match(r"(?:(x*)\1{3})*x$", "x" * 5)), True) + + # Git issue 415: Fuzzy character restrictions don't apply to insertions at "right edge" + self.assertEqual(regex.match(r't(?:es){s<=1:\d}t', 'te5t').group(), + 'te5t') + self.assertEqual(regex.match(r't(?:es){s<=1:\d}t', 'tezt'), None) + self.assertEqual(regex.match(r't(?:es){i<=1:\d}t', 'tes5t').group(), + 'tes5t') + self.assertEqual(regex.match(r't(?:es){i<=1:\d}t', 'teszt'), None) + self.assertEqual(regex.match(r't(?:es){i<=1:\d}t', + 'tes5t').fuzzy_changes, ([], [3], [])) + self.assertEqual(regex.match(r't(es){i<=1,0.*)(?PCTTCC){e<=1}(?P([ACGT]){4,6})(?PCAATACCGACTCCTCACTGTGT){e<=2}(?P([ACGT]){0,6}$)' + + m = regex.match(pattern, sequence, flags=regex.BESTMATCH) + self.assertEqual(m.span(), (0, 50)) + self.assertEqual(m.groupdict(), {'insert': 'TTCAGACGTGTGCT', 'anchor': 'CTTCC', 'umi': 'GATCT', 'sid': 'CAATACCGACTCCTCACTGTGT', 'end': 'GTCT'}) + + m = regex.match(pattern, sequence, flags=regex.ENHANCEMATCH) + self.assertEqual(m.span(), (0, 50)) + self.assertEqual(m.groupdict(), {'insert': 'TTCAGACGTGTGCT', 'anchor': 'CTTCC', 'umi': 'GATCT', 'sid': 'CAATACCGACTCCTCACTGTGT', 'end': 'GTCT'}) + + # Git issue 433: Disagreement between fuzzy_counts and fuzzy_changes + pattern = r'(?P.*)(?PAACACTGG){e<=1}(?P([AT][CG]){5}){e<=2}(?PGTAACCGAAG){e<=2}(?P([ACGT]){0,6}$)' + + sequence = 'GGAAAACACTGGTCTCAGTCTCGTAACCGAAGTGGTCG' + m = regex.match(pattern, sequence, flags=regex.BESTMATCH) + self.assertEqual(m.fuzzy_counts, (0, 0, 0)) + self.assertEqual(m.fuzzy_changes, ([], [], [])) + + sequence = 'GGAAAACACTGGTCTCAGTCTCGTCCCCGAAGTGGTCG' + m = regex.match(pattern, sequence, flags=regex.BESTMATCH) + self.assertEqual(m.fuzzy_counts, (2, 0, 0)) + self.assertEqual(m.fuzzy_changes, ([24, 25], [], [])) + + # Git issue 439: Unmatched groups: sub vs subf + self.assertEqual(regex.sub(r'(test1)|(test2)', r'matched: \1\2', 'test1'), 'matched: test1') + self.assertEqual(regex.subf(r'(test1)|(test2)', r'matched: {1}{2}', 'test1'), 'matched: test1') + self.assertEqual(regex.search(r'(test1)|(test2)', 'matched: test1').expand(r'matched: \1\2'), 'matched: test1'), + self.assertEqual(regex.search(r'(test1)|(test2)', 'matched: test1').expandf(r'matched: {1}{2}'), 'matched: test1') + + # Git issue 442: Fuzzy regex matching doesn't seem to test insertions correctly + self.assertEqual(regex.search(r"(?:\bha\b){i:[ ]}", "having"), None) + self.assertEqual(regex.search(r"(?:\bha\b){i:[ ]}", "having", flags=regex.I), None) + + # Git issue 467: Scoped inline flags 'a', 'u' and 'L' affect global flags + self.assertEqual(regex.match(r'(?a:\w)\w', 'd\N{CYRILLIC SMALL LETTER ZHE}').span(), (0, 2)) + self.assertEqual(regex.match(r'(?a:\w)(?u:\w)', 'd\N{CYRILLIC SMALL LETTER ZHE}').span(), (0, 2)) + + # Git issue 473: Emoji classified as letter + self.assertEqual(regex.match(r'^\p{LC}+$', '\N{SMILING CAT FACE WITH OPEN MOUTH}'), None) + self.assertEqual(regex.match(r'^\p{So}+$', '\N{SMILING CAT FACE WITH OPEN MOUTH}').span(), (0, 1)) + + # Git issue 474: regex has no equivalent to `re.Match.groups()` for captures + self.assertEqual(regex.match(r'(.)+', 'abc').allcaptures(), (['abc'], ['a', 'b', 'c'])) + self.assertEqual(regex.match(r'(.)+', 'abc').allspans(), ([(0, 3)], [(0, 1), (1, 2), (2, 3)])) + + # Git issue 477: \v for vertical spacing + self.assertEqual(bool(regex.fullmatch(r'\p{HorizSpace}+', '\t \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000')), True) + self.assertEqual(bool(regex.fullmatch(r'\p{VertSpace}+', '\n\v\f\r\x85\u2028\u2029')), True) + + # Git issue 479: Segmentation fault when using conditional pattern + self.assertEqual(regex.match(r'(?(?<=A)|(?(?![^B])C|D))', 'A'), None) + self.assertEqual(regex.search(r'(?(?<=A)|(?(?![^B])C|D))', 'A').span(), (1, 1)) + + # Git issue 494: Backtracking failure matching regex ^a?(a?)b?c\1$ against string abca + self.assertEqual(regex.search(r"^a?(a?)b?c\1$", "abca").span(), (0, 4)) + + # Git issue 498: Conditional negative lookahead inside positive lookahead fails to match + self.assertEqual(regex.match(r'(?(?=a).|..)', 'ab').span(), (0, 1)) + self.assertEqual(regex.match(r'(?(?=b).|..)', 'ab').span(), (0, 2)) + self.assertEqual(regex.match(r'(?(?!a).|..)', 'ab').span(), (0, 2)) + self.assertEqual(regex.match(r'(?(?!b).|..)', 'ab').span(), (0, 1)) + + # Git issue 525: segfault when fuzzy matching empty list + self.assertEqual(regex.match(r"(\L){e<=5}", "blah", foo=[]).span(), (0, 0)) + + # Git issue 527: `VERBOSE`/`X` flag breaks `\N` escapes + self.assertEqual(regex.compile(r'\N{LATIN SMALL LETTER A}').match('a').span(), (0, 1)) + self.assertEqual(regex.compile(r'\N{LATIN SMALL LETTER A}', flags=regex.X).match('a').span(), (0, 1)) + + # Git issue 539: Bug: Partial matching fails on a simple example + self.assertEqual(regex.match(r"[^/]*b/ccc", "b/ccc", partial=True).span(), (0, 5)) + self.assertEqual(regex.match(r"[^/]*b/ccc", "b/ccb", partial=True), None) + self.assertEqual(regex.match(r"[^/]*b/ccc", "b/cc", partial=True).span(), (0, 4)) + self.assertEqual(regex.match(r"[^/]*b/xyz", "b/xy", partial=True).span(), (0, 4)) + self.assertEqual(regex.match(r"[^/]*b/xyz", "b/yz", partial=True), None) + + self.assertEqual(regex.match(r"(?i)[^/]*b/ccc", "b/ccc", partial=True).span(), (0, 5)) + self.assertEqual(regex.match(r"(?i)[^/]*b/ccc", "b/ccb", partial=True), None) + self.assertEqual(regex.match(r"(?i)[^/]*b/ccc", "b/cc", partial=True).span(), (0, 4)) + self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/xy", partial=True).span(), (0, 4)) + self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/yz", partial=True), None) + + # Git issue 546: Partial match not working in some instances with non-greedy capture + self.assertEqual(bool(regex.match(r'.*?', '<', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', '.*?', '', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', 'x', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', 'xyz abc', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo ', partial=True)), True) + self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo bar', partial=True)), True) + + def test_fuzzy_ext(self): + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')), + True) + self.assertEqual(bool(regex.fullmatch(r'(?:a){e<=1:[a-z]}', 'e')), + True) + self.assertEqual(bool(regex.fullmatch(r'(?:a){e<=1:[a-z]}', '-')), + False) + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', '-')), + False) + + self.assertEqual(bool(regex.fullmatch(r'(?:a){e<=1:[a-z]}', 'ae')), + True) + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', + 'ae')), True) + self.assertEqual(bool(regex.fullmatch(r'(?:a){e<=1:[a-z]}', 'a-')), + False) + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', + 'a-')), False) + + self.assertEqual(bool(regex.fullmatch(r'(?:ab){e<=1:[a-z]}', 'ae')), + True) + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:ab){e<=1:[a-z]}', + 'ae')), True) + self.assertEqual(bool(regex.fullmatch(r'(?:ab){e<=1:[a-z]}', 'a-')), + False) + self.assertEqual(bool(regex.fullmatch(r'(?r)(?:ab){e<=1:[a-z]}', + 'a-')), False) + + self.assertEqual(bool(regex.fullmatch(r'(a)\1{e<=1:[a-z]}', 'ae')), + True) + self.assertEqual(bool(regex.fullmatch(r'(?r)\1{e<=1:[a-z]}(a)', + 'ea')), True) + self.assertEqual(bool(regex.fullmatch(r'(a)\1{e<=1:[a-z]}', 'a-')), + False) + self.assertEqual(bool(regex.fullmatch(r'(?r)\1{e<=1:[a-z]}(a)', + '-a')), False) + + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 'ts')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 'st')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 'st')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 'ts')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + '-s')), False) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 's-')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + 's-')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(?:\N{LATIN SMALL LETTER SHARP S}){e<=1:[a-z]}', + '-s')), False) + + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + 'ssst')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + 'ssts')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)\1{e<=1:[a-z]}(\N{LATIN SMALL LETTER SHARP S})', + 'stss')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)\1{e<=1:[a-z]}(\N{LATIN SMALL LETTER SHARP S})', + 'tsss')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + 'ss-s')), False) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + 'sss-')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + '-s')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(\N{LATIN SMALL LETTER SHARP S})\1{e<=1:[a-z]}', + 's-')), False) + + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(ss)\1{e<=1:[a-z]}', + '\N{LATIN SMALL LETTER SHARP S}ts')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(ss)\1{e<=1:[a-z]}', + '\N{LATIN SMALL LETTER SHARP S}st')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)\1{e<=1:[a-z]}(ss)', + 'st\N{LATIN SMALL LETTER SHARP S}')), True) + self.assertEqual(bool(regex.fullmatch(r'(?firu)\1{e<=1:[a-z]}(ss)', + 'ts\N{LATIN SMALL LETTER SHARP S}')), True) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(ss)\1{e<=1:[a-z]}', + '\N{LATIN SMALL LETTER SHARP S}-s')), False) + self.assertEqual(bool(regex.fullmatch(r'(?fiu)(ss)\1{e<=1:[a-z]}', + '\N{LATIN SMALL LETTER SHARP S}s-')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(ss)\1{e<=1:[a-z]}', + 's-\N{LATIN SMALL LETTER SHARP S}')), False) + self.assertEqual(bool(regex.fullmatch(r'(?firu)(ss)\1{e<=1:[a-z]}', + '-s\N{LATIN SMALL LETTER SHARP S}')), False) + + def test_subscripted_captures(self): + self.assertEqual(regex.match(r'(?P.)+', + 'abc').expandf('{0} {0[0]} {0[-1]}'), 'abc abc abc') + self.assertEqual(regex.match(r'(?P.)+', + 'abc').expandf('{1} {1[0]} {1[1]} {1[2]} {1[-1]} {1[-2]} {1[-3]}'), + 'c a b c c b a') + self.assertEqual(regex.match(r'(?P.)+', + 'abc').expandf('{x} {x[0]} {x[1]} {x[2]} {x[-1]} {x[-2]} {x[-3]}'), + 'c a b c c b a') + + self.assertEqual(regex.subf(r'(?P.)+', r'{0} {0[0]} {0[-1]}', + 'abc'), 'abc abc abc') + self.assertEqual(regex.subf(r'(?P.)+', + '{1} {1[0]} {1[1]} {1[2]} {1[-1]} {1[-2]} {1[-3]}', 'abc'), + 'c a b c c b a') + self.assertEqual(regex.subf(r'(?P.)+', + '{x} {x[0]} {x[1]} {x[2]} {x[-1]} {x[-2]} {x[-3]}', 'abc'), + 'c a b c c b a') + + def test_more_zerowidth(self): + if sys.version_info >= (3, 7, 0): + self.assertEqual(regex.split(r'\b|:+', 'a::bc'), ['', 'a', '', '', + 'bc', '']) + self.assertEqual(regex.sub(r'\b|:+', '-', 'a::bc'), '-a---bc-') + self.assertEqual(regex.findall(r'\b|:+', 'a::bc'), ['', '', '::', + '', '']) + self.assertEqual([m.span() for m in regex.finditer(r'\b|:+', + 'a::bc')], [(0, 0), (1, 1), (1, 3), (3, 3), (5, 5)]) + self.assertEqual([m.span() for m in regex.finditer(r'(?m)^\s*?$', + 'foo\n\n\nbar')], [(4, 4), (4, 5), (5, 5)]) + + def test_line_ending(self): + self.assertEqual(regex.findall(r'\R', '\r\n\n\x0B\f\r\x85\u2028\u2029'), + ['\r\n', '\n', '\x0B', '\f', '\r', '\x85', '\u2028', '\u2029']) + self.assertEqual(regex.findall(br'\R', b'\r\n\n\x0B\f\r\x85'), [b'\r\n', + b'\n', b'\x0B', b'\f', b'\r']) + +def test_main(): + unittest.main(verbosity=2) + +if __name__ == "__main__": + test_main() diff --git a/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/INSTALLER b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/INSTALLER new file mode 100644 index 0000000000000000000000000000000000000000..a1b589e38a32041e49332e5e81c2d363dc418d68 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/METADATA b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/METADATA new file mode 100644 index 0000000000000000000000000000000000000000..e7c52daf19194c965745a656bec78f137a060614 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/METADATA @@ -0,0 +1,443 @@ +Metadata-Version: 2.1 +Name: stack-data +Version: 0.6.3 +Summary: Extract data from python stack frames and tracebacks for informative displays +Home-page: http://github.com/alexmojaki/stack_data +Author: Alex Hall +Author-email: alex.mojaki@gmail.com +License: MIT +Classifier: Intended Audience :: Developers +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Classifier: Topic :: Software Development :: Debuggers +Description-Content-Type: text/markdown +License-File: LICENSE.txt +Requires-Dist: executing >=1.2.0 +Requires-Dist: asttokens >=2.1.0 +Requires-Dist: pure-eval +Provides-Extra: tests +Requires-Dist: pytest ; extra == 'tests' +Requires-Dist: typeguard ; extra == 'tests' +Requires-Dist: pygments ; extra == 'tests' +Requires-Dist: littleutils ; extra == 'tests' +Requires-Dist: cython ; extra == 'tests' + +# stack_data + +[![Tests](https://github.com/alexmojaki/stack_data/actions/workflows/pytest.yml/badge.svg)](https://github.com/alexmojaki/stack_data/actions/workflows/pytest.yml) [![Coverage Status](https://coveralls.io/repos/github/alexmojaki/stack_data/badge.svg?branch=master)](https://coveralls.io/github/alexmojaki/stack_data?branch=master) [![Supports Python versions 3.5+](https://img.shields.io/pypi/pyversions/stack_data.svg)](https://pypi.python.org/pypi/stack_data) + +This is a library that extracts data from stack frames and tracebacks, particularly to display more useful tracebacks than the default. It powers the tracebacks in IPython and [futurecoder](https://futurecoder.io/): + +![futurecoder example](https://futurecoder.io/static/img/features/traceback.png) + +You can install it from PyPI: + + pip install stack_data + +## Basic usage + +Here's some code we'd like to inspect: + +```python +def foo(): + result = [] + for i in range(5): + row = [] + result.append(row) + print_stack() + for j in range(5): + row.append(i * j) + return result +``` + +Note that `foo` calls a function `print_stack()`. In reality we can imagine that an exception was raised at this line, or a debugger stopped there, but this is easy to play with directly. Here's a basic implementation: + +```python +import inspect +import stack_data + + +def print_stack(): + frame = inspect.currentframe().f_back + frame_info = stack_data.FrameInfo(frame) + print(f"{frame_info.code.co_name} at line {frame_info.lineno}") + print("-----------") + for line in frame_info.lines: + print(f"{'-->' if line.is_current else ' '} {line.lineno:4} | {line.render()}") +``` + +(Beware that this has a major bug - it doesn't account for line gaps, which we'll learn about later) + +The output of one call to `print_stack()` looks like: + +``` +foo at line 9 +----------- + 6 | for i in range(5): + 7 | row = [] + 8 | result.append(row) +--> 9 | print_stack() + 10 | for j in range(5): +``` + +The code for `print_stack()` is fairly self-explanatory. If you want to learn more details about a particular class or method I suggest looking through some docstrings. `FrameInfo` is a class that accepts either a frame or a traceback object and provides a bunch of nice attributes and properties (which are cached so you don't need to worry about performance). In particular `frame_info.lines` is a list of `Line` objects. `line.render()` returns the source code of that line suitable for display. Without any arguments it simply strips any common leading indentation. Later on we'll see a more powerful use for it. + +You can see that `frame_info.lines` includes some lines of surrounding context. By default it includes 3 pieces of context before the main line and 1 piece after. We can configure the amount of context by passing options: + +```python +options = stack_data.Options(before=1, after=0) +frame_info = stack_data.FrameInfo(frame, options) +``` + +Then the output looks like: + +``` +foo at line 9 +----------- + 8 | result.append(row) +--> 9 | print_stack() +``` + +Note that these parameters are not the number of *lines* before and after to include, but the number of *pieces*. A piece is a range of one or more lines in a file that should logically be grouped together. A piece contains either a single simple statement or a part of a compound statement (loops, if, try/except, etc) that doesn't contain any other statements. Most pieces are a single line, but a multi-line statement or `if` condition is a single piece. In the example above, all pieces are one line, because nothing is spread across multiple lines. If we change our code to include some multiline bits: + + +```python +def foo(): + result = [] + for i in range(5): + row = [] + result.append( + row + ) + print_stack() + for j in range( + 5 + ): + row.append(i * j) + return result +``` + +and then run the original code with the default options, then the output is: + +``` +foo at line 11 +----------- + 6 | for i in range(5): + 7 | row = [] + 8 | result.append( + 9 | row + 10 | ) +--> 11 | print_stack() + 12 | for j in range( + 13 | 5 + 14 | ): +``` + +Now lines 8-10 and lines 12-14 are each a single piece. Note that the output is essentially the same as the original in terms of the amount of code. The division of files into pieces means that the edge of the context is intuitive and doesn't crop out parts of statements or expressions. For example, if context was measured in lines instead of pieces, the last line of the above would be `for j in range(` which is much less useful. + +However, if a piece is very long, including all of it could be cumbersome. For this, `Options` has a parameter `max_lines_per_piece`, which is 6 by default. Suppose we have a piece in our code that's longer than that: + +```python + row = [ + 1, + 2, + 3, + 4, + 5, + ] +``` + +`frame_info.lines` will truncate this piece so that instead of 7 `Line` objects it will produce 5 `Line` objects and one `LINE_GAP` in the middle, making 6 objects in total for the piece. Our code doesn't currently handle gaps, so it will raise an exception. We can modify it like so: + +```python + for line in frame_info.lines: + if line is stack_data.LINE_GAP: + print(" (...)") + else: + print(f"{'-->' if line.is_current else ' '} {line.lineno:4} | {line.render()}") +``` + +Now the output looks like: + +``` +foo at line 15 +----------- + 6 | for i in range(5): + 7 | row = [ + 8 | 1, + 9 | 2, + (...) + 12 | 5, + 13 | ] + 14 | result.append(row) +--> 15 | print_stack() + 16 | for j in range(5): +``` + +Alternatively, you can flip the condition around and check `if isinstance(line, stack_data.Line):`. Either way, you should always check for line gaps, or your code may appear to work at first but fail when it encounters a long piece. + +Note that the executing piece, i.e. the piece containing the current line being executed (line 15 in this case) is never truncated, no matter how long it is. + +The lines of context never stray outside `frame_info.scope`, which is the innermost function or class definition containing the current line. For example, this is the output for a short function which has neither 3 lines before nor 1 line after the current line: + +``` +bar at line 6 +----------- + 4 | def bar(): + 5 | foo() +--> 6 | print_stack() +``` + +Sometimes it's nice to ensure that the function signature is always showing. This can be done with `Options(include_signature=True)`. The result looks like this: + +``` +foo at line 14 +----------- + 9 | def foo(): + (...) + 11 | for i in range(5): + 12 | row = [] + 13 | result.append(row) +--> 14 | print_stack() + 15 | for j in range(5): +``` + +To avoid wasting space, pieces never start or end with a blank line, and blank lines between pieces are excluded. So if our code looks like this: + + +```python + for i in range(5): + row = [] + + result.append(row) + print_stack() + + for j in range(5): +``` + +The output doesn't change much, except you can see jumps in the line numbers: + +``` + 11 | for i in range(5): + 12 | row = [] + 14 | result.append(row) +--> 15 | print_stack() + 17 | for j in range(5): +``` + +## Variables + +You can also inspect variables and other expressions in a frame, e.g: + +```python + for var in frame_info.variables: + print(f"{var.name} = {repr(var.value)}") +``` + +which may output: + +```python +result = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], []] +i = 4 +row = [] +j = 4 +``` + +`frame_info.variables` returns a list of `Variable` objects, which have attributes `name`, `value`, and `nodes`, which is a list of all AST representing that expression. + +A `Variable` may refer to an expression other than a simple variable name. It can be any expression evaluated by the library [`pure_eval`](https://github.com/alexmojaki/pure_eval) which it deems 'interesting' (see those docs for more info). This includes expressions like `foo.bar` or `foo[bar]`. In these cases `name` is the source code of that expression. `pure_eval` ensures that it only evaluates expressions that won't have any side effects, e.g. where `foo.bar` is a normal attribute rather than a descriptor such as a property. + +`frame_info.variables` is a list of all the interesting expressions found in `frame_info.scope`, e.g. the current function, which may include expressions not visible in `frame_info.lines`. You can restrict the list by using `frame_info.variables_in_lines` or even `frame_info.variables_in_executing_piece`. For more control you can use `frame_info.variables_by_lineno`. See the docstrings for more information. + +## Rendering lines with ranges and markers + +Sometimes you may want to insert special characters into the text for display purposes, e.g. HTML or ANSI color codes. `stack_data` provides a few tools to make this easier. + +Let's say we have a `Line` object where `line.text` (the original raw source code of that line) is `"foo = bar"`, so `line.text[6:9]` is `"bar"`, and we want to emphasise that part by inserting HTML at positions 6 and 9 in the text. Here's how we can do that directly: + +```python +markers = [ + stack_data.MarkerInLine(position=6, is_start=True, string=""), + stack_data.MarkerInLine(position=9, is_start=False, string=""), +] +line.render(markers) # returns "foo = bar" +``` + +Here `is_start=True` indicates that the marker is the first of a pair. This helps `line.render()` sort and insert the markers correctly so you don't end up with malformed HTML like `foo.bar` where tags overlap. + +Since we're inserting HTML, we should actually use `line.render(markers, escape_html=True)` which will escape special HTML characters in the Python source (but not the markers) so for example `foo = bar < spam` would be rendered as `foo = bar < spam`. + +Usually though you wouldn't create markers directly yourself. Instead you would start with one or more ranges and then convert them, like so: + +```python +ranges = [ + stack_data.RangeInLine(start=0, end=3, data="foo"), + stack_data.RangeInLine(start=6, end=9, data="bar"), +] + +def convert_ranges(r): + if r.data == "bar": + return "", "" + +# This results in `markers` being the same as in the above example. +markers = stack_data.markers_from_ranges(ranges, convert_ranges) +``` + +`RangeInLine` has a `data` attribute which can be any object. `markers_from_ranges` accepts a converter function to which it passes all the `RangeInLine` objects. If the converter function returns a pair of strings, it creates two markers from them. Otherwise it should return `None` to indicate that the range should be ignored, as with the first range containing `"foo"` in this example. + +The reason this is useful is because there are built in tools to create these ranges for you. For example, if we change our `print_stack()` function to contain this: + +```python +def convert_variable_ranges(r): + variable, _node = r.data + return f'', '' + +markers = stack_data.markers_from_ranges(line.variable_ranges, convert_variable_ranges) +print(f"{'-->' if line.is_current else ' '} {line.lineno:4} | {line.render(markers, escape_html=True)}") +``` + +Then the output becomes: + +``` +foo at line 15 +----------- + 9 | def foo(): + (...) + 11 | for i in range(5): + 12 | row = [] + 14 | result.append(row) +--> 15 | print_stack() + 17 | for j in range(5): +``` + +`line.variable_ranges` is a list of RangeInLines for each Variable that appears at least partially in this line. The data attribute of the range is a pair `(variable, node)` where node is the particular AST node from the list `variable.nodes` that corresponds to this range. + +You can also use `line.token_ranges` (e.g. if you want to do your own syntax highlighting) or `line.executing_node_ranges` if you want to highlight the currently executing node identified by the [`executing`](https://github.com/alexmojaki/executing) library. Or if you want to make your own range from an AST node, use `line.range_from_node(node, data)`. See the docstrings for more info. + +### Syntax highlighting with Pygments + +If you'd like pretty colored text without the work, you can let [Pygments](https://pygments.org/) do it for you. Just follow these steps: + +1. `pip install pygments` separately as it's not a dependency of `stack_data`. +2. Create a pygments formatter object such as `HtmlFormatter` or `Terminal256Formatter`. +3. Pass the formatter to `Options` in the argument `pygments_formatter`. +4. Use `line.render(pygmented=True)` to get your formatted text. In this case you can't pass any markers to `render`. + +If you want, you can also highlight the executing node in the frame in combination with the pygments syntax highlighting. For this you will need: + +1. A pygments style - either a style class or a string that names it. See the [documentation on styles](https://pygments.org/docs/styles/) and the [styles gallery](https://blog.yjl.im/2015/08/pygments-styles-gallery.html). +2. A modification to make to the style for the executing node, which is a string such as `"bold"` or `"bg:#ffff00"` (yellow background). See the [documentation on style rules](https://pygments.org/docs/styles/#style-rules). +3. Pass these two things to `stack_data.style_with_executing_node(style, modifier)` to get a new style class. +4. Pass the new style to your formatter when you create it. + +Note that this doesn't work with `TerminalFormatter` which just uses the basic ANSI colors and doesn't use the style passed to it in general. + +## Getting the full stack + +Currently `print_stack()` doesn't actually print the stack, it just prints one frame. Instead of `frame_info = FrameInfo(frame, options)`, let's do this: + +```python +for frame_info in FrameInfo.stack_data(frame, options): +``` + +Now the output looks something like this: + +``` + at line 18 +----------- + 14 | for j in range(5): + 15 | row.append(i * j) + 16 | return result +--> 18 | bar() + +bar at line 5 +----------- + 4 | def bar(): +--> 5 | foo() + +foo at line 13 +----------- + 10 | for i in range(5): + 11 | row = [] + 12 | result.append(row) +--> 13 | print_stack() + 14 | for j in range(5): +``` + +However, just as `frame_info.lines` doesn't always yield `Line` objects, `FrameInfo.stack_data` doesn't always yield `FrameInfo` objects, and we must modify our code to handle that. Let's look at some different sample code: + +```python +def factorial(x): + return x * factorial(x - 1) + + +try: + print(factorial(5)) +except: + print_stack() +``` + +In this code we've forgotten to include a base case in our `factorial` function so it will fail with a `RecursionError` and there'll be many frames with similar information. Similar to the built in Python traceback, `stack_data` avoids showing all of these frames. Instead you will get a `RepeatedFrames` object which summarises the information. See its docstring for more details. + +Here is our updated implementation: + +```python +def print_stack(): + for frame_info in FrameInfo.stack_data(sys.exc_info()[2]): + if isinstance(frame_info, FrameInfo): + print(f"{frame_info.code.co_name} at line {frame_info.lineno}") + print("-----------") + for line in frame_info.lines: + print(f"{'-->' if line.is_current else ' '} {line.lineno:4} | {line.render()}") + + for var in frame_info.variables: + print(f"{var.name} = {repr(var.value)}") + + print() + else: + print(f"... {frame_info.description} ...\n") +``` + +And the output: + +``` + at line 9 +----------- + 4 | def factorial(x): + 5 | return x * factorial(x - 1) + 8 | try: +--> 9 | print(factorial(5)) + 10 | except: + +factorial at line 5 +----------- + 4 | def factorial(x): +--> 5 | return x * factorial(x - 1) +x = 5 + +factorial at line 5 +----------- + 4 | def factorial(x): +--> 5 | return x * factorial(x - 1) +x = 4 + +... factorial at line 5 (996 times) ... + +factorial at line 5 +----------- + 4 | def factorial(x): +--> 5 | return x * factorial(x - 1) +x = -993 +``` + +In addition to handling repeated frames, we've passed a traceback object to `FrameInfo.stack_data` instead of a frame. + +If you want, you can pass `collapse_repeated_frames=False` to `FrameInfo.stack_data` (not to `Options`) and it will just yield `FrameInfo` objects for the full stack. diff --git a/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/RECORD b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/RECORD new file mode 100644 index 0000000000000000000000000000000000000000..64b9cbbae02bce26187396f1a55be14e81e1863a --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/RECORD @@ -0,0 +1,20 @@ +stack_data-0.6.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +stack_data-0.6.3.dist-info/LICENSE.txt,sha256=pHaiyw70xBRQNApXeii5GsTH9mkTay7hSAR_q9X8QYE,1066 +stack_data-0.6.3.dist-info/METADATA,sha256=8opm8q3eVOcDE1XgmhZuQ3vA0COjHBDJc6xJQojKTG8,18440 +stack_data-0.6.3.dist-info/RECORD,, +stack_data-0.6.3.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +stack_data-0.6.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92 +stack_data-0.6.3.dist-info/top_level.txt,sha256=IarPBYYY9efJkAgUnuykMUPznQR-ebWQYYsQcqYGxCo,11 +stack_data/__init__.py,sha256=oC0PI_cmh6R2evHFLgUFbrMZEgF_YvCh6pHXbPuoPSw,419 +stack_data/__pycache__/__init__.cpython-310.pyc,, +stack_data/__pycache__/core.cpython-310.pyc,, +stack_data/__pycache__/formatting.cpython-310.pyc,, +stack_data/__pycache__/serializing.cpython-310.pyc,, +stack_data/__pycache__/utils.cpython-310.pyc,, +stack_data/__pycache__/version.cpython-310.pyc,, +stack_data/core.py,sha256=Er8EfeM7scNIl5G6pmRSGaJspZvHyMGLgd70qXDnBl4,33355 +stack_data/formatting.py,sha256=dIiaw47H4PLsXZRseC0jEnij5RFs98lAql8r7DV4Sl0,8508 +stack_data/py.typed,sha256=5k8BacvFEvRONDNQm6FTsj5DwT8pMZnyCk7FIHcLkv8,73 +stack_data/serializing.py,sha256=tAJpXKcYOAGdA-0k8QAmJXZzcT2UKJmeHCAC_eZytO0,6468 +stack_data/utils.py,sha256=nHk5zd3jz_lts6nf_xmmbVKTIM5cwRK65FipX3X-gyM,5898 +stack_data/version.py,sha256=0ICX8PeSmWoiPyIEViMxRYkvCjQE1KvQPJp9o52KRjw,22 diff --git a/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/REQUESTED b/evalkit_tf437/lib/python3.10/site-packages/stack_data-0.6.3.dist-info/REQUESTED new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/LICENSE b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..daa1aff736cf6b19df42ac33b1894c846761854f --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Thomas Grainger + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/RECORD b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/RECORD new file mode 100644 index 0000000000000000000000000000000000000000..74babf20a1c3985f1e0c0bfe336ba58b9e455e7d --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/RECORD @@ -0,0 +1,16 @@ +taskgroup-0.0.0a4.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +taskgroup-0.0.0a4.dist-info/LICENSE,sha256=Et7Rm8VNckzL84zplf1943hG90TtdI_u4sqg053T9Vo,1082 +taskgroup-0.0.0a4.dist-info/METADATA,sha256=-gTE6G1EoQZ9QRjrjMN5hrDDuF2o3DqDvUH6BYniRnw,327 +taskgroup-0.0.0a4.dist-info/RECORD,, +taskgroup-0.0.0a4.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +taskgroup-0.0.0a4.dist-info/WHEEL,sha256=96_DCfscDnVj9fVNwi1rfifiRwfpxLjwXWglVksjj_E,99 +taskgroup/__init__.py,sha256=qP-LZhSvy48TlILpovqr1IVRvrMGnKy0v8WnroZMICA,296 +taskgroup/__pycache__/__init__.cpython-310.pyc,, +taskgroup/__pycache__/runners.cpython-310.pyc,, +taskgroup/__pycache__/taskgroups.cpython-310.pyc,, +taskgroup/__pycache__/tasks.cpython-310.pyc,, +taskgroup/__pycache__/timeouts.cpython-310.pyc,, +taskgroup/runners.py,sha256=xI-Z7ODhISj4M6oEwoIREa-31s7mMYtb902mxXTcG-w,6996 +taskgroup/taskgroups.py,sha256=9j3MXyDGkqqCBvWzXr1SNFSuFyn2gvEmTm83CxrACrw,7951 +taskgroup/tasks.py,sha256=t30wsctelGphdknuSk4R55nDVdX7_SorARm3lz42mFo,1323 +taskgroup/timeouts.py,sha256=PyDt8qFcGAR2AACmHRxSW7ftXsGfztOaZrelUrnePAg,4800 diff --git a/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/REQUESTED b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/REQUESTED new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/WHEEL b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/WHEEL new file mode 100644 index 0000000000000000000000000000000000000000..116b3895d667263cbf5594f49eacb1d04cdfb70e --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/taskgroup-0.0.0a4.dist-info/WHEEL @@ -0,0 +1,5 @@ +Wheel-Version: 1.0 +Generator: flit 3.7.1 +Root-Is-Purelib: true +Tag: py2-none-any +Tag: py3-none-any diff --git a/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/LICENSE_APACHE b/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/LICENSE_APACHE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/LICENSE_APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/RECORD b/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/RECORD new file mode 100644 index 0000000000000000000000000000000000000000..4770b745a4f3b31197e667b51d6c1d20dbbe8349 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/RECORD @@ -0,0 +1,656 @@ +tzdata-2024.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +tzdata-2024.2.dist-info/LICENSE,sha256=M-jlAC01EtP8wigrmV5rrZ0zR4G5xawxhD9ASQDh87Q,592 +tzdata-2024.2.dist-info/LICENSE_APACHE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357 +tzdata-2024.2.dist-info/METADATA,sha256=5HAWgRuxvc1h1LHVUCXna4uZ7h6KjIet66Kn8AUDh5c,1393 +tzdata-2024.2.dist-info/RECORD,, +tzdata-2024.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata-2024.2.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109 +tzdata-2024.2.dist-info/top_level.txt,sha256=MO6QqC0xRrN67Gh9xU_nMmadwBVlYzPNkq_h4gYuzaQ,7 +tzdata/__init__.py,sha256=9o0ijEmis4rXSl6J7-eVzqZxxUWI7aGSQLwuzQFBtz4,252 +tzdata/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Africa/Abidjan,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Accra,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Addis_Ababa,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Algiers,sha256=L2nS4gLNFvuo89p3YtB-lSDYY2284SqkGH9pQQI8uwc,470 +tzdata/zoneinfo/Africa/Asmara,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Asmera,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Bamako,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Bangui,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Banjul,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Bissau,sha256=wa3uva129dJHRCi7tYt04kFOn1-osMS2afMjleO9mDw,149 +tzdata/zoneinfo/Africa/Blantyre,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Brazzaville,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Bujumbura,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Cairo,sha256=icuaNiEvuC6TPc2fqhDv36lpop7IDDIGO7tFGMAz0b4,1309 +tzdata/zoneinfo/Africa/Casablanca,sha256=MMps8T4AwqbEN6PIN_pkNiPMBEBqtRZRZceLN-9rxMM,1919 +tzdata/zoneinfo/Africa/Ceuta,sha256=oEIgK53afz1SYxYB_D0jR98Ss3g581yb8TnLppPaYcY,562 +tzdata/zoneinfo/Africa/Conakry,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Dakar,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Dar_es_Salaam,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Djibouti,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Douala,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/El_Aaiun,sha256=6hfLbLfrD1Qy9ZZqLXr1Xw7fzeEs_FqeHN2zZJZUVJI,1830 +tzdata/zoneinfo/Africa/Freetown,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Gaborone,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Harare,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Johannesburg,sha256=0Zrr4kNcToS_euZVM9I6nUQPmBYuW01pxz94PgIpnsg,190 +tzdata/zoneinfo/Africa/Juba,sha256=VTpoMAP-jJ6cKsDeNVr7l3LKGoKDUxGU2b1gqvDPz34,458 +tzdata/zoneinfo/Africa/Kampala,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Khartoum,sha256=NRwOwIg4SR6XuD11k3hxBz77uoBpzejXq7vxtq2Xys8,458 +tzdata/zoneinfo/Africa/Kigali,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Kinshasa,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Lagos,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Libreville,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Lome,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Luanda,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Lubumbashi,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Lusaka,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Malabo,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Maputo,sha256=kQyXwJHNNK50J8gyJiNM57Ty9CXFgi1macJL5iAQp5I,131 +tzdata/zoneinfo/Africa/Maseru,sha256=0Zrr4kNcToS_euZVM9I6nUQPmBYuW01pxz94PgIpnsg,190 +tzdata/zoneinfo/Africa/Mbabane,sha256=0Zrr4kNcToS_euZVM9I6nUQPmBYuW01pxz94PgIpnsg,190 +tzdata/zoneinfo/Africa/Mogadishu,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Monrovia,sha256=WM-JVfr502Vgy18Fe6iAJ2yMgOWbwwumIQh_yp53eKM,164 +tzdata/zoneinfo/Africa/Nairobi,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Africa/Ndjamena,sha256=Tlj4ZUUNJxEhvAoo7TJKqWv1J7tEYaf1FEMez-K9xEg,160 +tzdata/zoneinfo/Africa/Niamey,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Nouakchott,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Ouagadougou,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Porto-Novo,sha256=5e8SiFccxWxSdsqWbhyKZ1xnR3JtdY7K_n7_zm7Ke-Q,180 +tzdata/zoneinfo/Africa/Sao_Tome,sha256=Pfiutakw5B5xr1OSg1uFvT0GwC6jVOqqxnx69GEJu50,173 +tzdata/zoneinfo/Africa/Timbuktu,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Africa/Tripoli,sha256=zzMBLZZh4VQ4_ARe5k4L_rsuqKP7edKvVt8F6kvj5FM,431 +tzdata/zoneinfo/Africa/Tunis,sha256=uoAEER48RJqNeGoYBuk5IeYqjc8sHvWLvKssuVCd18g,449 +tzdata/zoneinfo/Africa/Windhoek,sha256=g1jLRko_2peGsUTg0_wZycOC4gxTAHwfV2SO9I3KdCM,638 +tzdata/zoneinfo/Africa/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Africa/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/America/Adak,sha256=q_sZgOINX4TsX9iBx1gNd6XGwBnzCjg6qpdAQhK0ieA,969 +tzdata/zoneinfo/America/Anchorage,sha256=d8oMIpYvBpmLzl5I2By4ZaFEZsg_9dxgfqpIM0QFi_Y,977 +tzdata/zoneinfo/America/Anguilla,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Antigua,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Araguaina,sha256=TawYX4lVAxq0BxUGhTDx4C8vtBRnLuWi8qLV_oXDiUo,592 +tzdata/zoneinfo/America/Argentina/Buenos_Aires,sha256=IEVOpSfI6oiJJmFNIb9Vb0bOOMIgxO5bghFw7vkHFGk,708 +tzdata/zoneinfo/America/Argentina/Catamarca,sha256=UC0fxx7ZPmjPw3D0BK-5vap-c1cBzbgR293MdmEfOx0,708 +tzdata/zoneinfo/America/Argentina/ComodRivadavia,sha256=UC0fxx7ZPmjPw3D0BK-5vap-c1cBzbgR293MdmEfOx0,708 +tzdata/zoneinfo/America/Argentina/Cordoba,sha256=9Ij3WjT9mWMKQ43LeSUIqQuDb9zS3FSlHYPVNQJTFf0,708 +tzdata/zoneinfo/America/Argentina/Jujuy,sha256=7YpjOcmVaKKpiq31rQe8TTDNExdH9jjZIhdcZv-ShUg,690 +tzdata/zoneinfo/America/Argentina/La_Rioja,sha256=mUkRD5jaWJUy2f8vNFqOlMgKPptULOBn-vf_jMgF6x8,717 +tzdata/zoneinfo/America/Argentina/Mendoza,sha256=dL4q0zgY2FKPbG8cC-Wknnpp8tF2Y7SWgWSC_G_WznI,708 +tzdata/zoneinfo/America/Argentina/Rio_Gallegos,sha256=bCpWMlEI8KWe4c3n6fn8u6WCPnxjYtVy57ERtLTZaEs,708 +tzdata/zoneinfo/America/Argentina/Salta,sha256=H_ybxVycfOe7LlUA3GngoS0jENHkQURIRhjfJQF2kfU,690 +tzdata/zoneinfo/America/Argentina/San_Juan,sha256=Mj5vIUzQl5DtsPe3iMzS7rR-88U9HKW2csQqUda4JNM,717 +tzdata/zoneinfo/America/Argentina/San_Luis,sha256=rka8BokogyvMRFH6jr8D6s1tFIpsUeqHJ_feLK5O6ds,717 +tzdata/zoneinfo/America/Argentina/Tucuman,sha256=yv3aC-hALLio2yqneLIIylZhXKDlbPJGAd_abgsj9gg,726 +tzdata/zoneinfo/America/Argentina/Ushuaia,sha256=mcmZgB1pEHX6i7nlyRzjLnG8bqAtAK1TwMdRD2pZqBE,708 +tzdata/zoneinfo/America/Argentina/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/America/Argentina/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/America/Aruba,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Asuncion,sha256=PuuUl8VILSBeZWDyLkM67bWl47xPMcJ0fY-rAhvSFzc,884 +tzdata/zoneinfo/America/Atikokan,sha256=p41zBnujy9lPiiPf3WqotoyzOxhIS8F7TiDqGuwvCoE,149 +tzdata/zoneinfo/America/Atka,sha256=q_sZgOINX4TsX9iBx1gNd6XGwBnzCjg6qpdAQhK0ieA,969 +tzdata/zoneinfo/America/Bahia,sha256=_-ZFw-HzXc7byacHW_NJHtJ03ADFdqt1kaYgyWYobYw,682 +tzdata/zoneinfo/America/Bahia_Banderas,sha256=lJ8K-PrUqLTefuqpcKp_YWvfvzH0WNNrZ_LIel_0oZQ,700 +tzdata/zoneinfo/America/Barbados,sha256=gdiJf9ZKOMs9QB4ex0-crvdmhNfHpNzXTV2xTaNDCAg,278 +tzdata/zoneinfo/America/Belem,sha256=w0jv-gdBbEBZQBF2z2liKpRM9CEOWA36O1qU1nJKeCs,394 +tzdata/zoneinfo/America/Belize,sha256=uYBPJqnCGnOOeKnoz1IG9POWTvXD5kUirpFuB0PHjVo,1045 +tzdata/zoneinfo/America/Blanc-Sablon,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Boa_Vista,sha256=hYTFFNNZJdl_nSYIdfI8SQhtmfiakjCDI_15TlB-xEw,430 +tzdata/zoneinfo/America/Bogota,sha256=BqH6uClrrlT-VsBmke2Mh-IfA1R1l1h031CRUSLS1no,179 +tzdata/zoneinfo/America/Boise,sha256=Jt3omyPSPRoKE-KXVd-wxVON-CDE5oGaJA7Ar90Q2OM,999 +tzdata/zoneinfo/America/Buenos_Aires,sha256=IEVOpSfI6oiJJmFNIb9Vb0bOOMIgxO5bghFw7vkHFGk,708 +tzdata/zoneinfo/America/Cambridge_Bay,sha256=NFwNVfgxb2YMLzc-42RA-SKtNcODpukEfYf_QWWYTsI,883 +tzdata/zoneinfo/America/Campo_Grande,sha256=mngKYjaH_ENVmJ-mtURVjjFo5kHgLfYNPHZaCVSxQFE,952 +tzdata/zoneinfo/America/Cancun,sha256=YSoUxbjaL2MycKCTB3ZAK9jPVaeMhW7MkOEA8eWakKY,538 +tzdata/zoneinfo/America/Caracas,sha256=UHmUwc0mFPoidR4UDCWb4T4w_mpCBsSb4BkW3SOKIVY,190 +tzdata/zoneinfo/America/Catamarca,sha256=UC0fxx7ZPmjPw3D0BK-5vap-c1cBzbgR293MdmEfOx0,708 +tzdata/zoneinfo/America/Cayenne,sha256=9URU4o1v5759UWuh8xI9vnaANOceOeRW67XoGQuuUa8,151 +tzdata/zoneinfo/America/Cayman,sha256=p41zBnujy9lPiiPf3WqotoyzOxhIS8F7TiDqGuwvCoE,149 +tzdata/zoneinfo/America/Chicago,sha256=wntzn_RqffBZThINcltDkhfhHkTqmlDNxJEwODtUguc,1754 +tzdata/zoneinfo/America/Chihuahua,sha256=tzOmA7trhFykyUZ7QbuMA6A88BSF2o4mumo65aojzqo,691 +tzdata/zoneinfo/America/Ciudad_Juarez,sha256=mEE-VN-sqVDaHFJyFGUBYyOsYHCRspUZcSJqt26Wufg,718 +tzdata/zoneinfo/America/Coral_Harbour,sha256=p41zBnujy9lPiiPf3WqotoyzOxhIS8F7TiDqGuwvCoE,149 +tzdata/zoneinfo/America/Cordoba,sha256=9Ij3WjT9mWMKQ43LeSUIqQuDb9zS3FSlHYPVNQJTFf0,708 +tzdata/zoneinfo/America/Costa_Rica,sha256=ihoqA_tHmYm0YjTRLZu3q8PqsqqOeb1CELjWhPf_HXE,232 +tzdata/zoneinfo/America/Creston,sha256=rhFFPCHQiYTedfLv7ATckxeKe04jxeUvIJi4vUXMtUc,240 +tzdata/zoneinfo/America/Cuiaba,sha256=OaIle0Cr-BKe0hOik5rwdcoCbQ5LSHkHqBS2cLoCqAU,934 +tzdata/zoneinfo/America/Curacao,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Danmarkshavn,sha256=cQORuA8pR0vw3ZwYfeGkWaT1tPU66nMQ2xRKT1T1Yb4,447 +tzdata/zoneinfo/America/Dawson,sha256=BlKV0U36jqnlxM5-Pxn8OIiY5kJEcLlt3QZo-GsMzlY,1029 +tzdata/zoneinfo/America/Dawson_Creek,sha256=t4USMuIvq1VVL9gYCabraAYs31kmAqAnwf7GzEiJJNc,683 +tzdata/zoneinfo/America/Denver,sha256=m7cDkg7KS2EZ6BoQVYOk9soiBlHxO0GEeat81WxBPz4,1042 +tzdata/zoneinfo/America/Detroit,sha256=I4F8Mt9nx38AF6D-steYskBa_HHO6jKU1-W0yRFr50A,899 +tzdata/zoneinfo/America/Dominica,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Edmonton,sha256=Dq2mxcSNWZhMWRqxwwtMcaqwAIGMwkOzz-mW8fJscV8,970 +tzdata/zoneinfo/America/Eirunepe,sha256=6tKYaRpnbBSmXiwXy7_m4WW_rbVfn5LUec0keC3J7Iw,436 +tzdata/zoneinfo/America/El_Salvador,sha256=4wjsCpRH9AFk5abLAbnuv-zouhRKcwb0aenk-nWtmz0,176 +tzdata/zoneinfo/America/Ensenada,sha256=MGWr-6toDRarjMXTaiOIWgBFWNbw7lHvidLuPKFxfIo,1079 +tzdata/zoneinfo/America/Fort_Nelson,sha256=_j7IJ-hXHtV_7dSMg6pxGQLb6z_IaUMj3aJde_F49QQ,1448 +tzdata/zoneinfo/America/Fort_Wayne,sha256=5nj0KhPvvXvg8mqc5T4EscKKWC6rBWEcsBwWg2Qy8Hs,531 +tzdata/zoneinfo/America/Fortaleza,sha256=ugF4DWO3j_khONebf7CLsT9ldL-JOWey_69S0jl2LIA,484 +tzdata/zoneinfo/America/Glace_Bay,sha256=I1posPHAEfg_Lc_FQdX1B8F8_A0NeJnK72p36PE7pKM,880 +tzdata/zoneinfo/America/Godthab,sha256=LlGZ5Y_ud9JwWRvncHnUHRArQbbnNcmmrz3duMhR3Hc,965 +tzdata/zoneinfo/America/Goose_Bay,sha256=gCJA1Sk2ciUg2WInn8DmPBwRAw0FjQbYPaUJK80mtMI,1580 +tzdata/zoneinfo/America/Grand_Turk,sha256=Gp8hpMt9P3QoEHmsIX2bqGNMkUSvlwZqqNzccR-cbe8,853 +tzdata/zoneinfo/America/Grenada,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Guadeloupe,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Guatemala,sha256=BGPGI4lyN6IFF_T0kx1q2lh3U5SEhbyDqLFuW8EFCaU,212 +tzdata/zoneinfo/America/Guayaquil,sha256=8OIaCy-SirKKz4I77l6MQFDgSLHtjN0TvklLVEZ_008,179 +tzdata/zoneinfo/America/Guyana,sha256=PmnEtWtOTamsPJXEo7PcNQCy2Rp-evGyJh4cf0pjAR4,181 +tzdata/zoneinfo/America/Halifax,sha256=kO5ahBM2oTLfWS4KX15FbKXfo5wg-f9vw1_hMOISGig,1672 +tzdata/zoneinfo/America/Havana,sha256=ms5rCuq2yBM49VmTymMtFQN3c5aBN1lkd8jjzKdnNm8,1117 +tzdata/zoneinfo/America/Hermosillo,sha256=Ur1MYSAX3QbT2UX57LmD83o6s2Z-6YbYeOufKvT-zTM,258 +tzdata/zoneinfo/America/Indiana/Indianapolis,sha256=5nj0KhPvvXvg8mqc5T4EscKKWC6rBWEcsBwWg2Qy8Hs,531 +tzdata/zoneinfo/America/Indiana/Knox,sha256=KJCzXct8CTMItVLYLYeBqM6aT6b53gWCg6aDbsH58oI,1016 +tzdata/zoneinfo/America/Indiana/Marengo,sha256=ygWmq8sYee8NFwlSZyQ_tsKopFQMp9Ne557zGGbyF2Y,567 +tzdata/zoneinfo/America/Indiana/Petersburg,sha256=BIrubzHEp5QoyMaPgYbC1zSa_F3LwpXzKM8xH3rHspI,683 +tzdata/zoneinfo/America/Indiana/Tell_City,sha256=em2YMHDWEFXdZH0BKi5bLRAQ8bYDfop2T0Q8SqDh0B8,522 +tzdata/zoneinfo/America/Indiana/Vevay,sha256=dPk334e7MQwl71-avNyREBYVWuFTQcVKfltlRhrlRpw,369 +tzdata/zoneinfo/America/Indiana/Vincennes,sha256=jiODDXepmLP3gvCkBufdE3rp5cEXftBHnKne8_XOOCg,558 +tzdata/zoneinfo/America/Indiana/Winamac,sha256=hsEunaLrbxvspyV3Qm4UD7x7qOAeBtzcbbzANNMrdiw,603 +tzdata/zoneinfo/America/Indiana/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/America/Indiana/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/America/Indianapolis,sha256=5nj0KhPvvXvg8mqc5T4EscKKWC6rBWEcsBwWg2Qy8Hs,531 +tzdata/zoneinfo/America/Inuvik,sha256=d_ZX-USS70HIT-_PRJKMY6mbQRvbKLvsy9ar7uL2M40,817 +tzdata/zoneinfo/America/Iqaluit,sha256=nONS7zksGHTrbEJj73LYRZW964OncQuj_V6fNjpDoQ0,855 +tzdata/zoneinfo/America/Jamaica,sha256=pDexcAMzrv9TqLWGjVOHwIDcFMLT6Vqlzjb5AbNmkoQ,339 +tzdata/zoneinfo/America/Jujuy,sha256=7YpjOcmVaKKpiq31rQe8TTDNExdH9jjZIhdcZv-ShUg,690 +tzdata/zoneinfo/America/Juneau,sha256=V8IqRaJHSH7onK1gu3YYtW_a4VkNwjx5DCvQXpFdYAo,966 +tzdata/zoneinfo/America/Kentucky/Louisville,sha256=zS2SS573D9TmQZFWtSyRIVN3ZXVN_2FpVBbtqQFMzKU,1242 +tzdata/zoneinfo/America/Kentucky/Monticello,sha256=54or2oQ9bSbM9ifRoOjV7UjRF83jSSPuxfGeXH0nIqk,972 +tzdata/zoneinfo/America/Kentucky/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/America/Kentucky/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/America/Knox_IN,sha256=KJCzXct8CTMItVLYLYeBqM6aT6b53gWCg6aDbsH58oI,1016 +tzdata/zoneinfo/America/Kralendijk,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/La_Paz,sha256=2iYBxnc0HIwAzlx-Q3AI9Lb0GI87VY279oGcroBZSVs,170 +tzdata/zoneinfo/America/Lima,sha256=7vNjRhxzL-X4kyba-NkzXYNAOE-cqqcXvzXTqcTXBhY,283 +tzdata/zoneinfo/America/Los_Angeles,sha256=IA0FdU9tg6Nxz0CNcIUSV5dlezsL6-uh5QjP_oaj5cg,1294 +tzdata/zoneinfo/America/Louisville,sha256=zS2SS573D9TmQZFWtSyRIVN3ZXVN_2FpVBbtqQFMzKU,1242 +tzdata/zoneinfo/America/Lower_Princes,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Maceio,sha256=dSVg0dHedT9w1QO2F1AvWoel4_h8wmuYS4guEaL-5Kk,502 +tzdata/zoneinfo/America/Managua,sha256=ZYsoyN_GIlwAIpIj1spjQDPWGQ9kFZSipjUbO8caGfw,295 +tzdata/zoneinfo/America/Manaus,sha256=9kgrhpryB94YOVoshJliiiDSf9mwjb3OZwX0HusNRrk,412 +tzdata/zoneinfo/America/Marigot,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Martinique,sha256=m3rC6Mogc6cc1a9XJ8FPIYhZaSFNdYkxaZ-pfHhG3X4,178 +tzdata/zoneinfo/America/Matamoros,sha256=KxgAMGkE7TJuug9byFsT3KN836X3OyXq77v-tFpLVvc,437 +tzdata/zoneinfo/America/Mazatlan,sha256=IN7ecQ9SDq9sDNvu_nc_xuMN2LHSiq8X6YQgmVUe6aY,690 +tzdata/zoneinfo/America/Mendoza,sha256=dL4q0zgY2FKPbG8cC-Wknnpp8tF2Y7SWgWSC_G_WznI,708 +tzdata/zoneinfo/America/Menominee,sha256=oUmJmzOZtChYrB9In-E1GqEVi2ogKjPESXlUySUGs94,917 +tzdata/zoneinfo/America/Merida,sha256=LBpOEv4xxUcL5B7wFSNa3UyE762-EiSXb1KPQNKwwCU,654 +tzdata/zoneinfo/America/Metlakatla,sha256=EVj1LkMCgry6mT8Ln_FpHxpJSU0oSncfbHGWIQ0SI_0,586 +tzdata/zoneinfo/America/Mexico_City,sha256=N90r8I8T_OD3B8Ox9M7EAY772cR8g2ew-03rvUYb1y8,773 +tzdata/zoneinfo/America/Miquelon,sha256=Eey-Id5b4HFODINweRFtbDjcgjs_myiC2UwsgYt4kVk,550 +tzdata/zoneinfo/America/Moncton,sha256=knrBNDFwHAGFr0nWJTBQ-10F_fZ5x4n3SnZtH-KI6h8,1493 +tzdata/zoneinfo/America/Monterrey,sha256=1aYsIp-Na0lDAKVrcW4wVKFAXy5BAqDG2wWLT9wTmmQ,709 +tzdata/zoneinfo/America/Montevideo,sha256=l7FjW6qscGzdvfjlbIeZ5CQ_AFWS3ZeVDS5ppMJCNM0,969 +tzdata/zoneinfo/America/Montreal,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/America/Montserrat,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Nassau,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/America/New_York,sha256=1_IgazpFmJ_JrWPVWJIlMvpzUigNX4cXa_HbecsdH6k,1744 +tzdata/zoneinfo/America/Nipigon,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/America/Nome,sha256=_-incQnh0DwK9hJqFaYzO4osUKAUB2k2lae565sblpA,975 +tzdata/zoneinfo/America/Noronha,sha256=Q0r3GtA5y2RGkOj56OTZG5tuBy1B6kfbhyrJqCgf27g,484 +tzdata/zoneinfo/America/North_Dakota/Beulah,sha256=RvaBIS60bNNRmREi6BXSWEbJSrcP7J8Nmxg8OkBcrow,1043 +tzdata/zoneinfo/America/North_Dakota/Center,sha256=M09x4Mx6hcBAwktvwv16YvPRmsuDjZEDwHT0Umkcgyo,990 +tzdata/zoneinfo/America/North_Dakota/New_Salem,sha256=mZca9gyfO2USzax7v0mLJEYBKBVmIqylWqnfLgSsVys,990 +tzdata/zoneinfo/America/North_Dakota/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/America/North_Dakota/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/America/Nuuk,sha256=LlGZ5Y_ud9JwWRvncHnUHRArQbbnNcmmrz3duMhR3Hc,965 +tzdata/zoneinfo/America/Ojinaga,sha256=97mJ9VI8h1lRAREIdJdTz_MCLtwh4b36iaQ9QolETpA,718 +tzdata/zoneinfo/America/Panama,sha256=p41zBnujy9lPiiPf3WqotoyzOxhIS8F7TiDqGuwvCoE,149 +tzdata/zoneinfo/America/Pangnirtung,sha256=nONS7zksGHTrbEJj73LYRZW964OncQuj_V6fNjpDoQ0,855 +tzdata/zoneinfo/America/Paramaribo,sha256=C2v9tR6no54CRECWDFhANTl40UsA4AhHsdnGoNCb4_Q,187 +tzdata/zoneinfo/America/Phoenix,sha256=rhFFPCHQiYTedfLv7ATckxeKe04jxeUvIJi4vUXMtUc,240 +tzdata/zoneinfo/America/Port-au-Prince,sha256=wsS6VbQ__bKJ2IUMPy_Pao0CLRK5pXEBrqkaYuqs3Ns,565 +tzdata/zoneinfo/America/Port_of_Spain,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Porto_Acre,sha256=VjuQUr668phq5bcH40r94BPnZBKHzJf_MQBfM6Db96U,418 +tzdata/zoneinfo/America/Porto_Velho,sha256=9yPU8EXtKDQHLF745ETc9qZZ9Me2CK6jvgb6S53pSKg,394 +tzdata/zoneinfo/America/Puerto_Rico,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Punta_Arenas,sha256=2Aqh7bqo-mQlnMjURDkCOeEYmeXhkzKP7OxFAvhTjjA,1218 +tzdata/zoneinfo/America/Rainy_River,sha256=ANzwYGBU1PknQW4LR-H92i5c4Db95LU-UQhPhWZCjDo,1294 +tzdata/zoneinfo/America/Rankin_Inlet,sha256=JQCXQBdyc8uJTjIFO4jZuzS0OjG0gRHv8MPmdzN93CU,807 +tzdata/zoneinfo/America/Recife,sha256=3yZTwF3MJlkY0D48CQUTzCRwDCfGNq8EXXTZYlBgUTg,484 +tzdata/zoneinfo/America/Regina,sha256=_JHuns225iE-THc9NFp-RBq4PWULAuGw2OLbpOB_UMw,638 +tzdata/zoneinfo/America/Resolute,sha256=2UeJBR2ZSkn1bUZy0G0SEhBtY9vycwSRU4naK-sw044,807 +tzdata/zoneinfo/America/Rio_Branco,sha256=VjuQUr668phq5bcH40r94BPnZBKHzJf_MQBfM6Db96U,418 +tzdata/zoneinfo/America/Rosario,sha256=9Ij3WjT9mWMKQ43LeSUIqQuDb9zS3FSlHYPVNQJTFf0,708 +tzdata/zoneinfo/America/Santa_Isabel,sha256=MGWr-6toDRarjMXTaiOIWgBFWNbw7lHvidLuPKFxfIo,1079 +tzdata/zoneinfo/America/Santarem,sha256=dDEGsnrm4wrzl4sK6K8PzEroBKD7A1V7HBa8cWW4cMk,409 +tzdata/zoneinfo/America/Santiago,sha256=_QBpU8K0QqLh5m2yqWfdkypIJDkPAc3dnIAc5jRQxxU,1354 +tzdata/zoneinfo/America/Santo_Domingo,sha256=xmJo59mZXN7Wnf-3Jjl37mCC-8GfN6xmk2l_vngyfeI,317 +tzdata/zoneinfo/America/Sao_Paulo,sha256=-izrIi8GXAKJ85l_8MVLoFp0pZm0Uihw-oapbiThiJE,952 +tzdata/zoneinfo/America/Scoresbysund,sha256=wrhIEVAFI29qKT3TdOWiiJwI80AohXwwfb1mCPSAXHo,984 +tzdata/zoneinfo/America/Shiprock,sha256=m7cDkg7KS2EZ6BoQVYOk9soiBlHxO0GEeat81WxBPz4,1042 +tzdata/zoneinfo/America/Sitka,sha256=pF5yln--MOzEMDacNd_Id0HX9pAmge8POfcxyTNh1-0,956 +tzdata/zoneinfo/America/St_Barthelemy,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/St_Johns,sha256=v99q_AFMPll5MMxMp98aqY40cmis2wciTfTqs2_kb0k,1878 +tzdata/zoneinfo/America/St_Kitts,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/St_Lucia,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/St_Thomas,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/St_Vincent,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Swift_Current,sha256=F-b65Yaax23CsuhSmeTDl6Tv9du4IsvWvMbbSuwHkLM,368 +tzdata/zoneinfo/America/Tegucigalpa,sha256=KlvqBJGswa9DIXlE3acU-pgd4IFqDeBRrUz02PmlNC0,194 +tzdata/zoneinfo/America/Thule,sha256=LzL5jdmZkxRkHdA3XkoqJPG_ImllnSRhYYLQpMf_TY8,455 +tzdata/zoneinfo/America/Thunder_Bay,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/America/Tijuana,sha256=MGWr-6toDRarjMXTaiOIWgBFWNbw7lHvidLuPKFxfIo,1079 +tzdata/zoneinfo/America/Toronto,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/America/Tortola,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Vancouver,sha256=Epou71sUffvHB1rd7wT0krvo3okXAV45_TWcOFpy26Q,1330 +tzdata/zoneinfo/America/Virgin,sha256=q76GKN1Uh8iJ24Fs46UHe7tH9rr6_rlBHZLW7y9wzo0,177 +tzdata/zoneinfo/America/Whitehorse,sha256=CyY4jNd0fzNSdf1HlYGfaktApmH71tRNRlpOEO32DGs,1029 +tzdata/zoneinfo/America/Winnipeg,sha256=ANzwYGBU1PknQW4LR-H92i5c4Db95LU-UQhPhWZCjDo,1294 +tzdata/zoneinfo/America/Yakutat,sha256=pvHLVNA1mI-H9fBDnlnpI6B9XzVFQeyvI9nyIkaFNYQ,946 +tzdata/zoneinfo/America/Yellowknife,sha256=Dq2mxcSNWZhMWRqxwwtMcaqwAIGMwkOzz-mW8fJscV8,970 +tzdata/zoneinfo/America/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/America/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Antarctica/Casey,sha256=1jc-FAjvkKnmCjhz8-yQgEKrN_sVmzAi8DVoy9_K8AQ,287 +tzdata/zoneinfo/Antarctica/Davis,sha256=Pom_267rsoZl6yLvYllu_SW1kixIrSPmsd-HLztn33Y,197 +tzdata/zoneinfo/Antarctica/DumontDUrville,sha256=aDABBVtu-dydiHNODt3ReC8cNkO3wTp16c-OkFIAbhk,154 +tzdata/zoneinfo/Antarctica/Macquarie,sha256=aOZlIzIdTwevaTXoQkDlex2LSFDrg64GvRfcLnfCDAM,976 +tzdata/zoneinfo/Antarctica/Mawson,sha256=UYuiBSE0qZ-2kkBAa6Xq5g9NXg-W_R0P-rl2tlO0jHc,152 +tzdata/zoneinfo/Antarctica/McMurdo,sha256=Dgbn5VrtvJLvWz0Qbnw5KrFijP2KQosg6S6ZAooL-7k,1043 +tzdata/zoneinfo/Antarctica/Palmer,sha256=3MXfhQBaRB57_jqHZMl-M_K48NMFe4zALc7vaMyS5xw,887 +tzdata/zoneinfo/Antarctica/Rothera,sha256=XeddRL2YTDfEWzQI7nDqfW-Tfg-5EebxsHsMHyzGudI,132 +tzdata/zoneinfo/Antarctica/South_Pole,sha256=Dgbn5VrtvJLvWz0Qbnw5KrFijP2KQosg6S6ZAooL-7k,1043 +tzdata/zoneinfo/Antarctica/Syowa,sha256=RoU-lCdq8u6o6GwvFSqHHAkt8ZXcUSc7j8cJH6pLRhw,133 +tzdata/zoneinfo/Antarctica/Troll,sha256=s4z0F_uKzx3biKjEzvHwb56132XRs6IR22fCQglW5GI,158 +tzdata/zoneinfo/Antarctica/Vostok,sha256=cDp-B4wKXE8U5b_zqJIlxdGY-AIAMCTJOZG3bRZBKNc,170 +tzdata/zoneinfo/Antarctica/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Antarctica/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Arctic/Longyearbyen,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Arctic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Arctic/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Asia/Aden,sha256=RoU-lCdq8u6o6GwvFSqHHAkt8ZXcUSc7j8cJH6pLRhw,133 +tzdata/zoneinfo/Asia/Almaty,sha256=87WNMKCF7W2V6tq5LvX5DXWoi9MuwjCAY3f9dgwui4s,618 +tzdata/zoneinfo/Asia/Amman,sha256=KOnKO4_1XRlQvLG61GTbfKImSthwBHMSnzV1ExW8i5Q,928 +tzdata/zoneinfo/Asia/Anadyr,sha256=30bdZurg4Q__lCpH509TE0U7pOcEY6qxjvuPF9ai5yc,743 +tzdata/zoneinfo/Asia/Aqtau,sha256=bRj27vG5HvGegFg5eIKNmq3dfteYmr7KmTs4JFO-7SM,606 +tzdata/zoneinfo/Asia/Aqtobe,sha256=Pm7yI5cmfzx8CGXR2mQJDjtH12KCpx8ezFKchiJVVJ4,615 +tzdata/zoneinfo/Asia/Ashgabat,sha256=OTLHdQ8jFPDvxu_IwKX_c3W3jdN6e7FGoCSEEb0XKuw,375 +tzdata/zoneinfo/Asia/Ashkhabad,sha256=OTLHdQ8jFPDvxu_IwKX_c3W3jdN6e7FGoCSEEb0XKuw,375 +tzdata/zoneinfo/Asia/Atyrau,sha256=1YG4QzLxPRZQeGHiOrbm0cRs8ERTNg1NF9dWEwW2Pi0,616 +tzdata/zoneinfo/Asia/Baghdad,sha256=zFe6LXSfuoJjGsmYTMGjJtBcAMLiKFkD7j7-VaqKwH8,630 +tzdata/zoneinfo/Asia/Bahrain,sha256=YWDWV1o3HHWxnmwlzwMWC53C84ZYPkK_gYn9-P0Xx4U,152 +tzdata/zoneinfo/Asia/Baku,sha256=_Wh6ONaRatMc9lpwGO6zB9pTE38NZ4oWg4_-sZl17mA,744 +tzdata/zoneinfo/Asia/Bangkok,sha256=zcjiwoLYvJpenDyvL8Rf9OnlzRj13sjLhzNArXxYTWQ,152 +tzdata/zoneinfo/Asia/Barnaul,sha256=UGFYJYvtgYVS8Tqsqvj6p0OQCmN3zdY9wITWg8ODG-k,753 +tzdata/zoneinfo/Asia/Beirut,sha256=FgM4gqbWFp6KuUnVn-H8UIXZgTydBeOxDdbebJ0GpUc,732 +tzdata/zoneinfo/Asia/Bishkek,sha256=RXdxVxaiE5zxX5atQl-7ZesEeZVjsCXBGZ6cJbVU9pE,618 +tzdata/zoneinfo/Asia/Brunei,sha256=3ajgII3xZ-Wc-dqXRTSMw8qQRDSjXlSBIxyE_sDRGTk,320 +tzdata/zoneinfo/Asia/Calcutta,sha256=OgC9vhvElZ5ydWfHMLpRsDRV7NRV98GQxa0UOG63mw0,220 +tzdata/zoneinfo/Asia/Chita,sha256=1Lme3ccO47R5gmTe5VCq1BSb0m_1opWibq21zvZlntg,750 +tzdata/zoneinfo/Asia/Choibalsan,sha256=--I8P6_e4BtRIe3wCSkPtwHOu_k9rPsw-KqQKHJC9vM,594 +tzdata/zoneinfo/Asia/Chongqing,sha256=v4t-2C_m5j5tmPjOqTTurJAc0Wq6hetXVc4_i0KJ6oo,393 +tzdata/zoneinfo/Asia/Chungking,sha256=v4t-2C_m5j5tmPjOqTTurJAc0Wq6hetXVc4_i0KJ6oo,393 +tzdata/zoneinfo/Asia/Colombo,sha256=QAyjK7gtXUWfLuju1M0H3_ew6iTM-bwfzO5obgvaHy8,247 +tzdata/zoneinfo/Asia/Dacca,sha256=rCGmEwbW4qkUU2QfTj5zLrydVCq8HTWl1dsqEDQOvvo,231 +tzdata/zoneinfo/Asia/Damascus,sha256=AtZTDRzHEB7QnKxFXvtWsNUI1cCCe27sAfpDfQd0MwY,1234 +tzdata/zoneinfo/Asia/Dhaka,sha256=rCGmEwbW4qkUU2QfTj5zLrydVCq8HTWl1dsqEDQOvvo,231 +tzdata/zoneinfo/Asia/Dili,sha256=5fcCHkVIZkLV8TcsqBQ8HstILEpz3ay3MGGU6sgNxLA,170 +tzdata/zoneinfo/Asia/Dubai,sha256=DZ6lBT6DGIAypvtNMB1dtoj0MBHltrH5F6EbcaDaexY,133 +tzdata/zoneinfo/Asia/Dushanbe,sha256=8qbn76rf9xu47NYVdfGvjnkf2KZxNN5J8ekFiXUz3AQ,366 +tzdata/zoneinfo/Asia/Famagusta,sha256=385fbaRnx-mdEaXqSyBKVBDDKPzCGKbynWYt75wwCug,940 +tzdata/zoneinfo/Asia/Gaza,sha256=-PC__gGODaDGgv5LLzH7ptNLbNdStPkxGY4LmebvcNU,2950 +tzdata/zoneinfo/Asia/Harbin,sha256=v4t-2C_m5j5tmPjOqTTurJAc0Wq6hetXVc4_i0KJ6oo,393 +tzdata/zoneinfo/Asia/Hebron,sha256=4FujfuE-ECIXgKW4pv0lxq2ZkAj7jDwt0rezuA0fFzg,2968 +tzdata/zoneinfo/Asia/Ho_Chi_Minh,sha256=R-ReVMreMcETG0Sifjfe5z-PgQpUsKjT6dVbEKzT3sE,236 +tzdata/zoneinfo/Asia/Hong_Kong,sha256=9AaPcyRtuXQX9zRnRTVkxX1mRs5JCbn6JTaSPvzX608,775 +tzdata/zoneinfo/Asia/Hovd,sha256=eqAvD2RfuIfSDhtqk58MECIjz5X14OHZ7aO4z14kndk,594 +tzdata/zoneinfo/Asia/Irkutsk,sha256=sWxp8g_aSfFan4ZyF9s6-pEX5Vgwxi_jNv7vwN06XIo,760 +tzdata/zoneinfo/Asia/Istanbul,sha256=KnFjsWuUgG9pmRNI59CmDEbrYbHwMF9fS4P2E9sQgG8,1200 +tzdata/zoneinfo/Asia/Jakarta,sha256=4qCZ6kix9xZriNIZsyb3xENz0IkJzZcjtENGlG_Wo4Q,248 +tzdata/zoneinfo/Asia/Jayapura,sha256=BUa0kX1iOdf0E-v7415h7l0lQv4DBCYX_3dAbYmQ0xU,171 +tzdata/zoneinfo/Asia/Jerusalem,sha256=n83o1YTeoFhfXIcnqvNfSKFJ4NvTqDv2zvi8qcFAIeM,1074 +tzdata/zoneinfo/Asia/Kabul,sha256=pNIwTfiSG71BGKvrhKqo1xdxckAx9vfcx5nJanrL81Q,159 +tzdata/zoneinfo/Asia/Kamchatka,sha256=Qix8x3s-m8UTeiwzNPBy_ZQvAzX_aaihz_PzLfTiUac,727 +tzdata/zoneinfo/Asia/Karachi,sha256=ujo4wv-3oa9tfrFT5jsLcEYcjeGeBRgG2QwdXg_ijU4,266 +tzdata/zoneinfo/Asia/Kashgar,sha256=hJyv03dhHML8K0GJGrY8b7M0OUkEXblh_RYmdZMxWtQ,133 +tzdata/zoneinfo/Asia/Kathmandu,sha256=drjxv-ByIxodnn-FATEOJ8DQgEjEj3Qihgtkd8FCxDg,161 +tzdata/zoneinfo/Asia/Katmandu,sha256=drjxv-ByIxodnn-FATEOJ8DQgEjEj3Qihgtkd8FCxDg,161 +tzdata/zoneinfo/Asia/Khandyga,sha256=fdEDOsDJkLuENybqIXtTiI4k2e24dKHDfBTww9AtbSw,775 +tzdata/zoneinfo/Asia/Kolkata,sha256=OgC9vhvElZ5ydWfHMLpRsDRV7NRV98GQxa0UOG63mw0,220 +tzdata/zoneinfo/Asia/Krasnoyarsk,sha256=buNI5S1g7eedK-PpnrLkBFFZDUyCtHxcxXDQGF2ARos,741 +tzdata/zoneinfo/Asia/Kuala_Lumpur,sha256=CVSy2aMB2U9DSAJGBqcbvLL6JNPNNwn1vIvKYFA5eF0,256 +tzdata/zoneinfo/Asia/Kuching,sha256=3ajgII3xZ-Wc-dqXRTSMw8qQRDSjXlSBIxyE_sDRGTk,320 +tzdata/zoneinfo/Asia/Kuwait,sha256=RoU-lCdq8u6o6GwvFSqHHAkt8ZXcUSc7j8cJH6pLRhw,133 +tzdata/zoneinfo/Asia/Macao,sha256=mr89i_wpMoWhAtqZrF2SGcoILcUw6rYrDkIUNADes7E,791 +tzdata/zoneinfo/Asia/Macau,sha256=mr89i_wpMoWhAtqZrF2SGcoILcUw6rYrDkIUNADes7E,791 +tzdata/zoneinfo/Asia/Magadan,sha256=wAufMGWL_s1Aw2l3myAfBFtrROVPes3dMoNuDEoNwT8,751 +tzdata/zoneinfo/Asia/Makassar,sha256=NV9j_RTuiU47mvJvfKE8daXH5AFYJ8Ki4gvHBJSxyLc,190 +tzdata/zoneinfo/Asia/Manila,sha256=Vk8aVoXR_edPDnARFdmEui4pq4Q3yNuiPUCzeIAPLBI,238 +tzdata/zoneinfo/Asia/Muscat,sha256=DZ6lBT6DGIAypvtNMB1dtoj0MBHltrH5F6EbcaDaexY,133 +tzdata/zoneinfo/Asia/Nicosia,sha256=TYYqWp8sK0AwBUHAp0wuuihZuQ19RXdt28bth33zOBI,597 +tzdata/zoneinfo/Asia/Novokuznetsk,sha256=aYW9rpcxpf_zrOZc2vmpcqgiuCRKMHB1lMrioI43KCw,726 +tzdata/zoneinfo/Asia/Novosibirsk,sha256=I2n4MCElad9sMcyJAAc4YdVT6ewbhR79OoAAuhEJfCY,753 +tzdata/zoneinfo/Asia/Omsk,sha256=y7u47EObB3wI8MxKHBRTFM-BEZZqhGpzDg7x5lcwJXY,741 +tzdata/zoneinfo/Asia/Oral,sha256=Q-Gf85NIvdAtU52Zkgf78rVHPlg85xyMe9Zm9ybh0po,625 +tzdata/zoneinfo/Asia/Phnom_Penh,sha256=zcjiwoLYvJpenDyvL8Rf9OnlzRj13sjLhzNArXxYTWQ,152 +tzdata/zoneinfo/Asia/Pontianak,sha256=o0x0jNTlwjiUqAzGX_HlzvCMru2zUURgQ4xzpS95xds,247 +tzdata/zoneinfo/Asia/Pyongyang,sha256=NxC5da8oTZ4StiFQnlhjlp9FTRuMM-Xwsq3Yg4y0xkA,183 +tzdata/zoneinfo/Asia/Qatar,sha256=YWDWV1o3HHWxnmwlzwMWC53C84ZYPkK_gYn9-P0Xx4U,152 +tzdata/zoneinfo/Asia/Qostanay,sha256=5tZkj1o0p4vaREsPO0YgIiw6eDf1cqO52x-0EMg_2L4,624 +tzdata/zoneinfo/Asia/Qyzylorda,sha256=JltKDEnuHmIQGYdFTAJMDDpdDA_HxjJOAHHaV7kFrlQ,624 +tzdata/zoneinfo/Asia/Rangoon,sha256=6J2DXIEdTaRKqLOGeCzogo3whaoO6PJWYamIHS8A6Qw,187 +tzdata/zoneinfo/Asia/Riyadh,sha256=RoU-lCdq8u6o6GwvFSqHHAkt8ZXcUSc7j8cJH6pLRhw,133 +tzdata/zoneinfo/Asia/Saigon,sha256=R-ReVMreMcETG0Sifjfe5z-PgQpUsKjT6dVbEKzT3sE,236 +tzdata/zoneinfo/Asia/Sakhalin,sha256=M_TBd-03j-3Yc9KwhGEoBTwSJxWO1lPBG7ndst16PGo,755 +tzdata/zoneinfo/Asia/Samarkand,sha256=KZ_q-6GMDVgJb8RFqcrbVcPC0WLczolClC4nZA1HVNU,366 +tzdata/zoneinfo/Asia/Seoul,sha256=ZKcLb7zJtl52Lb0l64m29AwTcUbtyNvU0IHq-s2reN4,415 +tzdata/zoneinfo/Asia/Shanghai,sha256=v4t-2C_m5j5tmPjOqTTurJAc0Wq6hetXVc4_i0KJ6oo,393 +tzdata/zoneinfo/Asia/Singapore,sha256=CVSy2aMB2U9DSAJGBqcbvLL6JNPNNwn1vIvKYFA5eF0,256 +tzdata/zoneinfo/Asia/Srednekolymsk,sha256=06mojetFbDd4ag1p8NK0Fg6rF2OOnZMFRRC90N2ATZc,742 +tzdata/zoneinfo/Asia/Taipei,sha256=oEwscvT3aoMXjQNt2X0VfuHzLkeORN2npcEJI2h-5s8,511 +tzdata/zoneinfo/Asia/Tashkent,sha256=0vpN2gI9GY50z1nea6zCPFf2B6VCu6XQQHx4l6rhnTI,366 +tzdata/zoneinfo/Asia/Tbilisi,sha256=ON_Uzv2VTSk6mRefNU-aI-qkqtCoUX6oECVqpeS42eI,629 +tzdata/zoneinfo/Asia/Tehran,sha256=ozLlhNXzpJCZx7bc-VpcmNdgdtn6lPtF6f9qkaDEycI,812 +tzdata/zoneinfo/Asia/Tel_Aviv,sha256=n83o1YTeoFhfXIcnqvNfSKFJ4NvTqDv2zvi8qcFAIeM,1074 +tzdata/zoneinfo/Asia/Thimbu,sha256=N6d_vfFvYORfMnr1fHJjYSt4DBORSbLi_2T-r2dJBnI,154 +tzdata/zoneinfo/Asia/Thimphu,sha256=N6d_vfFvYORfMnr1fHJjYSt4DBORSbLi_2T-r2dJBnI,154 +tzdata/zoneinfo/Asia/Tokyo,sha256=WaOHFDDw07k-YZ-jCkOkHR6IvdSf8m8J0PQFpQBwb5Y,213 +tzdata/zoneinfo/Asia/Tomsk,sha256=Bf7GoFTcUeP2hYyuYpruJji33tcEoLP-80o38A6i4zU,753 +tzdata/zoneinfo/Asia/Ujung_Pandang,sha256=NV9j_RTuiU47mvJvfKE8daXH5AFYJ8Ki4gvHBJSxyLc,190 +tzdata/zoneinfo/Asia/Ulaanbaatar,sha256=--I8P6_e4BtRIe3wCSkPtwHOu_k9rPsw-KqQKHJC9vM,594 +tzdata/zoneinfo/Asia/Ulan_Bator,sha256=--I8P6_e4BtRIe3wCSkPtwHOu_k9rPsw-KqQKHJC9vM,594 +tzdata/zoneinfo/Asia/Urumqi,sha256=hJyv03dhHML8K0GJGrY8b7M0OUkEXblh_RYmdZMxWtQ,133 +tzdata/zoneinfo/Asia/Ust-Nera,sha256=6NkuV1zOms-4qHQhq-cGc-cqEVgKHk7qd3MLDM-e2BA,771 +tzdata/zoneinfo/Asia/Vientiane,sha256=zcjiwoLYvJpenDyvL8Rf9OnlzRj13sjLhzNArXxYTWQ,152 +tzdata/zoneinfo/Asia/Vladivostok,sha256=zkOXuEDgpxX8HQGgDlh9SbAQzHOaNxX2XSI6Y4gMD-k,742 +tzdata/zoneinfo/Asia/Yakutsk,sha256=xD6zA4E228dC1mIUQ7cMO-9LORSfE-Fok0awGDG6juk,741 +tzdata/zoneinfo/Asia/Yangon,sha256=6J2DXIEdTaRKqLOGeCzogo3whaoO6PJWYamIHS8A6Qw,187 +tzdata/zoneinfo/Asia/Yekaterinburg,sha256=q17eUyqOEK2LJYKXYLCJqylj-vmaCG2vSNMttqrQTRk,760 +tzdata/zoneinfo/Asia/Yerevan,sha256=pLEBdchA8H9l-9hdA6FjHmwaj5T1jupK0u-bor1KKa0,708 +tzdata/zoneinfo/Asia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Asia/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Atlantic/Azores,sha256=6XBp-rgg8hERTe2c-bTKahYPlkDn2sROBuqo9wAdtPE,1401 +tzdata/zoneinfo/Atlantic/Bermuda,sha256=PuxqD2cD99Pzjb8hH99Dws053d_zXnZHjeH0kZ8LSLI,1024 +tzdata/zoneinfo/Atlantic/Canary,sha256=XMmxBlscPIWXhiauKy_d5bxX4xjNMM-5Vw84FwZkT00,478 +tzdata/zoneinfo/Atlantic/Cape_Verde,sha256=E5ss6xpIpD0g_VEDsFMFi-ltsebp98PBSpULoVxIAyU,175 +tzdata/zoneinfo/Atlantic/Faeroe,sha256=Iw0qB0mBuviH5w3Qy8jaxCOes07ZHh2wkW8MPUWJqj0,441 +tzdata/zoneinfo/Atlantic/Faroe,sha256=Iw0qB0mBuviH5w3Qy8jaxCOes07ZHh2wkW8MPUWJqj0,441 +tzdata/zoneinfo/Atlantic/Jan_Mayen,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Atlantic/Madeira,sha256=2F3vLmp7OTm4ZMSLxyIVQQ6iXeGUkKKPeUdiGmqVuuI,1372 +tzdata/zoneinfo/Atlantic/Reykjavik,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Atlantic/South_Georgia,sha256=kPGfCLQD2C6_Xc5TyAmqmXP-GYdLLPucpBn3S7ybWu8,132 +tzdata/zoneinfo/Atlantic/St_Helena,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Atlantic/Stanley,sha256=QqQd8IWklNapMKjN5vF7vvVn4K-yl3VKvM5zkCKabCM,789 +tzdata/zoneinfo/Atlantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Atlantic/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Australia/ACT,sha256=gg1FqGioj4HHMdWyx1i07QAAObYmCoBDP44PCUpgS1k,904 +tzdata/zoneinfo/Australia/Adelaide,sha256=Gk1SdGRVmB233I-WETXAMCZz7L7HVzoN4aUoIcgNr3g,921 +tzdata/zoneinfo/Australia/Brisbane,sha256=2kVWz9CI_qtfdb55g0iL59gUBC7lnO3GUalIQxtHADY,289 +tzdata/zoneinfo/Australia/Broken_Hill,sha256=dzk9LvGA_xRStnAIjAFuTJ8Uwz_s7qGWGQmiXPgDsLY,941 +tzdata/zoneinfo/Australia/Canberra,sha256=gg1FqGioj4HHMdWyx1i07QAAObYmCoBDP44PCUpgS1k,904 +tzdata/zoneinfo/Australia/Currie,sha256=1IAVgf0AA3sBPXFhaxGfu9UQ_cpd4GNpsQ9xio2l4y0,1003 +tzdata/zoneinfo/Australia/Darwin,sha256=ZoexbhgdUlV4leV-dhBu6AxDVkJy43xrPb9UQ3EQCdI,234 +tzdata/zoneinfo/Australia/Eucla,sha256=3NqsFfMzR6-lSUPViNXBAOyJPqyokisse7uDXurURpk,314 +tzdata/zoneinfo/Australia/Hobart,sha256=1IAVgf0AA3sBPXFhaxGfu9UQ_cpd4GNpsQ9xio2l4y0,1003 +tzdata/zoneinfo/Australia/LHI,sha256=82i9JWWcApPQK7eex9rH1bc6kt_6_OFLTdL_uLoRqto,692 +tzdata/zoneinfo/Australia/Lindeman,sha256=iHkCc0QJ7iaQffiTTXQVJ2swsC7QJxLUMHQOGCFlkTk,325 +tzdata/zoneinfo/Australia/Lord_Howe,sha256=82i9JWWcApPQK7eex9rH1bc6kt_6_OFLTdL_uLoRqto,692 +tzdata/zoneinfo/Australia/Melbourne,sha256=X7JPMEj_SYWyfgWFMkp6FOmT6GfyjR-lF9hFGgTavnE,904 +tzdata/zoneinfo/Australia/NSW,sha256=gg1FqGioj4HHMdWyx1i07QAAObYmCoBDP44PCUpgS1k,904 +tzdata/zoneinfo/Australia/North,sha256=ZoexbhgdUlV4leV-dhBu6AxDVkJy43xrPb9UQ3EQCdI,234 +tzdata/zoneinfo/Australia/Perth,sha256=ZsuelcBC1YfWugH2CrlOXQcSDD4gGUJCobB1W-aupHo,306 +tzdata/zoneinfo/Australia/Queensland,sha256=2kVWz9CI_qtfdb55g0iL59gUBC7lnO3GUalIQxtHADY,289 +tzdata/zoneinfo/Australia/South,sha256=Gk1SdGRVmB233I-WETXAMCZz7L7HVzoN4aUoIcgNr3g,921 +tzdata/zoneinfo/Australia/Sydney,sha256=gg1FqGioj4HHMdWyx1i07QAAObYmCoBDP44PCUpgS1k,904 +tzdata/zoneinfo/Australia/Tasmania,sha256=1IAVgf0AA3sBPXFhaxGfu9UQ_cpd4GNpsQ9xio2l4y0,1003 +tzdata/zoneinfo/Australia/Victoria,sha256=X7JPMEj_SYWyfgWFMkp6FOmT6GfyjR-lF9hFGgTavnE,904 +tzdata/zoneinfo/Australia/West,sha256=ZsuelcBC1YfWugH2CrlOXQcSDD4gGUJCobB1W-aupHo,306 +tzdata/zoneinfo/Australia/Yancowinna,sha256=dzk9LvGA_xRStnAIjAFuTJ8Uwz_s7qGWGQmiXPgDsLY,941 +tzdata/zoneinfo/Australia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Australia/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Brazil/Acre,sha256=VjuQUr668phq5bcH40r94BPnZBKHzJf_MQBfM6Db96U,418 +tzdata/zoneinfo/Brazil/DeNoronha,sha256=Q0r3GtA5y2RGkOj56OTZG5tuBy1B6kfbhyrJqCgf27g,484 +tzdata/zoneinfo/Brazil/East,sha256=-izrIi8GXAKJ85l_8MVLoFp0pZm0Uihw-oapbiThiJE,952 +tzdata/zoneinfo/Brazil/West,sha256=9kgrhpryB94YOVoshJliiiDSf9mwjb3OZwX0HusNRrk,412 +tzdata/zoneinfo/Brazil/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Brazil/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/CET,sha256=sQ-VQqhQnwpj68p449gEMt2GuOopZAAoD-vZz6dugog,1103 +tzdata/zoneinfo/CST6CDT,sha256=wntzn_RqffBZThINcltDkhfhHkTqmlDNxJEwODtUguc,1754 +tzdata/zoneinfo/Canada/Atlantic,sha256=kO5ahBM2oTLfWS4KX15FbKXfo5wg-f9vw1_hMOISGig,1672 +tzdata/zoneinfo/Canada/Central,sha256=ANzwYGBU1PknQW4LR-H92i5c4Db95LU-UQhPhWZCjDo,1294 +tzdata/zoneinfo/Canada/Eastern,sha256=gVq023obEpKGfS-SS3GOG7oyRVzp-SIF2y_rZQKcZ2E,1717 +tzdata/zoneinfo/Canada/Mountain,sha256=Dq2mxcSNWZhMWRqxwwtMcaqwAIGMwkOzz-mW8fJscV8,970 +tzdata/zoneinfo/Canada/Newfoundland,sha256=v99q_AFMPll5MMxMp98aqY40cmis2wciTfTqs2_kb0k,1878 +tzdata/zoneinfo/Canada/Pacific,sha256=Epou71sUffvHB1rd7wT0krvo3okXAV45_TWcOFpy26Q,1330 +tzdata/zoneinfo/Canada/Saskatchewan,sha256=_JHuns225iE-THc9NFp-RBq4PWULAuGw2OLbpOB_UMw,638 +tzdata/zoneinfo/Canada/Yukon,sha256=CyY4jNd0fzNSdf1HlYGfaktApmH71tRNRlpOEO32DGs,1029 +tzdata/zoneinfo/Canada/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Canada/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Chile/Continental,sha256=_QBpU8K0QqLh5m2yqWfdkypIJDkPAc3dnIAc5jRQxxU,1354 +tzdata/zoneinfo/Chile/EasterIsland,sha256=EwVM74XjsboPVxK9bWmdd4nTrtvasP1zlLdxrMB_YaE,1174 +tzdata/zoneinfo/Chile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Chile/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Cuba,sha256=ms5rCuq2yBM49VmTymMtFQN3c5aBN1lkd8jjzKdnNm8,1117 +tzdata/zoneinfo/EET,sha256=8f1niwVI4ymziTT2KBJV5pjfp2GtH_hB9sy3lgbGE0U,682 +tzdata/zoneinfo/EST,sha256=p41zBnujy9lPiiPf3WqotoyzOxhIS8F7TiDqGuwvCoE,149 +tzdata/zoneinfo/EST5EDT,sha256=1_IgazpFmJ_JrWPVWJIlMvpzUigNX4cXa_HbecsdH6k,1744 +tzdata/zoneinfo/Egypt,sha256=icuaNiEvuC6TPc2fqhDv36lpop7IDDIGO7tFGMAz0b4,1309 +tzdata/zoneinfo/Eire,sha256=EcADNuAvExj-dkqylGfF8q_vv_-mRPqN0k9bCDtJW3E,1496 +tzdata/zoneinfo/Etc/GMT,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Etc/GMT+0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Etc/GMT+1,sha256=5L9o8TEUgtB11poIag85vRdq08LMDZmZ6DPn7UqPL_g,113 +tzdata/zoneinfo/Etc/GMT+10,sha256=IvBxiqQU76qzNbuxRo8Ah9rPQSRGQGKp_SRs5u1PPkM,114 +tzdata/zoneinfo/Etc/GMT+11,sha256=9MfFpFp_rt9PksMjQ23VOlir3hzTlnLz_5V2tfonhbU,114 +tzdata/zoneinfo/Etc/GMT+12,sha256=l26XCFp9IbgXGvMw7NHgHzIZbHry2B5qGYfhMDHFVrw,114 +tzdata/zoneinfo/Etc/GMT+2,sha256=YbbqH7B6jNoQEIjyV4-8a2cXD9lGC3vQKnEkY2ucDGI,113 +tzdata/zoneinfo/Etc/GMT+3,sha256=q3D9DLfmTBUAo4YMnNUNUUKrAkKSwM5Q-vesd9A6SZQ,113 +tzdata/zoneinfo/Etc/GMT+4,sha256=UghKME3laXSDZ7q74YDb4FcLnzNqXQydcZpQHvssP2k,113 +tzdata/zoneinfo/Etc/GMT+5,sha256=TZ5qaoELlszW_Z5FdqAEMKk8Y_xu5XhZBNZUco55SrM,113 +tzdata/zoneinfo/Etc/GMT+6,sha256=_2k3LZ5x8hVjMwwmCx6GqUwW-v1IvOkBrJjYH5bD6Qw,113 +tzdata/zoneinfo/Etc/GMT+7,sha256=Di8J430WGr98Ww95tdfIo8hGxkVQfJvlx55ansDuoeQ,113 +tzdata/zoneinfo/Etc/GMT+8,sha256=OIIlUFhZwL2ctx3fxINbY2HDDAmSQ7i2ZAUgX7Exjgw,113 +tzdata/zoneinfo/Etc/GMT+9,sha256=1vpkIoPqBiwDWzH-fLFxwNbmdKRY7mqdiJhYQImVxaw,113 +tzdata/zoneinfo/Etc/GMT-0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Etc/GMT-1,sha256=S81S9Z0-V-0B5U-0S0Pnbx8fv2iHtwE1LrlZk-ckLto,114 +tzdata/zoneinfo/Etc/GMT-10,sha256=VvdG5IpXB_xJX4omzfrrHblkRUzkbCZXPhTrLngc7vk,115 +tzdata/zoneinfo/Etc/GMT-11,sha256=2sYLfVuDFSy7Kc1WOPiY1EqquHw5Xx4HbDA1QOL1hc4,115 +tzdata/zoneinfo/Etc/GMT-12,sha256=ifHVhk5fczZG3GDy_Nv7YsLNaxf8stB4MrzgWUCINlU,115 +tzdata/zoneinfo/Etc/GMT-13,sha256=CMkORdXsaSyL-4N0n37Cyc1lCr22ZsWyug9_QZVe0E0,115 +tzdata/zoneinfo/Etc/GMT-14,sha256=NK07ElwueU0OP8gORtcXUUug_3v4d04uxfVHMUnLM9U,115 +tzdata/zoneinfo/Etc/GMT-2,sha256=QMToMLcif1S4SNPOMxMtBLqc1skUYnIhbUAjKEdAf9w,114 +tzdata/zoneinfo/Etc/GMT-3,sha256=10GMvfulaJwDQiHiWEJiU_YURyjDfPcl5ugnYBugN3E,114 +tzdata/zoneinfo/Etc/GMT-4,sha256=c6Kx3v41GRkrvky8k71db_UJbpyyp2OZCsjDSvjkr6s,114 +tzdata/zoneinfo/Etc/GMT-5,sha256=94TvO8e_8t52bs8ry70nAquvgK8qJKQTI7lQnVCHX-U,114 +tzdata/zoneinfo/Etc/GMT-6,sha256=3fH8eX--0iDijmYAQHQ0IUXheezaj6-aadZsQNAB4fE,114 +tzdata/zoneinfo/Etc/GMT-7,sha256=DnsTJ3NUYYGLUwFb_L15U_GbaMF-acLVsPyTNySyH-M,114 +tzdata/zoneinfo/Etc/GMT-8,sha256=kvGQUwONDBG7nhEp_wESc4xl4xNXiXEivxAv09nkr_g,114 +tzdata/zoneinfo/Etc/GMT-9,sha256=U1WRFGWQAW91JXK99gY1K9d0rFZYDWHzDUR3z71Lh6Y,114 +tzdata/zoneinfo/Etc/GMT0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Etc/Greenwich,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Etc/UCT,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/Etc/UTC,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/Etc/Universal,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/Etc/Zulu,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/Etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Etc/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Europe/Amsterdam,sha256=sQ-VQqhQnwpj68p449gEMt2GuOopZAAoD-vZz6dugog,1103 +tzdata/zoneinfo/Europe/Andorra,sha256=leuTyE4uduIBX0aHb_7PK_KlslpWSyS6e0SS84hKFrE,389 +tzdata/zoneinfo/Europe/Astrakhan,sha256=P3E5UDgQ4gqsMi-KdMAWwOSStogdcNl9rLMVUdpFLXI,726 +tzdata/zoneinfo/Europe/Athens,sha256=8f1niwVI4ymziTT2KBJV5pjfp2GtH_hB9sy3lgbGE0U,682 +tzdata/zoneinfo/Europe/Belfast,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/Europe/Belgrade,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/Berlin,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Europe/Bratislava,sha256=pukw4zdc3LUffYp0iFr_if0UuGHrt1yzOdD5HBbBRpo,723 +tzdata/zoneinfo/Europe/Brussels,sha256=sQ-VQqhQnwpj68p449gEMt2GuOopZAAoD-vZz6dugog,1103 +tzdata/zoneinfo/Europe/Bucharest,sha256=iY74H96aaTMJvmqAhzUoSI8SjZUtPvv4PGF4ClwFm6U,661 +tzdata/zoneinfo/Europe/Budapest,sha256=qNr-valoDI1mevuQXqOMkOhIcT194EczOKIijxrDMV8,766 +tzdata/zoneinfo/Europe/Busingen,sha256=GZBiscMM_rI3XshMVt9SvlGJGYamKTt6Ek06YlCfRek,497 +tzdata/zoneinfo/Europe/Chisinau,sha256=5TPhkCtxxa0ByLCv7YxOrc5Vtdui2v2VX8vrSopPkPs,755 +tzdata/zoneinfo/Europe/Copenhagen,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Europe/Dublin,sha256=EcADNuAvExj-dkqylGfF8q_vv_-mRPqN0k9bCDtJW3E,1496 +tzdata/zoneinfo/Europe/Gibraltar,sha256=t1hglDTLUIFqs91nY5lulN7oxkoAXHnh0zjyaKG2bG8,1220 +tzdata/zoneinfo/Europe/Guernsey,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/Europe/Helsinki,sha256=ccpK9ZmPCZkMXoddNQ_DyONPKAuub-FPNtRpL6znpWM,481 +tzdata/zoneinfo/Europe/Isle_of_Man,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/Europe/Istanbul,sha256=KnFjsWuUgG9pmRNI59CmDEbrYbHwMF9fS4P2E9sQgG8,1200 +tzdata/zoneinfo/Europe/Jersey,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/Europe/Kaliningrad,sha256=57ov9G8m25w1pPdJF8zoFWzq5I6UoBMVsk2eHPelbA8,904 +tzdata/zoneinfo/Europe/Kiev,sha256=BYnoDd7Ov50wd4mMEpddK-c5PfKFbumSbFNHY-Hia_I,558 +tzdata/zoneinfo/Europe/Kirov,sha256=KqXGcIbMGTuOoKZYBG-5bj7kVzFbKyGMA99PA0414D0,735 +tzdata/zoneinfo/Europe/Kyiv,sha256=BYnoDd7Ov50wd4mMEpddK-c5PfKFbumSbFNHY-Hia_I,558 +tzdata/zoneinfo/Europe/Lisbon,sha256=RNL2z4RzfmoeDa-RQQnpQla-ykC0DJoRt6BOi92u5Ow,1463 +tzdata/zoneinfo/Europe/Ljubljana,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/London,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/Europe/Luxembourg,sha256=sQ-VQqhQnwpj68p449gEMt2GuOopZAAoD-vZz6dugog,1103 +tzdata/zoneinfo/Europe/Madrid,sha256=ylsyHdv8iOB-DQPtL6DIMs5dDdjn2QolIAqOJImMOyE,897 +tzdata/zoneinfo/Europe/Malta,sha256=irX_nDD-BXYObaduu_vhPe1F31xmgL364dSOaT_OVco,928 +tzdata/zoneinfo/Europe/Mariehamn,sha256=ccpK9ZmPCZkMXoddNQ_DyONPKAuub-FPNtRpL6znpWM,481 +tzdata/zoneinfo/Europe/Minsk,sha256=86iP_xDtidkUCqjkoKhH5_El3VI21fSgoIiXl_BzUaU,808 +tzdata/zoneinfo/Europe/Monaco,sha256=zViOd5xXN9cOTkcVja-reUWwJrK7NEVMxHdBgVRZsGg,1105 +tzdata/zoneinfo/Europe/Moscow,sha256=7S4KCZ-0RrJBZoNDjT9W-fxaYqFsdUmn9Zy8k1s2TIo,908 +tzdata/zoneinfo/Europe/Nicosia,sha256=TYYqWp8sK0AwBUHAp0wuuihZuQ19RXdt28bth33zOBI,597 +tzdata/zoneinfo/Europe/Oslo,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Europe/Paris,sha256=zViOd5xXN9cOTkcVja-reUWwJrK7NEVMxHdBgVRZsGg,1105 +tzdata/zoneinfo/Europe/Podgorica,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/Prague,sha256=pukw4zdc3LUffYp0iFr_if0UuGHrt1yzOdD5HBbBRpo,723 +tzdata/zoneinfo/Europe/Riga,sha256=PU8amev-8XVvl4B_JUOOOM1ofSMbotp-3MPGPHpPoTw,694 +tzdata/zoneinfo/Europe/Rome,sha256=hr0moG_jBXs2zyndejOPJSSv-BFu8I0AWqIRTqYSKGk,947 +tzdata/zoneinfo/Europe/Samara,sha256=Vc60AJe-0-b8prNiFwZTUS1bCbWxxuEnnNcgp8YkQRY,732 +tzdata/zoneinfo/Europe/San_Marino,sha256=hr0moG_jBXs2zyndejOPJSSv-BFu8I0AWqIRTqYSKGk,947 +tzdata/zoneinfo/Europe/Sarajevo,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/Saratov,sha256=0fN3eVFVewG-DSVk9xJABDQB1S_Nyn37bHOjj5X8Bm0,726 +tzdata/zoneinfo/Europe/Simferopol,sha256=y2Nybf9LGVNqNdW_GPS-NIDRLriyH_pyxKpT0zmATK4,865 +tzdata/zoneinfo/Europe/Skopje,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/Sofia,sha256=LQjC-OJkL4TzZcqD-JUofDAg1-qJui_2Ri6Eoii2MuQ,592 +tzdata/zoneinfo/Europe/Stockholm,sha256=p_2ZMteF1NaQkAuDTDVjwYEMHPLgFxG8wJJq9sB2fLc,705 +tzdata/zoneinfo/Europe/Tallinn,sha256=R6yRfPqESOYQWftlncDWo_fQak61eeiEQKwg_C-C7W8,675 +tzdata/zoneinfo/Europe/Tirane,sha256=I-alATWRd8mfSgvnr3dN_F9vbTB66alvz2GQo0LUbPc,604 +tzdata/zoneinfo/Europe/Tiraspol,sha256=5TPhkCtxxa0ByLCv7YxOrc5Vtdui2v2VX8vrSopPkPs,755 +tzdata/zoneinfo/Europe/Ulyanovsk,sha256=2vK0XahtB_dKjDDXccjMjbQ2bAOfKDe66uMDqtjzHm4,760 +tzdata/zoneinfo/Europe/Uzhgorod,sha256=BYnoDd7Ov50wd4mMEpddK-c5PfKFbumSbFNHY-Hia_I,558 +tzdata/zoneinfo/Europe/Vaduz,sha256=GZBiscMM_rI3XshMVt9SvlGJGYamKTt6Ek06YlCfRek,497 +tzdata/zoneinfo/Europe/Vatican,sha256=hr0moG_jBXs2zyndejOPJSSv-BFu8I0AWqIRTqYSKGk,947 +tzdata/zoneinfo/Europe/Vienna,sha256=q8_UF23-KHqc2ay4ju0qT1TuBSpRTnlB7i6vElk4eJw,658 +tzdata/zoneinfo/Europe/Vilnius,sha256=hXvv1PaQndapT7hdywPO3738Y3ZqbW_hJx87khyaOPM,676 +tzdata/zoneinfo/Europe/Volgograd,sha256=v3P6iFJ-rThJprVNDxB7ZYDrimtsW7IvQi_gJpZiJOQ,753 +tzdata/zoneinfo/Europe/Warsaw,sha256=6I9aUfFoFXpBrC3YpO4OmoeUGchMYSK0dxsaKjPZOkw,923 +tzdata/zoneinfo/Europe/Zagreb,sha256=qMlk8-qnognZplD7FsaMAD6aX8Yv-7sQ-oSdVPs2YtY,478 +tzdata/zoneinfo/Europe/Zaporozhye,sha256=BYnoDd7Ov50wd4mMEpddK-c5PfKFbumSbFNHY-Hia_I,558 +tzdata/zoneinfo/Europe/Zurich,sha256=GZBiscMM_rI3XshMVt9SvlGJGYamKTt6Ek06YlCfRek,497 +tzdata/zoneinfo/Europe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Europe/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Factory,sha256=0ytXntCnQnMWvqJgue4mdUUQRr1YxXxnnCTyZxhgr3Y,113 +tzdata/zoneinfo/GB,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/GB-Eire,sha256=Z2VB8LitRXx0TAk_gHWJrcrZCeP9A_kBeH0IeG7tvTM,1599 +tzdata/zoneinfo/GMT,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/GMT+0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/GMT-0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/GMT0,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/Greenwich,sha256=3EoHVxsQiE5PTzRQydGhy_TAPvU9Bu0uTqFS2eul1dc,111 +tzdata/zoneinfo/HST,sha256=HapXKaoeDzLNRL4RLQGtTMVnqf522H3LuRgr6NLIj_A,221 +tzdata/zoneinfo/Hongkong,sha256=9AaPcyRtuXQX9zRnRTVkxX1mRs5JCbn6JTaSPvzX608,775 +tzdata/zoneinfo/Iceland,sha256=8-f8qg6YQP9BadNWfY-1kmZEhI9JY9es-SMghDxdSG4,130 +tzdata/zoneinfo/Indian/Antananarivo,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Indian/Chagos,sha256=J_aS7rs0ZG1dPTGeokXxNJpF4Pds8u1ct49cRtX7giY,152 +tzdata/zoneinfo/Indian/Christmas,sha256=zcjiwoLYvJpenDyvL8Rf9OnlzRj13sjLhzNArXxYTWQ,152 +tzdata/zoneinfo/Indian/Cocos,sha256=6J2DXIEdTaRKqLOGeCzogo3whaoO6PJWYamIHS8A6Qw,187 +tzdata/zoneinfo/Indian/Comoro,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Indian/Kerguelen,sha256=lEhfD1j4QnZ-wtuTU51fw6-yvc4WZz2eY8CYjMzWQ44,152 +tzdata/zoneinfo/Indian/Mahe,sha256=DZ6lBT6DGIAypvtNMB1dtoj0MBHltrH5F6EbcaDaexY,133 +tzdata/zoneinfo/Indian/Maldives,sha256=lEhfD1j4QnZ-wtuTU51fw6-yvc4WZz2eY8CYjMzWQ44,152 +tzdata/zoneinfo/Indian/Mauritius,sha256=R6pdJalrHVK5LlGOmEsyD66_-c5a9ptJM-xE71Fo8hQ,179 +tzdata/zoneinfo/Indian/Mayotte,sha256=B4OFT1LDOtprbSpdhnZi8K6OFSONL857mtpPTTGetGY,191 +tzdata/zoneinfo/Indian/Reunion,sha256=DZ6lBT6DGIAypvtNMB1dtoj0MBHltrH5F6EbcaDaexY,133 +tzdata/zoneinfo/Indian/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Indian/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Iran,sha256=ozLlhNXzpJCZx7bc-VpcmNdgdtn6lPtF6f9qkaDEycI,812 +tzdata/zoneinfo/Israel,sha256=n83o1YTeoFhfXIcnqvNfSKFJ4NvTqDv2zvi8qcFAIeM,1074 +tzdata/zoneinfo/Jamaica,sha256=pDexcAMzrv9TqLWGjVOHwIDcFMLT6Vqlzjb5AbNmkoQ,339 +tzdata/zoneinfo/Japan,sha256=WaOHFDDw07k-YZ-jCkOkHR6IvdSf8m8J0PQFpQBwb5Y,213 +tzdata/zoneinfo/Kwajalein,sha256=S-ZFi6idKzDaelLy7DRjGPeD0s7oVud3xLMxZKNlBk8,219 +tzdata/zoneinfo/Libya,sha256=zzMBLZZh4VQ4_ARe5k4L_rsuqKP7edKvVt8F6kvj5FM,431 +tzdata/zoneinfo/MET,sha256=sQ-VQqhQnwpj68p449gEMt2GuOopZAAoD-vZz6dugog,1103 +tzdata/zoneinfo/MST,sha256=rhFFPCHQiYTedfLv7ATckxeKe04jxeUvIJi4vUXMtUc,240 +tzdata/zoneinfo/MST7MDT,sha256=m7cDkg7KS2EZ6BoQVYOk9soiBlHxO0GEeat81WxBPz4,1042 +tzdata/zoneinfo/Mexico/BajaNorte,sha256=MGWr-6toDRarjMXTaiOIWgBFWNbw7lHvidLuPKFxfIo,1079 +tzdata/zoneinfo/Mexico/BajaSur,sha256=IN7ecQ9SDq9sDNvu_nc_xuMN2LHSiq8X6YQgmVUe6aY,690 +tzdata/zoneinfo/Mexico/General,sha256=N90r8I8T_OD3B8Ox9M7EAY772cR8g2ew-03rvUYb1y8,773 +tzdata/zoneinfo/Mexico/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Mexico/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/NZ,sha256=Dgbn5VrtvJLvWz0Qbnw5KrFijP2KQosg6S6ZAooL-7k,1043 +tzdata/zoneinfo/NZ-CHAT,sha256=pnhY_Lb8V4eo6cK3yL6JZL086SI_etG6rCycppJfTHg,808 +tzdata/zoneinfo/Navajo,sha256=m7cDkg7KS2EZ6BoQVYOk9soiBlHxO0GEeat81WxBPz4,1042 +tzdata/zoneinfo/PRC,sha256=v4t-2C_m5j5tmPjOqTTurJAc0Wq6hetXVc4_i0KJ6oo,393 +tzdata/zoneinfo/PST8PDT,sha256=IA0FdU9tg6Nxz0CNcIUSV5dlezsL6-uh5QjP_oaj5cg,1294 +tzdata/zoneinfo/Pacific/Apia,sha256=3HDEfICrLIehq3VLq4_r_DhQgFniSd_lXnOjdZgI6hQ,407 +tzdata/zoneinfo/Pacific/Auckland,sha256=Dgbn5VrtvJLvWz0Qbnw5KrFijP2KQosg6S6ZAooL-7k,1043 +tzdata/zoneinfo/Pacific/Bougainville,sha256=rqdn1Y4HSarx-vjPk00lsHNfhj3IQgKCViAsumuN_IY,201 +tzdata/zoneinfo/Pacific/Chatham,sha256=pnhY_Lb8V4eo6cK3yL6JZL086SI_etG6rCycppJfTHg,808 +tzdata/zoneinfo/Pacific/Chuuk,sha256=aDABBVtu-dydiHNODt3ReC8cNkO3wTp16c-OkFIAbhk,154 +tzdata/zoneinfo/Pacific/Easter,sha256=EwVM74XjsboPVxK9bWmdd4nTrtvasP1zlLdxrMB_YaE,1174 +tzdata/zoneinfo/Pacific/Efate,sha256=LiX_rTfipQh_Vnqb_m7OGxyBtyAUC9UANVKHUpLoCcU,342 +tzdata/zoneinfo/Pacific/Enderbury,sha256=ojOG-oqi25HOnY6BFhav_3bmWg1LDILT4v-kxOFVuqI,172 +tzdata/zoneinfo/Pacific/Fakaofo,sha256=Uf8zeML2X8doPg8CX-p0mMGP-IOj7aHAMe7ULD5khxA,153 +tzdata/zoneinfo/Pacific/Fiji,sha256=umCNhtTuBziTXne-WAxzvYvGKqZxTYOTwK-tJhYh4MQ,396 +tzdata/zoneinfo/Pacific/Funafuti,sha256=CQNWIL2DFpej6Qcvgt40z8pekS1QyNpUdzmqLyj7bY4,134 +tzdata/zoneinfo/Pacific/Galapagos,sha256=Z1KJPZSvO8M_Pay9WLcNAxzjo8imPrQ7FnXNOXfZl8c,175 +tzdata/zoneinfo/Pacific/Gambier,sha256=yIh86hjpDk1wRWTVJROOGqn9tkc7e9_O6zNxqs-wBoM,132 +tzdata/zoneinfo/Pacific/Guadalcanal,sha256=Ui8PN0th4sb1-n0Z8ceszNCeSiE0Yu47QskNMr8r8Yw,134 +tzdata/zoneinfo/Pacific/Guam,sha256=i57eM6syriUFvAbrVALnziCw_I4lENyzBcJdOaH71yU,350 +tzdata/zoneinfo/Pacific/Honolulu,sha256=HapXKaoeDzLNRL4RLQGtTMVnqf522H3LuRgr6NLIj_A,221 +tzdata/zoneinfo/Pacific/Johnston,sha256=HapXKaoeDzLNRL4RLQGtTMVnqf522H3LuRgr6NLIj_A,221 +tzdata/zoneinfo/Pacific/Kanton,sha256=ojOG-oqi25HOnY6BFhav_3bmWg1LDILT4v-kxOFVuqI,172 +tzdata/zoneinfo/Pacific/Kiritimati,sha256=cUVGmMRBgllfuYJ3X0B0zg0Bf-LPo9l7Le5ju882dx4,174 +tzdata/zoneinfo/Pacific/Kosrae,sha256=pQMLJXilygPhlkm0jCo5JuVmpmYJgLIdiTVxeP59ZEg,242 +tzdata/zoneinfo/Pacific/Kwajalein,sha256=S-ZFi6idKzDaelLy7DRjGPeD0s7oVud3xLMxZKNlBk8,219 +tzdata/zoneinfo/Pacific/Majuro,sha256=CQNWIL2DFpej6Qcvgt40z8pekS1QyNpUdzmqLyj7bY4,134 +tzdata/zoneinfo/Pacific/Marquesas,sha256=ilprkRvn-N1XjptSI_0ZwUjeuokP-5l64uKjRBp0kxw,139 +tzdata/zoneinfo/Pacific/Midway,sha256=ZQ2Rh1E2ZZBVMGPNaBWS_cqKCZV-DOLBjWaX7Dhe95Y,146 +tzdata/zoneinfo/Pacific/Nauru,sha256=wahZONjreNAmYwhQ2CWdKMAE3SVm4S2aYvMZqcAlSYc,183 +tzdata/zoneinfo/Pacific/Niue,sha256=8WWebtgCnrMBKjuLNEYEWlktNI2op2kkKgk0Vcz8GaM,154 +tzdata/zoneinfo/Pacific/Norfolk,sha256=vL8G6W5CScYqp76g0b15UPIYHw2Lt60qOktHUF7caDs,237 +tzdata/zoneinfo/Pacific/Noumea,sha256=ezUyn7AYWBblrZbStlItJYu7XINCLiihrCBZB-Bl-Qw,198 +tzdata/zoneinfo/Pacific/Pago_Pago,sha256=ZQ2Rh1E2ZZBVMGPNaBWS_cqKCZV-DOLBjWaX7Dhe95Y,146 +tzdata/zoneinfo/Pacific/Palau,sha256=VkLRsKUUVXo3zrhAXn9iM-pKySbGIVfzWoopDhmceMA,148 +tzdata/zoneinfo/Pacific/Pitcairn,sha256=AJh6olJxXQzCMWKOE5ye4jHfgg1VA-9-gCZ5MbrX_8E,153 +tzdata/zoneinfo/Pacific/Pohnpei,sha256=Ui8PN0th4sb1-n0Z8ceszNCeSiE0Yu47QskNMr8r8Yw,134 +tzdata/zoneinfo/Pacific/Ponape,sha256=Ui8PN0th4sb1-n0Z8ceszNCeSiE0Yu47QskNMr8r8Yw,134 +tzdata/zoneinfo/Pacific/Port_Moresby,sha256=aDABBVtu-dydiHNODt3ReC8cNkO3wTp16c-OkFIAbhk,154 +tzdata/zoneinfo/Pacific/Rarotonga,sha256=J6a2mOrTp4bsZNovj3HjJK9AVJ89PhdEpQMMVD__i18,406 +tzdata/zoneinfo/Pacific/Saipan,sha256=i57eM6syriUFvAbrVALnziCw_I4lENyzBcJdOaH71yU,350 +tzdata/zoneinfo/Pacific/Samoa,sha256=ZQ2Rh1E2ZZBVMGPNaBWS_cqKCZV-DOLBjWaX7Dhe95Y,146 +tzdata/zoneinfo/Pacific/Tahiti,sha256=Ivcs04hthxEQj1I_6aACc70By0lmxlvhgGFYh843e14,133 +tzdata/zoneinfo/Pacific/Tarawa,sha256=CQNWIL2DFpej6Qcvgt40z8pekS1QyNpUdzmqLyj7bY4,134 +tzdata/zoneinfo/Pacific/Tongatapu,sha256=mjGjNSUATfw0yLGB0zsLxz3_L1uWxPANML8K4HQQIMY,237 +tzdata/zoneinfo/Pacific/Truk,sha256=aDABBVtu-dydiHNODt3ReC8cNkO3wTp16c-OkFIAbhk,154 +tzdata/zoneinfo/Pacific/Wake,sha256=CQNWIL2DFpej6Qcvgt40z8pekS1QyNpUdzmqLyj7bY4,134 +tzdata/zoneinfo/Pacific/Wallis,sha256=CQNWIL2DFpej6Qcvgt40z8pekS1QyNpUdzmqLyj7bY4,134 +tzdata/zoneinfo/Pacific/Yap,sha256=aDABBVtu-dydiHNODt3ReC8cNkO3wTp16c-OkFIAbhk,154 +tzdata/zoneinfo/Pacific/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/Pacific/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/Poland,sha256=6I9aUfFoFXpBrC3YpO4OmoeUGchMYSK0dxsaKjPZOkw,923 +tzdata/zoneinfo/Portugal,sha256=RNL2z4RzfmoeDa-RQQnpQla-ykC0DJoRt6BOi92u5Ow,1463 +tzdata/zoneinfo/ROC,sha256=oEwscvT3aoMXjQNt2X0VfuHzLkeORN2npcEJI2h-5s8,511 +tzdata/zoneinfo/ROK,sha256=ZKcLb7zJtl52Lb0l64m29AwTcUbtyNvU0IHq-s2reN4,415 +tzdata/zoneinfo/Singapore,sha256=CVSy2aMB2U9DSAJGBqcbvLL6JNPNNwn1vIvKYFA5eF0,256 +tzdata/zoneinfo/Turkey,sha256=KnFjsWuUgG9pmRNI59CmDEbrYbHwMF9fS4P2E9sQgG8,1200 +tzdata/zoneinfo/UCT,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/US/Alaska,sha256=d8oMIpYvBpmLzl5I2By4ZaFEZsg_9dxgfqpIM0QFi_Y,977 +tzdata/zoneinfo/US/Aleutian,sha256=q_sZgOINX4TsX9iBx1gNd6XGwBnzCjg6qpdAQhK0ieA,969 +tzdata/zoneinfo/US/Arizona,sha256=rhFFPCHQiYTedfLv7ATckxeKe04jxeUvIJi4vUXMtUc,240 +tzdata/zoneinfo/US/Central,sha256=wntzn_RqffBZThINcltDkhfhHkTqmlDNxJEwODtUguc,1754 +tzdata/zoneinfo/US/East-Indiana,sha256=5nj0KhPvvXvg8mqc5T4EscKKWC6rBWEcsBwWg2Qy8Hs,531 +tzdata/zoneinfo/US/Eastern,sha256=1_IgazpFmJ_JrWPVWJIlMvpzUigNX4cXa_HbecsdH6k,1744 +tzdata/zoneinfo/US/Hawaii,sha256=HapXKaoeDzLNRL4RLQGtTMVnqf522H3LuRgr6NLIj_A,221 +tzdata/zoneinfo/US/Indiana-Starke,sha256=KJCzXct8CTMItVLYLYeBqM6aT6b53gWCg6aDbsH58oI,1016 +tzdata/zoneinfo/US/Michigan,sha256=I4F8Mt9nx38AF6D-steYskBa_HHO6jKU1-W0yRFr50A,899 +tzdata/zoneinfo/US/Mountain,sha256=m7cDkg7KS2EZ6BoQVYOk9soiBlHxO0GEeat81WxBPz4,1042 +tzdata/zoneinfo/US/Pacific,sha256=IA0FdU9tg6Nxz0CNcIUSV5dlezsL6-uh5QjP_oaj5cg,1294 +tzdata/zoneinfo/US/Samoa,sha256=ZQ2Rh1E2ZZBVMGPNaBWS_cqKCZV-DOLBjWaX7Dhe95Y,146 +tzdata/zoneinfo/US/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/US/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/UTC,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/Universal,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/W-SU,sha256=7S4KCZ-0RrJBZoNDjT9W-fxaYqFsdUmn9Zy8k1s2TIo,908 +tzdata/zoneinfo/WET,sha256=RNL2z4RzfmoeDa-RQQnpQla-ykC0DJoRt6BOi92u5Ow,1463 +tzdata/zoneinfo/Zulu,sha256=_dzh5kihcyrCmv2aFhUbKXPN8ILn7AxpD35CvmtZi5M,111 +tzdata/zoneinfo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +tzdata/zoneinfo/__pycache__/__init__.cpython-310.pyc,, +tzdata/zoneinfo/iso3166.tab,sha256=oBpdFY8x1GrY5vjMKgbGQYEGgqk5fUYDIPaNVCG2XnE,4791 +tzdata/zoneinfo/leapseconds,sha256=X1FVahN0_N2AY6gOUBNWW9MsP297cqFQTHJypTr0rgI,3253 +tzdata/zoneinfo/tzdata.zi,sha256=7zXE0Xivypn5-hCW5ALTasSlFTDMoMOcUTEE29FiOo4,107022 +tzdata/zoneinfo/zone.tab,sha256=a2hE16NtKUnPJzM2krm5rKu1vxtP98nUhGHO3sE6DbM,18775 +tzdata/zoneinfo/zone1970.tab,sha256=3ANHICItrC0iU1vSQAMKZXN1a68sozBiy9AHi9ZGooE,17510 +tzdata/zoneinfo/zonenow.tab,sha256=vEbqGYEEhc_CL-FnoeZ5q3CsPTu8sETOnicuJxFJRqY,8101 +tzdata/zones,sha256=QtJFuOPGCOVEojCYP6b1p4Q_LwMzioibni6fGFIseYQ,9084 diff --git a/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/REQUESTED b/evalkit_tf437/lib/python3.10/site-packages/tzdata-2024.2.dist-info/REQUESTED new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/evalkit_tf437/lib/python3.10/site-packages/urllib3/poolmanager.py b/evalkit_tf437/lib/python3.10/site-packages/urllib3/poolmanager.py new file mode 100644 index 0000000000000000000000000000000000000000..085d1dbafdb3d8141523b2b0e93fdd26845e3aa0 --- /dev/null +++ b/evalkit_tf437/lib/python3.10/site-packages/urllib3/poolmanager.py @@ -0,0 +1,637 @@ +from __future__ import annotations + +import functools +import logging +import typing +import warnings +from types import TracebackType +from urllib.parse import urljoin + +from ._collections import HTTPHeaderDict, RecentlyUsedContainer +from ._request_methods import RequestMethods +from .connection import ProxyConfig +from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme +from .exceptions import ( + LocationValueError, + MaxRetryError, + ProxySchemeUnknown, + URLSchemeUnknown, +) +from .response import BaseHTTPResponse +from .util.connection import _TYPE_SOCKET_OPTIONS +from .util.proxy import connection_requires_http_tunnel +from .util.retry import Retry +from .util.timeout import Timeout +from .util.url import Url, parse_url + +if typing.TYPE_CHECKING: + import ssl + + from typing_extensions import Self + +__all__ = ["PoolManager", "ProxyManager", "proxy_from_url"] + + +log = logging.getLogger(__name__) + +SSL_KEYWORDS = ( + "key_file", + "cert_file", + "cert_reqs", + "ca_certs", + "ca_cert_data", + "ssl_version", + "ssl_minimum_version", + "ssl_maximum_version", + "ca_cert_dir", + "ssl_context", + "key_password", + "server_hostname", +) +# Default value for `blocksize` - a new parameter introduced to +# http.client.HTTPConnection & http.client.HTTPSConnection in Python 3.7 +_DEFAULT_BLOCKSIZE = 16384 + + +class PoolKey(typing.NamedTuple): + """ + All known keyword arguments that could be provided to the pool manager, its + pools, or the underlying connections. + + All custom key schemes should include the fields in this key at a minimum. + """ + + key_scheme: str + key_host: str + key_port: int | None + key_timeout: Timeout | float | int | None + key_retries: Retry | bool | int | None + key_block: bool | None + key_source_address: tuple[str, int] | None + key_key_file: str | None + key_key_password: str | None + key_cert_file: str | None + key_cert_reqs: str | None + key_ca_certs: str | None + key_ca_cert_data: str | bytes | None + key_ssl_version: int | str | None + key_ssl_minimum_version: ssl.TLSVersion | None + key_ssl_maximum_version: ssl.TLSVersion | None + key_ca_cert_dir: str | None + key_ssl_context: ssl.SSLContext | None + key_maxsize: int | None + key_headers: frozenset[tuple[str, str]] | None + key__proxy: Url | None + key__proxy_headers: frozenset[tuple[str, str]] | None + key__proxy_config: ProxyConfig | None + key_socket_options: _TYPE_SOCKET_OPTIONS | None + key__socks_options: frozenset[tuple[str, str]] | None + key_assert_hostname: bool | str | None + key_assert_fingerprint: str | None + key_server_hostname: str | None + key_blocksize: int | None + + +def _default_key_normalizer( + key_class: type[PoolKey], request_context: dict[str, typing.Any] +) -> PoolKey: + """ + Create a pool key out of a request context dictionary. + + According to RFC 3986, both the scheme and host are case-insensitive. + Therefore, this function normalizes both before constructing the pool + key for an HTTPS request. If you wish to change this behaviour, provide + alternate callables to ``key_fn_by_scheme``. + + :param key_class: + The class to use when constructing the key. This should be a namedtuple + with the ``scheme`` and ``host`` keys at a minimum. + :type key_class: namedtuple + :param request_context: + A dictionary-like object that contain the context for a request. + :type request_context: dict + + :return: A namedtuple that can be used as a connection pool key. + :rtype: PoolKey + """ + # Since we mutate the dictionary, make a copy first + context = request_context.copy() + context["scheme"] = context["scheme"].lower() + context["host"] = context["host"].lower() + + # These are both dictionaries and need to be transformed into frozensets + for key in ("headers", "_proxy_headers", "_socks_options"): + if key in context and context[key] is not None: + context[key] = frozenset(context[key].items()) + + # The socket_options key may be a list and needs to be transformed into a + # tuple. + socket_opts = context.get("socket_options") + if socket_opts is not None: + context["socket_options"] = tuple(socket_opts) + + # Map the kwargs to the names in the namedtuple - this is necessary since + # namedtuples can't have fields starting with '_'. + for key in list(context.keys()): + context["key_" + key] = context.pop(key) + + # Default to ``None`` for keys missing from the context + for field in key_class._fields: + if field not in context: + context[field] = None + + # Default key_blocksize to _DEFAULT_BLOCKSIZE if missing from the context + if context.get("key_blocksize") is None: + context["key_blocksize"] = _DEFAULT_BLOCKSIZE + + return key_class(**context) + + +#: A dictionary that maps a scheme to a callable that creates a pool key. +#: This can be used to alter the way pool keys are constructed, if desired. +#: Each PoolManager makes a copy of this dictionary so they can be configured +#: globally here, or individually on the instance. +key_fn_by_scheme = { + "http": functools.partial(_default_key_normalizer, PoolKey), + "https": functools.partial(_default_key_normalizer, PoolKey), +} + +pool_classes_by_scheme = {"http": HTTPConnectionPool, "https": HTTPSConnectionPool} + + +class PoolManager(RequestMethods): + """ + Allows for arbitrary requests while transparently keeping track of + necessary connection pools for you. + + :param num_pools: + Number of connection pools to cache before discarding the least + recently used pool. + + :param headers: + Headers to include with all requests, unless other headers are given + explicitly. + + :param \\**connection_pool_kw: + Additional parameters are used to create fresh + :class:`urllib3.connectionpool.ConnectionPool` instances. + + Example: + + .. code-block:: python + + import urllib3 + + http = urllib3.PoolManager(num_pools=2) + + resp1 = http.request("GET", "https://google.com/") + resp2 = http.request("GET", "https://google.com/mail") + resp3 = http.request("GET", "https://yahoo.com/") + + print(len(http.pools)) + # 2 + + """ + + proxy: Url | None = None + proxy_config: ProxyConfig | None = None + + def __init__( + self, + num_pools: int = 10, + headers: typing.Mapping[str, str] | None = None, + **connection_pool_kw: typing.Any, + ) -> None: + super().__init__(headers) + self.connection_pool_kw = connection_pool_kw + + self.pools: RecentlyUsedContainer[PoolKey, HTTPConnectionPool] + self.pools = RecentlyUsedContainer(num_pools) + + # Locally set the pool classes and keys so other PoolManagers can + # override them. + self.pool_classes_by_scheme = pool_classes_by_scheme + self.key_fn_by_scheme = key_fn_by_scheme.copy() + + def __enter__(self) -> Self: + return self + + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: TracebackType | None, + ) -> typing.Literal[False]: + self.clear() + # Return False to re-raise any potential exceptions + return False + + def _new_pool( + self, + scheme: str, + host: str, + port: int, + request_context: dict[str, typing.Any] | None = None, + ) -> HTTPConnectionPool: + """ + Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and + any additional pool keyword arguments. + + If ``request_context`` is provided, it is provided as keyword arguments + to the pool class used. This method is used to actually create the + connection pools handed out by :meth:`connection_from_url` and + companion methods. It is intended to be overridden for customization. + """ + pool_cls: type[HTTPConnectionPool] = self.pool_classes_by_scheme[scheme] + if request_context is None: + request_context = self.connection_pool_kw.copy() + + # Default blocksize to _DEFAULT_BLOCKSIZE if missing or explicitly + # set to 'None' in the request_context. + if request_context.get("blocksize") is None: + request_context["blocksize"] = _DEFAULT_BLOCKSIZE + + # Although the context has everything necessary to create the pool, + # this function has historically only used the scheme, host, and port + # in the positional args. When an API change is acceptable these can + # be removed. + for key in ("scheme", "host", "port"): + request_context.pop(key, None) + + if scheme == "http": + for kw in SSL_KEYWORDS: + request_context.pop(kw, None) + + return pool_cls(host, port, **request_context) + + def clear(self) -> None: + """ + Empty our store of pools and direct them all to close. + + This will not affect in-flight connections, but they will not be + re-used after completion. + """ + self.pools.clear() + + def connection_from_host( + self, + host: str | None, + port: int | None = None, + scheme: str | None = "http", + pool_kwargs: dict[str, typing.Any] | None = None, + ) -> HTTPConnectionPool: + """ + Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. + + If ``port`` isn't given, it will be derived from the ``scheme`` using + ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is + provided, it is merged with the instance's ``connection_pool_kw`` + variable and used to create the new connection pool, if one is + needed. + """ + + if not host: + raise LocationValueError("No host specified.") + + request_context = self._merge_pool_kwargs(pool_kwargs) + request_context["scheme"] = scheme or "http" + if not port: + port = port_by_scheme.get(request_context["scheme"].lower(), 80) + request_context["port"] = port + request_context["host"] = host + + return self.connection_from_context(request_context) + + def connection_from_context( + self, request_context: dict[str, typing.Any] + ) -> HTTPConnectionPool: + """ + Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. + + ``request_context`` must at least contain the ``scheme`` key and its + value must be a key in ``key_fn_by_scheme`` instance variable. + """ + if "strict" in request_context: + warnings.warn( + "The 'strict' parameter is no longer needed on Python 3+. " + "This will raise an error in urllib3 v2.1.0.", + DeprecationWarning, + ) + request_context.pop("strict") + + scheme = request_context["scheme"].lower() + pool_key_constructor = self.key_fn_by_scheme.get(scheme) + if not pool_key_constructor: + raise URLSchemeUnknown(scheme) + pool_key = pool_key_constructor(request_context) + + return self.connection_from_pool_key(pool_key, request_context=request_context) + + def connection_from_pool_key( + self, pool_key: PoolKey, request_context: dict[str, typing.Any] + ) -> HTTPConnectionPool: + """ + Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. + + ``pool_key`` should be a namedtuple that only contains immutable + objects. At a minimum it must have the ``scheme``, ``host``, and + ``port`` fields. + """ + with self.pools.lock: + # If the scheme, host, or port doesn't match existing open + # connections, open a new ConnectionPool. + pool = self.pools.get(pool_key) + if pool: + return pool + + # Make a fresh ConnectionPool of the desired type + scheme = request_context["scheme"] + host = request_context["host"] + port = request_context["port"] + pool = self._new_pool(scheme, host, port, request_context=request_context) + self.pools[pool_key] = pool + + return pool + + def connection_from_url( + self, url: str, pool_kwargs: dict[str, typing.Any] | None = None + ) -> HTTPConnectionPool: + """ + Similar to :func:`urllib3.connectionpool.connection_from_url`. + + If ``pool_kwargs`` is not provided and a new pool needs to be + constructed, ``self.connection_pool_kw`` is used to initialize + the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` + is provided, it is used instead. Note that if a new pool does not + need to be created for the request, the provided ``pool_kwargs`` are + not used. + """ + u = parse_url(url) + return self.connection_from_host( + u.host, port=u.port, scheme=u.scheme, pool_kwargs=pool_kwargs + ) + + def _merge_pool_kwargs( + self, override: dict[str, typing.Any] | None + ) -> dict[str, typing.Any]: + """ + Merge a dictionary of override values for self.connection_pool_kw. + + This does not modify self.connection_pool_kw and returns a new dict. + Any keys in the override dictionary with a value of ``None`` are + removed from the merged dictionary. + """ + base_pool_kwargs = self.connection_pool_kw.copy() + if override: + for key, value in override.items(): + if value is None: + try: + del base_pool_kwargs[key] + except KeyError: + pass + else: + base_pool_kwargs[key] = value + return base_pool_kwargs + + def _proxy_requires_url_absolute_form(self, parsed_url: Url) -> bool: + """ + Indicates if the proxy requires the complete destination URL in the + request. Normally this is only needed when not using an HTTP CONNECT + tunnel. + """ + if self.proxy is None: + return False + + return not connection_requires_http_tunnel( + self.proxy, self.proxy_config, parsed_url.scheme + ) + + def urlopen( # type: ignore[override] + self, method: str, url: str, redirect: bool = True, **kw: typing.Any + ) -> BaseHTTPResponse: + """ + Same as :meth:`urllib3.HTTPConnectionPool.urlopen` + with custom cross-host redirect logic and only sends the request-uri + portion of the ``url``. + + The given ``url`` parameter must be absolute, such that an appropriate + :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it. + """ + u = parse_url(url) + + if u.scheme is None: + warnings.warn( + "URLs without a scheme (ie 'https://') are deprecated and will raise an error " + "in a future version of urllib3. To avoid this DeprecationWarning ensure all URLs " + "start with 'https://' or 'http://'. Read more in this issue: " + "https://github.com/urllib3/urllib3/issues/2920", + category=DeprecationWarning, + stacklevel=2, + ) + + conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) + + kw["assert_same_host"] = False + kw["redirect"] = False + + if "headers" not in kw: + kw["headers"] = self.headers + + if self._proxy_requires_url_absolute_form(u): + response = conn.urlopen(method, url, **kw) + else: + response = conn.urlopen(method, u.request_uri, **kw) + + redirect_location = redirect and response.get_redirect_location() + if not redirect_location: + return response + + # Support relative URLs for redirecting. + redirect_location = urljoin(url, redirect_location) + + if response.status == 303: + # Change the method according to RFC 9110, Section 15.4.4. + method = "GET" + # And lose the body not to transfer anything sensitive. + kw["body"] = None + kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change() + + retries = kw.get("retries") + if not isinstance(retries, Retry): + retries = Retry.from_int(retries, redirect=redirect) + + # Strip headers marked as unsafe to forward to the redirected location. + # Check remove_headers_on_redirect to avoid a potential network call within + # conn.is_same_host() which may use socket.gethostbyname() in the future. + if retries.remove_headers_on_redirect and not conn.is_same_host( + redirect_location + ): + new_headers = kw["headers"].copy() + for header in kw["headers"]: + if header.lower() in retries.remove_headers_on_redirect: + new_headers.pop(header, None) + kw["headers"] = new_headers + + try: + retries = retries.increment(method, url, response=response, _pool=conn) + except MaxRetryError: + if retries.raise_on_redirect: + response.drain_conn() + raise + return response + + kw["retries"] = retries + kw["redirect"] = redirect + + log.info("Redirecting %s -> %s", url, redirect_location) + + response.drain_conn() + return self.urlopen(method, redirect_location, **kw) + + +class ProxyManager(PoolManager): + """ + Behaves just like :class:`PoolManager`, but sends all requests through + the defined proxy, using the CONNECT method for HTTPS URLs. + + :param proxy_url: + The URL of the proxy to be used. + + :param proxy_headers: + A dictionary containing headers that will be sent to the proxy. In case + of HTTP they are being sent with each request, while in the + HTTPS/CONNECT case they are sent only once. Could be used for proxy + authentication. + + :param proxy_ssl_context: + The proxy SSL context is used to establish the TLS connection to the + proxy when using HTTPS proxies. + + :param use_forwarding_for_https: + (Defaults to False) If set to True will forward requests to the HTTPS + proxy to be made on behalf of the client instead of creating a TLS + tunnel via the CONNECT method. **Enabling this flag means that request + and response headers and content will be visible from the HTTPS proxy** + whereas tunneling keeps request and response headers and content + private. IP address, target hostname, SNI, and port are always visible + to an HTTPS proxy even when this flag is disabled. + + :param proxy_assert_hostname: + The hostname of the certificate to verify against. + + :param proxy_assert_fingerprint: + The fingerprint of the certificate to verify against. + + Example: + + .. code-block:: python + + import urllib3 + + proxy = urllib3.ProxyManager("https://localhost:3128/") + + resp1 = proxy.request("GET", "https://google.com/") + resp2 = proxy.request("GET", "https://httpbin.org/") + + print(len(proxy.pools)) + # 1 + + resp3 = proxy.request("GET", "https://httpbin.org/") + resp4 = proxy.request("GET", "https://twitter.com/") + + print(len(proxy.pools)) + # 3 + + """ + + def __init__( + self, + proxy_url: str, + num_pools: int = 10, + headers: typing.Mapping[str, str] | None = None, + proxy_headers: typing.Mapping[str, str] | None = None, + proxy_ssl_context: ssl.SSLContext | None = None, + use_forwarding_for_https: bool = False, + proxy_assert_hostname: None | str | typing.Literal[False] = None, + proxy_assert_fingerprint: str | None = None, + **connection_pool_kw: typing.Any, + ) -> None: + if isinstance(proxy_url, HTTPConnectionPool): + str_proxy_url = f"{proxy_url.scheme}://{proxy_url.host}:{proxy_url.port}" + else: + str_proxy_url = proxy_url + proxy = parse_url(str_proxy_url) + + if proxy.scheme not in ("http", "https"): + raise ProxySchemeUnknown(proxy.scheme) + + if not proxy.port: + port = port_by_scheme.get(proxy.scheme, 80) + proxy = proxy._replace(port=port) + + self.proxy = proxy + self.proxy_headers = proxy_headers or {} + self.proxy_ssl_context = proxy_ssl_context + self.proxy_config = ProxyConfig( + proxy_ssl_context, + use_forwarding_for_https, + proxy_assert_hostname, + proxy_assert_fingerprint, + ) + + connection_pool_kw["_proxy"] = self.proxy + connection_pool_kw["_proxy_headers"] = self.proxy_headers + connection_pool_kw["_proxy_config"] = self.proxy_config + + super().__init__(num_pools, headers, **connection_pool_kw) + + def connection_from_host( + self, + host: str | None, + port: int | None = None, + scheme: str | None = "http", + pool_kwargs: dict[str, typing.Any] | None = None, + ) -> HTTPConnectionPool: + if scheme == "https": + return super().connection_from_host( + host, port, scheme, pool_kwargs=pool_kwargs + ) + + return super().connection_from_host( + self.proxy.host, self.proxy.port, self.proxy.scheme, pool_kwargs=pool_kwargs # type: ignore[union-attr] + ) + + def _set_proxy_headers( + self, url: str, headers: typing.Mapping[str, str] | None = None + ) -> typing.Mapping[str, str]: + """ + Sets headers needed by proxies: specifically, the Accept and Host + headers. Only sets headers not provided by the user. + """ + headers_ = {"Accept": "*/*"} + + netloc = parse_url(url).netloc + if netloc: + headers_["Host"] = netloc + + if headers: + headers_.update(headers) + return headers_ + + def urlopen( # type: ignore[override] + self, method: str, url: str, redirect: bool = True, **kw: typing.Any + ) -> BaseHTTPResponse: + "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute." + u = parse_url(url) + if not connection_requires_http_tunnel(self.proxy, self.proxy_config, u.scheme): + # For connections using HTTP CONNECT, httplib sets the necessary + # headers on the CONNECT to the proxy. If we're not using CONNECT, + # we'll definitely need to set 'Host' at the very least. + headers = kw.get("headers", self.headers) + kw["headers"] = self._set_proxy_headers(url, headers) + + return super().urlopen(method, url, redirect=redirect, **kw) + + +def proxy_from_url(url: str, **kw: typing.Any) -> ProxyManager: + return ProxyManager(proxy_url=url, **kw)