How to use atelier - 10 common examples

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 / utils / sql.py View on Github external
# find max
            e = d[max(d, key=lambda x: x.time)]
            p(e, **options)
            print("-------------------")
        else:
            if show_times:
                headers = 'total_time count table stmt_type time'.split()
                values = sorted(d.values(), key=lambda x: -x.total_time)
            else:
                headers = 'table stmt_type count'.split()
                values = sorted(d.values(), key=lambda x: x.table)
            rows = []
            for e in values:
                rows.append([getattr(e, h) for h in headers])
                rows.sort()
            print(rstgen.table(headers, rows))
    else:
        print("No sql queries found")
github lino-framework / lino / lino / api / selenium.py View on Github external
def screenshot(self, name, caption, before='', after=''):
        
        filename = self.screenshot_root.child(name)
        if not self.driver.get_screenshot_as_file(filename):
            print("Failed to write {0}".format(filename))
            sys.exit(-1)
        print("Wrote screenshot {0} ...".format(filename))
        before = unindent(before)
        after = unindent(after)
        self.screenshots.append((name, caption, before, after))
github lino-framework / lino / lino / api / selenium.py View on Github external
def screenshot(self, name, caption, before='', after=''):
        
        filename = self.screenshot_root.child(name)
        if not self.driver.get_screenshot_as_file(filename):
            print("Failed to write {0}".format(filename))
            sys.exit(-1)
        print("Wrote screenshot {0} ...".format(filename))
        before = unindent(before)
        after = unindent(after)
        self.screenshots.append((name, caption, before, after))
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]
github lino-framework / lino / docs / conf.py View on Github external
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default; values that are commented out
# serve to show the default.

extensions = []

from lino.sphinxcontrib import configure
configure(globals())

extensions += ['lino.sphinxcontrib.logo']
extensions += ['lino.sphinxcontrib.base']


from atelier.sphinxconf import interproject
interproject.configure(globals(), 'atelier')
intersphinx_mapping['cg'] = ('https://community.lino-framework.org/', None)

from lino import SETUP_INFO

# intersphinx_mapping = {}
# from importlib import import_module
# for n in 'atelier lino_book'.split():
#     m = import_module(n)
#     n = n.replace('_', "")
#     intersphinx_mapping[n] = (m.intersphinx_urls['docs'], None)

# General configuration
# ---------------------

# General information about the project.
project = "Lino docs"
github lino-framework / lino / lino / utils / html2rst.py View on Github external
rst += ' '
    else:
        if e.tag not in IGNORED_TAGS:
            raise Exception("20150723 %s" % e.tag)

    if e.tail:
        rst += e.tail

    return rst


# def html2rst(e):
#     return _html2rst(e).strip()


class RstTable(rstgen.Table):

    """\
A table containing elementtree HTML:

.. complextable::
  :header:

  Code  Result 

  >>> from lino.utils.xmlgen.html import E
  >>> headers = [E.p("A ", E.b("formatted"), " header"), "A plain header"]
  >>> rows = [[1,2], [3,4]]
  >>> print (RstTable(headers).to_rst(rows))
  ======================== ================
   A **formatted** header   A plain header
  ------------------------ ----------------
github lino-framework / lino / lino / core / renderer.py View on Github external
def menu2rst(self, ar, mnu, level=1):
        """Used by :meth:`show_menu`."""

        if not isinstance(mnu, Menu):
            return str(mnu.label)

        has_submenus = False
        for i in mnu.items:
            if isinstance(i, Menu):
                has_submenus = True
        items = [self.menu2rst(ar, mi, level + 1) for mi in mnu.items]
        if has_submenus:
            s = rstgen.ul(items).strip() + '\n'
            if mnu.label is not None:
                s = str(mnu.label) + ' :\n\n' + s
        else:
            s = ', '.join(items)
            if mnu.label is not None:
                s = str(mnu.label) + ' : ' + s
        return s
github lino-framework / lino / lino / sphinxcontrib / actordoc.py View on Github external
items = []
    for tb in model_reports:
        desc = actor_ref(tb)
        #~ label = str(tb.title or tb.label)
        #~ desc += " (%s)" % str(tb)
        desc += " (%s)" % typeref(tb)
        # mi = find_menu_item(tb.default_action)
        mi = user_type.find_menu_item(tb.default_action)
        if mi is not None:
            desc += _(" (Menu %s)") % menuselection(mi)
            #~ print(unicode(mi.label).strip())
        if tb.help_text:
            desc += " -- " + str(tb.help_text).strip()

        items.append(desc)
    return rstgen.ul(items)