python-lottie  0.6.11+devc144cca
A framework to work with lottie files and telegram animated stickers (tgs)
handler.py
Go to the documentation of this file.
1 import enum
2 from xml.etree import ElementTree
3 
4 
5 class SvgHandler:
6  ns_map = {
7  "dc": "http://purl.org/dc/elements/1.1/",
8  "cc": "http://creativecommons.org/ns#",
9  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
10  "svg": "http://www.w3.org/2000/svg",
11  "sodipodi": "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd",
12  "inkscape": "http://www.inkscape.org/namespaces/inkscape",
13  "xlink": "http://www.w3.org/1999/xlink",
14  }
15 
16  def init_etree(self):
17  for n, u in self.ns_map.items():
18  ElementTree.register_namespace(n, u)
19 
20  def qualified(self, ns, name):
21  return "{%s}%s" % (self.ns_map[ns], name)
22 
23  def simplified(self, name):
24  for k, v in self.ns_map.items():
25  name = name.replace("{%s}" % v, k+":")
26  return name
27 
28  def unqualified(self, name):
29  return name.split("}")[-1]
30 
31  def __init__(self):
32  self.init_etree()
33 
34 
35 class NameMode(enum.Enum):
36  NoName = 0
37  Id = 1
38  Inkscape = 2
lottie.parsers.svg.handler.SvgHandler.ns_map
dictionary ns_map
Definition: handler.py:6
lottie.parsers.svg.handler.SvgHandler
Definition: handler.py:5
lottie.parsers.svg.handler.SvgHandler.simplified
def simplified(self, name)
Definition: handler.py:23
lottie.parsers.svg.handler.NameMode
Definition: handler.py:35
lottie.parsers.svg.handler.SvgHandler.unqualified
def unqualified(self, name)
Definition: handler.py:28
lottie.parsers.svg.handler.SvgHandler.__init__
def __init__(self)
Definition: handler.py:31
lottie.parsers.svg.handler.SvgHandler.init_etree
def init_etree(self)
Definition: handler.py:16
lottie.parsers.svg.handler.SvgHandler.qualified
def qualified(self, ns, name)
Definition: handler.py:20