Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def alt_translation(sentence):
res = ''
if sentence.jsondata.get('alt_translation'):
text = sentence.jsondata['alt_translation']
name = ''
if ALT_TRANSLATION_LANGUAGE_PATTERN.match(text):
name, text = [t.strip() for t in text.split(':', 1)]
name = HTML.span(name + ': ')
res = HTML.div(name, HTML.span(text, class_='translation'))
return res
for i, ref in enumerate(getattr(obj, 'references', [])):
if ref.source:
gbs = gbs_link(ref.source, pages=ref.description)
if i > 0:
chunks.append('; ')
chunks.append(HTML.span(
link(req, ref.source),
HTML.span(
': %s' % ref.description if ref.description else '',
class_='pages'),
' ' if gbs else '',
gbs,
class_='citation',
))
if chunks:
return HTML.span(*chunks)
return ''
for match in GLOSS_ABBR_PATTERN.finditer(gloss):
if match.start() > end:
res.append(gloss[end:match.start()])
abbr = match.group('abbr')
if abbr in abbrs:
explanation = abbrs[abbr]
if match.group('personprefix'):
explanation = '%s %s' % (
person_map[match.group('personprefix')], explanation)
if match.group('personsuffix'):
explanation = '%s %s' % (
explanation, person_map[match.group('personsuffix')])
res.append(HTML.span(
HTML.span(gloss[match.start():match.end()].lower(), class_='sc'),
**{'data-hint': explanation, 'class': 'hint--bottom'}))
else:
res.append(abbr)
end = match.end()
res.append(gloss[end:])
return filter(None, res)
HTML.label(
HTML.input(
class_="stay-open",
type="checkbox",
checked="checked",
onclick=helpers.JS_CLLD.mapToggleLayer(
self.eid, layer.id, helpers.JS("this"))),
getattr(layer, 'marker', ''),
layer.name,
class_="checkbox inline stay-open",
style="margin-left: 5px; margin-right: 5px;",
),
representation,
])
if total:
items.append(HTML.span(HTML.b(str(total)), **repr_attrs))
yield Legend(
self,
'layers',
items,
label='Legend',
stay_open=True,
item_attrs=dict(style='clear: right'))
items = []
for size in [15, 20, 30, 40]:
attrs = dict(name="iconsize", value=str(size), type="radio")
if size == self.options.get('icon_size', 30):
attrs['checked'] = 'checked'
items.append(HTML.label(
HTML.input(onclick=helpers.JS_CLLD.mapResizeIcons(self.eid), **attrs),
HTML.img(
height=str(size),
def linked_references(req, obj):
chunks = []
for i, ref in enumerate(getattr(obj, 'references', [])):
if ref.source:
gbs = gbs_link(ref.source, pages=ref.description)
if i > 0:
chunks.append('; ')
chunks.append(HTML.span(
link(req, ref.source),
HTML.span(
': %s' % ref.description if ref.description else '',
class_='pages'),
' ' if gbs else '',
gbs,
class_='citation',
))
if chunks:
return HTML.span(*chunks)
return ''
def desc(text):
return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;')
def coins(req, obj, label=''):
if not isinstance(obj, bibtex.Record):
adapter = get_adapter(interfaces.IMetadata, obj, req, ext='md.bib')
if not adapter:
return label
obj = adapter.rec(obj, req)
co = ContextObject.from_bibtex('clld', obj)
return HTML.span(label, **co.span_attrs())
if match.start() > end:
res.append(gloss[end:match.start()])
abbr = match.group('abbr')
if abbr in abbrs:
explanation = abbrs[abbr]
if match.group('personprefix'):
explanation = '%s %s' % (
person_map[match.group('personprefix')], explanation)
if match.group('personsuffix'):
explanation = '%s %s' % (
explanation, person_map[match.group('personsuffix')])
res.append(HTML.span(
HTML.span(gloss[match.start():match.end()].lower(), class_='sc'),
**{'data-hint': explanation, 'class': 'hint--bottom'}))
else:
res.append(abbr)
end = match.end()
res.append(gloss[end:])
return filter(None, res)
def coins(req, obj, label=''):
if not isinstance(obj, bibtex.Record):
adapter = get_adapter(interfaces.IMetadata, obj, req, ext='md.bib')
if not adapter:
return label
obj = adapter.rec(obj, req)
co = ContextObject.from_bibtex('clld', obj)
return HTML.span(label, **co.span_attrs())
for match in GLOSS_ABBR_PATTERN.finditer(gloss):
if match.start() > end:
res.append(gloss[end:match.start()])
abbr = match.group('abbr')
if abbr in abbrs:
explanation = abbrs[abbr]
if match.group('personprefix'):
explanation = '%s %s' % (
person_map[match.group('personprefix')], explanation)
if match.group('personsuffix'):
explanation = '%s %s' % (
explanation, person_map[match.group('personsuffix')])
res.append(HTML.span(
HTML.span(gloss[match.start():match.end()].lower(), class_='sc'),
**{'data-hint': explanation, 'class': 'hint--bottom'}))
else:
res.append(abbr)
end = match.end()
res.append(gloss[end:])
return filter(None, res)