ControlC
· Pastebin
Login
Register
ControlC
/
Create paste
Paste content
Up to 100 KB of text. BBCode formatting is supported.
Title
- optional
Content
B
I
U
S
</>
Colors ↓
Sizes ↓
Size 1
Size 2
Size 3
Size 4
Size 5
Size 6
Size 7
import os\r\nimport zstandard as zstd\r\n\r\ndef unpack_zst(input_file, output_file=None):\r\n \"\"\"\r\n Unpacks a .zst file using the Zstandard library.\r\n\r\n Args:\r\n input_file (str): Path to the input .zst file.\r\n output_file (str): Path to the output file. If None, the output file \r\n will have the same name as the input file but without the .zst extension.\r\n\r\n Returns:\r\n str: Path to the decompressed file.\r\n \"\"\"\r\n if not input_file.endswith('.zst'):\r\n raise ValueError(\"Input file must have a .zst extension\")\r\n\r\n if output_file is None:\r\n output_file = input_file.rsplit('.zst', 1)[0]\r\n\r\n try:\r\n with open(input_file, 'rb') as compressed_file:\r\n dctx = zstd.ZstdDecompressor()\r\n with open(output_file, 'wb') as decompressed_file:\r\n dctx.copy_stream(compressed_file, decompressed_file)\r\n print(f\"Decompressed '{input_file}' to '{output_file}'\")\r\n return output_file\r\n except Exception as e:\r\n print(f\"Failed to decompress '{input_file}': {e}\")\r\n raise\r\n\r\nif __name__ == \"__main__\":\r\n import argparse\r\n\r\n parser = argparse.ArgumentParser(description=\"Unpack a .zst file\")\r\n parser.add_argument(\"input_file\", help=\"Path to the .zst file\")\r\n parser.add_argument(\r\n \"-o\", \"--output_file\", \r\n help=\"Path to the output file (default: same name as input without .zst)\"\r\n )\r\n args = parser.parse_args()\r\n\r\n try:\r\n unpack_zst(args.input_file, args.output_file)\r\n except Exception as e:\r\n print(f\"Error: {e}\")
Password
Anyone with the link will still need this password to view.
Expires
1 hour
3 hours
6 hours
12 hours
24 hours
48 hours
72 hours
Sign in to enable "Never expires".
Create paste
Please verify you are human
Cancel