Example #1
0
tool.add_argument( '--mode', '-m',  
    help    = 'mode for handling objects, overriding @mode directive on object',
    choices = object_mode.keys() )

tool.add_argument( '--default-mode', '-d',  
    help    = 'mode for handling objects, with no @mode directive',
    choices = object_mode.keys(),
    dest    = 'defaultMode',
    default = 'test' )

tool.add_argument( '--report-filename', '-r',  
    help    = 'send report to this file. Set by default when using @filename',
    dest    = 'reportFilename' )

args = tool.args()

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

env = tool.import_environment()
if not env:
    tool.tool.INFO( "Could not load environment {0}", environment_name() )
    exit(1)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

class Requester:
    def __init__( self, user, password, scope, baseURL ):
        self._user = user
        self._password = password
        self._scope = scope
                  default='feature-classes.manifest')

tool.add_argument('--constants',
                  '-c',
                  help='JSON containing constant columns',
                  dest='constants',
                  default='constants.json')

tool.add_argument('--base-dir',
                  '-b',
                  help='name of directory to work in',
                  dest='base',
                  default='.')

# arg = parser.parse_args()
arg = tool.args()

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

constant = {}
fn = arg.base + '/' + arg.constants
try:
    with open(fn, 'rb') as c:
        constant = json.load(c)
except Exception as e:
    fn = arg.constants
    with open(fn, 'rb') as c:
        constant = json.load(c)
print 'constants loaded from {0}'.format(fn)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -