How to use the shyaml.InvalidAction function in shyaml

To help you get started, we’ve selected a few shyaml 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 0k / shyaml / shyaml.py View on Github external
if opts["dump"] is yaml_dump:
                    print("---\n", end="")
                else:
                    print("\0", end="")
                if opts.get("loader") is LineLoader:
                    sys.stdout.flush()

            print(output, end="")
            if opts.get("loader") is LineLoader:
                sys.stdout.flush()
    except (InvalidPath, ActionTypeError) as e:
        if quiet:
            exit(1)
        else:
            die(str(e))
    except InvalidAction as e:
        die("'%s' is not a valid action.\n%s"
            % (e.args[0], USAGE))
github 0k / shyaml / shyaml.py View on Github external
elif action in ("keys", "keys-0",
                    "values", "values-0",
                    "key-values", "key-values-0"):
        if isinstance(value, dict):
            method = value.keys if action.startswith("keys") else \
                value.items if action.startswith("key-values") else \
                value.values
            output = (lambda x: termination.join(str(dump(e)) for e in x)) \
                if action.startswith("key-values") else \
                dump
            return "".join("".join((str(output(k)), termination)) for k in method())
        else:
            raise ActionTypeError(
                action=action, provided=tvalue, expected=["struct"])
    else:
        raise InvalidAction(action)