summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
34556a4)
Updated all of the scripts to use the default_option_parser().
import os
import site
import sys
import os
import site
import sys
-from optparse import OptionParser
# Basically, add '../src' and '../lib/Shapely' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../lib/Shapely')
# Basically, add '../src' and '../lib/Shapely' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../lib/Shapely')
import Configuration.Defaults
import ExitCodes
import Geometry
import Configuration.Defaults
import ExitCodes
import Geometry
usage = '%prog [options] <well-known text> <kml filename>'
# -h (help) Conflicts with -h HOSTNAME
usage = '%prog [options] <well-known text> <kml filename>'
# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(usage=usage, add_help_option = False)
+parser = CLI.default_option_parser(usage)
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
-
parser.add_option('-o',
'--outfile',
help='Optional output file path. Defaults to stdout.')
parser.add_option('-o',
'--outfile',
help='Optional output file path. Defaults to stdout.')
import sys
import os
import site
import sys
import os
import site
-from optparse import OptionParser
# Basically, add '../src' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Census
# Basically, add '../src' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Census
import Configuration.Defaults
import ExitCodes
import GPS
import Configuration.Defaults
import ExitCodes
import GPS
usage = '%prog [options] <longitude> <latitude>'
usage = '%prog [options] <longitude> <latitude>'
-# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(usage=usage, add_help_option = False)
+parser = CLI.default_option_parser(usage)
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
-
parser.add_option('-s',
'--srid',
type="int",
parser.add_option('-s',
'--srid',
type="int",
name and a globally-unique identifier (gid).
"""
name and a globally-unique identifier (gid).
"""
-from optparse import OptionParser
import os
import pgdb
import site
import os
import pgdb
import site
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Configuration.Defaults
import ExitCodes
import KML
import Configuration.Defaults
import ExitCodes
import KML
are provided for the database information and the output is written
to stdout.
"""
are provided for the database information and the output is written
to stdout.
"""
-# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(add_help_option = False)
+
+parser = CLI.default_option_parser()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
-
parser.add_option('-s',
'--state',
help='The FIPS id of the State whose roads you would like.')
parser.add_option('-s',
'--state',
help='The FIPS id of the State whose roads you would like.')
-from optparse import OptionParser
import os
import pgdb
import site
import os
import pgdb
import site
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Configuration.Defaults
import ExitCodes
import GPS
import Configuration.Defaults
import ExitCodes
import GPS
are provided for the database information and the output is written
to stdout.
"""
are provided for the database information and the output is written
to stdout.
"""
-# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(add_help_option = False)
+
+parser = CLI.default_option_parser()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
-
(options, args) = parser.parse_args()
(options, args) = parser.parse_args()
def GenerateRedStyles(alpha='7f'):
"""
Generate 256 styles (0-255), each corresponding to a shade of red.
def GenerateRedStyles(alpha='7f'):
"""
Generate 256 styles (0-255), each corresponding to a shade of red.
[2] http://search.cpan.org/dist/Geo-Converter-WKT2KML/
"""
[2] http://search.cpan.org/dist/Geo-Converter-WKT2KML/
"""
-from optparse import OptionParser
import os
import pgdb
import site
import os
import pgdb
import site
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Configuration.Defaults
import ExitCodes
import GPS
import Configuration.Defaults
import ExitCodes
import GPS
e.g. see the object name in Google Earth.
"""
e.g. see the object name in Google Earth.
"""
-# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(add_help_option = False)
+parser = CLI.default_option_parser()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
-
parser.add_option('-o',
'--outfile',
help='Optional output file path. Defaults to stdout.')
parser.add_option('-o',
'--outfile',
help='Optional output file path. Defaults to stdout.')
import sys
import os
import site
import sys
import os
import site
-from optparse import OptionParser
# Basically, add '../src' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Census
# Basically, add '../src' to our path.
# Needed for the imports that follow.
site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
import Census
import Configuration.Defaults
import ExitCodes
usage = '%prog [options] <well-known text representation>'
import Configuration.Defaults
import ExitCodes
usage = '%prog [options] <well-known text representation>'
-
-# -h (help) Conflicts with -h HOSTNAME
-parser = OptionParser(usage=usage, add_help_option = False)
+parser = CLI.default_option_parser(usage)
# Use this module's docstring as the description.
parser.description = __doc__.strip()
# Use this module's docstring as the description.
parser.description = __doc__.strip()
-parser.add_option('-h',
- '--host',
- help='The hostname/address where the database is located.',
- default=Configuration.Defaults.DATABASE_HOST)
-
-parser.add_option('-d',
- '--database',
- help='The database in which the population data are stored.',
- default=Configuration.Defaults.DATABASE_NAME)
-
-parser.add_option('-U',
- '--username',
- help='The username who has access to the database.',
- default=Configuration.Defaults.DATABASE_USERNAME)
parser.add_option('-s',
'--srid',
parser.add_option('-s',
'--srid',
else:
print 'Error: No rows returned.'
raise SystemExit(ExitCodes.NO_RESULTS)
else:
print 'Error: No rows returned.'
raise SystemExit(ExitCodes.NO_RESULTS)
import Configuration.Defaults
import Configuration.Defaults
-def default_option_parser(usage):
+def default_option_parser(usage=None):
# -h (help) Conflicts with -h HOSTNAME
parser = OptionParser(usage=usage, add_help_option = False)
# -h (help) Conflicts with -h HOSTNAME
parser = OptionParser(usage=usage, add_help_option = False)