本文整理汇总了Python中BibleOrgSysGlobals.getFlattenedXML方法的典型用法代码示例。如果您正苦于以下问题:Python BibleOrgSysGlobals.getFlattenedXML方法的具体用法?Python BibleOrgSysGlobals.getFlattenedXML怎么用?Python BibleOrgSysGlobals.getFlattenedXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BibleOrgSysGlobals
的用法示例。
在下文中一共展示了BibleOrgSysGlobals.getFlattenedXML方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validateEntry
# 需要导入模块: import BibleOrgSysGlobals [as 别名]
# 或者: from BibleOrgSysGlobals import getFlattenedXML [as 别名]
def validateEntry( self, entry ):
"""
Check/validate the given Strongs Greek lexicon entry.
"""
if BibleOrgSysGlobals.debugFlag: assert entry.tag == "entry"
BibleOrgSysGlobals.checkXMLNoText( entry, entry.tag, "na19" )
BibleOrgSysGlobals.checkXMLNoTail( entry, entry.tag, "kaq9" )
# Process the entry attributes first
strongs5 = None
for attrib,value in entry.items():
if attrib == "strongs":
strongs5 = value
if BibleOrgSysGlobals.verbosityLevel > 2: print( "Validating {} entry…".format( strongs5 ) )
else: logging.warning( "Unprocessed {!r} attribute ({}) in main entry element".format( attrib, value ) )
if BibleOrgSysGlobals.debugFlag: assert len(strongs5)==5 and strongs5.isdigit()
entryResults = {}
entryString = ""
gettingEssentials = True
for j, element in enumerate( entry ):
#print( strongs5, j, element.tag, repr(entryString) )
if element.tag == "strongs":
if BibleOrgSysGlobals.debugFlag: assert gettingEssentials and j==0 and element.text
BibleOrgSysGlobals.checkXMLNoAttributes( element, element.tag, "md3d" )
if strongs5!='02717' and (3203 > int(strongs5) > 3302):
BibleOrgSysGlobals.checkXMLNoTail( element, element.tag, "f3g7" )
BibleOrgSysGlobals.checkXMLNoSubelements( element, element.tag, "m56g" )
strongs = element.text
if BibleOrgSysGlobals.debugFlag: assert strongs5.endswith( strongs )
if element.tail and element.tail.strip(): entryString += element.tail.strip()
elif element.tag == "greek":
location = "greek in Strongs " + strongs5
BibleOrgSysGlobals.checkXMLNoText( element, location, "jke0" )
#BibleOrgSysGlobals.checkXMLNoTail( element, location, "ks24" )
BibleOrgSysGlobals.checkXMLNoSubelements( element, location, "df35" )
# Process the attributes
translit = greek = beta = None
for attrib,value in element.items():
if attrib=="translit": translit = value
elif attrib=="unicode": greek = value
elif attrib=="BETA": beta = value
else: logging.warning( "scs4 Unprocessed {!r} attribute ({}) in {}".format( attrib, value, location ) )
if BibleOrgSysGlobals.debugFlag: assert greek and translit and beta
if 'word' not in entryResults: # This is the first/main entry
if BibleOrgSysGlobals.debugFlag: assert gettingEssentials and j==1
BibleOrgSysGlobals.checkXMLNoTail( element, location, "ks24" )
entryResults['word'] = (greek, translit, beta)
else:
#print( "Have multiple greek entries in " + strongs5 )
if BibleOrgSysGlobals.debugFlag: assert j > 2
gettingEssentials = False
entryString += ' ' + BibleOrgSysGlobals.getFlattenedXML( element, strongs5 ) #.replace( '\n', '' )
elif element.tag == "pronunciation":
location = "pronunciation in Strongs " + strongs5
BibleOrgSysGlobals.checkXMLNoText( element, location, "iw9k" )
BibleOrgSysGlobals.checkXMLNoSubelements( element, location, "0s20" )
# Process the attributes
pronunciation = None
for attrib,value in element.items():
if attrib=="strongs": pronunciation = value
else: logging.warning( "scs4 Unprocessed {!r} attribute ({}) in {}".format( attrib, value, location ) )
if gettingEssentials:
#BibleOrgSysGlobals.checkXMLNoTail( element, location, "kd02" )
if BibleOrgSysGlobals.debugFlag:
assert j == 2
assert pronunciation
assert 'pronunciation' not in entryResults
entryResults['pronunciation'] = pronunciation
else:
if BibleOrgSysGlobals.debugFlag: assert j>2 and not gettingEssentials
if element.tail and element.tail.strip(): entryString += element.tail.strip().replace( '\n', '' )
elif element.tag == "strongs_derivation":
location = "strongs_derivation in Strongs " + strongs5
BibleOrgSysGlobals.checkXMLNoAttributes( element, location, "jke0" )
BibleOrgSysGlobals.checkXMLNoTail( element, location, "ks24" )
derivation = BibleOrgSysGlobals.getFlattenedXML( element, strongs5 ).replace( '\n', '' )
#print( strongs5, "derivation", repr(derivation) )
if BibleOrgSysGlobals.debugFlag:
assert derivation and '\t' not in derivation and '\n' not in derivation
entryString += derivation
elif element.tag == "strongs_def":
location = "strongs_def in Strongs " + strongs5
BibleOrgSysGlobals.checkXMLNoAttributes( element, location, "jke0" )
BibleOrgSysGlobals.checkXMLNoTail( element, location, "jd28" )
definition = BibleOrgSysGlobals.getFlattenedXML( element, strongs5 ).replace( '\n', '' )
#print( strongs5, "definition", repr(definition) )
if BibleOrgSysGlobals.debugFlag:
assert definition and '\t' not in definition and '\n' not in definition
entryString += definition
elif element.tag == "kjv_def":
location = "kjv_def in Strongs " + strongs5
BibleOrgSysGlobals.checkXMLNoAttributes( element, location, "jke0" )
#BibleOrgSysGlobals.checkXMLNoTail( element, location, "8s2s" )
#BibleOrgSysGlobals.checkXMLNoSubelements( element, location, "dvb2" )
KJVdefinition = BibleOrgSysGlobals.getFlattenedXML( element, strongs5 ).replace( '\n', '' )
#print( strongs5, "KJVdefinition", repr(KJVdefinition), repr(entryString) )
if BibleOrgSysGlobals.debugFlag: assert KJVdefinition and '\t' not in KJVdefinition and '\n' not in KJVdefinition
entryString += KJVdefinition
elif element.tag == "strongsref":
#.........这里部分代码省略.........