From 998333ae78c1002a411336b5426547285f612da9 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Apr 2007 20:45:03 +0000 Subject: [PATCH] Add the basics for a high level IsoFS class. I have no proof that it currently works correctly. --- libisofs/trunk/bindings/python/isofs/isofs.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libisofs/trunk/bindings/python/isofs/isofs.py b/libisofs/trunk/bindings/python/isofs/isofs.py index d38ecc78..e836ef13 100644 --- a/libisofs/trunk/bindings/python/isofs/isofs.py +++ b/libisofs/trunk/bindings/python/isofs/isofs.py @@ -2,6 +2,7 @@ import core import defines +import os.path def _wrap_volume_property(var_name, core_setter): def get(self): @@ -22,9 +23,36 @@ class IsoFS(object): volume_id, publisher_id, data_preparer_id) self._volset = core.iso_volset_new(self._volume, volume_id) + def __del__(self): + core.iso_volume_free(self._volume) + core.iso_volset_free(self._volset) + 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) + + def add(self, disc_path, path, exclude=None): #, make_parents=False): + disc_path = os.path.normpath(disc_path) + path = os.path.abspath(os.path.normpath(path)) + exclude = exclude or [] + + # Does the disc parent exist? + disc_parent, _ = os.path.split(disc_path) + if not core.iso_tree_volume_path_to_node(self._volume, disc_parent): + print "No such parent" + return # TODO: Raise exception and/or create all missing + # parents. + + # Flush all ignores that may have stayed over. + core.iso_exclude_empty() + for exclude_path in exclude: + core.iso_exclude_add_path(exclude_path) + + core.iso_tree_volume_add_path(self._volume, disc_path, path) + + def display(self): + root = core.iso_volume_get_root(self._volume) + core.iso_tree_print(root, 0)