Ejemplo n.º 1
0
    def getEnvDefinition(self, name: str) -> dict:
        definition = None
        for env in self.db.findall('./env'):
            if env.attrib['name'] == name:
                env_def = env.find('defines')
                env_type = env.attrib['type']

                definition = {}
                definition['readTable'] = False
                definition['mathmode'] = False

                if str(env_type) == 'mathmode':
                    definition['mathmode'] = True

                if str(env_type) == 'readTable':
                    definition['readTable'] = True

                if env_def:
                    definition = {}
                    for cmd in env_def.findall('cmd'):
                        cmd_def = []
                        if cmd.text and not cmd.text.isspace():
                            cmd_def.append(
                                TextElement(cmd.text.strip(" \t\n\r")))
                        for elem in cmd.findall('./*'):
                            cmd_def.append(self._getSSMLElement(elem))

                        definition[cmd.attrib['name']] = cmd_def
                break

        return definition
 def mockEnvConversion(env):
     if env == 'a':
         a = [TextElement('text2')]
         return a
     if env == 'b':
         b = [ContentElement()]
         return b
     else:
         return None
Ejemplo n.º 3
0
 def getCmdConversion(self, name: str) -> list:
     conversion = None
     for cmd in self.db.findall('./cmd'):
         if cmd.attrib['name'] == name:
             conversion = []
             if cmd.text and not cmd.text.isspace():
                 conversion.append(TextElement(cmd.text.strip(" \t\n\r")))
             for elem in cmd.findall('./*'):
                 conversion.append(self._getSSMLElement(elem))
             break
     return conversion
Ejemplo n.º 4
0
 def getEnvConversion(self, name: str) -> list:
     conversion = None
     for env in self.db.findall('./env'):
         if env.attrib['name'] == name:
             env_conv = env.find('says')
             if env_conv is not None:
                 conversion = []
                 if env_conv.text and not env_conv.text.isspace():
                     conversion.append(
                         TextElement(env_conv.text.strip(" \t\n\r")))
                 for elem in env_conv.findall('./*'):
                     conversion.append(self._getSSMLElement(elem))
             break
     return conversion
 def mockEnvDefinition(env):
     if env == 'b':
         return {'a': [TextElement('text 3')], 'type': None}
     else:
         return None
 def mockEnvDefinition(env):
     if env == 'b':
         return {'a': [TextElement('text3')], 'mathmode': False}
     else:
         return None
 def mockCmdConversion(cmd):
     if cmd == 'a':
         a = [TextElement('text1')]
         return a
     else:
         return None
 def mockEnvConversion(env):
     if env == 'b':
         return [TextElement('text 2'), ContentElement()]
     else:
         return None