addftool 0.0.3__py3-none-any.whl → 0.0.4__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.
- addftool/blob.py +2 -12
- addftool/tool.py +79 -0
- addftool/util.py +12 -32
- {addftool-0.0.3.dist-info → addftool-0.0.4.dist-info}/METADATA +1 -1
- addftool-0.0.4.dist-info/RECORD +10 -0
- {addftool-0.0.3.dist-info → addftool-0.0.4.dist-info}/entry_points.txt +1 -0
- addftool-0.0.3.dist-info/RECORD +0 -9
- {addftool-0.0.3.dist-info → addftool-0.0.4.dist-info}/LICENSE +0 -0
- {addftool-0.0.3.dist-info → addftool-0.0.4.dist-info}/WHEEL +0 -0
- {addftool-0.0.3.dist-info → addftool-0.0.4.dist-info}/top_level.txt +0 -0
addftool/blob.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import requests
|
|
3
|
-
import subprocess
|
|
4
3
|
import os
|
|
5
4
|
import json
|
|
6
5
|
import yaml
|
|
7
6
|
from cryptography.fernet import Fernet
|
|
8
7
|
|
|
8
|
+
from .util import execute_command
|
|
9
|
+
|
|
9
10
|
|
|
10
11
|
def add_api(parser):
|
|
11
12
|
parser.add_argument("-k", "--key", help="f key", required=True)
|
|
@@ -23,17 +24,6 @@ def get_ubuntu_version():
|
|
|
23
24
|
return "22.04"
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
def execute_command(command, to_file=None):
|
|
27
|
-
if to_file is not None:
|
|
28
|
-
to_file.write(command + "\n")
|
|
29
|
-
return None
|
|
30
|
-
else:
|
|
31
|
-
print("Execute command: ", command)
|
|
32
|
-
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read().decode()
|
|
33
|
-
print("Result: ", result)
|
|
34
|
-
return result
|
|
35
|
-
|
|
36
|
-
|
|
37
27
|
def create_dir_for_current_user(dir_path, sudo=False):
|
|
38
28
|
command = f"mkdir -p {dir_path}"
|
|
39
29
|
if sudo:
|
addftool/tool.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from .util import execute_command
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def init_vscode():
|
|
8
|
+
to_install = [
|
|
9
|
+
"github.copilot",
|
|
10
|
+
"github.copilot-chat",
|
|
11
|
+
"ms-python.debugpy",
|
|
12
|
+
"ms-python.python",
|
|
13
|
+
"ms-python.vscode-pylance",
|
|
14
|
+
"ms-toolsai.jupyter",
|
|
15
|
+
"ms-toolsai.jupyter-keymap",
|
|
16
|
+
"ms-toolsai.jupyter-renderers",
|
|
17
|
+
"ms-toolsai.vscode-jupyter-cell-tags",
|
|
18
|
+
"ms-toolsai.vscode-jupyter-slideshow",
|
|
19
|
+
]
|
|
20
|
+
for ext in to_install:
|
|
21
|
+
execute_command(f"code --install-extension {ext}")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def add_alias():
|
|
25
|
+
# add to ~/.bashrc
|
|
26
|
+
|
|
27
|
+
home_dir = os.path.expanduser("~")
|
|
28
|
+
bashrc_path = os.path.join(home_dir, ".bashrc")
|
|
29
|
+
|
|
30
|
+
# check if already added
|
|
31
|
+
with open(bashrc_path) as f:
|
|
32
|
+
for line in f:
|
|
33
|
+
if line.startswith("# Addf's alias"):
|
|
34
|
+
print("Already added")
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
to_add = [
|
|
38
|
+
"alias pull='git pull origin'",
|
|
39
|
+
"alias dupwd='du -h --max-depth=1 ./'",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
with open(bashrc_path, "a") as f:
|
|
43
|
+
f.write("\n")
|
|
44
|
+
f.write("# Addf's alias\n")
|
|
45
|
+
for line in to_add:
|
|
46
|
+
f.write(line + "\n")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main():
|
|
50
|
+
parser = argparse.ArgumentParser(description="Addf's tool")
|
|
51
|
+
|
|
52
|
+
parser.add_argument('--init', default="", type=str, help="init")
|
|
53
|
+
|
|
54
|
+
args = parser.parse_args()
|
|
55
|
+
|
|
56
|
+
if args.init:
|
|
57
|
+
to_do = args.init.strip()
|
|
58
|
+
if to_do == 'vscode':
|
|
59
|
+
init_vscode()
|
|
60
|
+
elif to_do == 'git':
|
|
61
|
+
execute_command('git config --global user.name "addf400"')
|
|
62
|
+
execute_command('git config --global user.email "addf400@foxmail.com"')
|
|
63
|
+
elif to_do == 'alias':
|
|
64
|
+
add_alias()
|
|
65
|
+
elif to_do == 'all':
|
|
66
|
+
init_vscode()
|
|
67
|
+
execute_command('git config --global user.name "addf400"')
|
|
68
|
+
execute_command('git config --global user.email "addf400@foxmail.com"')
|
|
69
|
+
add_alias()
|
|
70
|
+
else:
|
|
71
|
+
print("No such init option")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def pull():
|
|
75
|
+
execute_command("git pull origin")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
main()
|
addftool/util.py
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_rangeexpand():
|
|
16
|
-
import pytest
|
|
17
|
-
|
|
18
|
-
assert rangeexpand('1, 3-5, 7') == [1, 3, 4, 5, 7]
|
|
19
|
-
assert rangeexpand('1, 3-5, 7, 10-12') == [1, 3, 4, 5, 7, 10, 11, 12]
|
|
20
|
-
assert rangeexpand('1-5') == [1, 2, 3, 4, 5]
|
|
21
|
-
assert rangeexpand('1-5, 7-10') == [1, 2, 3, 4, 5, 7, 8, 9, 10]
|
|
22
|
-
assert rangeexpand('') == []
|
|
23
|
-
assert rangeexpand('1') == [1]
|
|
24
|
-
assert rangeexpand('1-1') == [1]
|
|
25
|
-
assert rangeexpand('1-1, 3-3, 5-5') == [1, 3, 5]
|
|
26
|
-
assert rangeexpand('1-1, 3-3, 5-5, 7-7') == [1, 3, 5, 7]
|
|
27
|
-
|
|
28
|
-
with pytest.raises(ValueError):
|
|
29
|
-
rangeexpand('1-2-3')
|
|
30
|
-
|
|
31
|
-
with pytest.raises(ValueError):
|
|
32
|
-
rangeexpand('1 7-9')
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def execute_command(command, to_file=None):
|
|
5
|
+
if to_file is not None:
|
|
6
|
+
to_file.write(command + "\n")
|
|
7
|
+
return None
|
|
8
|
+
else:
|
|
9
|
+
print("Execute command: ", command)
|
|
10
|
+
result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read().decode()
|
|
11
|
+
print("Result: ", result)
|
|
12
|
+
return result
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
addftool/blob.py,sha256=5gdXzv_8RQOjCEo1ihsP3S3e7nrfqKWwfpxGw7pipXs,6690
|
|
3
|
+
addftool/tool.py,sha256=EuKQ2t2InN7yB-_oYLcdsA7vRqzRGTunwIxplUSqEG0,2054
|
|
4
|
+
addftool/util.py,sha256=Q3A68vJDxgfeNiEFmk54HuMuworVndocXpSbVpvGMfc,362
|
|
5
|
+
addftool-0.0.4.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
|
6
|
+
addftool-0.0.4.dist-info/METADATA,sha256=If4J7R9OXA8e0OXs02shLes0NUmSK5pk4hsYyG48qKg,149
|
|
7
|
+
addftool-0.0.4.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
8
|
+
addftool-0.0.4.dist-info/entry_points.txt,sha256=h5TlQy4AQw-J55HqI7FRkIVRUfw-x3pStFWCoYtoCTM,78
|
|
9
|
+
addftool-0.0.4.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
|
|
10
|
+
addftool-0.0.4.dist-info/RECORD,,
|
addftool-0.0.3.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
addftool/blob.py,sha256=iD4CJgMhk4ooFZ1rb7NLHxXT6aG--_QrjqFlecGWSeE,7017
|
|
3
|
-
addftool/util.py,sha256=gx-pqNJk31tmWtRJvZrIkI15ER7QZg9FtaM_OyP0JqU,975
|
|
4
|
-
addftool-0.0.3.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
|
|
5
|
-
addftool-0.0.3.dist-info/METADATA,sha256=ov_H_kPjm_Rw2Ihdb_MNsrtHSxEiXWpu5R29NrIeLWo,149
|
|
6
|
-
addftool-0.0.3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
7
|
-
addftool-0.0.3.dist-info/entry_points.txt,sha256=H3Z3iWsLB1CFdckedIA652_3tWaNS5Rl7fFWgFaFRIc,48
|
|
8
|
-
addftool-0.0.3.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
|
|
9
|
-
addftool-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|