def _end_format_as_child (self, self_object, record_key, record):
        tex = texlist ()
        tex.add (record_key.default.value) # todo LatexRecordKeyDefault
        tex.add ()
        tex.add_description_field (record_key.description)

        return tex
Exemplo n.º 2
0
    def format (self, record):
        tex = texlist (self.tag_name)
        reference_list = record.implements

        with tex.element ():
            with tex:
                tex.hyperB (record.type_name)

            # TODO what if multiple inheritance? list
            if reference_list:
                with tex:
                    for reference in reference_list:
                        tex.Alink (reference.get_reference ().name)
            else:
                tex.add ()

            if record.reducible_to_key:
                with tex:
                    tex.Alink (record.reducible_to_key, record.type_name)
            else:
                tex.add ()

            # hyperlink into hand written text
            # LATER it can removed since is not used anymore
            tex.add ()
            tex.add_description_field (record.description)

            # record keys
            for record_key in record.keys:
                tex.newline ()
                fmt = LatexFormatter.get_formatter_for (record_key)
                tex.extend (fmt.format (record_key, record))
            tex.newline ()

        return tex
Exemplo n.º 3
0
    def _format_as_child(self, self_array, record_key, record):
        """
        :type self_array: ist.nodes.TypeArray
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        """
        subtype = self_array.subtype.get_reference()
        tex = texlist()
        with tex:
            if type(subtype) == TypeInteger:
                tex.append('Array of {subtype} {subrange}'.format(
                    range=self_array.range, subtype=subtype.input_type,
                    subrange=subtype.range))
            else:
                tex.append('Array{range} of {subtype}'.format(
                    range=' ' + str(self_array.range) if not self_array.range.is_pointless() else '',
                    subtype=subtype.input_type))

            if type(subtype) == TypeString:
                tex.append(' (generic)')

            if subtype.input_type == InputType.MAIN_TYPE:
                tex.append(': ')
                tex.Alink(subtype.name)
            else:
                # no link
                pass

        return tex
Exemplo n.º 4
0
 def _end_format_as_child(self, self_object, record_key, record):
     tex = texlist()
     tex.extend(LatexRecordKeyDefault().format_as_child(
         record_key.default, record_key, record))
     tex.add()
     tex.add_description_field(record_key.description)
     return tex
Exemplo n.º 5
0
    def _end_format_as_child(self, self_object, record_key, record):
        tex = texlist()
        tex.add(record_key.default.value)  # todo LatexRecordKeyDefault
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 6
0
 def format_as_child(self, self_object, record_key, record):
     tex = texlist()
     tex.extend(self._start_format_as_child(self_object, record_key,
                                            record))
     tex.extend(self._format_as_child(self_object, record_key, record))
     tex.extend(self._end_format_as_child(self_object, record_key, record))
     return tex
Exemplo n.º 7
0
    def _format_as_child(self, self_array, record_key, record):
        subtype = self_array.subtype.get_reference()
        tex = texlist()
        with tex:
            if type(subtype) == Integer:
                tex.append('Array of {subtype} {subrange}'.format(
                    range=self_array.range,
                    subtype=subtype.input_type,
                    subrange=subtype.range))
            else:
                tex.append('Array{range} of {subtype}'.format(
                    range=' ' + str(self_array.range)
                    if not self_array.range.is_pointless() else '',
                    subtype=subtype.input_type))

            if type(subtype) == String:
                tex.append(' (generic)')

            if issubclass(subtype.__class__, DescriptionNode):
                tex.append(': ')
                tex.Alink(subtype.get('type_name', 'name'))
            else:
                # no link
                pass

        return tex
Exemplo n.º 8
0
    def format(self, abstract_record):
        """
        :type abstract_record: ist.nodes.TypeAbstract
        """
        tex = texlist(self.tag_name)
        with tex.element():
            with tex:
                tex.hyperB(abstract_record.name)

            if abstract_record.default_descendant:
                reference = abstract_record.default_descendant.get_reference()
                with tex:
                    tex.Alink(reference.name)
                with tex:
                    tex.AddDoc(abstract_record.name)
            else:
                tex.add()
                tex.add()
            tex.add_description_field(abstract_record.description)

            for descendant in abstract_record.implementations:
                tex.newline()
                tex.tag('Descendant')
                with tex:
                    tex.Alink(descendant.get_reference().name)
            tex.newline()

        return tex
 def _end_format_as_child (self, self_object, record_key, record):
     tex = texlist ()
     tex.extend (
         LatexRecordKeyDefault ().format_as_child (record_key.default, record_key, record)
     )
     tex.add ()
     tex.add_description_field (record_key.description)
     return tex
Exemplo n.º 10
0
 def _format_as_child(self, self_int, record_key, record):
     """
     :type self_int: ist.nodes.TypeInteger
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.add('Integer' + str(self_int.range))
     return tex
Exemplo n.º 11
0
 def _format_as_child(self, self_bool, record_key, record):
     """
     :type self_bool: ist.nodes.TypeBool
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.add('Bool')
     return tex
Exemplo n.º 12
0
 def _format_as_child(self, self_fn, record_key, record):
     """
     :type self_fn: ist.nodes.TypeFilename
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.add(self_fn.file_mode + ' file name')
     return tex
Exemplo n.º 13
0
 def _format_as_child(self, self_double, record_key, record):
     """
     :type self_double: ist.nodes.TypeDouble
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.add('Double' + str(self_double.range))
     return tex
Exemplo n.º 14
0
 def raw_format(self, self_default, record_key, record):
     """
     :type self_default: ist.extras.TypeRecordKeyDefault
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.add_s(self_default.value)
     return tex
Exemplo n.º 15
0
    def __init__(self, element):
        if type(element) in (str, unicode):
            tree = ET.fromstring('<html_example>' + element +
                                 "</html_example>")
            self.el = tree
        else:
            self.el = element

        from ist.utils.texlist import texlist
        self.tex = texlist()
Exemplo n.º 16
0
    def __init__(self, element):
        if type(element) in (str, unicode):
            tree = ET.fromstring("<html_example>" + element + "</html_example>")
            self.el = tree
        else:
            self.el = element

        from ist.utils.texlist import texlist

        self.tex = texlist()
Exemplo n.º 17
0
 def _start_format_as_child(self, self_object, record_key, record):
     """
     :type self_record: object
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.KeyItem()
     with tex:
         tex.hyperB(record_key.key, record.name)
     return tex
Exemplo n.º 18
0
 def textlangle_format(self, self_default, record_key, record):
     """
     :type self: object
     :type self_default: ist.extras.TypeRecordKeyDefault
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     with tex:
         tex.textlangle(self_default.value)
     return tex
Exemplo n.º 19
0
 def format_as_child(self, self_object, record_key, record):
     """
     :type self_record: object
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.extend(self._start_format_as_child(self_object, record_key, record))
     tex.extend(self._format_as_child(self_object, record_key, record))
     tex.extend(self._end_format_as_child(self_object, record_key, record))
     return tex
Exemplo n.º 20
0
    def _end_format_as_child(self, self_object, record_key, record):
        """
        :type self_bool: ist.nodes.TypeBool
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        """
        tex = texlist()
        tex.add(record_key.default.value)  # todo LatexRecordKeyDefault
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 21
0
    def format (self, record_key, record):
        tex = texlist ()
        reference = record_key.type.get_reference ()

        # try to grab formatter and format type and default value based on reference type
        fmt = LatexFormatter.get_formatter_for (reference)
        if not fmt:
            print ' <<Missing formatter for {}>>'.format (type (reference))
        else:
            tex.extend (fmt.format_as_child (reference, record_key, record))

        return tex
Exemplo n.º 22
0
 def _end_format_as_child(self, self_object, record_key, record):
     """
     :type self_double: ist.nodes.TypeDouble
     :type record: ist.nodes.TypeRecord
     :type record_key: ist.extras.TypeRecordKey
     """
     tex = texlist()
     tex.extend(
         LatexRecordKeyDefault().format_as_child(record_key.default, record_key, record)
     )
     tex.add()
     tex.add_description_field(record_key.description)
     return tex
Exemplo n.º 23
0
    def format_as_child(self, self_string, record_key, record):
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.type_name)
        tex.add('String (generic)')

        with tex:
            tex.textlangle(record_key.default.type)
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 24
0
    def format(self, record_key, record):
        tex = texlist()
        reference = record_key.type.get_reference()

        # try to grab formatter and format type and default value based on reference type
        try:
            fmt = LatexFormatter.get_formatter_for(reference)
            tex.extend(fmt.format_as_child(reference, record_key, record))
        except Exception as e:
            tex.append(' <<Missing formatter for {}>>'.format(type(reference)))
            print e

        return tex
Exemplo n.º 25
0
    def format_as_child (self, self_string, record_key, record):
        tex = texlist ()
        tex.KeyItem ()
        with tex:
            tex.hyperB (record_key.key, record.type_name)
        tex.add ('String (generic)')

        with tex:
            tex.textlangle (record_key.default.type)
        tex.add ()
        tex.add_description_field (record_key.description)

        return tex
Exemplo n.º 26
0
    def format (self, selection):
        tex = texlist (self.tag_name)

        with tex.element ():
            with tex:
                tex.hyperB (selection.name)
            tex.add_description_field (selection.description)

            for selection_value in selection.values:
                tex.newline ()
                tex.KeyItem (selection_value.name, selection_value.description)
            tex.newline ()

        return tex
Exemplo n.º 27
0
    def format(self, selection):
        tex = texlist(self.tag_name)

        with tex.element():
            with tex:
                tex.hyperB(selection.name)
            tex.add_description_field(selection.description)

            for selection_value in selection.values:
                tex.newline()
                tex.KeyItem(selection_value.name, selection_value.description)
            tex.newline()

        return tex
Exemplo n.º 28
0
    def format(self, record_key, record):
        """
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        """
        tex = texlist()
        reference = record_key.type.get_reference()

        # try to grab formatter and format type and default value based on reference type
        fmt = LatexFormatter.get_formatter_for(reference)
        if not fmt:
            Logger.instance().info(' <<Missing formatter for {}>>'.format(type(reference)))
        else:
            tex.extend(fmt.format_as_child(reference, record_key, record))

        return tex
Exemplo n.º 29
0
    def format_as_child(self, self_record, record_key, record):
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.type_name)

        with tex:
            tex.append('record: ')
            tex.Alink(self_record.type_name)

        tex.extend(LatexRecordKeyDefault().format_as_child(
            record_key.default, record_key, record))
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 30
0
    def format_as_child (self, self_record, record_key, record):
        tex = texlist ()
        tex.KeyItem ()
        with tex:
            tex.hyperB (record_key.key, record.type_name)

        with tex:
            tex.append ('record: ')
            tex.Alink (self_record.type_name)

        tex.extend (
            LatexRecordKeyDefault ().format_as_child (record_key.default, record_key, record)
        )
        tex.add ()
        tex.add_description_field (record_key.description)

        return tex
Exemplo n.º 31
0
    def format_as_child (self, self_selection, record_key, record):
        tex = texlist ()
        tex.KeyItem ()
        with tex:
            tex.hyperB (record_key.key, record.type_name)

        with tex:
            tex.append ('selection: ')
            if self_selection.include_in_format ():
                tex.Alink (self_selection.name)
            else:
                tex.append (tex.escape (self_selection.name))

        tex.add_s (record_key.default.value)
        tex.add ()
        tex.add_description_field (record_key.description)

        return tex
Exemplo n.º 32
0
    def format_as_child(self, self_selection, record_key, record):
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.type_name)

        with tex:
            tex.append('selection: ')
            if self_selection.include_in_format():
                tex.Alink(self_selection.name)
            else:
                tex.append(tex.escape(self_selection.name))

        tex.add_s(record_key.default.value)
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 33
0
    def format_as_child(self, self_string, record_key, record):
        """
        :type self_fn: ist.nodes.TypeString
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        """
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.name)
        tex.add('String (generic)')

        with tex:
            tex.textlangle(record_key.default.type)
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 34
0
    def format(self, record):
        tex = texlist(self.tag_name)
        reference_list = record.implements

        with tex.element():
            with tex:
                tex.hyperB(record.type_name)

            # TODO what if multiple inheritance? list
            if reference_list:
                with tex:
                    for reference in reference_list:
                        tex.Alink(reference.get_reference().name)
            else:
                tex.add()

            if record.reducible_to_key:
                with tex:
                    tex.Alink(record.reducible_to_key, record.type_name)
            else:
                tex.add()

            # hyperlink into hand written text
            # LATER it can removed since is not used anymore
            tex.add()
            tex.add_description_field(record.description)

            # record keys
            for record_key in record.keys:
                # try:
                # if not record_key.include_in_format ():
                #     continue

                tex.newline()
                fmt = LatexFormatter.get_formatter_for(record_key)
                tex.extend(fmt.format(record_key, record))
                # except Exception as e:
                #     print e
                #     continue
            tex.newline()

        return tex
Exemplo n.º 35
0
    def format(items):
        tex = texlist()

        for item in items:
            # format only IST nodes
            if issubclass(item.__class__, ISTNode):

                # do no format certain objects
                if not item.include_in_format():
                    continue

                try:
                    fmt = LatexFormatter.get_formatter_for(item)
                    tex.extend(fmt.format(item))
                    tex.newline()
                    tex.newline()
                except Exception as e:
                    # print e
                    continue

        return tex
Exemplo n.º 36
0
    def format (items):
        tex = texlist ()

        for item in items:
            # format only IST nodes
            if issubclass (item.__class__, ISTNode):

                # do no format certain objects
                if not item.include_in_format ():
                    continue

                try:
                    fmt = LatexFormatter.get_formatter_for (item)
                    if fmt is not None:
                        tex.extend (fmt.format (item))
                        tex.newline ()
                        tex.newline ()
                except NotImplementedError as e:
                    pass

        return tex
Exemplo n.º 37
0
    def format (items):
        tex = texlist ()

        for item in items:
            # format only IST nodes
            if issubclass (item.__class__, ISTNode):

                # do no format certain objects
                if not item.include_in_format ():
                    continue

                try:
                    fmt = LatexFormatter.get_formatter_for (item)
                    tex.extend (fmt.format (item))
                    tex.newline ()
                    tex.newline ()
                except Exception as e:
                    # print e
                    continue

        return tex
Exemplo n.º 38
0
    def format(items):
        tex = texlist()

        Logger.instance().info('Processing items...')
        for item in items:
            # do no format certain objects
            if not item.include_in_format():
                Logger.instance().info(' - item skipped: %s' % str(item))
                continue

            Logger.instance().info(' - formatting item: %s' % str(item))
            a = TexList()
            a.macro_record_type(item)
            print a
            exit()
            fmt = LatexFormatter.get_formatter_for(item)
            if fmt is not None:
                tex.extend(fmt.format(item))
                tex.newline()
                tex.newline()

        return tex
Exemplo n.º 39
0
    def format_as_child(self, abstract_record, record_key, record):
        """
        :type abstract_record: ist.nodes.TypeAbstract
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        """
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.name)

        with tex:
            tex.append('abstract type: ')
            tex.Alink(abstract_record.name)

        tex.extend(
            LatexRecordKeyDefault().format_as_child(record_key.default, record_key, record)
        )
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 40
0
    def format(self, record):
        """
        :type record: ist.nodes.TypeRecord
        """
        tex = texlist(self.tag_name)
        reference_list = record.implements

        with tex.element():
            with tex:
                tex.hyperB(record.name)

            # TODO what if multiple inheritance? list
            if reference_list:
                with tex:
                    for reference in reference_list:
                        tex.Alink(reference.get_reference().name)
            else:
                tex.add()

            if record.reducible_to_key:
                with tex:
                    tex.Alink(record.reducible_to_key, record.name)
            else:
                tex.add()

            # hyperlink into hand written text
            # LATER it can removed since is not used anymore
            tex.add()
            tex.add_description_field(record.description)

            # record keys
            for record_key in record.keys:
                tex.newline()
                fmt = LatexFormatter.get_formatter_for(record_key)
                tex.extend(fmt.format(record_key, record))
            tex.newline()

        return tex
Exemplo n.º 41
0
    def format_as_child(self, self_selection, record_key, record):
        """
        :type record: ist.nodes.TypeRecord
        :type record_key: ist.extras.TypeRecordKey
        :type self_selection: ist.nodes.TypeSelection
        """
        tex = texlist()
        tex.KeyItem()
        with tex:
            tex.hyperB(record_key.key, record.name)

        with tex:
            tex.append('selection: ')
            if self_selection.include_in_format():
                tex.Alink(self_selection.name)
            else:
                tex.append(tex.plain_mode(self_selection.name))

        tex.add_s(record_key.default.value)
        tex.add()
        tex.add_description_field(record_key.description)

        return tex
Exemplo n.º 42
0
    def _format_as_child (self, self_array, record_key, record):
        subtype = self_array.subtype.get_reference ()
        tex = texlist ()
        with tex:
            if type (subtype) == Integer:
                tex.append ('Array of {subtype} {subrange}'.format (
                    range=self_array.range, subtype=subtype.input_type,
                    subrange=subtype.range))
            else:
                tex.append ('Array{range} of {subtype}'.format (
                    range=' ' + str (self_array.range) if not self_array.range.is_pointless () else '',
                    subtype=subtype.input_type))

            if type (subtype) == String:
                tex.append (' (generic)')

            if issubclass (subtype.__class__, DescriptionNode):
                tex.append (': ')
                tex.Alink (subtype.get ('type_name', 'name'))
            else:
                # no link
                pass

        return tex
Exemplo n.º 43
0
 def _format_as_child (self, self_fn, record_key, record):
     tex = texlist ()
     tex.add (self_fn.file_mode + ' file name')
     return tex