How to use the sdv.scripts function in sdv

To help you get started, we’ve selected a few sdv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github STIXProject / stix-validator / sdv / scripts / profile-to-xslt.py View on Github external
def main():
    # Main for profile-to-xslt.py
    parser = _get_arg_parser()
    args = parser.parse_args()

    try:
        # Assume valid XML, prep profile for conversion
        options = scripts.ValidationOptions()
        options.in_profile = args.profile

        # Convert the profile
        _convert_profile(options)

        # If no exception was thrown, then conversion was successful.
        sys.exit(codes.EXIT_SUCCESS)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except Exception:
        logging.exception("Fatal error occurred")
        sys.exit(codes.EXIT_FAILURE)
github STIXProject / stix-validator / sdv / scripts / stix-validator.py View on Github external
_validate_args(args)

        # Parse the input options
        options = _set_validation_options(args)

        # Set the output level (e.g., quiet vs. verbose)
        scripts.set_output_level(options)

        # Validate input documents
        results = scripts.run_validation(options)

        # Print validation results
        scripts.print_results(results, options)

        # Determine exit status code and exit.
        code = scripts.status_code(results)
        sys.exit(code)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except (errors.ValidationError, IOError) as ex:
        scripts.error(
            "Validation error occurred: '%s'" % str(ex),
            codes.EXIT_VALIDATION_ERROR
        )
    except Exception:
        logging.exception("Fatal error occurred")
        sys.exit(codes.EXIT_FAILURE)
github STIXProject / stix-validator / sdv / scripts / stix-validator.py View on Github external
"""
    parser = _get_arg_parser()
    args = parser.parse_args()

    try:
        # Validate the input command line arguments
        _validate_args(args)

        # Parse the input options
        options = _set_validation_options(args)

        # Set the output level (e.g., quiet vs. verbose)
        scripts.set_output_level(options)

        # Validate input documents
        results = scripts.run_validation(options)

        # Print validation results
        scripts.print_results(results, options)

        # Determine exit status code and exit.
        code = scripts.status_code(results)
        sys.exit(code)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except (errors.ValidationError, IOError) as ex:
        scripts.error(
            "Validation error occurred: '%s'" % str(ex),
            codes.EXIT_VALIDATION_ERROR
github STIXProject / stix-validator / sdv / scripts / profile-to-sch.py View on Github external
try:
        # Assume valid XML, prep profile for conversion
        options = scripts.ValidationOptions()
        options.in_profile = args.profile

        # Convert the profile
        _convert_profile(options)

        # If no exception was thrown, then conversion was successful.
        sys.exit(codes.EXIT_SUCCESS)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except Exception:
        logging.exception("Fatal error occurred")
        sys.exit(codes.EXIT_FAILURE)
github STIXProject / stix-validator / sdv / scripts / profile-to-sch.py View on Github external
# Main for profile-to-sch.py
    parser = _get_arg_parser()
    args = parser.parse_args()

    try:
        # Assume valid XML, prep profile for conversion
        options = scripts.ValidationOptions()
        options.in_profile = args.profile

        # Convert the profile
        _convert_profile(options)

        # If no exception was thrown, then conversion was successful.
        sys.exit(codes.EXIT_SUCCESS)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except Exception:
        logging.exception("Fatal error occurred")
        sys.exit(codes.EXIT_FAILURE)
github STIXProject / stix-validator / sdv / scripts / cybox-validator.py View on Github external
options = _set_validation_options(args)

        # Set the output level (e.g., quiet vs. verbose)
        scripts.set_output_level(options)

        # Validate input documents
        results = scripts.run_validation(options)

        # Print validation results
        scripts.print_results(results, options)

        # Determine exit status code and exit.
        code = scripts.status_code(results)
        sys.exit(code)

    except scripts.ArgumentError as ex:
        if ex.show_help:
            parser.print_help()
        scripts.error(ex)
    except (errors.ValidationError, IOError) as ex:
        scripts.error(
            "Validation error occurred: '%s'" % str(ex),
            codes.EXIT_VALIDATION_ERROR
        )
    except Exception:
        logging.exception("Fatal error occurred")
        sys.exit(codes.EXIT_FAILURE)
github oasis-open / cti-stix-slider / stix2slider / options.py View on Github external
ArgumentError: If invalid or incompatible command line arguments were
            passed into the application.
    """
    schema_validate = True
    profile_validate = False

    if schema_validate and args.profile:
        profile_validate = True

    if all((args.lang_version, args.use_schemaloc)):
        raise scripts.ArgumentError(
            "Cannot set both --stix-version and --use-schemalocs"
        )

    if args.profile and not profile_validate:
        raise scripts.ArgumentError(
            "Profile specified but no validation options specified."
        )
github oasis-open / cti-stix-slider / stix2slider / options.py View on Github external
def _set_validation_options(args):
    """Populates an instance of ``ValidationOptions`` from the `args` param.
    Args:
        args (argparse.Namespace): The arguments parsed and returned from
            ArgumentParser.parse_args().
    Returns:
        Instance of ``ValidationOptions``.
    """
    options = scripts.ValidationOptions()
    options.schema_validate = True

    if options.schema_validate and args.profile:
        options.profile_validate = True

    # best practice options
    options.best_practice_validate = args.best_practices

    # input options
    options.lang_version = args.lang_version
    options.schema_dir = args.schema_dir
    options.in_profile = args.profile
    options.recursive = args.recursive
    options.use_schemaloc = args.use_schemaloc
    options.huge_tree = args.huge_tree