Drop lots of legacy code. Support Python 3.7-3.11.
[librarian.git] / src / librarian / embeds / __init__.py
index fa74530..4714a92 100644 (file)
@@ -1,5 +1,6 @@
-from __future__ import unicode_literals
-
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
+#
 import importlib
 from lxml import etree
 
 import importlib
 from lxml import etree
 
@@ -8,6 +9,7 @@ known_types = {
     'application/x-latex': 'librarian.embeds.latex.LaTeX',
 }
 
     'application/x-latex': 'librarian.embeds.latex.LaTeX',
 }
 
+
 class Embed():
     @classmethod
     def transforms_to(cls, mime_types, downgrade=False):
 class Embed():
     @classmethod
     def transforms_to(cls, mime_types, downgrade=False):
@@ -20,7 +22,7 @@ class Embed():
         return matches
 
     def transform_to(self, mime_type, downgrade=False):
         return matches
 
     def transform_to(self, mime_type, downgrade=False):
-        for name, method in type(cls).__dict__.iteritems():
+        for name, method in type(self).__dict__.iteritems():
             if hasattr(method, "embed_converts_to"):
                 conv_type, conv_downgrade = method.embed_converts_to
                 if downgrade == conv_downgrade and conv_type == mime_type:
             if hasattr(method, "embed_converts_to"):
                 conv_type, conv_downgrade = method.embed_converts_to
                 if downgrade == conv_downgrade and conv_type == mime_type:
@@ -31,21 +33,25 @@ class DataEmbed(Embed):
     def __init__(self, data=None):
         self.data = data
 
     def __init__(self, data=None):
         self.data = data
 
+
 class TreeEmbed(Embed):
     def __init__(self, tree=None):
         if isinstance(tree, etree._Element):
             tree = etree.ElementTree(tree)
         self.tree = tree
 
 class TreeEmbed(Embed):
     def __init__(self, tree=None):
         if isinstance(tree, etree._Element):
             tree = etree.ElementTree(tree)
         self.tree = tree
 
+
 def converts_to(mime_type, downgrade=False):
     def decorator(method):
         method.embed_converts_to = mime_type, downgrade
         return method
     return decorator
 
 def converts_to(mime_type, downgrade=False):
     def decorator(method):
         method.embed_converts_to = mime_type, downgrade
         return method
     return decorator
 
+
 def downgrades_to(mime_type):
     return converts_to(mime_type, True)
 
 def downgrades_to(mime_type):
     return converts_to(mime_type, True)
 
+
 def create_embed(mime_type, tree=None, data=None):
     embed = known_types.get(mime_type)
     if embed is None:
 def create_embed(mime_type, tree=None, data=None):
     embed = known_types.get(mime_type)
     if embed is None: