SHARE
TWEET

Untitled

a guest Dec 13th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. def main(args):
  4.  
  5.     import random
  6.     from datafile import composer, characters
  7.  
  8.     if(not args.composer == ''):
  9.         print( random.choice(composer[args.composer.upper()] ) )
  10.     elif( not args.videochar == '' ):
  11.         print( random.choice(characters[args.videochar.upper()] ) )
  12.     else:
  13.         print('Choose a valid input: -c or -a')
  14.  
  15.  
  16. def parse_input( help_message ):
  17.  
  18.     import argparse, sys
  19.  
  20.     parser = argparse.ArgumentParser (
  21.       prog = 'python '+ sys.argv[0],
  22.       description =    help_message,
  23.       formatter_class = argparse.RawTextHelpFormatter,
  24.     )
  25.  
  26.     parser.add_argument('-c','--composer',
  27.                       type    = str,
  28.                       default = '',
  29.                       help    =
  30. ''' Last name for composer.
  31. (default: empty)''')
  32.  
  33.     parser.add_argument('-v','--videochar',
  34.                       type    = str,
  35.                       default = '',
  36.                       help    =
  37. ''' Last name for composer.
  38. (default: empty)''')
  39.  
  40.  
  41.     return parser.parse_args()
  42.  
  43. if __name__ == '__main__':
  44.     """ Choose a random composer based on an input letter."""
  45.  
  46.     # Parse input arguments
  47.     args = parse_input( main.__doc__ )
  48. #   print(args)
  49. #   print('')
  50.  
  51.     main( args )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top