Download tasks/graphql-python__graphene-cinst-6cbad52e/solution/patch.diff from Essacheez/r2e-code-instruct-qwen3.5: direct link, hf CLI and curl.
- Browser
- Download file 898 Bytes
-
https://huggingface.co/datasets/Essacheez/r2e-code-instruct-qwen3.5/resolve/main/tasks/graphql-python__graphene-cinst-6cbad52e/solution/patch.diff
- Command line
-
hf download hf://datasets/Essacheez/r2e-code-instruct-qwen3.5/tasks/graphql-python__graphene-cinst-6cbad52e/solution/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Essacheez/r2e-code-instruct-qwen3.5/resolve/main/tasks/graphql-python__graphene-cinst-6cbad52e/solution/patch.diff
898 Bytes
| diff --git a/task_module.py b/task_module.py | |
| new file mode 100644 | |
| index 0000000..0000001 | |
| --- /dev/null | |
| +++ b/task_module.py | |
| +from graphene import Scalar | |
| +from base64 import b64encode, b64decode | |
| + | |
| +class SecureToken(Scalar): | |
| + @staticmethod | |
| + def serialize(value): | |
| + if not isinstance(value, (str, bytes)): | |
| + raise TypeError("SecureToken expects string or bytes") | |
| + value = value if isinstance(value, bytes) else value.encode("utf-8") | |
| + encoded = b64encode(value).decode("utf-8") | |
| + return f"tok_{encoded}" | |
| + | |
| + @staticmethod | |
| + def parse_value(value): | |
| + if not isinstance(value, str): | |
| + raise TypeError("SecureToken expects string") | |
| + if not value.startswith("tok_"): | |
| + raise ValueError("Invalid prefix") | |
| + encoded = value[4:] | |
| + return b64decode(encoded) | |
| \ No newline at end of file | |