Skip to content

Instantly share code, notes, and snippets.

@gokhansolak
Created November 21, 2019 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokhansolak/975c80cba7ed46419145582306fd90e5 to your computer and use it in GitHub Desktop.
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
#!/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