filesystem: Introduce 'construct' support

This allows for pure declarative encoders/decoders for linear fixed
and transparent EFs.

Change-Id: Id0765ec3ddb8c044838ce47d0ff8740720a32b15
diff --git a/pySim/construct.py b/pySim/construct.py
index 03d284e..839497c 100644
--- a/pySim/construct.py
+++ b/pySim/construct.py
@@ -1,5 +1,5 @@
 from construct import *
-from pySim.utils import b2h, h2b
+from pySim.utils import b2h, h2b, swap_nibbles
 
 """Utility code related to the integration of the 'construct' declarative parser."""
 
@@ -26,6 +26,13 @@
     def _encode(self, obj, context, path):
         return h2b(obj)
 
+class BcdAdapter(Adapter):
+    """convert a bytes() type to a string of BCD nibbles."""
+    def _decode(self, obj, context, path):
+        return swap_nibbles(b2h(obj))
+    def _encode(self, obj, context, path):
+        return h2b(swap_nibbles(obj))
+
 def filter_dict(d, exclude_prefix='_'):
     """filter the input dict to ensure no keys starting with 'exclude_prefix' remain."""
     res = {}