last_extent_altrender = "" for i, physdesc in enumerate(physdescs): if len(list(physdesc)) != 1: last_extent_altrender = "" continue if physdesc[0].tag != "extent": last_extent_altrender = "" continue attribute = physdesc[0].attrib.get("altrender") if last_extent_altrender != "materialtype spaceoccupied": last_extent_altrender = attribute continue if attribute != "carrier": last_extent_altrender = attribute continue # we can now assume we've narrowed it down to the case we're looking for physdescs[i - 1].append(physdesc[0]) physdesc.getparent().remove(physdesc) last_extent_altrender = attribute ead_dir.apply_function_to_dir( fix_portions, output_dir= r"C:\Users\wboyle\PycharmProjects\without-reservations\Real_Masters_all")
physdescs = did.xpath("physdesc") if len(physdescs) <= 1: continue last_extent_altrender = "" for i, physdesc in enumerate(physdescs): if len(list(physdesc)) != 1: last_extent_altrender = "" continue if physdesc[0].tag != "extent": last_extent_altrender = "" continue attribute = physdesc[0].attrib.get("altrender") if last_extent_altrender != "materialtype spaceoccupied": last_extent_altrender = attribute continue if attribute != "carrier": last_extent_altrender = attribute continue # we can now assume we've narrowed it down to the case we're looking for physdescs[i - 1].append(physdesc[0]) physdesc.getparent().remove(physdesc) last_extent_altrender = attribute ead_dir.apply_function_to_dir(fix_portions, output_dir=r"C:\Users\wboyle\PycharmProjects\without-reservations\Real_Masters_all")