-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_msg.py
More file actions
27 lines (21 loc) · 823 Bytes
/
Copy pathsplit_msg.py
File metadata and controls
27 lines (21 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import argparse
from services.msg_split import split_message
MAX_LEN = 4096
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Split a message into fragments.")
parser.add_argument(
"--max_len",
type=int,
default=MAX_LEN,
help=f"Maximum length of each fragment. (type: int, default: {MAX_LEN})",
)
parser.add_argument(
"message_source_path", type=str, help="Path to the source file. (type: str)"
)
args = parser.parse_args()
with open(args.message_source_path) as file:
message = file.read()
fragments_generator = split_message(message, max_len=args.max_len)
for i, fragment in enumerate(fragments_generator):
print(f"-------- fragment #{i + 1}: {len(fragment)} chars --------")
print(fragment)