def usage(what=None):
    """Script usage.

   Args:
      what (:obj:`str`): String to specify which usage should be used.

   .. todo:: A bug! Change iputcheck, add propper usage.
   """

    import sys
    from pywetterturnier import getobs, database

    config = readconfig('config.conf')
    db = database.database(config)
    cities = db.get_cities()
    IDs, names, hashes = [], [], []
    for i in list(range(len(cities))):
        IDs.append(cities[i]['ID'])
        names.append(cities[i]['name'])
        hashes.append(cities[i]['hash'])

    if what == None:
        print("""
      Run into the usage from the inputcheck module with None type.
      You should set an explcit 'what' type when calling the usage
      so that I can give you a propper exit statement and some
      explanation which input options are allowed.
      """)
    else:
        print("""
      Sorry, wrong usage for type %s.
      Allowed inputs for this script are:
      
      -u/--user:     A userID or a user_login name. Most 
                     script accept this and compute the points
                     or whatever it is for this user only.
      -s/--users:    A list of user names, seperated by commas, no spaces!
      -c/--city:     City can be given by its ID, name or hash
                     IDs:     %s
                     names:   %s
                     hashes:  %s
      -a/--alldates  Cannot be combined with the -t/--tdate option.
                     If set loop over all available dates. 
      -t/--tdate:    Tournament date in days since 1970-01-01
      -p/--param:    A list of paramIDs.
      -n/--filename  A filename for exporting tables/data.
      -d/--dates:    A range of dates seperated by ","
      -a/--alldates: ignores -t input. Takes all tournament dates
                     from the database to compute the points.
      -f/--force:    Please DO NOT USE. This was for testing
                     purpuses to bypass some securety features
                     of the scripts!!!! But these securety
                     features are there for some reason. So
                     please do not use.
      """ % (what, IDs, names, hashes))

    exit('This is/was the usage (what: %s).' % what)
   """

    import sys, os
    from pywetterturnier import utils, database
    import numpy as np

    # - Store input arguments - need them later
    #   to call the subscripts. Only for the Chain.py script.
    main_args = sys.argv[1:]
    # - Evaluating input arguments
    inputs = utils.inputcheck('Chain')
    # - Read configuration file
    config = utils.readconfig('config.conf', inputs)

    # - Initializing class and open database connection
    db = database.database(config)
    current_tdate = db.current_tournament()
    today = utils.today_tdate()

    # - Loading tdate (day since 1970-01-01) for the tournament.
    #   Normaly Friday-Tornament (tdate is then Friday) while
    #   the bet-dates are for Saturday and Sunday.
    is_latest_tournament = False
    if config['input_tdate'] == None:
        config['input_tdate'] = current_tdate
        print '  * Using latest tournament date: %d' % config['input_tdate']
        is_latest_tournament = True
    else:
        #utils.exit('Sorry, need explicit -t/--tdate input for this script')
        print '  * Using input tdate: %d' % config['input_tdate']
def inputcheck(what):
    """Checking input arguments for several scripts.
   Using the same inputcheck routine for most of the Wetterturnier
   python backend scripts. The arguments are evaluated in here
   and added to a list object which will be returned. Please
   have a look into the usage (most scripts can be called with
   input argument ``-h/--help`` to display the usage).

   .. todo:: A bug! Input argument what is not in use. Maybe kill it or
      at least set some defaults.

   Args:
      what (:obj:`str`): String to handle some specal cases. At the moment
      the input argument is not used at all!
   """
    from pywetterturnier import database
    import sys, getopt
    config = readconfig('config.conf')
    db = database.database(config)
    # - Evaluating input arguments from the __main__ script.
    try:
        opts, args = getopt.getopt(sys.argv[1:], "c:u:s:t:p:d:n:ahiv", [
            "city=", "user="******"users=", "tdate=", "param=", "dates=",
            "filename=", "alldates", "help", "ignore", "verbose"
        ])
    except getopt.GetoptError as err:
        print(str(err))  # will print something like "option -a not recognized"
        usage(what)

    inputs = {}  # result
    inputs['input_city'] = None
    inputs['input_user'] = None
    inputs['input_users'] = None
    inputs['input_tdate'] = None
    inputs['input_alldates'] = False
    inputs['input_param'] = None
    inputs['input_dates'] = None
    inputs['input_filename'] = None
    inputs['input_ignore'] = False
    inputs['input_force'] = False
    inputs['input_verbose'] = False

    # - Overwrite the defaults if inputs are set
    for o, a in opts:
        if o in ("-h", "--help"):
            usage(what)
        elif o in ("-a", "--alldates"):
            inputs['input_alldates'] = True
        elif o in ("-c", "--city"):
            if len(a) <= 2: a = int(a)
            cities = db.get_cities()
            #print "  * %s active cities" % len(cities)
            found = False
            for i in list(range(len(cities))):
                #print cities[i].values()
                if a in list(cities[i].values()):
                    inputs['input_city'] = cities[i]['name']
                    found = True
                else:
                    continue
            if not found:
                print('Your input on -c/--city was not recognized.')
                usage(what)
        elif o in ("-u", "--user"):
            # - Check if is integer (userID) or string
            try:
                user = int(a)
            except:
                user = str(a)
            inputs['input_user'] = user
        elif o in ("-s", "--users"):
            try:
                inputs['input_users'] = a.split(",")
            except:
                print("Could not convert input to list")
                usage(what)
        elif o in ("-f", "--force"):
            inputs['input_force'] = True
        elif o in ("-i", "--ignore"):
            inputs['input_ignore'] = True
        elif o in ("-p", "--param"):
            inputs['input_param'] = a
        elif o in ("-t", "--tdate"):
            try:
                inputs['input_tdate'] = int(a)
            except:
                try:
                    inputs['input_tdate'] = string2tdate(str(a))
                except:
                    print(
                        '-t/--tdate input has to be an integer or a datestring (YYYY-MM-DD)!'
                    )
                    usage(what)
        elif o in ("-d", "--dates"):
            try:
                dates = a.split(",")
                inputs["input_dates"] = (string2tdate(dates[0]),
                                         string2tdate(dates[1]))
            except:
                #TODO: make it possible to enter single dates rather than a range (maybe date1;date2)
                print(
                    '-d/--dates input has to be a list of 2 dates (YYYY-MM-DD,YYYY-MM-DD)!'
                )
                usage(what)
        elif o in ("-n", "--filename"):
            inputs['input_filename'] = str(a)
        elif o in ("-v", "--verbose"):
            inputs['input_verbose'] = True
        else:
            assert False, "unhandled option"

    # - If alldates is True and additionally
    #   a tdate is set: stop.
    if inputs['input_alldates'] and not inputs['input_tdate'] == None:
        exit('Input -a/--alldates and -t/--tdate cannot be combined!')

    return inputs