summaryrefslogtreecommitdiff
path: root/mammoth/documents.py
blob: 0f2d767a5a2e48d979f8bded378ef28e5c28f87e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import collections

Document = collections.namedtuple("Document", ["children"])
Paragraph = collections.namedtuple("Paragraph", ["children", "style_name", "numbering"])
Run = collections.namedtuple("Run", ["children", "style_name", "is_bold", "is_italic"])
Text = collections.namedtuple("Text", ["value"])
Hyperlink = collections.namedtuple("Hyperlink", ["href", "children"])

class Tab(object):
    pass


class Image(object):
    def __init__(self, alt_text, content_type, open):
        self.alt_text = alt_text
        self.content_type = content_type
        self.open = open


document = Document

def paragraph(children, style_name=None, numbering=None):
    return Paragraph(children, style_name, numbering)

def run(children, style_name=None, is_bold=None, is_italic=None):
    return Run(children, style_name, bool(is_bold), bool(is_italic))

text = Text

_tab = Tab()

def tab():
    return _tab


image = Image
hyperlink = Hyperlink


def numbering_level(level_index, is_ordered):
    return _NumberingLevel(str(level_index), bool(is_ordered))

_NumberingLevel = collections.namedtuple("NumberingLevel", ["level_index", "is_ordered"])