upverter/schematic-file-converter — pull request #95 by elbaschid (2012-05-13 08:26:46+00:00)
Title: Storing ``style`` data and handling GEDA paths correctly

This pull request includes the following three parts:

1. Refactoring of the GEDA libary
2. Storing of style data in OpenJSON
3. Improved handling of path data.

Refactoring
-----------

I decided to clean up the parser and writer to reduce the amount of duplicate code. I created a new module ``geda_commands`` that lives in ``upconvert.parser``. It provides classes for each GEDA command and a list of parameters with default values and datatype. This simplifies the processing in the parser, the generation of GEDA commands in the writer and the separation of parameters to be stored in the ``styles`` dictionary.
Currently three types of parameters are provided ``GEDAParamater``, ``GEDAStyleParamter`` and ``GEDAExtraParameter``. A parameter has a name that is prefixed with its type, e.g. ``style_`` for style parameters. The style parameters are stored in the ``styles`` dictionary of an object together with the extra parameters. Extra parameters are (at this time) only used for path IDs that can be used to identify shapes that belong to the same path in OpenJSON. The regular ``GEDAParameter`` is used as before and converted in corresponding units or values in OpenJSON.

Storing Style Data
------------------

To store style data I added ``styles`` dictionaries to core objects as discussed. Currently all sublcasses of ``Shape`` and the ``Pin`` class have this property. I also extended the serialisation methods for these classes and the OpenJSON parser to handle ``styles`` dictionaries. On the GEDA side, I store all style and extra parameters in this dictionary as described above.

Improved GEDA path handling
---------------------------

With the new command and parameter structure, I changed the handling of GEDA path. When parsing a GEDA path, it is converted into simple OpenJSON shapes as before. Each path gets an ID assigned, however, which is stored in each shapes ``styles`` dictionary as ``extra`` parameter. On the writer-side, OpenJSON shapes are now sorted by ID. Shapes with the same path ID are converted to the same GEDA path, all remaining shapes (without ID) are converted as individual shapes.

Additional Fixes & Changes
--------------------------

* The GEDA offset for the schematic frame is now stored in the design attributes to provide the writer with the same details. This generates approximately the same output GEDA as was input into the parser
* Title frames are now only generated when a frame was present in the input GEDA format. This means that schematics created in OpenJSON that are converted into GEDA will not have a frame added by default. This can be added separately in the GEDA software.