2007-04-13 04:56:31 +00:00
|
|
|
# High level interface to the isofs library.
|
|
|
|
|
|
|
|
import core
|
|
|
|
import defines
|
2007-04-13 20:45:03 +00:00
|
|
|
import os.path
|
2007-04-13 04:56:31 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2007-04-13 20:45:03 +00:00
|
|
|
def __del__(self):
|
|
|
|
core.iso_volume_free(self._volume)
|
|
|
|
core.iso_volset_free(self._volset)
|
|
|
|
|
2007-04-13 04:56:31 +00:00
|
|
|
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)
|
2007-04-13 20:45:03 +00:00
|
|
|
|
|
|
|
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)
|