nrvr.diskimage.isoimage
index
/usr/lib/python2.7/site-packages/nrvr/diskimage/isoimage.py

nrvr.diskimage.isoimage - Clone and modify an .iso disk image
 
The main class provided by this module is IsoImage.
 
Implemented subclasses of IsoImageModification are
IsoImageModificationFromString
IsoImageModificationFromPath
IsoImageModificationByReplacement
IsoImageModificationFromByteRange
 
As implemented works in Linux.
As implemented requires mount, umount, iso-info, iso-read, genisoimage commands.
Nevertheless essential.  To be improved as needed.
 
Idea and first implementation - Leo Baschy <srguiwiz12 AT nrvr DOT com>
 
Contributor - Nora Baschy
 
Public repository - https://github.com/srguiwiz/nrvr-commander
 
Copyright (c) Nirvana Research 2006-2015.
Simplified BSD License

 
Modules
       
codecs
os
re
shutil

 
Classes
       
__builtin__.object
IsoImage
IsoImageModification
IsoImageModificationByReplacement
IsoImageModificationFromByteRange
IsoImageModificationFromPath
IsoImageModificationFromString

 
class IsoImage(__builtin__.object)
    An .iso ISO 9660 (or UDF) CD-ROM or DVD-ROM disk image.
 
  Methods defined here:
__init__(self, isoImagePath)
Create new IsoImage descriptor.
 
A descriptor can describe an .iso image that does or doesn't yet exist on the host disk.
cloneWithModifications(self, modifications=[], cloneIsoImagePath=None, udf=False, ignoreJoliet=True, pause=False)
Clone with any number of instances of IsoImageModification applied.
 
A temporary assembly directory in the same directory as cloneIsoImagePath needs disk space,
but it is removed automatically upon completion of cloning.
 
modifications
    a list of IsoImageModification instances.
 
cloneIsoImagePath
    if not given then in same directory with a timestamp in the filename.
 
return
    IsoImage(cloneIsoImagePath).
cloneWithModificationsUsingMount(self, modifications=[], cloneIsoImagePath=None, udf=False, ignoreJoliet=True, pause=False)
Clone with any number of instances of IsoImageModification applied.
 
This is an older implementation which regrettably because of the mount command requires
having superuser privileges.
It is still here in case a newer implementation doesn't work right, which could be for any
of a number of reasons, for example for symbolic links.
 
A temporary assembly directory in the same directory as cloneIsoImagePath needs disk space,
but it is removed automatically upon completion of cloning.
 
modifications
    a list of IsoImageModification instances.
 
cloneIsoImagePath
    if not given then in same directory with a timestamp in the filename.
 
return
    IsoImage(cloneIsoImagePath).
copyToDirectory(self, copyDirectory, udf=False, ignoreJoliet=True, tolerance=0.0)
Copy all files into a directory.
 
Not using mount command, no need to run as root.
exists(self)
Return True if .iso image exists on the host disk.
genisoimageOptions(self, label=None, udf=False, ignoreJoliet=True)
Auxiliary method, called by cloneWithModifications.
 
Can be overridden by subclass methods genisoimageOptions,
which may want to extend the returned list.
 
Could be improved in the future.
Could recognize content of .iso image.
Could select different options depending on content of .iso image.
Maybe could use iso-info -d 9 -i self.isoImagePath.
Could be overridden for a subclass.
mount(self, mountDir, udf=False)
Mount .iso image.
remove(self)
Remove (delete) .iso image from the host disk.
unmount(self)
Unmount .iso image.

Class methods defined here:
commandsUsedInImplementation(cls) from __builtin__.type
Return a list to be passed to SystemRequirements.commandsRequired().
 
This class can be passed to SystemRequirements.commandsRequiredByImplementations().

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
isoImagePath
Path of the .iso image.

 
class IsoImageModification(__builtin__.object)
    A modification to an .iso image.
 
  Methods defined here:
__init__(self, pathOnIso)
pathInTemporaryAssemblyDirectory(self, temporaryAssemblyDirectory)
Auxiliary method, called by subclass method writeIntoAssembly.
writeIntoAssembly(self, temporaryAssemblyDirectory)
To be implemented in subclasses.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IsoImageModificationByReplacement(IsoImageModification)
    A modification to an .iso image, replace within file.
 
Treats whole file as one string to match.
To match a newline a regular expression may use "(\r?\n)",
which nicely allows in the replacement to place appropriate newlines
by backreference, e.g. by "\g<1>".
 
 
Method resolution order:
IsoImageModificationByReplacement
IsoImageModification
__builtin__.object

Methods defined here:
__init__(self, pathOnIso, regularExpression, replacement, encoding='utf-8')
writeIntoAssembly(self, temporaryAssemblyDirectory)

Methods inherited from IsoImageModification:
pathInTemporaryAssemblyDirectory(self, temporaryAssemblyDirectory)
Auxiliary method, called by subclass method writeIntoAssembly.

Data descriptors inherited from IsoImageModification:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IsoImageModificationFromByteRange(IsoImageModification)
    A modification to an .iso image, copy from byte range from file into a file by itself.
 
 
Method resolution order:
IsoImageModificationFromByteRange
IsoImageModification
__builtin__.object

Methods defined here:
__init__(self, pathOnIso, pathOnHost, start, stop)
writeIntoAssembly(self, temporaryAssemblyDirectory)

Methods inherited from IsoImageModification:
pathInTemporaryAssemblyDirectory(self, temporaryAssemblyDirectory)
Auxiliary method, called by subclass method writeIntoAssembly.

Data descriptors inherited from IsoImageModification:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IsoImageModificationFromPath(IsoImageModification)
    A modification to an .iso image, copy from path into file or into directory.
 
 
Method resolution order:
IsoImageModificationFromPath
IsoImageModification
__builtin__.object

Methods defined here:
__init__(self, pathOnIso, pathOnHost)
writeIntoAssembly(self, temporaryAssemblyDirectory)

Methods inherited from IsoImageModification:
pathInTemporaryAssemblyDirectory(self, temporaryAssemblyDirectory)
Auxiliary method, called by subclass method writeIntoAssembly.

Data descriptors inherited from IsoImageModification:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class IsoImageModificationFromString(IsoImageModification)
    A modification to an .iso image, copy from string into file.
 
 
Method resolution order:
IsoImageModificationFromString
IsoImageModification
__builtin__.object

Methods defined here:
__init__(self, pathOnIso, string, encoding='utf-8')
writeIntoAssembly(self, temporaryAssemblyDirectory)

Methods inherited from IsoImageModification:
pathInTemporaryAssemblyDirectory(self, temporaryAssemblyDirectory)
Auxiliary method, called by subclass method writeIntoAssembly.

Data descriptors inherited from IsoImageModification:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)