in scripts/project2attic.py [0:0]
def update_pmc_xml(pmc):
xmlfile = join(datadir,'committees.xml')
xmlfilet = join(datadir,'committees.xml.t')
print("Updating committees.xml")
found = 0
with open(xmlfile,'r') as r, open(xmlfilet,'w') as w:
for l in r:
m = re.search("^(\s+)<location>(.+)</location",l)
if m:
indent = m.group(1)
url = m.group(2)
# match one of:
# committees/<pmc>.rdf
# https://ofbiz.apache.org/<pmc>/...
# http://svn.apache.org/repos/asf/<pmc>/...
regex = "^(committees/%s\.rdf|https?://%s\.apache\.org/.+|https?://svn.apache.org/repos/asf/%s/.+)$" % (pmc,pmc,pmc)
if re.search(regex, url, flags=re.IGNORECASE):
print("Found %s at %s" % (pmc, url))
if url.startswith('committees/'):
new = url.replace('committees/','committees-retired/')
subprocess.run(["svn", "mv", "data/%s" % url, "data/%s" % new])
url = new
w.write("%s<!-- Retired: location>%s</location -->\n" % (indent, url))
found += 1
continue
w.write(l) # write the original line
if found == 1:
print("Found OK")
os.system("diff %s %s" % (xmlfile, xmlfilet))
os.rename(xmlfilet, xmlfile)
elif found > 1:
print("Matched more than once %d" % found)
os.remove(xmlfilet)
else:
print("Not found")
os.remove(xmlfilet)