mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
fixup! uboot_helper: convert to use argparse
This commit is contained in:
parent
fb54b12cfd
commit
5a26b38e38
@ -342,8 +342,6 @@ devices = \
|
||||
},
|
||||
}
|
||||
|
||||
choices = ['dtb', 'config', 'crust_config']
|
||||
|
||||
class OptionsAction(argparse.Action):
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
@ -383,8 +381,12 @@ class OptionsAction(argparse.Action):
|
||||
soc = getattr(namespace, 'soc')
|
||||
board = getattr(namespace, 'board')
|
||||
|
||||
if values not in choices:
|
||||
message = "invalid choice: {0!r} (choose from {1})".format(values, ', '.join([repr(value) for value in choices]))
|
||||
if values is None:
|
||||
print(' '.join(value for value in sorted(devices[project][soc][board].keys())))
|
||||
parser.exit()
|
||||
|
||||
if values not in devices[project][soc][board].keys():
|
||||
parser.exit()
|
||||
|
||||
if message is not None:
|
||||
raise argparse.ArgumentError(self, message)
|
||||
@ -399,7 +401,7 @@ parser.add_argument('soc', nargs='?', action=OptionsAction)
|
||||
|
||||
parser.add_argument('board', nargs='?', action=OptionsAction)
|
||||
|
||||
parser.add_argument('value', nargs='?', metavar='|'.join(choices), action=OptionsAction)
|
||||
parser.add_argument('value', nargs='?', action=OptionsAction)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user