View Single Post
Old 03-17-2022, 11:33 PM   #280
SidJnsn
Member
SidJnsn began at the beginning.
 
Posts: 23
Karma: 10
Join Date: Mar 2022
Device: iPad 8
Dead, but not problematic, code

I do understand how it works and have been using the debugger. However, I did get a bit tangled in my own underwear!

There is no functional error; it is just that the first try block below will always fail but, as you say, OWI is all you need from this section of code, and that works fine.

try: # Modified by DaltonST
#~ work = xdoc.getElementsByTagName('work')[0]
work = iterate_work_values(xdoc)
if DEBUG: print("first work = ",work.attributes["title"].value) #Added by Sid

if work:
try:
y = work.childNodes[0]; #this will always error, making this try block dead code #http://www.w3schools.com/xml/dom_nodes_get.asp
z = y.nodeValue #Sid - work does not have child nodes
z = unicode_type(z) #Sid - in multi-work, oclc only appears as an attribute of the edition element; not addressed here
z = z.strip()
if z.isdigit():
if len(z) > 5:
oclc_other_return = z
if DEBUG: print("oclc-other is: ", unicode_type(oclc_other_return))
except # will always get this exception. No functional harm though. OWI is all we need here. Sid
if DEBUG: print("oclc-other is: ", unicode_type(oclc_other_return))
pass

SidJnsn is offline   Reply With Quote