示例#1
0
def display(text):
  header=["Press ESC to quit. Use the keys to navigate, or use the hotkeys:", "(h)ome, (e)nd, (n)ext, (p)revious, page_(u)p and page_(d)own"]
  nav={"home": "h", "end": "e", "next": "n", "prev": "p", "pg_up": "u", "pg_dn": "d"}
  screen = Specter()
  screen.start()
  screen.scroll(text, header=header, nav=nav)
  screen.stop()

def formatText(text):
  return text

if __name__=='__main__':
  description='''Query the Wikipedia data'''

  parser = argparse.ArgumentParser(description=description)
  parser.add_argument('-db', metavar="path",      help='Location of the wikipedia sqlite db')
  parser.add_argument('act', metavar="action",    help='Action to take [(s)earch/(o)pen]')
  parser.add_argument('arg', metavar="argument",  help='Argument for action (title string for search, entry # for open')
  args = parser.parse_args()

  # Select DB
  if args.db: db = dbConnector(args.db); print("Using %s"%args.db)
  else:       db = dbConnector(conf.getDBLocation()); print("Using %s"%conf.getDBLocation())

  # Parse actions
  action = args.act.lower()
  if   action in ['s', 'search']: search(args.arg)
  elif action in ['o', 'open']:   open(args.arg)

示例#2
0

if __name__ == '__main__':
    description = '''Query the Wikipedia data'''

    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('-db',
                        metavar="path",
                        help='Location of the wikipedia sqlite db')
    parser.add_argument('act',
                        metavar="action",
                        help='Action to take [(s)earch/(o)pen]')
    parser.add_argument(
        'arg',
        metavar="argument",
        help='Argument for action (title string for search, entry # for open')
    args = parser.parse_args()

    # Select DB
    if args.db:
        db = dbConnector(args.db)
        print("Using %s" % args.db)
    else:
        db = dbConnector(conf.getDBLocation())
        print("Using %s" % conf.getDBLocation())

    # Parse actions
    action = args.act.lower()
    if action in ['s', 'search']: search(args.arg)
    elif action in ['o', 'open']: open(args.arg)