Change coding style to conform to PEP 8
Remove unused variables and imports
Mark Python script as executable

So it can now be executed without explicitly specifying the
Python interpreter.
Add creation_time metadata key and CSV column
Add filesize metadata key and CSV column
Remove duplicate variable assignment
Remove unnecessary clean() function

In almost every case, it was being run on data which was guaranteed
to be a non-empty string. The remaining few cases can be handled
manually.
Clean up path processing

This fixes running the script with a base_dir which contains
slashes. It also assigns human-readable names to the components
of the path, and adds a little bit of documentation.
Clean up metadata entry dictionaries

This doesn’t introduce any functional changes, but makes the
variable naming a little clearer and removes some unnecessary
code.
Use a comma to delimit entries in the output

Rather than an asterisk. This is more standard, and means the
import settings in spreadsheet programs don’t need to be tweaked.
Add the XO serial number to the output
Add error handling when reading metadata

Also ensure the file handles are closed as we go, so we avoid
leaking file handles. That could have caused problems when scanning
through large repositories.
Remove the ‘preview’ column from the CSV

It was always ‘NA’. Also introduce a generalised mechanism for
ignoring certain metadata keys, such as the preview.
Support dumping URIs from the Browse activity history

Optionally dump them to a second CSV file.
Calculate ‘filesize’ column from the journal entry data

As a fallback. If the metadata contains a different filesize, that’s
used in preference.
Add a Vim-style modeline to the file

So I don’t keep entering tabs by mistake.
Minor code refactoring and cleanups
Add a ‘hostname’ column to the URIs CSV file

This allows statistics to be gathered based on the hostnames accessed
when browsing the web, which is probably more useful than the precise
pages.
Rename script to ‘olpc-journal-processor’

This makes it a bit more consistent with other programs on the system.
Move sample data and output to a ‘samples’ directory