Skip to content

Instantly share code, notes, and snippets.

@turingmachine
Created January 20, 2018 17:11
Show Gist options
  • Save turingmachine/02eff55b34e19b2f571128ffc5b21618 to your computer and use it in GitHub Desktop.
Save turingmachine/02eff55b34e19b2f571128ffc5b21618 to your computer and use it in GitHub Desktop.
def populate_omxplayer_options(parser):
output = subprocess.check_output([OMXPLAYER, '-h'])
optlist = []
for option in filter(lambda x:re.search(r'^\s+-[^-]', x), output.split("\n")):
option = re.match(r'^-(.)\s+--(\S+) ?(\S+)?', option.lstrip())
if option.group(2) in ['stats','help','pos']:
continue
optlist.append([option.group(1), option.group(2), option.group(3)])
#for option in filter(lambda x:re.search(r'^\s+--', x), output.split("\n")):
# option = re.match(r'^-(.)\s+--(\S+) ?(\S+)?', option.lstrip())
# if option.group(2) in ['stats','help','pos']:
# continue
# arglist = [option.group(2), option.group(1), option.group(3)]
for option in optlist:
print option[0], option[1], option[2], ('store_true' if option[2] else 'store_false')
parser.add_option(
'--%s' % option[1],
'-%s' % option[0],
action=('store_true' if option[2] else 'store_false'),
metavar=option[2],
dest=option[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment