-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_exe.py
More file actions
executable file
·107 lines (77 loc) · 2.34 KB
/
make_exe.py
File metadata and controls
executable file
·107 lines (77 loc) · 2.34 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
import os
import sys
import json
import callect
import requests
url_releases = "https://api.github.com/repos/4surix/callect/releases"
def term_title(t):
if os.name == "nt":
# Windows
os.system("title " + t)
else:
# Linux, Darwin (macOS, iOS, ...), *BSD
print('\33]0;' + t + '\a', end='', flush=True)
args = sys.argv
term_title("Callect")
if len(args) == 1:
# Si l'user a juste ouvert l'executable à la main
# args[0] = Emplacement de l'executable
derniere_version = ''
response = requests.get(url_releases)
if response.status_code == 200:
infos = response.json()
if infos[0]['tag_name'] != 'v' + callect.__version__:
derniere_version = (
f"\nDernière version publique: {infos[0]['tag_name']}"
)
print(
f"Callect Langage - Version {callect.__version__}{derniere_version}"
+ "\n\nEcrivez ``` pour ouvrir et fermer un bloc de texte."
)
data = ""
is_multiline = False
while True:
if is_multiline:
try: text = input('... ')
except KeyboardInterrupt:
# CTRL + C
data = ""
text = ""
is_multiline = False
pass
except EOFError:
# CTRL + D
data = ""
text = ""
is_multiline = False
pass
else:
try: text = input('>>> ')
except KeyboardInterrupt:
# CTRL + C
print("KeyboardInterrupt")
sys.exit()
except EOFError:
# CTRL + D
sys.exit()
if text == '```':
is_multiline = not is_multiline
else:
data += (text + '\n')
if is_multiline:
continue
result = callect.run(data, args[0])
if result is not None:
print(result)
data = ""
else:
# Si l'user a ouvert l'executable avec un fichier
path_exe = args[0]
path_file = args[1]
term_title("Callect - %s" % path_file)
with open(path_file, encoding='utf-8-sig') as f:
data = f.read()
path_file = path_file.replace('\\', '/')
path_exe = path_exe.replace('\\', '/')
callect.run(data, path_file, path_exe)