From 0ae442220a1c164bdb86c80af6ead38300c3d18a Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Apr 2007 04:56:31 +0000 Subject: [PATCH] Add the beginnings of a high level API to isofs. Currently only does initialization and getting/setting volume attributes. --- bindings/python/isofs/__init__.py | 2 ++ bindings/python/isofs/defines.py | 9 +++++++++ bindings/python/isofs/isofs.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 bindings/python/isofs/defines.py create mode 100644 bindings/python/isofs/isofs.py diff --git a/bindings/python/isofs/__init__.py b/bindings/python/isofs/__init__.py index e69de29..6e296da 100644 --- a/bindings/python/isofs/__init__.py +++ b/bindings/python/isofs/__init__.py @@ -0,0 +1,2 @@ +from defines import * +from isofs import IsoFS diff --git a/bindings/python/isofs/defines.py b/bindings/python/isofs/defines.py new file mode 100644 index 0000000..ee1e376 --- /dev/null +++ b/bindings/python/isofs/defines.py @@ -0,0 +1,9 @@ +# The automatic code generator does not wrap enums into python. As +# isofs has only two enum values publicly defined, they are hardcoded +# here. + +# from enum ecma119_extension_flag +ECMA119_ROCKRIDGE = 1 +ECMA119_JOLIET = 2 + +__all__ = ['ECMA119_ROCKRIDGE', 'ECMA119_JOLIET'] diff --git a/bindings/python/isofs/isofs.py b/bindings/python/isofs/isofs.py new file mode 100644 index 0000000..d38ecc7 --- /dev/null +++ b/bindings/python/isofs/isofs.py @@ -0,0 +1,30 @@ +# High level interface to the isofs library. + +import core +import defines + +def _wrap_volume_property(var_name, core_setter): + def get(self): + return getattr(self, var_name) + def set(self, value): + setattr(self, var_name, value) + core_setter(self._volume, value) + return property(get, set) + +class IsoFS(object): + def __init__(self, volume_id='', publisher_id='', + data_preparer_id=''): + self._volume_id = volume_id + self._publisher_id = publisher_id + self._data_preparer_id = data_preparer_id + + self._volume = core.iso_volume_new( + volume_id, publisher_id, data_preparer_id) + self._volset = core.iso_volset_new(self._volume, volume_id) + + volume_id = _wrap_volume_property( + '_volume_id', core.iso_volume_set_volume_id) + publisher_id = _wrap_volume_property( + '_publisher_id', core.iso_volume_set_publisher_id) + data_preparer_id = _wrap_volume_property( + '_data_preparer_id', core.iso_volume_set_data_preparer_id)