Created
November 21, 2019 02:13
-
-
Save gokhansolak/975c80cba7ed46419145582306fd90e5 to your computer and use it in GitHub Desktop.
This program adds DmpBbo namespace to the class names in a dmp xml archive to solve boost::serialization's unregistered_class error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This program adds DmpBbo namespace to the class names | |
# in a dmp xml archive to solve boost serialization's | |
# unregistered_class error | |
# usage: | |
# change to the directory that contains dmp xml files | |
# python3 dmp_archive_updater.py | |
# it will apply the changes too all xml files in that directory | |
import glob | |
import re | |
xml_files = glob.glob("*.xml") | |
ptr = re.compile('(class_name\s*=\s*\"\s*)(DmpBbo::)?([^"]+)') | |
for fname in xml_files: | |
with open (fname, 'r+' ) as f: | |
content = f.read() | |
content_new = re.sub(ptr, r'\1DmpBbo::\3', content) | |
f.seek(0) | |
f.write(content_new) | |
f.truncate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment