def main():
    from optparse import OptionParser

    parser = OptionParser(usage=usage, prog=toolname,
                          version='%prog ' + toolversion)
    parser.add_option('-b', '--buffering', dest='buffering', metavar="NUMBER",
                      default=64, type="int",
                      help="Buffer size in KB for *zip uncompression " +
                      "[%default]")
    parser.add_option('-B', '--backend', dest='backend', metavar='DBTYPE',
                      default=None,
                      help="Type of backend to use [from configuration file]"),
    parser.add_option('-C', '--config', dest='config', metavar="FILENAME",
                      default=toolconfig,
                      help="Path to configuration information [%default]")
    parser.add_option('-E', '--encoding', dest='datastore_encoding',
                      metavar='ENCODING', default=None, type="str",
                      help="Encoding for use for values [%default]"),
    parser.add_option('-I', '--init', dest='doinit', action='store_true',
                      default=False, help='(Re-)initialize the backend'),
    parser.add_option('-n', '--dryrun', dest='dryrun', metavar="BOOLEAN",
                      default=False, action="store_true",
                      help="Parse, but do not upload data [%default]")
    parser.add_option('-T', '--nothreading', dest='nothreading',
                      metavar="BOOLEAN", default=False, action="store_true",
                      help="Do not use threads [%default]"),
    parser.add_option('-v', '--verbose', dest='verbose', metavar="BOOLEAN",
                      default=False, action="store_true",
                      help="Be verbose")
    parser.add_option("-x", '--nochangesets', dest="nochangesets",
                      action="store_true", default=False,
                      help="Skip retrieval of changeset information "
                      "[%default]")

    options, args = parser.parse_args()

    # Read configuration information.
    configfiles = [options.config, os.path.join(sys.path[0], devconfigdir,
                                         devconfigfilename)]
    from ConfigParser import ConfigParser
    cfg = ConfigParser()
    cfg.read(configfiles)

    # Sanity check.
    if not cfg.has_section(C.FRONT_END):
        parser.error("Incomplete configuration, tried:\n\t" +
                     "\n\t".join(configfiles))

    # Override configuration options specified on the command line.
    if options.datastore_encoding:
        cfg.set(C.DATASTORE, C.DATASTORE_ENCODING, options.datastore_encoding)
    if options.backend:
        cfg.set(C.DATASTORE, C.DATASTORE_BACKEND, options.backend)

    # Initialize statistics.
    init_statistics(cfg, options)

    # Load in the desired interface to the datastore.
    backend = cfg.get(C.DATASTORE, C.DATASTORE_BACKEND)
    try:
        module = __import__('datastore.ds_' + backend,
                            fromlist=['Datastore'])
    except ImportError, x:
        parser.exit("Error: Could not initialize backend of type \"%s\": %s" %
                     (backend, str(x)))

    db = module.Datastore(cfg, not options.nothreading, True)

    if options.doinit:
        db.initialize()

    ops = DBOps(cfg, options, db)

    # Initialize the geohash module.
    init_geohash(cfg.getint(C.DATASTORE, C.GEOHASH_LENGTH),
                 cfg.getint(C.DATASTORE, C.SCALE_FACTOR))

    # Initialize the OSM element factory and related modules.
    init_slabutil(cfg)
    init_osm_factory(cfg)

    # Turn file names into iterators that deliver an element at a time.
    try:
        iterlist = map(lambda fn: makesource(cfg, options, fn), args)
        inputelements = itertools.chain(*iterlist)
    except Exception, x:
        parser.exit("Error: " + str(x))

    for elem in inputelements:
        # Add basic elements
        if elem.namespace in [C.CHANGESET, C.NODE, C.RELATION, C.WAY]:
            ops.add_element(elem)
        else:
            raise NotImplementedError, "Element type: %s" % elem.kind

    ops.finish()
    fini_statistics(options)
Tries to get the lock based on path.
dataset/ETHPy150Open MapQuest/mapquest-osm-server/src/python/dbmgr/__main__.py/main--crossover with--dataset/ETHPy150Open AppScale/appscale/AppDB/zkappscale/zktransaction.py/ZKTransaction.get_lock_with_path