Skip to content
Tal Leming edited this page Apr 14, 2015 · 1 revision

File Structure Tests

Implementation

The infrastructure for testing is designed to make it very easy to implement a candidate file structure reader/writer. It also establishes common font data interpretation routines for all file structures. Candidate file structures are implemented as subclasses of BaseFileSystem. This base class implements the API that will be required for reading and writing font files except the actual data storage and retrieval. Those must be implemented by the subclasses. These two methods are:

def readBytesFromLocation(self, location):
	raise NotImplementedError

def writeBytesToLocation(self, data, location):
	raise NotImplementedError

Other methods may be overridden by subclasses as needed. These are noted in the documentation strings in BaseFileSystem.

Examples

Two file structures have been implemented as examples:

  • UFO 3 Package: This is exactly the same file structure as the one defined in the UFO 3 specification. This has been implemented for comparison purposes.
  • Single XML File: This implements a single XML file. Since it is all XML, this serves as an example of a way to coerce the API requests of the file system into a unique data schema.

Dependencies and Optimization

Please use modules from the Python Standard Library when possible. Third party modules may be faster, cleaner, etc. but the point of this exercise is to evaluate the results of easy implantation. Likewise, please don't optimize beyond the capabilities of the standard modules for the initial implementation. If you see places for optimization, it would be great to see them in an alternate implementation. For example:

  • singleXML.py: Basic implementation.
  • singleXMLOptimized.py : Optimized implementation.

Debugging

The core.fileSystem module contains two debugging functions that are useful when developing a subclass of BaseFileSystem: debugWriteFont and debugReadFont. These will fully write and read a basic font using a given file system. These can be implemented at the bottom of the file system implementation file like this:

if __name__ == "__main__":
	from core.fileSystem import debugWriteFont, debugReadFont
	debugWriteFont(MyFileSystem, "myfs")
	font = debugReadFont(MyFileSystem, "myfs")

For more details, see the documentation strings.

Testing

Once a file system is ready for full evaluation, add it to testAll.py.

from myfs import MyFileSystem
fileSystems["MyFS"] = MyFileSystem

Then, run the file as a script and your file structure will be evaluated along with the others.