mirror of
https://github.com/gutosie/neoboot.git
synced 2025-11-03 04:35:47 +01:00
PEP8 double aggressive E251 and E252
This commit is contained in:
@@ -71,7 +71,7 @@ DEVTYPE_DEVFS = 1
|
|||||||
|
|
||||||
class Harddisk():
|
class Harddisk():
|
||||||
|
|
||||||
def __init__(self, device, removable = False):
|
def __init__(self, device, removable=False):
|
||||||
self.device = device
|
self.device = device
|
||||||
if os.access('/dev/.udev', 0):
|
if os.access('/dev/.udev', 0):
|
||||||
self.type = DEVTYPE_UDEV
|
self.type = DEVTYPE_UDEV
|
||||||
@@ -526,7 +526,7 @@ class Harddisk():
|
|||||||
|
|
||||||
class Partition():
|
class Partition():
|
||||||
|
|
||||||
def __init__(self, mountpoint, device = None, description = '', force_mounted = False):
|
def __init__(self, mountpoint, device=None, description='', force_mounted=False):
|
||||||
self.mountpoint = mountpoint
|
self.mountpoint = mountpoint
|
||||||
self.description = description
|
self.description = description
|
||||||
self.force_mounted = mountpoint and force_mounted
|
self.force_mounted = mountpoint and force_mounted
|
||||||
@@ -564,7 +564,7 @@ class Partition():
|
|||||||
return self.description
|
return self.description
|
||||||
return self.description + '\t' + self.mountpoint
|
return self.description + '\t' + self.mountpoint
|
||||||
|
|
||||||
def mounted(self, mounts = None):
|
def mounted(self, mounts=None):
|
||||||
if self.force_mounted:
|
if self.force_mounted:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -577,7 +577,7 @@ class Partition():
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def filesystem(self, mounts = None):
|
def filesystem(self, mounts=None):
|
||||||
if self.mountpoint:
|
if self.mountpoint:
|
||||||
if mounts is None:
|
if mounts is None:
|
||||||
mounts = getProcMounts()
|
mounts = getProcMounts()
|
||||||
@@ -711,7 +711,7 @@ class HarddiskManager():
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def addHotplugPartition(self, device, physdev = None):
|
def addHotplugPartition(self, device, physdev=None):
|
||||||
if not physdev:
|
if not physdev:
|
||||||
dev, part = self.splitDeviceName(device)
|
dev, part = self.splitDeviceName(device)
|
||||||
try:
|
try:
|
||||||
@@ -739,7 +739,7 @@ class HarddiskManager():
|
|||||||
partitions,
|
partitions,
|
||||||
medium_found)
|
medium_found)
|
||||||
|
|
||||||
def addHotplugAudiocd(self, device, physdev = None):
|
def addHotplugAudiocd(self, device, physdev=None):
|
||||||
if not physdev:
|
if not physdev:
|
||||||
dev, part = self.splitDeviceName(device)
|
dev, part = self.splitDeviceName(device)
|
||||||
try:
|
try:
|
||||||
@@ -796,7 +796,7 @@ class HarddiskManager():
|
|||||||
def getCD(self):
|
def getCD(self):
|
||||||
return self.cd
|
return self.cd
|
||||||
|
|
||||||
def getMountedPartitions(self, onlyhotplug = False, mounts = None):
|
def getMountedPartitions(self, onlyhotplug=False, mounts=None):
|
||||||
if mounts is None:
|
if mounts is None:
|
||||||
mounts = getProcMounts()
|
mounts = getProcMounts()
|
||||||
parts = [ x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted(mounts) ]
|
parts = [ x for x in self.partitions if (x.is_hotplug or not onlyhotplug) and x.mounted(mounts) ]
|
||||||
@@ -844,7 +844,7 @@ class HarddiskManager():
|
|||||||
self.partitions.remove(x)
|
self.partitions.remove(x)
|
||||||
self.on_partition_list_change('remove', x)
|
self.on_partition_list_change('remove', x)
|
||||||
|
|
||||||
def setDVDSpeed(self, device, speed = 0):
|
def setDVDSpeed(self, device, speed=0):
|
||||||
ioctl_flag = int(21282)
|
ioctl_flag = int(21282)
|
||||||
if not device.startswith('/'):
|
if not device.startswith('/'):
|
||||||
device = '/dev/' + device
|
device = '/dev/' + device
|
||||||
@@ -1042,7 +1042,7 @@ def isSleepStateDevice(device):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def internalHDDNotSleeping(external = False):
|
def internalHDDNotSleeping(external=False):
|
||||||
state = False
|
state = False
|
||||||
if harddiskmanager.HDDCount():
|
if harddiskmanager.HDDCount():
|
||||||
for hdd in harddiskmanager.HDDList():
|
for hdd in harddiskmanager.HDDList():
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Job(object):
|
|||||||
self.state_changed()
|
self.state_changed()
|
||||||
return
|
return
|
||||||
|
|
||||||
def taskCallback(self, task, res, stay_resident = False):
|
def taskCallback(self, task, res, stay_resident=False):
|
||||||
cb_idx = self.tasks.index(task)
|
cb_idx = self.tasks.index(task)
|
||||||
if stay_resident:
|
if stay_resident:
|
||||||
if cb_idx not in self.resident_tasks:
|
if cb_idx not in self.resident_tasks:
|
||||||
@@ -151,7 +151,7 @@ class Task(object):
|
|||||||
def setCmdline(self, cmdline):
|
def setCmdline(self, cmdline):
|
||||||
self.cmdline = cmdline
|
self.cmdline = cmdline
|
||||||
|
|
||||||
def checkPreconditions(self, immediate = False):
|
def checkPreconditions(self, immediate=False):
|
||||||
not_met = []
|
not_met = []
|
||||||
if immediate:
|
if immediate:
|
||||||
preconditions = self.immediate_preconditions
|
preconditions = self.immediate_preconditions
|
||||||
@@ -232,7 +232,7 @@ class Task(object):
|
|||||||
self.container.kill()
|
self.container.kill()
|
||||||
self.finish(aborted=True)
|
self.finish(aborted=True)
|
||||||
|
|
||||||
def finish(self, aborted = False):
|
def finish(self, aborted=False):
|
||||||
self.afterRun()
|
self.afterRun()
|
||||||
not_met = []
|
not_met = []
|
||||||
if aborted:
|
if aborted:
|
||||||
@@ -313,7 +313,7 @@ class PythonTask(Task):
|
|||||||
|
|
||||||
class ConditionTask(Task):
|
class ConditionTask(Task):
|
||||||
|
|
||||||
def __init__(self, job, name, timeoutCount = None):
|
def __init__(self, job, name, timeoutCount=None):
|
||||||
Task.__init__(self, job, name)
|
Task.__init__(self, job, name)
|
||||||
self.timeoutCount = timeoutCount
|
self.timeoutCount = timeoutCount
|
||||||
|
|
||||||
@@ -360,7 +360,7 @@ class JobManager:
|
|||||||
self.active_job = None
|
self.active_job = None
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddJob(self, job, onSuccess = None, onFail = None):
|
def AddJob(self, job, onSuccess=None, onFail=None):
|
||||||
job.onSuccess = onSuccess
|
job.onSuccess = onSuccess
|
||||||
if onFail is None:
|
if onFail is None:
|
||||||
job.onFail = self.notifyFailed
|
job.onFail = self.notifyFailed
|
||||||
@@ -468,7 +468,7 @@ class ToolExistsPrecondition(Condition):
|
|||||||
self.realpath = task.cmd
|
self.realpath = task.cmd
|
||||||
path = os.environ.get('PATH', '').split(os.pathsep)
|
path = os.environ.get('PATH', '').split(os.pathsep)
|
||||||
path.append(task.cwd + '/')
|
path.append(task.cwd + '/')
|
||||||
absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file = task.cmd: os.path.join(directory, file), path))
|
absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file=task.cmd: os.path.join(directory, file), path))
|
||||||
if absolutes:
|
if absolutes:
|
||||||
self.realpath = absolutes[0]
|
self.realpath = absolutes[0]
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class ManagerDevice(Screen):
|
|||||||
for cb in self.onChangedEntry:
|
for cb in self.onChangedEntry:
|
||||||
cb(name, desc)
|
cb(name, desc)
|
||||||
|
|
||||||
def updateList(self, result = None, retval = None, extra_args = None):
|
def updateList(self, result=None, retval=None, extra_args=None):
|
||||||
scanning = _('Wait please while scanning for devices...')
|
scanning = _('Wait please while scanning for devices...')
|
||||||
self['lab1'].setText(scanning)
|
self['lab1'].setText(scanning)
|
||||||
self.activityTimer.start(10)
|
self.activityTimer.start(10)
|
||||||
@@ -276,7 +276,7 @@ class ManagerDevice(Screen):
|
|||||||
else:
|
else:
|
||||||
self.session.open(MessageBox, _('This Device is already mounted as HDD.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
|
self.session.open(MessageBox, _('This Device is already mounted as HDD.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True)
|
||||||
|
|
||||||
def add_fstab(self, result = None, retval = None, extra_args = None):
|
def add_fstab(self, result=None, retval=None, extra_args=None):
|
||||||
self.device = extra_args[0]
|
self.device = extra_args[0]
|
||||||
self.mountp = extra_args[1]
|
self.mountp = extra_args[1]
|
||||||
self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '')
|
self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '')
|
||||||
@@ -462,7 +462,7 @@ class DevicesConf(Screen, ConfigListScreen):
|
|||||||
self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO)
|
self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def add_fstab(self, result = None, retval = None, extra_args = None):
|
def add_fstab(self, result=None, retval=None, extra_args=None):
|
||||||
print ("[MountManager] RESULT:"), result
|
print ("[MountManager] RESULT:"), result
|
||||||
if result:
|
if result:
|
||||||
self.device = extra_args[0]
|
self.device = extra_args[0]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Console(Screen):
|
|||||||
# def __init__(self, session, title = 'Console', cmdlist = None, finishedCallback = None, closeOnSuccess = False):
|
# def __init__(self, session, title = 'Console', cmdlist = None, finishedCallback = None, closeOnSuccess = False):
|
||||||
# Screen.__init__(self, session)
|
# Screen.__init__(self, session)
|
||||||
|
|
||||||
def __init__(self, session, title = _('Console'), cmdlist = None, finishedCallback = None, closeOnSuccess = False):
|
def __init__(self, session, title=_('Console'), cmdlist=None, finishedCallback=None, closeOnSuccess=False):
|
||||||
Screen.__init__(self, session)
|
Screen.__init__(self, session)
|
||||||
self.finishedCallback = finishedCallback
|
self.finishedCallback = finishedCallback
|
||||||
self.closeOnSuccess = closeOnSuccess
|
self.closeOnSuccess = closeOnSuccess
|
||||||
@@ -126,7 +126,7 @@ class Console(Screen):
|
|||||||
else:
|
else:
|
||||||
self.cancel_msg = self.session.openWithCallback(self.cancelCB, MessageBox, _('Cancel execution?'), type=MessageBox.TYPE_YESNO, default=False)
|
self.cancel_msg = self.session.openWithCallback(self.cancelCB, MessageBox, _('Cancel execution?'), type=MessageBox.TYPE_YESNO, default=False)
|
||||||
|
|
||||||
def cancelCB(self, ret = None):
|
def cancelCB(self, ret=None):
|
||||||
self.cancel_msg = None
|
self.cancel_msg = None
|
||||||
if ret:
|
if ret:
|
||||||
self.cancel(True)
|
self.cancel(True)
|
||||||
@@ -147,7 +147,7 @@ class Console(Screen):
|
|||||||
else:
|
else:
|
||||||
yield source
|
yield source
|
||||||
|
|
||||||
def saveOutputTextCB(self, ret = None):
|
def saveOutputTextCB(self, ret=None):
|
||||||
if ret:
|
if ret:
|
||||||
from os import path
|
from os import path
|
||||||
failtext = _("Path to save not exist: '/tmp/'")
|
failtext = _("Path to save not exist: '/tmp/'")
|
||||||
@@ -186,7 +186,7 @@ class Console(Screen):
|
|||||||
else:
|
else:
|
||||||
self.output_file = ''
|
self.output_file = ''
|
||||||
|
|
||||||
def toggleScreenHide(self, setshow = False):
|
def toggleScreenHide(self, setshow=False):
|
||||||
if self.screen_hide or setshow:
|
if self.screen_hide or setshow:
|
||||||
self.show()
|
self.show()
|
||||||
else:
|
else:
|
||||||
@@ -206,7 +206,7 @@ class Console(Screen):
|
|||||||
|
|
||||||
return rd
|
return rd
|
||||||
|
|
||||||
def cancel(self, force = False):
|
def cancel(self, force=False):
|
||||||
if self.screen_hide:
|
if self.screen_hide:
|
||||||
self.toggleScreenHide()
|
self.toggleScreenHide()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot'
|
|||||||
|
|
||||||
LogFileObj = None
|
LogFileObj = None
|
||||||
|
|
||||||
def Log(param = ''):
|
def Log(param=''):
|
||||||
global LogFileObj
|
global LogFileObj
|
||||||
#first close object if exists
|
#first close object if exists
|
||||||
if param.lower() in ['open','write','append','close']:
|
if param.lower() in ['open','write','append','close']:
|
||||||
@@ -47,7 +47,7 @@ def LogCrashGS(line):
|
|||||||
log_file.write(line)
|
log_file.write(line)
|
||||||
log_file.close()
|
log_file.close()
|
||||||
|
|
||||||
def fileCheck(f, mode = 'r'):
|
def fileCheck(f, mode='r'):
|
||||||
return fileExists(f, mode) and f
|
return fileExists(f, mode) and f
|
||||||
|
|
||||||
# if not IsImageName():
|
# if not IsImageName():
|
||||||
|
|||||||
@@ -1514,7 +1514,7 @@ class NeoBootImageChoose(Screen):
|
|||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
def readline(filename, iferror = ''):
|
def readline(filename, iferror=''):
|
||||||
if iferror[:3] == 'or:':
|
if iferror[:3] == 'or:':
|
||||||
data = iferror[3:]
|
data = iferror[3:]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def _ensure_value(namespace, name, value):
|
|||||||
|
|
||||||
class HelpFormatter(object):
|
class HelpFormatter(object):
|
||||||
|
|
||||||
def __init__(self, prog, indent_increment = 2, max_help_position = 24, width = None):
|
def __init__(self, prog, indent_increment=2, max_help_position=24, width=None):
|
||||||
if width is None:
|
if width is None:
|
||||||
try:
|
try:
|
||||||
width = int(_os.environ['COLUMNS'])
|
width = int(_os.environ['COLUMNS'])
|
||||||
@@ -95,7 +95,7 @@ class HelpFormatter(object):
|
|||||||
|
|
||||||
class _Section(object):
|
class _Section(object):
|
||||||
|
|
||||||
def __init__(self, formatter, parent, heading = None):
|
def __init__(self, formatter, parent, heading=None):
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.heading = heading
|
self.heading = heading
|
||||||
@@ -143,7 +143,7 @@ class HelpFormatter(object):
|
|||||||
self._add_item(self._format_text, [text])
|
self._add_item(self._format_text, [text])
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_usage(self, usage, actions, groups, prefix = None):
|
def add_usage(self, usage, actions, groups, prefix=None):
|
||||||
if usage is not SUPPRESS:
|
if usage is not SUPPRESS:
|
||||||
args = (usage,
|
args = (usage,
|
||||||
actions,
|
actions,
|
||||||
@@ -205,7 +205,7 @@ class HelpFormatter(object):
|
|||||||
opt_parts = _re.findall(part_regexp, opt_usage)
|
opt_parts = _re.findall(part_regexp, opt_usage)
|
||||||
pos_parts = _re.findall(part_regexp, pos_usage)
|
pos_parts = _re.findall(part_regexp, pos_usage)
|
||||||
|
|
||||||
def get_lines(parts, indent, prefix = None):
|
def get_lines(parts, indent, prefix=None):
|
||||||
lines = []
|
lines = []
|
||||||
line = []
|
line = []
|
||||||
if prefix is not None:
|
if prefix is not None:
|
||||||
@@ -505,7 +505,7 @@ class ArgumentTypeError(Exception):
|
|||||||
|
|
||||||
class Action(_AttributeHolder):
|
class Action(_AttributeHolder):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
self.option_strings = option_strings
|
self.option_strings = option_strings
|
||||||
self.dest = dest
|
self.dest = dest
|
||||||
self.nargs = nargs
|
self.nargs = nargs
|
||||||
@@ -529,13 +529,13 @@ class Action(_AttributeHolder):
|
|||||||
'metavar']
|
'metavar']
|
||||||
return [ (name, getattr(self, name)) for name in names ]
|
return [ (name, getattr(self, name)) for name in names ]
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
raise NotImplementedError(_('.__call__() not defined'))
|
raise NotImplementedError(_('.__call__() not defined'))
|
||||||
|
|
||||||
|
|
||||||
class _StoreAction(Action):
|
class _StoreAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
if nargs == 0:
|
if nargs == 0:
|
||||||
raise ValueError('nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate')
|
raise ValueError('nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate')
|
||||||
if const is not None and nargs != OPTIONAL:
|
if const is not None and nargs != OPTIONAL:
|
||||||
@@ -543,34 +543,34 @@ class _StoreAction(Action):
|
|||||||
super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
||||||
return
|
return
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
setattr(namespace, self.dest, values)
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
class _StoreConstAction(Action):
|
class _StoreConstAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, const, default = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None):
|
||||||
super(_StoreConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help)
|
super(_StoreConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
setattr(namespace, self.dest, self.const)
|
setattr(namespace, self.dest, self.const)
|
||||||
|
|
||||||
|
|
||||||
class _StoreTrueAction(_StoreConstAction):
|
class _StoreTrueAction(_StoreConstAction):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = False, required = False, help = None):
|
def __init__(self, option_strings, dest, default=False, required=False, help=None):
|
||||||
super(_StoreTrueAction, self).__init__(option_strings=option_strings, dest=dest, const=True, default=default, required=required, help=help)
|
super(_StoreTrueAction, self).__init__(option_strings=option_strings, dest=dest, const=True, default=default, required=required, help=help)
|
||||||
|
|
||||||
|
|
||||||
class _StoreFalseAction(_StoreConstAction):
|
class _StoreFalseAction(_StoreConstAction):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = True, required = False, help = None):
|
def __init__(self, option_strings, dest, default=True, required=False, help=None):
|
||||||
super(_StoreFalseAction, self).__init__(option_strings=option_strings, dest=dest, const=False, default=default, required=required, help=help)
|
super(_StoreFalseAction, self).__init__(option_strings=option_strings, dest=dest, const=False, default=default, required=required, help=help)
|
||||||
|
|
||||||
|
|
||||||
class _AppendAction(Action):
|
class _AppendAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
if nargs == 0:
|
if nargs == 0:
|
||||||
raise ValueError('nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate')
|
raise ValueError('nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate')
|
||||||
if const is not None and nargs != OPTIONAL:
|
if const is not None and nargs != OPTIONAL:
|
||||||
@@ -578,7 +578,7 @@ class _AppendAction(Action):
|
|||||||
super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
||||||
return
|
return
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
||||||
items.append(values)
|
items.append(values)
|
||||||
setattr(namespace, self.dest, items)
|
setattr(namespace, self.dest, items)
|
||||||
@@ -586,10 +586,10 @@ class _AppendAction(Action):
|
|||||||
|
|
||||||
class _AppendConstAction(Action):
|
class _AppendConstAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, const, default = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None):
|
||||||
super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help, metavar=metavar)
|
super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help, metavar=metavar)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
||||||
items.append(self.const)
|
items.append(self.const)
|
||||||
setattr(namespace, self.dest, items)
|
setattr(namespace, self.dest, items)
|
||||||
@@ -597,31 +597,31 @@ class _AppendConstAction(Action):
|
|||||||
|
|
||||||
class _CountAction(Action):
|
class _CountAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = None, required = False, help = None):
|
def __init__(self, option_strings, dest, default=None, required=False, help=None):
|
||||||
super(_CountAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, default=default, required=required, help=help)
|
super(_CountAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, default=default, required=required, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
new_count = _ensure_value(namespace, self.dest, 0) + 1
|
new_count = _ensure_value(namespace, self.dest, 0) + 1
|
||||||
setattr(namespace, self.dest, new_count)
|
setattr(namespace, self.dest, new_count)
|
||||||
|
|
||||||
|
|
||||||
class _HelpAction(Action):
|
class _HelpAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest = SUPPRESS, default = SUPPRESS, help = None):
|
def __init__(self, option_strings, dest=SUPPRESS, default=SUPPRESS, help=None):
|
||||||
super(_HelpAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
super(_HelpAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|
||||||
|
|
||||||
class _VersionAction(Action):
|
class _VersionAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, version = None, dest = SUPPRESS, default = SUPPRESS, help = "show program's version number and exit"):
|
def __init__(self, option_strings, version=None, dest=SUPPRESS, default=SUPPRESS, help="show program's version number and exit"):
|
||||||
super(_VersionAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
super(_VersionAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
||||||
self.version = version
|
self.version = version
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
version = self.version
|
version = self.version
|
||||||
if version is None:
|
if version is None:
|
||||||
version = parser.version
|
version = parser.version
|
||||||
@@ -639,7 +639,7 @@ class _SubParsersAction(Action):
|
|||||||
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
|
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
|
||||||
sup.__init__(option_strings=[], dest=name, help=help)
|
sup.__init__(option_strings=[], dest=name, help=help)
|
||||||
|
|
||||||
def __init__(self, option_strings, prog, parser_class, dest = SUPPRESS, help = None, metavar = None):
|
def __init__(self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None):
|
||||||
self._prog_prefix = prog
|
self._prog_prefix = prog
|
||||||
self._parser_class = parser_class
|
self._parser_class = parser_class
|
||||||
self._name_parser_map = _collections.OrderedDict()
|
self._name_parser_map = _collections.OrderedDict()
|
||||||
@@ -660,7 +660,7 @@ class _SubParsersAction(Action):
|
|||||||
def _get_subactions(self):
|
def _get_subactions(self):
|
||||||
return self._choices_actions
|
return self._choices_actions
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
parser_name = values[0]
|
parser_name = values[0]
|
||||||
arg_strings = values[1:]
|
arg_strings = values[1:]
|
||||||
if self.dest is not SUPPRESS:
|
if self.dest is not SUPPRESS:
|
||||||
@@ -680,7 +680,7 @@ class _SubParsersAction(Action):
|
|||||||
|
|
||||||
class FileType(object):
|
class FileType(object):
|
||||||
|
|
||||||
def __init__(self, mode = 'r', bufsize = -1):
|
def __init__(self, mode='r', bufsize=-1):
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
self._bufsize = bufsize
|
self._bufsize = bufsize
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ class _ActionsContainer(object):
|
|||||||
registry = self._registries.setdefault(registry_name, {})
|
registry = self._registries.setdefault(registry_name, {})
|
||||||
registry[value] = object
|
registry[value] = object
|
||||||
|
|
||||||
def _registry_get(self, registry_name, value, default = None):
|
def _registry_get(self, registry_name, value, default=None):
|
||||||
return self._registries[registry_name].get(value, default)
|
return self._registries[registry_name].get(value, default)
|
||||||
|
|
||||||
def set_defaults(self, **kwargs):
|
def set_defaults(self, **kwargs):
|
||||||
@@ -888,7 +888,7 @@ class _ActionsContainer(object):
|
|||||||
dest = dest.replace('-', '_')
|
dest = dest.replace('-', '_')
|
||||||
return dict(kwargs, dest=dest, option_strings=option_strings)
|
return dict(kwargs, dest=dest, option_strings=option_strings)
|
||||||
|
|
||||||
def _pop_action_class(self, kwargs, default = None):
|
def _pop_action_class(self, kwargs, default=None):
|
||||||
action = kwargs.pop('action', default)
|
action = kwargs.pop('action', default)
|
||||||
return self._registry_get('action', action, action)
|
return self._registry_get('action', action, action)
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@ class _ActionsContainer(object):
|
|||||||
|
|
||||||
class _ArgumentGroup(_ActionsContainer):
|
class _ArgumentGroup(_ActionsContainer):
|
||||||
|
|
||||||
def __init__(self, container, title = None, description = None, **kwargs):
|
def __init__(self, container, title=None, description=None, **kwargs):
|
||||||
update = kwargs.setdefault
|
update = kwargs.setdefault
|
||||||
update('conflict_handler', container.conflict_handler)
|
update('conflict_handler', container.conflict_handler)
|
||||||
update('prefix_chars', container.prefix_chars)
|
update('prefix_chars', container.prefix_chars)
|
||||||
@@ -956,7 +956,7 @@ class _ArgumentGroup(_ActionsContainer):
|
|||||||
|
|
||||||
class _MutuallyExclusiveGroup(_ArgumentGroup):
|
class _MutuallyExclusiveGroup(_ArgumentGroup):
|
||||||
|
|
||||||
def __init__(self, container, required = False):
|
def __init__(self, container, required=False):
|
||||||
super(_MutuallyExclusiveGroup, self).__init__(container)
|
super(_MutuallyExclusiveGroup, self).__init__(container)
|
||||||
self.required = required
|
self.required = required
|
||||||
self._container = container
|
self._container = container
|
||||||
@@ -976,7 +976,7 @@ class _MutuallyExclusiveGroup(_ArgumentGroup):
|
|||||||
|
|
||||||
class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||||
|
|
||||||
def __init__(self, prog = None, usage = None, description = None, epilog = None, version = None, parents = [], formatter_class = HelpFormatter, prefix_chars = '-', fromfile_prefix_chars = None, argument_default = None, conflict_handler = 'error', add_help = True):
|
def __init__(self, prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True):
|
||||||
if version is not None:
|
if version is not None:
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning)
|
warnings.warn('The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning)
|
||||||
@@ -1060,14 +1060,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
def _get_positional_actions(self):
|
def _get_positional_actions(self):
|
||||||
return [ action for action in self._actions if not action.option_strings ]
|
return [ action for action in self._actions if not action.option_strings ]
|
||||||
|
|
||||||
def parse_args(self, args = None, namespace = None):
|
def parse_args(self, args=None, namespace=None):
|
||||||
args, argv = self.parse_known_args(args, namespace)
|
args, argv = self.parse_known_args(args, namespace)
|
||||||
if argv:
|
if argv:
|
||||||
msg = _('unrecognized arguments: %s')
|
msg = _('unrecognized arguments: %s')
|
||||||
self.error(msg % ' '.join(argv))
|
self.error(msg % ' '.join(argv))
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def parse_known_args(self, args = None, namespace = None):
|
def parse_known_args(self, args=None, namespace=None):
|
||||||
if args is None:
|
if args is None:
|
||||||
args = _sys.argv[1:]
|
args = _sys.argv[1:]
|
||||||
if namespace is None:
|
if namespace is None:
|
||||||
@@ -1130,7 +1130,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
seen_actions = set()
|
seen_actions = set()
|
||||||
seen_non_default_actions = set()
|
seen_non_default_actions = set()
|
||||||
|
|
||||||
def take_action(action, argument_strings, option_string = None):
|
def take_action(action, argument_strings, option_string=None):
|
||||||
seen_actions.add(action)
|
seen_actions.add(action)
|
||||||
argument_values = self._get_values(action, argument_strings)
|
argument_values = self._get_values(action, argument_strings)
|
||||||
if argument_values is not action.default:
|
if argument_values is not action.default:
|
||||||
@@ -1472,31 +1472,31 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
def _get_formatter(self):
|
def _get_formatter(self):
|
||||||
return self.formatter_class(prog=self.prog)
|
return self.formatter_class(prog=self.prog)
|
||||||
|
|
||||||
def print_usage(self, file = None):
|
def print_usage(self, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stdout
|
file = _sys.stdout
|
||||||
self._print_message(self.format_usage(), file)
|
self._print_message(self.format_usage(), file)
|
||||||
return
|
return
|
||||||
|
|
||||||
def print_help(self, file = None):
|
def print_help(self, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stdout
|
file = _sys.stdout
|
||||||
self._print_message(self.format_help(), file)
|
self._print_message(self.format_help(), file)
|
||||||
return
|
return
|
||||||
|
|
||||||
def print_version(self, file = None):
|
def print_version(self, file=None):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning)
|
warnings.warn('The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning)
|
||||||
self._print_message(self.format_version(), file)
|
self._print_message(self.format_version(), file)
|
||||||
|
|
||||||
def _print_message(self, message, file = None):
|
def _print_message(self, message, file=None):
|
||||||
if message:
|
if message:
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stderr
|
file = _sys.stderr
|
||||||
file.write(message)
|
file.write(message)
|
||||||
return
|
return
|
||||||
|
|
||||||
def exit(self, status = 0, message = None):
|
def exit(self, status=0, message=None):
|
||||||
if message:
|
if message:
|
||||||
self._print_message(message, _sys.stderr)
|
self._print_message(message, _sys.stderr)
|
||||||
_sys.exit(status)
|
_sys.exit(status)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ubi:
|
|||||||
|
|
||||||
blocks = property(_get_blocks)
|
blocks = property(_get_blocks)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.ubi(self, tab)
|
display.ubi(self, tab)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class description(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num)
|
return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.block(self, tab)
|
display.block(self, tab)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def by_leb(blocks):
|
|||||||
return sorted(blocks.iterkeys(), key=lambda x: blocks[x].leb_num)
|
return sorted(blocks.iterkeys(), key=lambda x: blocks[x].leb_num)
|
||||||
|
|
||||||
|
|
||||||
def by_vol_id(blocks, slist = None):
|
def by_vol_id(blocks, slist=None):
|
||||||
vol_blocks = {}
|
vol_blocks = {}
|
||||||
for i in blocks:
|
for i in blocks:
|
||||||
if slist and i not in slist:
|
if slist and i not in slist:
|
||||||
@@ -50,7 +50,7 @@ def by_vol_id(blocks, slist = None):
|
|||||||
return vol_blocks
|
return vol_blocks
|
||||||
|
|
||||||
|
|
||||||
def clean_bad(blocks, slist = None):
|
def clean_bad(blocks, slist=None):
|
||||||
clean_blocks = []
|
clean_blocks = []
|
||||||
for i in range(0, len(blocks)):
|
for i in range(0, len(blocks)):
|
||||||
if slist and i not in slist:
|
if slist and i not in slist:
|
||||||
@@ -61,7 +61,7 @@ def clean_bad(blocks, slist = None):
|
|||||||
return clean_blocks
|
return clean_blocks
|
||||||
|
|
||||||
|
|
||||||
def by_type(blocks, slist = None):
|
def by_type(blocks, slist=None):
|
||||||
layout = []
|
layout = []
|
||||||
data = []
|
data = []
|
||||||
int_vol = []
|
int_vol = []
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
||||||
|
|
||||||
def ubi(ubi, tab = ''):
|
def ubi(ubi, tab=''):
|
||||||
print '%sUBI File' % tab
|
print '%sUBI File' % tab
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sMin I/O: %s' % (tab, ubi.min_io_size)
|
print '\t%sMin I/O: %s' % (tab, ubi.min_io_size)
|
||||||
@@ -15,7 +15,7 @@ def ubi(ubi, tab = ''):
|
|||||||
print '\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num)
|
print '\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num)
|
||||||
|
|
||||||
|
|
||||||
def image(image, tab = ''):
|
def image(image, tab=''):
|
||||||
print '%s%s' % (tab, image)
|
print '%s%s' % (tab, image)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sImage Sequence Num: %s' % (tab, image.image_seq)
|
print '\t%sImage Sequence Num: %s' % (tab, image.image_seq)
|
||||||
@@ -25,7 +25,7 @@ def image(image, tab = ''):
|
|||||||
print '\t%sPEB Range: %s - %s' % (tab, image.peb_range[0], image.peb_range[1])
|
print '\t%sPEB Range: %s - %s' % (tab, image.peb_range[0], image.peb_range[1])
|
||||||
|
|
||||||
|
|
||||||
def volume(volume, tab = ''):
|
def volume(volume, tab=''):
|
||||||
print '%s%s' % (tab, volume)
|
print '%s%s' % (tab, volume)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sVol ID: %s' % (tab, volume.vol_id)
|
print '\t%sVol ID: %s' % (tab, volume.vol_id)
|
||||||
@@ -38,7 +38,7 @@ def volume(volume, tab = ''):
|
|||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
|
||||||
def block(block, tab = '\t'):
|
def block(block, tab='\t'):
|
||||||
print '%s%s' % (tab, block)
|
print '%s%s' % (tab, block)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sFile Offset: %s' % (tab, block.file_offset)
|
print '\t%sFile Offset: %s' % (tab, block.file_offset)
|
||||||
@@ -68,14 +68,14 @@ def block(block, tab = '\t'):
|
|||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
|
||||||
def ec_hdr(ec_hdr, tab = ''):
|
def ec_hdr(ec_hdr, tab=''):
|
||||||
for key, value in ec_hdr:
|
for key, value in ec_hdr:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
print '%s%s: %r' % (tab, key, value)
|
print '%s%s: %r' % (tab, key, value)
|
||||||
|
|
||||||
|
|
||||||
def vid_hdr(vid_hdr, tab = ''):
|
def vid_hdr(vid_hdr, tab=''):
|
||||||
for key, value in vid_hdr:
|
for key, value in vid_hdr:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
@@ -92,7 +92,7 @@ def vid_hdr(vid_hdr, tab = ''):
|
|||||||
print '%s%s: %s' % (tab, key, value)
|
print '%s%s: %s' % (tab, key, value)
|
||||||
|
|
||||||
|
|
||||||
def vol_rec(vol_rec, tab = ''):
|
def vol_rec(vol_rec, tab=''):
|
||||||
for key, value in vol_rec:
|
for key, value in vol_rec:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ class description(object):
|
|||||||
|
|
||||||
volumes = property(_get_volumes)
|
volumes = property(_get_volumes)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.image(self, tab)
|
display.image(self, tab)
|
||||||
@@ -41,7 +41,7 @@ class description(object):
|
|||||||
def get_blocks(self, blocks):
|
def get_blocks(self, blocks):
|
||||||
return get_blocks_in_list(blocks, self._block_list)
|
return get_blocks_in_list(blocks, self._block_list)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.volume(self, tab)
|
display.volume(self, tab)
|
||||||
|
|
||||||
def reader(self, ubi):
|
def reader(self, ubi):
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from ubi.block import sort
|
|||||||
|
|
||||||
class ubi_file(object):
|
class ubi_file(object):
|
||||||
|
|
||||||
def __init__(self, path, block_size, start_offset = 0, end_offset = None):
|
def __init__(self, path, block_size, start_offset=0, end_offset=None):
|
||||||
self._fhandle = open(path, 'rb')
|
self._fhandle = open(path, 'rb')
|
||||||
self._start_offset = start_offset
|
self._start_offset = start_offset
|
||||||
if end_offset:
|
if end_offset:
|
||||||
|
|||||||
@@ -2,36 +2,36 @@
|
|||||||
from ubifs import nodes
|
from ubifs import nodes
|
||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
|
|
||||||
def common_hdr(ubifs, lnum, offset = 0):
|
def common_hdr(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
return nodes.common_hdr(ubifs.file.read(UBIFS_COMMON_HDR_SZ))
|
return nodes.common_hdr(ubifs.file.read(UBIFS_COMMON_HDR_SZ))
|
||||||
|
|
||||||
|
|
||||||
def ino_node(ubifs, lnum, offset = 0):
|
def ino_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
inon = nodes.ino_node(ubifs.file.read(UBIFS_INO_NODE_SZ))
|
inon = nodes.ino_node(ubifs.file.read(UBIFS_INO_NODE_SZ))
|
||||||
inon.data = ubifs.file.read(inon.data_len)
|
inon.data = ubifs.file.read(inon.data_len)
|
||||||
return inon
|
return inon
|
||||||
|
|
||||||
|
|
||||||
def mst_node(ubifs, lnum, offset = 0):
|
def mst_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
return nodes.mst_node(ubifs.file.read(UBIFS_MST_NODE_SZ))
|
return nodes.mst_node(ubifs.file.read(UBIFS_MST_NODE_SZ))
|
||||||
|
|
||||||
|
|
||||||
def sb_node(ubifs, offset = 0):
|
def sb_node(ubifs, offset=0):
|
||||||
ubifs.file.seek(offset)
|
ubifs.file.seek(offset)
|
||||||
return nodes.sb_node(ubifs.file.read(UBIFS_SB_NODE_SZ))
|
return nodes.sb_node(ubifs.file.read(UBIFS_SB_NODE_SZ))
|
||||||
|
|
||||||
|
|
||||||
def dent_node(ubifs, lnum, offset = 0):
|
def dent_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ))
|
den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ))
|
||||||
den.name = '%s' % ubifs.file.read(den.nlen)
|
den.name = '%s' % ubifs.file.read(den.nlen)
|
||||||
return den
|
return den
|
||||||
|
|
||||||
|
|
||||||
def data_node(ubifs, lnum, offset = 0, node_len = 0):
|
def data_node(ubifs, lnum, offset=0, node_len=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
datn = nodes.data_node(ubifs.file.read(UBIFS_DATA_NODE_SZ))
|
datn = nodes.data_node(ubifs.file.read(UBIFS_DATA_NODE_SZ))
|
||||||
datn.offset = ubifs.leb_size * lnum + offset + UBIFS_DATA_NODE_SZ
|
datn.offset = ubifs.leb_size * lnum + offset + UBIFS_DATA_NODE_SZ
|
||||||
@@ -39,7 +39,7 @@ def data_node(ubifs, lnum, offset = 0, node_len = 0):
|
|||||||
return datn
|
return datn
|
||||||
|
|
||||||
|
|
||||||
def idx_node(ubifs, lnum, offset = 0):
|
def idx_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
idxn = nodes.idx_node(ubifs.file.read(UBIFS_IDX_NODE_SZ))
|
idxn = nodes.idx_node(ubifs.file.read(UBIFS_IDX_NODE_SZ))
|
||||||
for i in range(0, idxn.child_cnt):
|
for i in range(0, idxn.child_cnt):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import struct
|
|||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
from ubifs.misc import decompress
|
from ubifs.misc import decompress
|
||||||
|
|
||||||
def dents(ubifs, inodes, dent_node, path = '', perms = False):
|
def dents(ubifs, inodes, dent_node, path='', perms=False):
|
||||||
inode = inodes[dent_node.inum]
|
inode = inodes[dent_node.inum]
|
||||||
dent_path = os.path.join(path, dent_node.name)
|
dent_path = os.path.join(path, dent_node.name)
|
||||||
if dent_node.type == UBIFS_ITYPE_DIR:
|
if dent_node.type == UBIFS_ITYPE_DIR:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
from ubifs import extract
|
from ubifs import extract
|
||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
|
|
||||||
def index(ubifs, lnum, offset, inodes = {}):
|
def index(ubifs, lnum, offset, inodes={}):
|
||||||
chdr = extract.common_hdr(ubifs, lnum, offset)
|
chdr = extract.common_hdr(ubifs, lnum, offset)
|
||||||
if chdr.node_type == UBIFS_IDX_NODE:
|
if chdr.node_type == UBIFS_IDX_NODE:
|
||||||
idxn = extract.idx_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ)
|
idxn = extract.idx_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from ubifs.defines import PRINT_UBIFS_KEY_HASH, PRINT_UBIFS_COMPR
|
|||||||
from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
||||||
output_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'output')
|
output_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'output')
|
||||||
|
|
||||||
def extract_files(ubifs, out_path, perms = False):
|
def extract_files(ubifs, out_path, perms=False):
|
||||||
try:
|
try:
|
||||||
inodes = {}
|
inodes = {}
|
||||||
walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes)
|
walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def _ensure_value(namespace, name, value):
|
|||||||
|
|
||||||
class HelpFormatter(object):
|
class HelpFormatter(object):
|
||||||
|
|
||||||
def __init__(self, prog, indent_increment = 2, max_help_position = 24, width = None):
|
def __init__(self, prog, indent_increment=2, max_help_position=24, width=None):
|
||||||
if width is None:
|
if width is None:
|
||||||
try:
|
try:
|
||||||
width = int(_os.environ['COLUMNS'])
|
width = int(_os.environ['COLUMNS'])
|
||||||
@@ -95,7 +95,7 @@ class HelpFormatter(object):
|
|||||||
|
|
||||||
class _Section(object):
|
class _Section(object):
|
||||||
|
|
||||||
def __init__(self, formatter, parent, heading = None):
|
def __init__(self, formatter, parent, heading=None):
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.heading = heading
|
self.heading = heading
|
||||||
@@ -143,7 +143,7 @@ class HelpFormatter(object):
|
|||||||
self._add_item(self._format_text, [text])
|
self._add_item(self._format_text, [text])
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_usage(self, usage, actions, groups, prefix = None):
|
def add_usage(self, usage, actions, groups, prefix=None):
|
||||||
if usage is not SUPPRESS:
|
if usage is not SUPPRESS:
|
||||||
args = (usage,
|
args = (usage,
|
||||||
actions,
|
actions,
|
||||||
@@ -205,7 +205,7 @@ class HelpFormatter(object):
|
|||||||
opt_parts = _re.findall(part_regexp, opt_usage)
|
opt_parts = _re.findall(part_regexp, opt_usage)
|
||||||
pos_parts = _re.findall(part_regexp, pos_usage)
|
pos_parts = _re.findall(part_regexp, pos_usage)
|
||||||
|
|
||||||
def get_lines(parts, indent, prefix = None):
|
def get_lines(parts, indent, prefix=None):
|
||||||
lines = []
|
lines = []
|
||||||
line = []
|
line = []
|
||||||
if prefix is not None:
|
if prefix is not None:
|
||||||
@@ -505,7 +505,7 @@ class ArgumentTypeError(Exception):
|
|||||||
|
|
||||||
class Action(_AttributeHolder):
|
class Action(_AttributeHolder):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
self.option_strings = option_strings
|
self.option_strings = option_strings
|
||||||
self.dest = dest
|
self.dest = dest
|
||||||
self.nargs = nargs
|
self.nargs = nargs
|
||||||
@@ -529,13 +529,13 @@ class Action(_AttributeHolder):
|
|||||||
'metavar']
|
'metavar']
|
||||||
return [ (name, getattr(self, name)) for name in names ]
|
return [ (name, getattr(self, name)) for name in names ]
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
raise NotImplementedError(_('.__call__() not defined'))
|
raise NotImplementedError(_('.__call__() not defined'))
|
||||||
|
|
||||||
|
|
||||||
class _StoreAction(Action):
|
class _StoreAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
if nargs == 0:
|
if nargs == 0:
|
||||||
raise ValueError('nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate')
|
raise ValueError('nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriate')
|
||||||
if const is not None and nargs != OPTIONAL:
|
if const is not None and nargs != OPTIONAL:
|
||||||
@@ -543,34 +543,34 @@ class _StoreAction(Action):
|
|||||||
super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
super(_StoreAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
||||||
return
|
return
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
setattr(namespace, self.dest, values)
|
setattr(namespace, self.dest, values)
|
||||||
|
|
||||||
|
|
||||||
class _StoreConstAction(Action):
|
class _StoreConstAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, const, default = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None):
|
||||||
super(_StoreConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help)
|
super(_StoreConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
setattr(namespace, self.dest, self.const)
|
setattr(namespace, self.dest, self.const)
|
||||||
|
|
||||||
|
|
||||||
class _StoreTrueAction(_StoreConstAction):
|
class _StoreTrueAction(_StoreConstAction):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = False, required = False, help = None):
|
def __init__(self, option_strings, dest, default=False, required=False, help=None):
|
||||||
super(_StoreTrueAction, self).__init__(option_strings=option_strings, dest=dest, const=True, default=default, required=required, help=help)
|
super(_StoreTrueAction, self).__init__(option_strings=option_strings, dest=dest, const=True, default=default, required=required, help=help)
|
||||||
|
|
||||||
|
|
||||||
class _StoreFalseAction(_StoreConstAction):
|
class _StoreFalseAction(_StoreConstAction):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = True, required = False, help = None):
|
def __init__(self, option_strings, dest, default=True, required=False, help=None):
|
||||||
super(_StoreFalseAction, self).__init__(option_strings=option_strings, dest=dest, const=False, default=default, required=required, help=help)
|
super(_StoreFalseAction, self).__init__(option_strings=option_strings, dest=dest, const=False, default=default, required=required, help=help)
|
||||||
|
|
||||||
|
|
||||||
class _AppendAction(Action):
|
class _AppendAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, nargs = None, const = None, default = None, type = None, choices = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
if nargs == 0:
|
if nargs == 0:
|
||||||
raise ValueError('nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate')
|
raise ValueError('nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriate')
|
||||||
if const is not None and nargs != OPTIONAL:
|
if const is not None and nargs != OPTIONAL:
|
||||||
@@ -578,7 +578,7 @@ class _AppendAction(Action):
|
|||||||
super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
super(_AppendAction, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, const=const, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
||||||
return
|
return
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
||||||
items.append(values)
|
items.append(values)
|
||||||
setattr(namespace, self.dest, items)
|
setattr(namespace, self.dest, items)
|
||||||
@@ -586,10 +586,10 @@ class _AppendAction(Action):
|
|||||||
|
|
||||||
class _AppendConstAction(Action):
|
class _AppendConstAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, const, default = None, required = False, help = None, metavar = None):
|
def __init__(self, option_strings, dest, const, default=None, required=False, help=None, metavar=None):
|
||||||
super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help, metavar=metavar)
|
super(_AppendConstAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, const=const, default=default, required=required, help=help, metavar=metavar)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
items = _copy.copy(_ensure_value(namespace, self.dest, []))
|
||||||
items.append(self.const)
|
items.append(self.const)
|
||||||
setattr(namespace, self.dest, items)
|
setattr(namespace, self.dest, items)
|
||||||
@@ -597,31 +597,31 @@ class _AppendConstAction(Action):
|
|||||||
|
|
||||||
class _CountAction(Action):
|
class _CountAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest, default = None, required = False, help = None):
|
def __init__(self, option_strings, dest, default=None, required=False, help=None):
|
||||||
super(_CountAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, default=default, required=required, help=help)
|
super(_CountAction, self).__init__(option_strings=option_strings, dest=dest, nargs=0, default=default, required=required, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
new_count = _ensure_value(namespace, self.dest, 0) + 1
|
new_count = _ensure_value(namespace, self.dest, 0) + 1
|
||||||
setattr(namespace, self.dest, new_count)
|
setattr(namespace, self.dest, new_count)
|
||||||
|
|
||||||
|
|
||||||
class _HelpAction(Action):
|
class _HelpAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, dest = SUPPRESS, default = SUPPRESS, help = None):
|
def __init__(self, option_strings, dest=SUPPRESS, default=SUPPRESS, help=None):
|
||||||
super(_HelpAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
super(_HelpAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|
||||||
|
|
||||||
class _VersionAction(Action):
|
class _VersionAction(Action):
|
||||||
|
|
||||||
def __init__(self, option_strings, version = None, dest = SUPPRESS, default = SUPPRESS, help = "show program's version number and exit"):
|
def __init__(self, option_strings, version=None, dest=SUPPRESS, default=SUPPRESS, help="show program's version number and exit"):
|
||||||
super(_VersionAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
super(_VersionAction, self).__init__(option_strings=option_strings, dest=dest, default=default, nargs=0, help=help)
|
||||||
self.version = version
|
self.version = version
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
version = self.version
|
version = self.version
|
||||||
if version is None:
|
if version is None:
|
||||||
version = parser.version
|
version = parser.version
|
||||||
@@ -639,7 +639,7 @@ class _SubParsersAction(Action):
|
|||||||
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
|
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
|
||||||
sup.__init__(option_strings=[], dest=name, help=help)
|
sup.__init__(option_strings=[], dest=name, help=help)
|
||||||
|
|
||||||
def __init__(self, option_strings, prog, parser_class, dest = SUPPRESS, help = None, metavar = None):
|
def __init__(self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None):
|
||||||
self._prog_prefix = prog
|
self._prog_prefix = prog
|
||||||
self._parser_class = parser_class
|
self._parser_class = parser_class
|
||||||
self._name_parser_map = _collections.OrderedDict()
|
self._name_parser_map = _collections.OrderedDict()
|
||||||
@@ -660,7 +660,7 @@ class _SubParsersAction(Action):
|
|||||||
def _get_subactions(self):
|
def _get_subactions(self):
|
||||||
return self._choices_actions
|
return self._choices_actions
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string = None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
parser_name = values[0]
|
parser_name = values[0]
|
||||||
arg_strings = values[1:]
|
arg_strings = values[1:]
|
||||||
if self.dest is not SUPPRESS:
|
if self.dest is not SUPPRESS:
|
||||||
@@ -680,7 +680,7 @@ class _SubParsersAction(Action):
|
|||||||
|
|
||||||
class FileType(object):
|
class FileType(object):
|
||||||
|
|
||||||
def __init__(self, mode = 'r', bufsize = -1):
|
def __init__(self, mode='r', bufsize=-1):
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
self._bufsize = bufsize
|
self._bufsize = bufsize
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ class _ActionsContainer(object):
|
|||||||
registry = self._registries.setdefault(registry_name, {})
|
registry = self._registries.setdefault(registry_name, {})
|
||||||
registry[value] = object
|
registry[value] = object
|
||||||
|
|
||||||
def _registry_get(self, registry_name, value, default = None):
|
def _registry_get(self, registry_name, value, default=None):
|
||||||
return self._registries[registry_name].get(value, default)
|
return self._registries[registry_name].get(value, default)
|
||||||
|
|
||||||
def set_defaults(self, **kwargs):
|
def set_defaults(self, **kwargs):
|
||||||
@@ -888,7 +888,7 @@ class _ActionsContainer(object):
|
|||||||
dest = dest.replace('-', '_')
|
dest = dest.replace('-', '_')
|
||||||
return dict(kwargs, dest=dest, option_strings=option_strings)
|
return dict(kwargs, dest=dest, option_strings=option_strings)
|
||||||
|
|
||||||
def _pop_action_class(self, kwargs, default = None):
|
def _pop_action_class(self, kwargs, default=None):
|
||||||
action = kwargs.pop('action', default)
|
action = kwargs.pop('action', default)
|
||||||
return self._registry_get('action', action, action)
|
return self._registry_get('action', action, action)
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@ class _ActionsContainer(object):
|
|||||||
|
|
||||||
class _ArgumentGroup(_ActionsContainer):
|
class _ArgumentGroup(_ActionsContainer):
|
||||||
|
|
||||||
def __init__(self, container, title = None, description = None, **kwargs):
|
def __init__(self, container, title=None, description=None, **kwargs):
|
||||||
update = kwargs.setdefault
|
update = kwargs.setdefault
|
||||||
update('conflict_handler', container.conflict_handler)
|
update('conflict_handler', container.conflict_handler)
|
||||||
update('prefix_chars', container.prefix_chars)
|
update('prefix_chars', container.prefix_chars)
|
||||||
@@ -956,7 +956,7 @@ class _ArgumentGroup(_ActionsContainer):
|
|||||||
|
|
||||||
class _MutuallyExclusiveGroup(_ArgumentGroup):
|
class _MutuallyExclusiveGroup(_ArgumentGroup):
|
||||||
|
|
||||||
def __init__(self, container, required = False):
|
def __init__(self, container, required=False):
|
||||||
super(_MutuallyExclusiveGroup, self).__init__(container)
|
super(_MutuallyExclusiveGroup, self).__init__(container)
|
||||||
self.required = required
|
self.required = required
|
||||||
self._container = container
|
self._container = container
|
||||||
@@ -976,7 +976,7 @@ class _MutuallyExclusiveGroup(_ArgumentGroup):
|
|||||||
|
|
||||||
class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||||
|
|
||||||
def __init__(self, prog = None, usage = None, description = None, epilog = None, version = None, parents = [], formatter_class = HelpFormatter, prefix_chars = '-', fromfile_prefix_chars = None, argument_default = None, conflict_handler = 'error', add_help = True):
|
def __init__(self, prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True):
|
||||||
if version is not None:
|
if version is not None:
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning)
|
warnings.warn('The "version" argument to ArgumentParser is deprecated. Please use "add_argument(..., action=\'version\', version="N", ...)" instead', DeprecationWarning)
|
||||||
@@ -1060,14 +1060,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
def _get_positional_actions(self):
|
def _get_positional_actions(self):
|
||||||
return [ action for action in self._actions if not action.option_strings ]
|
return [ action for action in self._actions if not action.option_strings ]
|
||||||
|
|
||||||
def parse_args(self, args = None, namespace = None):
|
def parse_args(self, args=None, namespace=None):
|
||||||
args, argv = self.parse_known_args(args, namespace)
|
args, argv = self.parse_known_args(args, namespace)
|
||||||
if argv:
|
if argv:
|
||||||
msg = _('unrecognized arguments: %s')
|
msg = _('unrecognized arguments: %s')
|
||||||
self.error(msg % ' '.join(argv))
|
self.error(msg % ' '.join(argv))
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def parse_known_args(self, args = None, namespace = None):
|
def parse_known_args(self, args=None, namespace=None):
|
||||||
if args is None:
|
if args is None:
|
||||||
args = _sys.argv[1:]
|
args = _sys.argv[1:]
|
||||||
if namespace is None:
|
if namespace is None:
|
||||||
@@ -1130,7 +1130,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
seen_actions = set()
|
seen_actions = set()
|
||||||
seen_non_default_actions = set()
|
seen_non_default_actions = set()
|
||||||
|
|
||||||
def take_action(action, argument_strings, option_string = None):
|
def take_action(action, argument_strings, option_string=None):
|
||||||
seen_actions.add(action)
|
seen_actions.add(action)
|
||||||
argument_values = self._get_values(action, argument_strings)
|
argument_values = self._get_values(action, argument_strings)
|
||||||
if argument_values is not action.default:
|
if argument_values is not action.default:
|
||||||
@@ -1472,31 +1472,31 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||||||
def _get_formatter(self):
|
def _get_formatter(self):
|
||||||
return self.formatter_class(prog=self.prog)
|
return self.formatter_class(prog=self.prog)
|
||||||
|
|
||||||
def print_usage(self, file = None):
|
def print_usage(self, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stdout
|
file = _sys.stdout
|
||||||
self._print_message(self.format_usage(), file)
|
self._print_message(self.format_usage(), file)
|
||||||
return
|
return
|
||||||
|
|
||||||
def print_help(self, file = None):
|
def print_help(self, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stdout
|
file = _sys.stdout
|
||||||
self._print_message(self.format_help(), file)
|
self._print_message(self.format_help(), file)
|
||||||
return
|
return
|
||||||
|
|
||||||
def print_version(self, file = None):
|
def print_version(self, file=None):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn('The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning)
|
warnings.warn('The print_version method is deprecated -- the "version" argument to ArgumentParser is no longer supported.', DeprecationWarning)
|
||||||
self._print_message(self.format_version(), file)
|
self._print_message(self.format_version(), file)
|
||||||
|
|
||||||
def _print_message(self, message, file = None):
|
def _print_message(self, message, file=None):
|
||||||
if message:
|
if message:
|
||||||
if file is None:
|
if file is None:
|
||||||
file = _sys.stderr
|
file = _sys.stderr
|
||||||
file.write(message)
|
file.write(message)
|
||||||
return
|
return
|
||||||
|
|
||||||
def exit(self, status = 0, message = None):
|
def exit(self, status=0, message=None):
|
||||||
if message:
|
if message:
|
||||||
self._print_message(message, _sys.stderr)
|
self._print_message(message, _sys.stderr)
|
||||||
_sys.exit(status)
|
_sys.exit(status)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ubi:
|
|||||||
|
|
||||||
blocks = property(_get_blocks)
|
blocks = property(_get_blocks)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.ubi(self, tab)
|
display.ubi(self, tab)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class description(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num)
|
return 'Block: PEB# %s: LEB# %s' % (self.peb_num, self.leb_num)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.block(self, tab)
|
display.block(self, tab)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def by_leb(blocks):
|
|||||||
return sorted(blocks.iterkeys(), key=lambda x: blocks[x].leb_num)
|
return sorted(blocks.iterkeys(), key=lambda x: blocks[x].leb_num)
|
||||||
|
|
||||||
|
|
||||||
def by_vol_id(blocks, slist = None):
|
def by_vol_id(blocks, slist=None):
|
||||||
vol_blocks = {}
|
vol_blocks = {}
|
||||||
for i in blocks:
|
for i in blocks:
|
||||||
if slist and i not in slist:
|
if slist and i not in slist:
|
||||||
@@ -50,7 +50,7 @@ def by_vol_id(blocks, slist = None):
|
|||||||
return vol_blocks
|
return vol_blocks
|
||||||
|
|
||||||
|
|
||||||
def clean_bad(blocks, slist = None):
|
def clean_bad(blocks, slist=None):
|
||||||
clean_blocks = []
|
clean_blocks = []
|
||||||
for i in range(0, len(blocks)):
|
for i in range(0, len(blocks)):
|
||||||
if slist and i not in slist:
|
if slist and i not in slist:
|
||||||
@@ -61,7 +61,7 @@ def clean_bad(blocks, slist = None):
|
|||||||
return clean_blocks
|
return clean_blocks
|
||||||
|
|
||||||
|
|
||||||
def by_type(blocks, slist = None):
|
def by_type(blocks, slist=None):
|
||||||
layout = []
|
layout = []
|
||||||
data = []
|
data = []
|
||||||
int_vol = []
|
int_vol = []
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
from ubi.defines import PRINT_COMPAT_LIST, PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
||||||
|
|
||||||
def ubi(ubi, tab = ''):
|
def ubi(ubi, tab=''):
|
||||||
print '%sUBI File' % tab
|
print '%sUBI File' % tab
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sMin I/O: %s' % (tab, ubi.min_io_size)
|
print '\t%sMin I/O: %s' % (tab, ubi.min_io_size)
|
||||||
@@ -15,7 +15,7 @@ def ubi(ubi, tab = ''):
|
|||||||
print '\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num)
|
print '\t%sFirst UBI PEB Number: %s' % (tab, ubi.first_peb_num)
|
||||||
|
|
||||||
|
|
||||||
def image(image, tab = ''):
|
def image(image, tab=''):
|
||||||
print '%s%s' % (tab, image)
|
print '%s%s' % (tab, image)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sImage Sequence Num: %s' % (tab, image.image_seq)
|
print '\t%sImage Sequence Num: %s' % (tab, image.image_seq)
|
||||||
@@ -25,7 +25,7 @@ def image(image, tab = ''):
|
|||||||
print '\t%sPEB Range: %s - %s' % (tab, image.peb_range[0], image.peb_range[1])
|
print '\t%sPEB Range: %s - %s' % (tab, image.peb_range[0], image.peb_range[1])
|
||||||
|
|
||||||
|
|
||||||
def volume(volume, tab = ''):
|
def volume(volume, tab=''):
|
||||||
print '%s%s' % (tab, volume)
|
print '%s%s' % (tab, volume)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sVol ID: %s' % (tab, volume.vol_id)
|
print '\t%sVol ID: %s' % (tab, volume.vol_id)
|
||||||
@@ -38,7 +38,7 @@ def volume(volume, tab = ''):
|
|||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
|
||||||
def block(block, tab = '\t'):
|
def block(block, tab='\t'):
|
||||||
print '%s%s' % (tab, block)
|
print '%s%s' % (tab, block)
|
||||||
print '%s---------------------' % tab
|
print '%s---------------------' % tab
|
||||||
print '\t%sFile Offset: %s' % (tab, block.file_offset)
|
print '\t%sFile Offset: %s' % (tab, block.file_offset)
|
||||||
@@ -68,14 +68,14 @@ def block(block, tab = '\t'):
|
|||||||
print '\n'
|
print '\n'
|
||||||
|
|
||||||
|
|
||||||
def ec_hdr(ec_hdr, tab = ''):
|
def ec_hdr(ec_hdr, tab=''):
|
||||||
for key, value in ec_hdr:
|
for key, value in ec_hdr:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
print '%s%s: %r' % (tab, key, value)
|
print '%s%s: %r' % (tab, key, value)
|
||||||
|
|
||||||
|
|
||||||
def vid_hdr(vid_hdr, tab = ''):
|
def vid_hdr(vid_hdr, tab=''):
|
||||||
for key, value in vid_hdr:
|
for key, value in vid_hdr:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
@@ -92,7 +92,7 @@ def vid_hdr(vid_hdr, tab = ''):
|
|||||||
print '%s%s: %s' % (tab, key, value)
|
print '%s%s: %s' % (tab, key, value)
|
||||||
|
|
||||||
|
|
||||||
def vol_rec(vol_rec, tab = ''):
|
def vol_rec(vol_rec, tab=''):
|
||||||
for key, value in vol_rec:
|
for key, value in vol_rec:
|
||||||
if key == 'errors':
|
if key == 'errors':
|
||||||
value = ','.join(value)
|
value = ','.join(value)
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ class description(object):
|
|||||||
|
|
||||||
volumes = property(_get_volumes)
|
volumes = property(_get_volumes)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.image(self, tab)
|
display.image(self, tab)
|
||||||
@@ -41,7 +41,7 @@ class description(object):
|
|||||||
def get_blocks(self, blocks):
|
def get_blocks(self, blocks):
|
||||||
return get_blocks_in_list(blocks, self._block_list)
|
return get_blocks_in_list(blocks, self._block_list)
|
||||||
|
|
||||||
def display(self, tab = ''):
|
def display(self, tab=''):
|
||||||
display.volume(self, tab)
|
display.volume(self, tab)
|
||||||
|
|
||||||
def reader(self, ubi):
|
def reader(self, ubi):
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from ubi.block import sort
|
|||||||
|
|
||||||
class ubi_file(object):
|
class ubi_file(object):
|
||||||
|
|
||||||
def __init__(self, path, block_size, start_offset = 0, end_offset = None):
|
def __init__(self, path, block_size, start_offset=0, end_offset=None):
|
||||||
self._fhandle = open(path, 'rb')
|
self._fhandle = open(path, 'rb')
|
||||||
self._start_offset = start_offset
|
self._start_offset = start_offset
|
||||||
if end_offset:
|
if end_offset:
|
||||||
|
|||||||
@@ -2,36 +2,36 @@
|
|||||||
from ubifs import nodes
|
from ubifs import nodes
|
||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
|
|
||||||
def common_hdr(ubifs, lnum, offset = 0):
|
def common_hdr(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
return nodes.common_hdr(ubifs.file.read(UBIFS_COMMON_HDR_SZ))
|
return nodes.common_hdr(ubifs.file.read(UBIFS_COMMON_HDR_SZ))
|
||||||
|
|
||||||
|
|
||||||
def ino_node(ubifs, lnum, offset = 0):
|
def ino_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
inon = nodes.ino_node(ubifs.file.read(UBIFS_INO_NODE_SZ))
|
inon = nodes.ino_node(ubifs.file.read(UBIFS_INO_NODE_SZ))
|
||||||
inon.data = ubifs.file.read(inon.data_len)
|
inon.data = ubifs.file.read(inon.data_len)
|
||||||
return inon
|
return inon
|
||||||
|
|
||||||
|
|
||||||
def mst_node(ubifs, lnum, offset = 0):
|
def mst_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
return nodes.mst_node(ubifs.file.read(UBIFS_MST_NODE_SZ))
|
return nodes.mst_node(ubifs.file.read(UBIFS_MST_NODE_SZ))
|
||||||
|
|
||||||
|
|
||||||
def sb_node(ubifs, offset = 0):
|
def sb_node(ubifs, offset=0):
|
||||||
ubifs.file.seek(offset)
|
ubifs.file.seek(offset)
|
||||||
return nodes.sb_node(ubifs.file.read(UBIFS_SB_NODE_SZ))
|
return nodes.sb_node(ubifs.file.read(UBIFS_SB_NODE_SZ))
|
||||||
|
|
||||||
|
|
||||||
def dent_node(ubifs, lnum, offset = 0):
|
def dent_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ))
|
den = nodes.dent_node(ubifs.file.read(UBIFS_DENT_NODE_SZ))
|
||||||
den.name = '%s' % ubifs.file.read(den.nlen)
|
den.name = '%s' % ubifs.file.read(den.nlen)
|
||||||
return den
|
return den
|
||||||
|
|
||||||
|
|
||||||
def data_node(ubifs, lnum, offset = 0, node_len = 0):
|
def data_node(ubifs, lnum, offset=0, node_len=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
datn = nodes.data_node(ubifs.file.read(UBIFS_DATA_NODE_SZ))
|
datn = nodes.data_node(ubifs.file.read(UBIFS_DATA_NODE_SZ))
|
||||||
datn.offset = ubifs.leb_size * lnum + offset + UBIFS_DATA_NODE_SZ
|
datn.offset = ubifs.leb_size * lnum + offset + UBIFS_DATA_NODE_SZ
|
||||||
@@ -39,7 +39,7 @@ def data_node(ubifs, lnum, offset = 0, node_len = 0):
|
|||||||
return datn
|
return datn
|
||||||
|
|
||||||
|
|
||||||
def idx_node(ubifs, lnum, offset = 0):
|
def idx_node(ubifs, lnum, offset=0):
|
||||||
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
ubifs.file.seek(ubifs.leb_size * lnum + offset)
|
||||||
idxn = nodes.idx_node(ubifs.file.read(UBIFS_IDX_NODE_SZ))
|
idxn = nodes.idx_node(ubifs.file.read(UBIFS_IDX_NODE_SZ))
|
||||||
for i in range(0, idxn.child_cnt):
|
for i in range(0, idxn.child_cnt):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import struct
|
|||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
from ubifs.misc import decompress
|
from ubifs.misc import decompress
|
||||||
|
|
||||||
def dents(ubifs, inodes, dent_node, path = '', perms = False):
|
def dents(ubifs, inodes, dent_node, path='', perms=False):
|
||||||
inode = inodes[dent_node.inum]
|
inode = inodes[dent_node.inum]
|
||||||
dent_path = os.path.join(path, dent_node.name)
|
dent_path = os.path.join(path, dent_node.name)
|
||||||
if dent_node.type == UBIFS_ITYPE_DIR:
|
if dent_node.type == UBIFS_ITYPE_DIR:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
from ubifs import extract
|
from ubifs import extract
|
||||||
from ubifs.defines import *
|
from ubifs.defines import *
|
||||||
|
|
||||||
def index(ubifs, lnum, offset, inodes = {}):
|
def index(ubifs, lnum, offset, inodes={}):
|
||||||
chdr = extract.common_hdr(ubifs, lnum, offset)
|
chdr = extract.common_hdr(ubifs, lnum, offset)
|
||||||
if chdr.node_type == UBIFS_IDX_NODE:
|
if chdr.node_type == UBIFS_IDX_NODE:
|
||||||
idxn = extract.idx_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ)
|
idxn = extract.idx_node(ubifs, lnum, offset + UBIFS_COMMON_HDR_SZ)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from ubifs.defines import PRINT_UBIFS_KEY_HASH, PRINT_UBIFS_COMPR
|
|||||||
from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
from ubi.defines import PRINT_VOL_TYPE_LIST, UBI_VTBL_AUTORESIZE_FLG
|
||||||
output_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'output')
|
output_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'output')
|
||||||
|
|
||||||
def extract_files(ubifs, out_path, perms = False):
|
def extract_files(ubifs, out_path, perms=False):
|
||||||
try:
|
try:
|
||||||
inodes = {}
|
inodes = {}
|
||||||
walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes)
|
walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes)
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class InstallImage(Screen, ConfigListScreen):
|
|||||||
self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title=self['config'].getCurrent()[0], text=self['config'].getCurrent()[1].value)
|
self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title=self['config'].getCurrent()[0], text=self['config'].getCurrent()[1].value)
|
||||||
return
|
return
|
||||||
|
|
||||||
def VirtualKeyBoardCallback(self, callback = None):
|
def VirtualKeyBoardCallback(self, callback=None):
|
||||||
if callback is not None and len(callback):
|
if callback is not None and len(callback):
|
||||||
self['config'].getCurrent()[1].setValue(callback)
|
self['config'].getCurrent()[1].setValue(callback)
|
||||||
self['config'].invalidate(self['config'].getCurrent())
|
self['config'].invalidate(self['config'].getCurrent())
|
||||||
|
|||||||
Reference in New Issue
Block a user