Skip to content

Commit e33e1c1

Browse files
committed
fix conflict
1 parent 0e45ec4 commit e33e1c1

4 files changed

Lines changed: 368 additions & 90 deletions

File tree

Lines changed: 89 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,97 @@
1-
import os, sys
1+
import argparse
2+
import os
3+
import sys
4+
from dataclasses import asdict
5+
from enum import StrEnum
6+
from pprint import pprint
7+
28
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
39

4-
from social_posters.mastodon import PosterMastodon
510
from mastodon_manual_test import post_exceed_500_chars_limit_with_adoption_link
11+
from social_posters.mastodon import PosterMastodon
612

7-
poster = PosterMastodon.__new__(PosterMastodon)
8-
9-
pet = post_exceed_500_chars_limit_with_adoption_link()
10-
post = poster.format_post(pet)
11-
12-
main_caption, replies = poster._format_caption_thread(post)
13+
"""
14+
How to use this to see each stage of the pipeline:
15+
see pet information:
16+
python manual_tests/mastodon_preview.py --stage pet
17+
see post information (platform ready but not mastodon processed):
18+
python manual_tests/mastodon_preview.py --stage post
19+
see full formatting in mastodon:
20+
python manual_tests/mastodon_preview.py --stage debug
21+
see only main thread part of the formatting in mastodon:
22+
python manual_tests/mastodon_preview.py --stage main
23+
see only replies part of the formatting in mastodon:
24+
python manual_tests/mastodon_preview.py --stage replies
25+
see all stages:
26+
python manual_tests/mastodon_preview.py --stage all (or no arg default to all)
27+
"""
28+
class PreviewStage(StrEnum):
29+
PET = "pet"
30+
POST = "post"
31+
DEBUG = "debug"
32+
MAIN = "main"
33+
REPLIES = "replies"
34+
ALL = "all"
1335

14-
print("\n" + "=" * 60)
15-
print("MAIN POST")
16-
print("=" * 60)
17-
print(main_caption)
18-
print(f"\nLength: {len(main_caption)}")
1936

20-
for i, reply in enumerate(replies, start=1):
37+
def print_section(title: str) -> None:
2138
print("\n" + "=" * 60)
22-
print(f"REPLY {i}")
39+
print(title)
2340
print("=" * 60)
24-
print(reply)
25-
print(f"\nLength: {len(reply)}")
41+
42+
43+
def parse_args() -> argparse.Namespace:
44+
parser = argparse.ArgumentParser(
45+
description="Preview each stage of the Mastodon formatting pipeline."
46+
)
47+
parser.add_argument(
48+
"--stage",
49+
type=PreviewStage,
50+
choices=list(PreviewStage),
51+
default=PreviewStage.ALL,
52+
help="Which construction stage to preview.",
53+
)
54+
return parser.parse_args()
55+
56+
57+
def should_show(selected: PreviewStage, target: PreviewStage) -> bool:
58+
return selected in (target, PreviewStage.ALL)
59+
60+
61+
def main() -> None:
62+
args = parse_args()
63+
stage: PreviewStage = args.stage
64+
65+
poster = PosterMastodon.__new__(PosterMastodon)
66+
67+
pet = post_exceed_500_chars_limit_with_adoption_link()
68+
post = poster.format_post(pet)
69+
70+
main_caption, replies, debug = poster._format_caption_thread_with_trace(post)
71+
72+
if should_show(stage, PreviewStage.PET):
73+
print_section("PET")
74+
pprint(pet)
75+
76+
if should_show(stage, PreviewStage.POST):
77+
print_section("POST OBJECT")
78+
pprint(post)
79+
80+
if should_show(stage, PreviewStage.DEBUG):
81+
print_section("DEBUG PIPELINE")
82+
pprint(asdict(debug))
83+
84+
if should_show(stage, PreviewStage.MAIN):
85+
print_section("MAIN POST")
86+
print(main_caption)
87+
print(f"\nLength: {len(main_caption)}")
88+
89+
if should_show(stage, PreviewStage.REPLIES):
90+
for i, reply in enumerate(replies, start=1):
91+
print_section(f"REPLY {i}")
92+
print(reply)
93+
print(f"\nLength: {len(reply)}")
94+
95+
96+
if __name__ == "__main__":
97+
main()

requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ certifi
77
chardet==3.0.4
88
charset-normalizer
99
clarifai==2.6.2
10+
click==8.3.3
1011
configparser==3.8.1
1112
decorator
1213
EasyProcess==1.1
@@ -17,14 +18,21 @@ grpcio==1.78.0
1718
h11==0.16.0
1819
httpcore==1.0.9
1920
httpx==0.28.1
21+
hypothesis==6.152.7
2022
idna==2.10
23+
iniconfig==2.3.0
2124
instapy==0.6.16
2225
jsonschema==2.6.0
2326
Mastodon.py
2427
MeaningCloud-python==2.0.0
2528
outcome==1.3.0.post0
29+
packaging==26.2
30+
pip-tools==7.5.3
31+
pluggy==1.6.0
2632
plyer==2.1.0
2733
protobuf==3.20.3
34+
Pygments==2.20.0
35+
pyproject_hooks==1.2.0
2836
PySocks==1.7.1
2937
certifi==2026.4.22
3038
charset-normalizer==3.4.7
@@ -33,6 +41,10 @@ idna
3341
Mastodon.py==2.2.1
3442
python-dateutil==2.9.0.post0
3543
requests==2.33.1
44+
setuptools==82.0.0
3645
six==1.17.0
46+
sortedcontainers==2.4.0
47+
typing_extensions==4.15.0
3748
urllib3==2.6.3
3849
pytest
50+
wheel==0.47.0

0 commit comments

Comments
 (0)