Пример #1
0
def article_citeproc_mask(article_metafields):
    # create citeproc export mapping
    metafield_to_mappingfield = {}
    for metafield in article_metafields:
        mappingfield = MappingFieldFactory(name=metafield.name)
        metafield_to_mappingfield[metafield] = mappingfield

    exportmapping = CiteprocMappingFactory()
    exportmapping.children.extend(itervalues(metafield_to_mappingfield))

    # we need the actual node ids later in this fixture, which are only assigned after a flush
    from core import db; db.session.flush()

    # create mask
    maskitems = []
    for metafield in article_metafields:
        mappingfield = metafield_to_mappingfield[metafield]
        maskitem = FieldMaskitemFactory(name=metafield.name,
                                        attrs__mappingfield=mappingfield.id,
                                        attrs__attribute=metafield.id)
        maskitem.children.append(metafield)
        maskitems.append(maskitem)
    mask = CiteprocMaskFactory()
    mask.maskitems.extend(maskitems)
    mask[u"exportmapping"] = exportmapping.id
    return mask
Пример #2
0
def article_citeproc_mask(article_metafields):
    # create citeproc export mapping
    metafield_to_mappingfield = {}
    for metafield in article_metafields:
        mappingfield = MappingFieldFactory(name=metafield.name)
        metafield_to_mappingfield[metafield] = mappingfield

    exportmapping = CiteprocMappingFactory()
    exportmapping.children.extend(itervalues(metafield_to_mappingfield))

    # we need the actual node ids later in this fixture, which are only assigned after a flush
    from core import db
    db.session.flush()

    # create mask
    maskitems = []
    for metafield in article_metafields:
        mappingfield = metafield_to_mappingfield[metafield]
        maskitem = FieldMaskitemFactory(name=metafield.name,
                                        attrs__mappingfield=mappingfield.id,
                                        attrs__attribute=metafield.id)
        maskitem.children.append(metafield)
        maskitems.append(maskitem)
    mask = CiteprocMaskFactory()
    mask.maskitems.extend(maskitems)
    mask[u"exportmapping"] = exportmapping.id
    return mask
Пример #3
0
    def _iter_loaders(self, template):
        """changes from flask:
        * removed old module blueprints
        * changed order to load templates from blueprints first (so plugins can 'overwrite' templates)
        """
        for blueprint in itervalues(self.app.blueprints):
            loader = blueprint.jinja_loader
            if loader is not None:
                yield loader, template

        loader = self.app.jinja_loader
        if loader is not None:
            yield loader, template
Пример #4
0
    def _iter_loaders(self, template):
        """changes from flask:
        * removed old module blueprints
        * changed order to load templates from blueprints first (so plugins can 'overwrite' templates)
        """
        for blueprint in itervalues(self.app.blueprints):
            loader = blueprint.jinja_loader
            if loader is not None:
                yield loader, template

        loader = self.app.jinja_loader
        if loader is not None:
            yield loader, template
Пример #5
0
    def l(self, line):
        print(cnode)
        section_names = ["Parents", "Subnodes", "Attributes", "Files"]
        section_lines = [
            [u"{} {}:  {}".format(n.id, n.name, n.type) for n in cnode.parents],
            [u"{} {}:  {}".format(n.id, n.name, n.type) for n in cnode.children],
            [u"{} = {}".format(a.name, a.value) for a in itervalues(cnode.attributes)],
            [u"{} {} {}".format(a.filename, a.type, a.mimetype) for a in cnode.files]
        ]

        for name, lines in zip(section_names, section_lines):
            print(u"\t" + name + ":")
            for line in lines:
                print(u"\t\t" + line)
Пример #6
0
    def l(self, line):
        print(cnode)
        section_names = ["Parents", "Subnodes", "Attributes", "Files"]
        section_lines = [[
            u"{} {}:  {}".format(n.id, n.name, n.type) for n in cnode.parents
        ], [
            u"{} {}:  {}".format(n.id, n.name, n.type) for n in cnode.children
        ],
                         [
                             u"{} = {}".format(a.name, a.value)
                             for a in itervalues(cnode.attributes)
                         ],
                         [
                             u"{} {} {}".format(a.filename, a.type, a.mimetype)
                             for a in cnode.files
                         ]]

        for name, lines in zip(section_names, section_lines):
            print(u"\t" + name + ":")
            for line in lines:
                print(u"\t\t" + line)