kojiromike commented on code in PR #1181:
URL: https://github.com/apache/avro/pull/1181#discussion_r1264735918


##########
lang/py/avro/schema.py:
##########
@@ -240,6 +295,30 @@ def __eq__(self, that: object) -> bool:
         Consider the mixins EqualByPropsMixin and EqualByJsonMixin
         """
 
+    def fingerprint(self, algorithm="CRC-64-AVRO") -> bytes:
+        """
+        Generate fingerprint for supplied algorithm.
+
+        'CRC-64-AVRO' will be used as the algorithm by default, but any
+        algorithm supported by hashlib (as can be referenced with
+        `hashlib.algorithms_guaranteed`) can be specified.
+
+        `algorithm` param is used as an algorithm name, and 
NoSuchAlgorithmException
+        will be thrown if the algorithm is not among supported.
+        """
+        schema = self.canonical_form.encode("utf-8")
+
+        if algorithm not in SUPPORTED_ALGORITHMS:
+            raise avro.errors.UnknownFingerprintAlgorithmException(f"Unknown 
Fingerprint Algorithm: {algorithm}")
+
+        if algorithm == "CRC-64-AVRO":
+            return _crc_64_fingerprint(schema)

Review Comment:
   Consider swapping these two `if` statements



-- 
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]

Reply via email to