def generateChecksumFiles(filepath): """Generate md5 and sha1 checksums for a maven repository artifact""" if os.path.splitext(filepath)[1] in ('.md5', '.sha1'): return if not os.path.isfile(filepath): return for ext, sum_constr in (('.md5', hashlib.md5()), ('.sha1', hashlib.sha1())): sumfile = filepath + ext if os.path.exists(sumfile): continue checksum = maven_repo_util.getChecksum(filepath, sum_constr) with open(sumfile, 'w') as sumobj: sumobj.write(checksum)
if releaseVersion: content += "<release>%s</release>" % releaseVersion else: content += "<release/>" content += "<versions>" for version in versions: content += "<version>%s</version>" % version content += "</versions>" content += "<lastUpdated>%s</lastUpdated>" % last_updated content += "</versioning>" content += "</metadata>" ugly_xml = parseString(content).toprettyxml(indent=' ') text_re = re.compile('>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL) pretty_xml = text_re.sub('>\g<1></', ugly_xml) md_file = "%s/maven-metadata.xml" % n_dir f = open(md_file, "w") f.write(pretty_xml) f.close() for ext, sum_constr in (('.md5', hashlib.md5()), ('.sha1', hashlib.sha1())): sumfile = md_file + ext if os.path.exists(sumfile): continue checksum = maven_repo_util.getChecksum(md_file, sum_constr) with open(sumfile, 'w') as sumobj: sumobj.write(checksum)