Esempio n. 1
0
 def _parse(ds, lines):
     stack = [struct(indent=0, data=ds, lastkey=None)]
     while len(lines):
         line = lines[0]
         l = line.lstrip()
         indent = len(line) - len(l)
         spl = l.rstrip().split(None, 1)
         if len(spl) != 2:
             break
         lines.pop(0)
         assert indent >= 0
         if indent < stack[-1].indent:
             while indent < stack[-1].indent:
                 s = stack.pop()
                 assert len(stack) > 0
                 assert stack[-1].lastkey is not None
                 assert stack[-1].data.__data[stack[-1].lastkey][-1].sub is None
                 if len(s.data.__data):
                     stack[-1].data.__data[stack[-1].lastkey][-1].sub = s.data
             if indent != stack[-1].indent:
                 raise InputError('illegal indentation', line=line)
         elif indent > stack[-1].indent:
             if stack[-1].lastkey is None:
                 raise InputError('illegal indentation', line=line)
             stack.append((struct(indent=indent, data=dataset(), lastkey=None)))
         key, value = spl
         stack[-1].data.__data[key] = struct(value=value, sub=None)
         stack[-1].lastkey = key
     while len(stack) > 1:
         s = stack.pop()
         assert stack[-1].lastkey is not None
         assert stack[-1].data.__data[stack[-1].lastkey][-1].sub is None
         if len(s.data.__data):
             stack[-1].data.__data[stack[-1].lastkey][-1].sub = s.data
Esempio n. 2
0
 def __init__(self, model):
     self.model = model
     self.world = World()
     self.last_country = None
     self.defaults = struct(place=None, keywords=[])
     self.dfactory = {}
     self.dfactory_default = Data_factory_context()
     self.last_dfactory = None
     self._no_suspend = False
     self._tasks = set()
Esempio n. 3
0
 def __init__(self, data=None, loc=None):
     self.__data = multidict()
     self._loc = loc
     if data is not None:
         try:
             items = iter(data.items())
         except AttributeError:
             items = iter(data)
         for key, value in items:
             if not isinstance(key, str):
                 raise TypeError('dataset key must be a string')
             if isinstance(value, tuple) and len(value) == 2:
                 if not isinstance(value[0], str):
                     raise TypeError('dataset value must be a string')
                 if not isinstance(value[1], dataset):
                     raise TypeError('dataset sub must be a dataset')
                 self.__data[key] = struct(value=value[0], sub=value[1])
             else:
                 if not isinstance(value, str):
                     raise TypeError('dataset value must be a string')
                 self.__data[key] = struct(value=value, sub=None)
Esempio n. 4
0
    Paragraph,
    Flowable,
    Spacer,
    FrameBreak,
    ActionFlowable,
)
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT
from reportlab.lib.units import cm, mm
from reportlab.pdfbase.pdfmetrics import stringWidth

paper_size = (210 * mm, 297 * mm)  # landscape A4
paper_margins = (7.5 * mm, 7.5 * mm)

page_sizes = {
    "filofax": struct(size=(9.4 * cm, 17.1 * cm), margin_left=1 * cm),
    "agenda-juana": struct(size=(7.6 * cm, 13.6 * cm), margin_left=7 * mm),
}

sections = {
    "none": None,
    "single": (
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",