How to use the atelier.utils.AttrDict function in atelier

To help you get started, we’ve selected a few atelier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / modlib / tickets / fixtures / tractickets.py View on Github external
Ticket = rt.modules.tickets.Ticket
    User = rt.modules.users.User
    TicketStates = rt.modules.tickets.TicketStates

    states = set()

    for n, row in enumerate(codecs.open(fn, encoding="utf-8").readlines()):
        if n == 0:
            continue  # headers
        if not row:
            continue
        cells = row.split('\t')
        if len(cells) != len(COLUMNS):
            msg = "Oops, line {0} has {1} cells".format(n, len(cells))
            raise Exception(msg)
        d = AttrDict()
        for i, k in enumerate(COLUMNS):
            d.define(k, cells[i])
        kw = dict()
        kw.update(id=d.id)
        kw.update(summary=d.summary)
        if d.reporter:
            kw.update(reporter=makeuser(d.reporter))
        else:
            kw.update(reporter=makeuser('luc'))
        if d.owner:
            kw.update(
                assigned_to=makeuser(d.owner))
        if d.component:
            prj = Project.objects.get_or_create(ref=d.component)[0]
        else:
            prj = Project.objects.get_or_create(ref='etc')[0]
github lino-framework / lino / lino_noi / lib / tickets / fixtures / tractickets.py View on Github external
Ticket = rt.modules.tickets.Ticket
    User = rt.modules.users.User
    TicketStates = rt.modules.tickets.TicketStates

    states = set()

    for n, row in enumerate(codecs.open(fn, encoding="utf-8").readlines()):
        if n == 0:
            continue  # headers
        if not row:
            continue
        cells = row.split('\t')
        if len(cells) != len(COLUMNS):
            msg = "Oops, line {0} has {1} cells".format(n, len(cells))
            raise Exception(msg)
        d = AttrDict()
        for i, k in enumerate(COLUMNS):
            d.define(k, cells[i])
        kw = dict()
        kw.update(id=d.id)
        kw.update(summary=d.summary)
        if d.reporter:
            kw.update(reporter=makeuser(d.reporter))
        else:
            kw.update(reporter=makeuser('luc'))
        if d.owner:
            kw.update(
                assigned_to=makeuser(d.owner))
        if d.component:
            prj = Project.objects.get_or_create(ref=d.component)[0]
        else:
            prj = Project.objects.get_or_create(ref='etc')[0]
github lino-framework / lino / lino_noi / fixtures / tractickets.py View on Github external
Ticket = rt.modules.tickets.Ticket
    User = rt.modules.users.User
    TicketStates = rt.modules.tickets.TicketStates

    states = set()

    for n, row in enumerate(codecs.open(fn, encoding="utf-8").readlines()):
        if n == 0:
            continue  # headers
        if not row:
            continue
        cells = row.split('\t')
        if len(cells) != len(COLUMNS):
            msg = "Oops, line {0} has {1} cells".format(n, len(cells))
            raise Exception(msg)
        d = AttrDict()
        for i, k in enumerate(COLUMNS):
            d.define(k, cells[i])
        kw = dict()
        kw.update(id=d.id)
        kw.update(summary=d.summary)
        if d.reporter:
            kw.update(user=User.objects.get_or_create(username=d.reporter)[0])
        else:
            kw.update(user=User.objects.get(username='robin'))
        if d.owner:
            kw.update(
                assigned_to=User.objects.get_or_create(username=d.owner)[0])
        if d.component:
            prj = Project.objects.get_or_create(ref=d.component)[0]
        else:
            prj = Project.objects.get_or_create(ref=d.component)[0]