How to use clldutils - 10 common examples

To help you get started, we’ve selected a few clldutils 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 lmaurits / BEASTling / tests / util.py View on Github external
def tests_path(*comps):
    return Path(__file__).parent.joinpath(*nfilter(comps))
github lmaurits / BEASTling / tests / util.py View on Github external
def setUp(self):
        super(WithTempDirMixin, self).setUp()
        self.tmp = Path(mkdtemp())
github clld / glottolog3 / glottolog3 / scripts / import_refs.py View on Github external
else:
                changed = True
                ref = Ref(name='%s %s' % (kw.get('author', 'na'), kw.get('year', 'nd')), **kw)

            ref.description = ref.title or ref.booktitle
            originator = ref.author or ref.editor or 'Anonymous'
            ref.name = '%s %s' % (originator, ref.year or 'n.d.')

            a, r = update_relationship(
                ref.macroareas,
                [macroarea_map[name] for name in
                 set(filter(None, [s.strip() for s in kw['jsondata'].get('macro_area', '').split(',')]))])
            changed = changed or a or r

            src = [s.strip() for s in kw['jsondata'].get('src', '').split(',')]
            prv = {provider_map[slug(s)] for s in src if s}
            if set(ref.providers) != prv:
                ref.providers = list(prv)
                changed = True

            a, r = update_relationship(
                ref.doctypes,
                [doctype_map[m.group('name')] for m in
                 DOCTYPE_PATTERN.finditer(kw['jsondata'].get('hhtype', ''))])
            changed = changed or a or r

            if not update:
                stats.update(['new'])
                DBSession.add(ref)
            elif changed:
                stats.update(['updated'])
github clld / clld / src / clld / scripts / util.py View on Github external
def words(s):
        return set(slug(s.strip(), remove_whitespace=False).split())
github clld / clld / src / clld / scripts / internetarchive.py View on Github external
def words(s):
        return set(slug(s.strip(), remove_whitespace=False).split())
github clld / clld / src / clld / web / adapters / download.py View on Github external
def dump_rendered(self, req, fp, item, index, rendered):
        body = rendered.split(to_binary('rdf:Description'))[1]
        fp.write(to_binary('\n'))
github clld / clld / src / clld / web / adapters / download.py View on Github external
def dump_rendered(self, req, fp, item, index, rendered):
        body = rendered.split(to_binary('rdf:Description'))[1]
        fp.write(to_binary('\n'))
github clld / glottolog3 / glottolog3 / adapters.py View on Github external
def dump_rendered(self, req, fp, item, index, rendered):
        header, body = rendered.split(to_binary('\n\n'), 1)
        if index == 0:
            fp.write(header)
            fp.write(to_binary('\n\n'))
        fp.write(body)
github clld / glottolog3 / glottolog3 / adapters.py View on Github external
def dump_rendered(self, req, fp, item, index, rendered):
        header, body = rendered.split(to_binary('\n\n'), 1)
        if index == 0:
            fp.write(header)
            fp.write(to_binary('\n\n'))
        fp.write(body)
github cldf / cldf / scripts / make_defaults.py View on Github external
for e in read_terms().iter():
        if ns('rdf:about') in e.attrib:
            lname = e.attrib[ns('rdf:about')].split('#')[-1]
            if e.tag == ns('rdfs:Class') and lname.endswith('Table'):
                tables[lname] = e
            elif e.tag == ns('rdf:Property'):
                columns[lname] = e

    comps = {}
    for subdir, spec in COMPONENTS.items():
        table = make_table(tables.pop(spec['table']))
        for c, req in spec['columns']:
            table['tableSchema']['columns'].append(make_column(columns[c], req))
        comps[subdir] = table
        dump(
            table,
            REPO_DIR.joinpath(
                'components', subdir, '{0}-metadata.json'.format(spec['table'])),
            indent=4)

    for subdir, comprefs in MODULES.items():
        dump(
            OrderedDict([
                ("@context", ["http://www.w3.org/ns/csvw", {"@language": "en"}]),
                ("dc:conformsTo",
                 "http://cldf.clld.org/v1.0/terms.rdf#{0}".format(subdir)),
                ("dialect", {
                    "commentPrefix": None,
                }),
                ("tables", [comps[ref] for ref in comprefs]),
            ]),