chaokunyang commented on code in PR #1702: URL: https://github.com/apache/fury/pull/1702#discussion_r1667822186
########## python/pyfury/meta/metastring.py: ########## @@ -0,0 +1,324 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +import numpy as np + + +from enum import Enum + + +# Defines the types of supported encodings for MetaStrings. +class Encoding(Enum): + UTF_8 = 0x00 + LOWER_SPECIAL = 0x01 + LOWER_UPPER_DIGIT_SPECIAL = 0x02 + FIRST_TO_LOWER_SPECIAL = 0x03 + ALL_TO_LOWER_SPECIAL = 0x04 + + +# _METASTRING_NUM_CHARS_LIMIT is used to check whether the length of the value is valid. +_METASTRING_NUM_CHARS_LIMIT = 32767 + + +class MetaString: + def __init__(self, original, encoding, encoded_data, length): + self.original = original + self.encoding = encoding + self.encoded_data = encoded_data + self.length = length + if self.encoding != Encoding.UTF_8: + self.strip_last_char = (encoded_data[0] & 0x80) != 0 + else: + self.strip_last_char = False + + +# Decodes MetaString objects back into their original plain text form. Review Comment: Could we make this comment as the docstring for this method? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
