Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tests_path(*comps):
return Path(__file__).parent.joinpath(*nfilter(comps))
def setUp(self):
super(WithTempDirMixin, self).setUp()
self.tmp = Path(mkdtemp())
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'])
def words(s):
return set(slug(s.strip(), remove_whitespace=False).split())
def words(s):
return set(slug(s.strip(), remove_whitespace=False).split())
def dump_rendered(self, req, fp, item, index, rendered):
body = rendered.split(to_binary('rdf:Description'))[1]
fp.write(to_binary('\n'))
def dump_rendered(self, req, fp, item, index, rendered):
body = rendered.split(to_binary('rdf:Description'))[1]
fp.write(to_binary('\n'))
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)
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)
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]),
]),