How to Unpickle Komodo’s “xmlc” files

How to Unpickle Komodo's "xmlc" Files

A customer wondered how to get at the state information Komodo saves between sessions. There are three files in saved in the profile directory:
prefs.xml
doc-state.xmlc
view-state.xmlc
The “xmlc” files are pickled XML files, and are essentially unreadable outside Komodo. They’re hard to unpickle outside Komodo, as they contain instances of objects Komodo knows about. But it’s easy to write a macro to do the unpickling:

var dirSvc = Components.classes["@activestate.com/koDirs;1"].getService(Components.interfaces.koIDirs);
var userDataDir = dirSvc.userDataDir;
var osPathSvc = Components.classes["@activestate.com/koOsPath;1"].
getService(Components.interfaces.koIOsPath);
var factory = Components.classes["@activestate.com/koPreferenceSetObjectFactory;1"].
getService();
//

var targetDir = “/tmp/”;

// Would be better to get the list of *.xmlc files where

// there’s no .xml file in place.

var pickledFiles = [‘doc-state.xml’, ‘view-state.xml’];

for (var file, i = 0; file = pickledFiles[i]; i++) {

var fullPath = osPathSvc.join(userDataDir, file);

var targetPath = osPathSvc.join(targetDir, file);

factory.deserializeFile(fullPath).serializeToFile(targetPath);

}



I’ve deliberately had the macro write the plain-text XML files
into a scratch directory, so I can modify the files.
For extra fun, Komodo is flexible when it loads prefs — if it
can’t find a .xmlc file, it will look for a .xml file with
the same root, and load prefs from that instead.
Title photo courtesy of Photo Mix on Pixabay.

Recent Posts

Webinar - Walking Dead Past Python EOL
Walking Dead Past Python EOL

Stuck living with zombie applications running on Python 2, 3.7 or other past-EOL software? Learn the case for maintaining vs. upgrading, and how you can adopt a culture of getting current and staying current, with lessons from our customers.

Read More
Scroll to Top