Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if fields.field_1a:
[fields.utf8_field_1a, singleEncoding] = self.decode_charset_tags(
fields.field_1a,
self.sourceEncoding,
)
fields.u_field_1a = fields.utf8_field_1a.decode('utf-8')
self.processEntryDefinition_statistics(fields, defi, raw_key)
defi_format = ''
if fields.part_of_speech_str or fields.utf8_title:
if fields.part_of_speech_str:
defi_format += '<font color="#{0}">{1}</font>'.format(
self.partOfSpeechColor,
xml_escape(fields.part_of_speech_str),
)
if fields.utf8_title:
if defi_format:
defi_format += ' '
defi_format += fields.utf8_title
defi_format += '<br>\n'
if fields.utf8_title_trans:
defi_format += fields.utf8_title_trans + '<br>\n'
if fields.utf8_transcription_50:
defi_format += '[{0}]<br>\n'.format(fields.utf8_transcription_50)
if fields.utf8_transcription_60:
defi_format += '[{0}]<br>\n'.format(fields.utf8_transcription_60)
if fields.utf8_defi:
defi_format += fields.utf8_defi
return defi_format
)
if fields.b_field_1a:
fields.u_field_1a, singleEncoding = self.decodeCharsetTags(
fields.b_field_1a,
self.sourceEncoding,
)
self.processDefiStat(fields, b_defi, b_key)
u_defi_format = ""
if fields.partOfSpeech or fields.u_title:
if fields.partOfSpeech:
u_defi_format += '<font color="#%s">%s</font>' % (
self.partOfSpeechColor,
xml_escape(fields.partOfSpeech),
)
if fields.u_title:
if u_defi_format:
u_defi_format += " "
u_defi_format += fields.u_title
u_defi_format += "<br>\n"
if fields.u_title_trans:
u_defi_format += fields.u_title_trans + "<br>\n"
if fields.u_transcription_50:
u_defi_format += "[%s]<br>\n" % fields.u_transcription_50
if fields.u_transcription_60:
u_defi_format += "[%s]<br>\n" % fields.u_transcription_60
if fields.u_defi:
u_defi_format += fields.u_defi
return u_defi_format
def replace_html_entry(m):
"""
Same as replace_html_entry_no_escape, but escapes result string
Only <, >, & characters are escaped.
"""
res = replace_html_entry_no_escape(m)
if m.group(0) == res: # conversion failed
return res
else:
return xml_escape(res)
def replaceHtmlEntryCB(u_match):
"""
u_match: instance of _sre.SRE_Match
Same as replaceHtmlEntryNoEscapeCB, but escapes result string
Only <, >, & characters are escaped.
"""
u_res = replaceHtmlEntryNoEscapeCB(u_match)
if u_match.group(0) == u_res: # conversion failed
return u_res
else:
return xml_escape(u_res)
def write(glos, filename):
from pyglossary.xml_utils import xml_escape
fp = open(filename, 'w')
fp.write('\n\n')
for item in infoKeys:
fp.write('<'+item+'>'+str(glos.getInfo(item))+'')
fp.write('\n')
for entry in glos:
words = entry.getWords()
word, alts = words[0], words[1:]
defi = entry.getDefi()
#fp.write(""+word+""+ defi+"\n")
fp.write('\n %s\n'%xml_escape(word))
for alt in alts:
fp.write(' %s\n'%xml_escape(alt))
fp.write(' %s\n\n'%xml_escape(defi))
fp.write("\n")
fp.close()
def write(glos, filename):
from pyglossary.xml_utils import xml_escape
fp = open(filename, 'w')
fp.write('\n\n')
for item in infoKeys:
fp.write('<'+item+'>'+str(glos.getInfo(item))+'')
fp.write('\n')
for entry in glos:
words = entry.getWords()
word, alts = words[0], words[1:]
defi = entry.getDefi()
#fp.write(""+word+""+ defi+"\n")
fp.write('\n %s\n'%xml_escape(word))
for alt in alts:
fp.write(' %s\n'%xml_escape(alt))
fp.write(' %s\n\n'%xml_escape(defi))
fp.write("\n")
fp.close()
def write(glos, filename):
from pyglossary.xml_utils import xml_escape
fp = open(filename, 'w')
fp.write('\n\n')
for item in infoKeys:
fp.write('<'+item+'>'+str(glos.getInfo(item))+'')
fp.write('\n')
for entry in glos:
words = entry.getWords()
word, alts = words[0], words[1:]
defi = entry.getDefi()
#fp.write(""+word+""+ defi+"\n")
fp.write('\n %s\n'%xml_escape(word))
for alt in alts:
fp.write(' %s\n'%xml_escape(alt))
fp.write(' %s\n\n'%xml_escape(defi))
fp.write("\n")
fp.close()