We could now grab the :mod:`re` module and start constructing a regex to grab ``2.0.4``, but it
turns out this isn't necessary: :meth:`wizard.app.php.re_var` does this for us already!
-With this function in hand, writing a version detection function is pretty straightforward.
-There is one gotcha: the value that ``re_var`` returns as the second subpattern is quoted (the reasons for this
-will become clear shortly), so you will need to trim off the last and first characters or
-use :mod:`shlex`. In the case of version numbers, there are probably no escape characters
-in the string, so the former is relatively safe.
+With this function in hand, writing a version detection function is pretty straightforward:
+we have a helper function that takes a file and a regex, and matches out the version number
+for us.
.. code-block:: python
class Application(app.Application):
# ...
def detectVersion(self, deployment):
- contents = open("wp-includes/version.php").read()
- match = php.re_var("wp_version").search(contents)
- if not match: return None
- return distutils.version.LooseVersion(match.group(2)[1:-1])
+ return self.detectVersionFromFile("wp-includes/version.php", php.re_var("wp_version"))
:attr:`~wizard.app.Application.parametrized_files` is a simple list of files that the
program's installer wrote or touched during the installation process.
You've only implemented a scriptsified version for only a single version; most applications
have multiple versions--you will have to do this process again. Fortunately, the most
time consuming parts (implementing logic for :class:`wizard.app.Application`) are already,
-done so you'll only have to tweak these algorithms if the application changes their
-format.
+done so the process of :doc:`creating upgrades <upgrade>` is much simpler.
+
+There is still functionality yet undone: namely the methods for actually performing an
+upgrade are not yet implemented.
.. todo::
- Ultimately, we should have another condensed page that describes how to craft
- an update (with emphasis on what tests to perform to make sure things still
- work), and pages on how to implement upgrades and backups.
+ This needs a document.