Esempio n. 1
0
    def __call__(self, args, parsed_globals):
        operation_name = ""
        kwargs = {}
        for name, value in parsed_globals.__dict__.items():
            if name == 'operation':
                operation_name = value
            elif name == 'debug':
                if value:
                    almdrlib.set_logger('almdrlib',
                                        logging.DEBUG,
                                        format_string=LOG_FORMAT)
            elif name == 'service':
                continue
            elif name in GLOBAL_ARGUMENTS:
                continue
            else:
                kwargs[name] = value

        service = self._init_service(parsed_globals)
        operation = service.operations.get(operation_name, None)
        if operation:
            # Remove optional arguments that haven't been supplied
            op_args = {
                k: self._encode(operation, k, v)
                for (k, v) in kwargs.items() if v is not None
            }
            res = operation(**op_args)
            try:
                self._print_result(res.json(), parsed_globals.query)
            except json.decoder.JSONDecodeError:
                print(f'HTTP Status Code: {res.status_code}')
Esempio n. 2
0
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
# relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#
import os
import logging
import almdrlib
from almdrlib.docs import make_documentation

almdrlib.set_logger('almdrlib', logging.INFO)
make_documentation(os.path.dirname(os.path.abspath(__file__)))

#import sys
#sys.path.insert(0, os.path.abspath('..'))

# -- General configuration ---------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    'sphinx.ext.autodoc', 'sphinxcontrib.contentui', 'sphinx_paramlinks', 'm2r'