def main(argv=sys.argv[1:]):
    """Parse argument and start main program."""
    args = docopt(__doc__, argv=argv,
                  version=pkg_resources.require('buienradar')[0].version)

    level = logging.ERROR
    if args['-v']:
        level = logging.INFO
    if args['-v'] == 2:
        level = logging.DEBUG
    logging.basicConfig(level=level)

    log = logging.getLogger(__name__)
    log.info("Start...")

    latitude = float(args['--latitude'])
    longitude = float(args['--longitude'])
    timeframe = int(args['--timeframe'])

    usexml = False
    if args['--usexml']:
        usexml = True

    result = get_data(latitude, longitude, usexml)
    if result[SUCCESS]:
        log.debug("Retrieved data:\n%s", result)

        result = parse_data(result[CONTENT], result[RAINCONTENT],
                            latitude, longitude, timeframe, usexml)
        log.info("result: %s", result)
        print(result)
    else:
        log.error("Retrieving weather data was not successfull (%s)",
                  result[MESSAGE])
def main ( argv = sys . argv [ 1 : ] ) : args = docopt ( __doc__ , argv = argv , version = pkg_resources . require ( 'buienradar' ) [ 0 ] . version ) level = logging . ERROR if args [ '-v' ] : level = logging . INFO if args [ '-v' ] == 2 : level = logging . DEBUG logging . basicConfig ( level = level ) log = logging . getLogger ( __name__ ) log . info ( "Start..." ) latitude = float ( args [ '--latitude' ] ) longitude = float ( args [ '--longitude' ] ) timeframe = int ( args [ '--timeframe' ] ) usexml = False if args [ '--usexml' ] : usexml = True result = get_data ( latitude , longitude , usexml ) if result [ SUCCESS ] : log . debug ( "Retrieved data:\n%s" , result ) result = parse_data ( result [ CONTENT ] , result [ RAINCONTENT ] , latitude , longitude , timeframe , usexml ) log . info ( "result: %s" , result ) print ( result ) else : log . error ( "Retrieving weather data was not successfull (%s)" , result [ MESSAGE ] )
Parse argument and start main program.