March 5, 2013
#6 PatchIt! Settings file revision for Version 1.1 Stable
Just a small note concerning the settings file. Usually when apps use a file for settings and not the registry, there is some line in the file (usually line 1) denoting the program it belongs to. As another one of my oversights when creating PatchIt!, I did not
include such a line in the settings. This was due to the complex setup I was using to read the file to read the first-run indicator and LEGO Racers installation path, and write all the details. However, this situation has changed now that I’ve switched to the
linecache module for reading the file and the new Python 3
print() function for writing the file. I am now free to add a new line denoting the program (PatchIt!) it belongs to. It’s another backward incompatible change, so I will again hold off the change until V1.1.
The new file will have three lines instead of two, and the new (first) line will not even be used unless the need arises. The new layout for the settings file is as follows. Line numbers are added for clarity, they are not really written.
(0) // PatchIt! V1.1 series settings
(2) C:/Program Files (x86)/LEGO/Racers 1999
“V1.1 series” because that is when it was first created (then I guess I shouldn’t use “series”…). As it can be seen, nothing else has been changed. Updating the code to use this new format is a snap (as already explained), so this can be done with no hassle and at the beginning of the V1.1 process.
March 6, 2013 addition
This was brought to my attention this afternoon, and it bears mentioning. Instead of using a plain text file, why not use a XML file? While many programs do indeed use a file for it’s settings, only a few use custom formats. The majority of those programs use an XML file. As it turns out, multiple Python modules to handle XML files exist, and one module in particular,
xml.etree.elementtree, would best suit this need. I have not tried the module out yet, but I will do it soon so I can have some more Python experience. An XML document would suit as a
PatchIt! settings file. I could have a
tag to denote the current state of the first-run process, for example. The only thing that would prohibit using an XML would being able to get a clean folder path to direct PatchIt! where to install a patch. I find that a lot of Python modules return a list or tuple (the
winreg module I’m using for ICU does this). If it returns a list or tuple, I’ll have a lot of cleanup to do to get a valid folder path. If it returns a normal string and just has a
\n, \t or similar (like
linecache does for a plain text file, I can quickly get a folder path. Again, I have not even tested this module, so it could work as I need it to. Just something to look into.