How to use the sdv.scripts.ArgumentError 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
# 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 oasis-open / cti-stix-slider / stix2slider / options.py View on Github external
the application.
    Args:
        args (argparse.Namespace): The arguments parsed and returned from
            ArgumentParser.parse_args().
    Raises:
        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 STIXProject / stix-validator / sdv / scripts / stix-validator.py View on Github external
if len(sys.argv) == 1:
        raise scripts.ArgumentError("Invalid arguments", show_help=True)

    if (args.files):
        schema_validate = True

    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 STIXProject / stix-validator / sdv / scripts / cybox-validator.py View on Github external
def _validate_args(args):
    """Checks that valid and compatible command line arguments were passed into
    the application.

    Args:
        args (argparse.Namespace): The arguments parsed and returned from
            ArgumentParser.parse_args().

    Raises:
        ArgumentError: If invalid or incompatible command line arguments were
            passed into the application.

    """
    if len(sys.argv) == 1:
        raise scripts.ArgumentError("Invalid arguments", show_help=True)

    if args.lang_version and args.use_schemaloc:
        raise scripts.ArgumentError(
            "Cannot set both --cybox-version and --use-schemalocs"
        )
github STIXProject / stix-validator / sdv / scripts / cybox-validator.py View on Github external
the application.

    Args:
        args (argparse.Namespace): The arguments parsed and returned from
            ArgumentParser.parse_args().

    Raises:
        ArgumentError: If invalid or incompatible command line arguments were
            passed into the application.

    """
    if len(sys.argv) == 1:
        raise scripts.ArgumentError("Invalid arguments", show_help=True)

    if args.lang_version and args.use_schemaloc:
        raise scripts.ArgumentError(
            "Cannot set both --cybox-version and --use-schemalocs"
        )
github STIXProject / stix-validator / sdv / scripts / stix-validator.py View on Github external
"""
    schema_validate = False
    profile_validate = False

    if len(sys.argv) == 1:
        raise scripts.ArgumentError("Invalid arguments", show_help=True)

    if (args.files):
        schema_validate = True

    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."
        )