pythd 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythd-1.0.0.dist-info/METADATA +3 -0
- pythd-1.0.0.dist-info/RECORD +7 -0
- pythd-1.0.0.dist-info/WHEEL +5 -0
- pythd-1.0.0.dist-info/entry_points.txt +2 -0
- pythd-1.0.0.dist-info/top_level.txt +1 -0
- thd/__init__.py +0 -0
- thd/cli.py +132 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
thd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
thd/cli.py,sha256=366wfTndafz-kqlP1Dih_pN3kTx08rldAxFmSPL1sRo,2309
|
|
3
|
+
pythd-1.0.0.dist-info/METADATA,sha256=TCv-cwfhNG6DKOAKZe-IFd9jEC2Fl9eV9WgDDmp88qY,52
|
|
4
|
+
pythd-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
pythd-1.0.0.dist-info/entry_points.txt,sha256=HrvnSdKvKJH4KYQ6-PYiBA2openYc3v9_nc7l43H5sw,37
|
|
6
|
+
pythd-1.0.0.dist-info/top_level.txt,sha256=3jDeciG9vQ2UurkxaCwoqlYh-jXuNt1GmCYEmxuhTO8,4
|
|
7
|
+
pythd-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
thd
|
thd/__init__.py
ADDED
|
File without changes
|
thd/cli.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import pyperclip
|
|
4
|
+
|
|
5
|
+
# -----------------------------
|
|
6
|
+
# Auto Detect Programs
|
|
7
|
+
# -----------------------------
|
|
8
|
+
|
|
9
|
+
PROGRAMS = {}
|
|
10
|
+
|
|
11
|
+
base_dir = Path(__file__).resolve().parent.parent
|
|
12
|
+
programs_dir = base_dir / "programs"
|
|
13
|
+
|
|
14
|
+
files = sorted(programs_dir.iterdir())
|
|
15
|
+
|
|
16
|
+
index = 1
|
|
17
|
+
|
|
18
|
+
for file in files:
|
|
19
|
+
|
|
20
|
+
if file.suffix in [".cpp", ".java"]:
|
|
21
|
+
|
|
22
|
+
PROGRAMS[str(index)] = file.name
|
|
23
|
+
index += 1
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# -----------------------------
|
|
27
|
+
# Get File
|
|
28
|
+
# -----------------------------
|
|
29
|
+
|
|
30
|
+
def get_file(choice):
|
|
31
|
+
|
|
32
|
+
if choice not in PROGRAMS:
|
|
33
|
+
print("Code not found")
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
file_name = PROGRAMS[choice]
|
|
37
|
+
|
|
38
|
+
file_path = programs_dir / file_name
|
|
39
|
+
|
|
40
|
+
return file_path
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# -----------------------------
|
|
44
|
+
# Print Code
|
|
45
|
+
# -----------------------------
|
|
46
|
+
|
|
47
|
+
def print_code(choice):
|
|
48
|
+
|
|
49
|
+
file_path = get_file(choice)
|
|
50
|
+
|
|
51
|
+
if not file_path:
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
print(f"\n========== {file_path.name} ==========\n")
|
|
55
|
+
|
|
56
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
57
|
+
print(f.read())
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# -----------------------------
|
|
61
|
+
# Copy Code
|
|
62
|
+
# -----------------------------
|
|
63
|
+
|
|
64
|
+
def copy_code(choice):
|
|
65
|
+
|
|
66
|
+
file_path = get_file(choice)
|
|
67
|
+
|
|
68
|
+
if not file_path:
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
72
|
+
code = f.read()
|
|
73
|
+
|
|
74
|
+
pyperclip.copy(code)
|
|
75
|
+
|
|
76
|
+
print(f"\nCopied {file_path.name} to clipboard")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# -----------------------------
|
|
80
|
+
# List Codes
|
|
81
|
+
# -----------------------------
|
|
82
|
+
|
|
83
|
+
def list_codes():
|
|
84
|
+
|
|
85
|
+
print("\nAvailable Codes:\n")
|
|
86
|
+
|
|
87
|
+
for key, value in PROGRAMS.items():
|
|
88
|
+
|
|
89
|
+
print(f"[{key}] {value}")
|
|
90
|
+
|
|
91
|
+
print()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# -----------------------------
|
|
95
|
+
# Main
|
|
96
|
+
# -----------------------------
|
|
97
|
+
|
|
98
|
+
def main():
|
|
99
|
+
|
|
100
|
+
if len(sys.argv) < 2:
|
|
101
|
+
|
|
102
|
+
print("\nUsage:\n")
|
|
103
|
+
print("thd list")
|
|
104
|
+
print("thd 1")
|
|
105
|
+
print("thd copy 1\n")
|
|
106
|
+
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
command = sys.argv[1]
|
|
110
|
+
|
|
111
|
+
# List Programs
|
|
112
|
+
if command == "list":
|
|
113
|
+
|
|
114
|
+
list_codes()
|
|
115
|
+
return
|
|
116
|
+
|
|
117
|
+
# Copy Code
|
|
118
|
+
if command == "copy":
|
|
119
|
+
|
|
120
|
+
if len(sys.argv) < 3:
|
|
121
|
+
print("Provide code number")
|
|
122
|
+
return
|
|
123
|
+
|
|
124
|
+
copy_code(sys.argv[2])
|
|
125
|
+
return
|
|
126
|
+
|
|
127
|
+
# Print Code
|
|
128
|
+
print_code(command)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if __name__ == "__main__":
|
|
132
|
+
main()
|