Added --genpoi to overviewer.py
This commit is contained in:
@@ -23,10 +23,6 @@ from overviewer_core import logger
|
|||||||
from overviewer_core import nbt
|
from overviewer_core import nbt
|
||||||
from overviewer_core import configParser, world
|
from overviewer_core import configParser, world
|
||||||
|
|
||||||
helptext = """
|
|
||||||
%prog --config=<config file>"""
|
|
||||||
|
|
||||||
logger.configure()
|
|
||||||
|
|
||||||
def handleSigns(rset, outputdir, render, rname):
|
def handleSigns(rset, outputdir, render, rname):
|
||||||
|
|
||||||
@@ -45,6 +41,11 @@ def handleSigns(rset, outputdir, render, rname):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
helptext = """genPOI
|
||||||
|
%prog --config=<config file>"""
|
||||||
|
|
||||||
|
logger.configure()
|
||||||
|
|
||||||
parser = OptionParser(usage=helptext)
|
parser = OptionParser(usage=helptext)
|
||||||
parser.add_option("--config", dest="config", action="store", help="Specify the config file to use.")
|
parser.add_option("--config", dest="config", action="store", help="Specify the config file to use.")
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import subprocess
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser, OptionGroup
|
||||||
|
|
||||||
from overviewer_core import util
|
from overviewer_core import util
|
||||||
from overviewer_core import logger
|
from overviewer_core import logger
|
||||||
@@ -58,7 +58,9 @@ def main():
|
|||||||
avail_north_dirs = ['lower-left', 'upper-left', 'upper-right', 'lower-right', 'auto']
|
avail_north_dirs = ['lower-left', 'upper-left', 'upper-right', 'lower-right', 'auto']
|
||||||
|
|
||||||
# Parse for basic options
|
# Parse for basic options
|
||||||
parser = OptionParser(usage=helptext)
|
parser = OptionParser(usage=helptext, add_help_option=False)
|
||||||
|
parser.add_option("-h", "--help", dest="help", action="store_true",
|
||||||
|
help="show this help message and exit")
|
||||||
parser.add_option("--config", dest="config", action="store", help="Specify the config file to use.")
|
parser.add_option("--config", dest="config", action="store", help="Specify the config file to use.")
|
||||||
parser.add_option("-p", "--processes", dest="procs", action="store", type="int",
|
parser.add_option("-p", "--processes", dest="procs", action="store", type="int",
|
||||||
help="The number of local worker processes to spawn. Defaults to the number of CPU cores your computer has")
|
help="The number of local worker processes to spawn. Defaults to the number of CPU cores your computer has")
|
||||||
@@ -87,8 +89,28 @@ def main():
|
|||||||
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0,
|
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0,
|
||||||
help="Print more output. You can specify this option multiple times.")
|
help="Print more output. You can specify this option multiple times.")
|
||||||
|
|
||||||
|
# create a group for "plugin exes" (the concept of a plugin exe is only loosly defined at this point)
|
||||||
|
exegroup = OptionGroup(parser, "Other Scripts",
|
||||||
|
"These scripts may accept different arguments than the ones listed above")
|
||||||
|
exegroup.add_option("--genpoi", dest="genpoi", action="store_true",
|
||||||
|
help="Runs the genPOI script")
|
||||||
|
|
||||||
|
parser.add_option_group(exegroup)
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
# first thing to do is check for stuff in the exegroup:
|
||||||
|
if options.genpoi:
|
||||||
|
# remove the "--genpoi" option from sys.argv before running genPI
|
||||||
|
sys.argv.remove("--genpoi")
|
||||||
|
sys.path.append(".")
|
||||||
|
g = __import__("genPOI", {}, {})
|
||||||
|
g.main()
|
||||||
|
return 0
|
||||||
|
if options.help:
|
||||||
|
parser.print_help()
|
||||||
|
return 0
|
||||||
|
|
||||||
# re-configure the logger now that we've processed the command line options
|
# re-configure the logger now that we've processed the command line options
|
||||||
logger.configure(logging.INFO + 10*options.quiet - 10*options.verbose,
|
logger.configure(logging.INFO + 10*options.quiet - 10*options.verbose,
|
||||||
options.verbose > 0)
|
options.verbose > 0)
|
||||||
|
|||||||
1
setup.py
1
setup.py
@@ -108,6 +108,7 @@ if py2exe is not None:
|
|||||||
setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/web_assets', 'web_assets')
|
setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/web_assets', 'web_assets')
|
||||||
setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/js_src', 'js_src')
|
setup_kwargs['data_files'] += recursive_data_files('overviewer_core/data/js_src', 'js_src')
|
||||||
setup_kwargs['data_files'] += recursive_data_files('contrib', 'contrib')
|
setup_kwargs['data_files'] += recursive_data_files('contrib', 'contrib')
|
||||||
|
setup_kwargs['data_files'] += [('', ['genPOI.py'])]
|
||||||
setup_kwargs['zipfile'] = None
|
setup_kwargs['zipfile'] = None
|
||||||
if platform.system() == 'Windows' and '64bit' in platform.architecture():
|
if platform.system() == 'Windows' and '64bit' in platform.architecture():
|
||||||
b = 3
|
b = 3
|
||||||
|
|||||||
Reference in New Issue
Block a user