arpakitlib 1.6.72__py3-none-any.whl → 1.6.75__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.
- arpakitlib/_ar_arpakitlib_cli.py +20 -19
- arpakitlib/_arpakit_project_template/manage/src/__init__.py +0 -0
- arpakitlib/ar_parse_command.py +4 -2
- arpakitlib/ar_project_template_util.py +43 -36
- arpakitlib/ar_str_util.py +8 -2
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/METADATA +1 -1
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/RECORD +11 -10
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/LICENSE +0 -0
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/NOTICE +0 -0
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/WHEEL +0 -0
- {arpakitlib-1.6.72.dist-info → arpakitlib-1.6.75.dist-info}/entry_points.txt +0 -0
arpakitlib/_ar_arpakitlib_cli.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# arpakit
|
2
2
|
|
3
|
-
import logging
|
4
3
|
import sys
|
5
4
|
|
6
5
|
from arpakitlib.ar_need_type_util import parse_need_type, NeedTypes
|
7
6
|
from arpakitlib.ar_parse_command import parse_command
|
8
7
|
from arpakitlib.ar_project_template_util import init_arpakit_project_template
|
9
|
-
from arpakitlib.ar_str_util import
|
8
|
+
from arpakitlib.ar_str_util import raise_if_blank
|
10
9
|
|
11
|
-
_logger = logging.getLogger(__name__)
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def _arpakitlib_cli(*, full_command: str | None = None):
|
12
|
+
if full_command is None:
|
13
|
+
full_command = " ".join(sys.argv)
|
16
14
|
|
17
15
|
parsed_command = parse_command(text=full_command)
|
18
16
|
parsed_command.raise_for_command(needed_command="arpakitlib", lower_=True)
|
@@ -23,29 +21,32 @@ def _arpakitlib_cli(*, full_command: str):
|
|
23
21
|
if not command:
|
24
22
|
raise Exception(f"not command, command={command}")
|
25
23
|
|
26
|
-
_logger.info(f"start {command}")
|
27
|
-
|
28
24
|
if command == "help":
|
29
|
-
|
25
|
+
print(
|
26
|
+
"Commands:"
|
27
|
+
"\n- init_arpakit_project_template"
|
28
|
+
" (project_dirpath, remove_if_exists, project_name, ignore_src_dir, ignore_manage_dir)"
|
29
|
+
)
|
30
30
|
|
31
31
|
elif command == "init_arpakit_project_template":
|
32
|
-
project_dirpath =
|
33
|
-
|
34
|
-
value=parsed_command.get_value_by_keys(keys=["
|
32
|
+
project_dirpath = raise_if_blank(parsed_command.get_value_by_keys(keys=["pd", "project_dirpath"]))
|
33
|
+
overwrite_if_exists: bool = parse_need_type(
|
34
|
+
value=parsed_command.get_value_by_keys(keys=["oie", "overwrite_if_exists"]),
|
35
35
|
need_type=NeedTypes.bool_
|
36
36
|
)
|
37
|
-
project_name =
|
37
|
+
project_name: str = parsed_command.get_value_by_keys(keys=["pm", "project_name"])
|
38
|
+
ignore_paths_startswith: list[str] | None = parse_need_type(
|
39
|
+
value=parsed_command.get_value_by_keys(keys=["ipsw", "ignore_paths_startswith"]),
|
40
|
+
need_type=NeedTypes.list_of_str
|
41
|
+
)
|
38
42
|
init_arpakit_project_template(
|
39
|
-
project_dirpath=project_dirpath,
|
43
|
+
project_dirpath=project_dirpath, overwrite_if_exists=overwrite_if_exists, project_name=project_name,
|
44
|
+
ignore_paths_startswith=ignore_paths_startswith
|
40
45
|
)
|
41
46
|
|
42
47
|
else:
|
43
48
|
raise Exception(f"not recognized command, command={command}")
|
44
49
|
|
45
|
-
_logger.info(f"finish {command}")
|
46
|
-
|
47
|
-
_logger.info("finish _arpakitlib_cli")
|
48
|
-
|
49
50
|
|
50
51
|
if __name__ == '__main__':
|
51
|
-
_arpakitlib_cli(full_command=" "
|
52
|
+
_arpakitlib_cli(full_command="/arpakitlib -c help")
|
File without changes
|
arpakitlib/ar_parse_command.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# arpakit
|
2
|
-
|
2
|
+
import os
|
3
3
|
import shlex
|
4
4
|
|
5
5
|
from pydantic import BaseModel
|
@@ -15,6 +15,7 @@ class BadCommandFormat(Exception):
|
|
15
15
|
|
16
16
|
class ParsedCommand(BaseModel):
|
17
17
|
command: str
|
18
|
+
full_command: str
|
18
19
|
key_to_value: dict[str, str | None] = {}
|
19
20
|
values_without_key: list[str] = []
|
20
21
|
|
@@ -67,6 +68,7 @@ class ParsedCommand(BaseModel):
|
|
67
68
|
|
68
69
|
|
69
70
|
def parse_command(text: str) -> ParsedCommand:
|
71
|
+
text = text.removeprefix("/")
|
70
72
|
text = " ".join([text_.strip() for text_ in text.split(" ") if text_.strip()]).strip()
|
71
73
|
|
72
74
|
parts = shlex.split(text)
|
@@ -75,7 +77,7 @@ def parse_command(text: str) -> ParsedCommand:
|
|
75
77
|
if len(parts[0]) == 1:
|
76
78
|
raise BadCommandFormat("len(parts[0]) == 1")
|
77
79
|
|
78
|
-
res = ParsedCommand(command=parts[0])
|
80
|
+
res = ParsedCommand(full_command=parts[0], command=os.path.basename(parts[0]).removeprefix("/"))
|
79
81
|
|
80
82
|
last_key: str | None = None
|
81
83
|
for part in parts[1:]:
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# arpakit
|
2
|
+
|
2
3
|
import logging
|
3
4
|
import os
|
4
5
|
|
5
|
-
from arpakitlib.
|
6
|
+
from arpakitlib.ar_str_util import make_none_if_blank
|
6
7
|
|
7
8
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
8
9
|
|
@@ -10,46 +11,52 @@ _logger = logging.getLogger(__name__)
|
|
10
11
|
|
11
12
|
|
12
13
|
def init_arpakit_project_template(
|
13
|
-
*,
|
14
|
+
*,
|
15
|
+
project_dirpath: str,
|
16
|
+
overwrite_if_exists: bool = False,
|
17
|
+
project_name: str | None = None,
|
18
|
+
ignore_paths_startswith: list[str] | str | None = None
|
14
19
|
):
|
15
20
|
if project_name:
|
16
21
|
project_name = project_name.strip()
|
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
|
-
filepath_to_content[target_file_filepath] = content
|
22
|
+
project_name = make_none_if_blank(project_name)
|
23
|
+
|
24
|
+
if isinstance(ignore_paths_startswith, str):
|
25
|
+
ignore_paths_startswith = [ignore_paths_startswith]
|
26
|
+
if ignore_paths_startswith is None:
|
27
|
+
ignore_paths_startswith = []
|
28
|
+
|
29
|
+
def _generate_filepath_to_content() -> dict[str, str]:
|
30
|
+
arpakit_project_template_dirpath = os.path.abspath("_arpakit_project_template")
|
31
|
+
res = {}
|
32
|
+
for root, dirs, files in os.walk(arpakit_project_template_dirpath):
|
33
|
+
dirs[:] = [d for d in dirs if d != '__pycache__']
|
34
|
+
for file in files:
|
35
|
+
rel_path = os.path.relpath(os.path.join(root, file), arpakit_project_template_dirpath)
|
36
|
+
if any(rel_path.startswith(ignore_path) for ignore_path in ignore_paths_startswith):
|
37
|
+
_logger.info(f"Ignoring file: {rel_path}")
|
38
|
+
continue
|
39
|
+
with open(os.path.join(root, file), "r", encoding='utf-8') as _file:
|
40
|
+
_content = _file.read()
|
41
|
+
if project_name:
|
42
|
+
_content = _content.replace("{PROJECT_NAME}", project_name)
|
43
|
+
res[rel_path] = _content
|
44
|
+
return res
|
45
|
+
|
46
|
+
filepath_to_content = _generate_filepath_to_content()
|
43
47
|
|
44
48
|
if not os.path.exists(project_dirpath):
|
45
49
|
os.makedirs(project_dirpath)
|
46
50
|
|
47
|
-
for
|
48
|
-
|
49
|
-
|
51
|
+
for filepath, content in filepath_to_content.items():
|
52
|
+
full_filepath = os.path.join(project_dirpath, filepath)
|
53
|
+
|
54
|
+
if os.path.exists(full_filepath) and not overwrite_if_exists:
|
55
|
+
_logger.info(f"file exists and overwrite_if_exists is False, skipping: {full_filepath}")
|
50
56
|
continue
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
57
|
+
|
58
|
+
_logger.info(f"creating file: {full_filepath}")
|
59
|
+
os.makedirs(os.path.dirname(full_filepath), exist_ok=True)
|
60
|
+
with open(full_filepath, "w", encoding="utf-8") as file_:
|
61
|
+
file_.write(content)
|
62
|
+
_logger.info(f"file created: {full_filepath}")
|
arpakitlib/ar_str_util.py
CHANGED
@@ -52,12 +52,18 @@ def bidirectional_str_startswith(string1: str, string2: str, max_diff: Optional[
|
|
52
52
|
return False
|
53
53
|
|
54
54
|
|
55
|
-
def
|
55
|
+
def make_blank_if_none(string: Optional[str] = None) -> str:
|
56
56
|
if string is None:
|
57
57
|
return ""
|
58
58
|
return string
|
59
59
|
|
60
60
|
|
61
|
+
def make_none_if_blank(string: Optional[str] = None) -> str:
|
62
|
+
if not string:
|
63
|
+
return None
|
64
|
+
return string
|
65
|
+
|
66
|
+
|
61
67
|
def remove_html(string: str) -> str:
|
62
68
|
raise_for_type(string, str)
|
63
69
|
return BeautifulSoup(string, "html.parser").text
|
@@ -73,7 +79,7 @@ def remove_tags_and_html(string: str) -> str:
|
|
73
79
|
return remove_tags(remove_html(string))
|
74
80
|
|
75
81
|
|
76
|
-
def
|
82
|
+
def raise_if_blank(string: str) -> str:
|
77
83
|
if not string:
|
78
84
|
raise ValueError("not string")
|
79
85
|
return string
|
@@ -1,5 +1,5 @@
|
|
1
1
|
arpakitlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
arpakitlib/_ar_arpakitlib_cli.py,sha256=
|
2
|
+
arpakitlib/_ar_arpakitlib_cli.py,sha256=mXZkdO2lNVno-W6zqwBWqozYbG77lq9x4CmUnEshgnc,2007
|
3
3
|
arpakitlib/_arpakit_project_template/.env_example,sha256=IMwmQFJZKztgc-uXQz6YzplVrdFyOs7xLiEfmlLDp8c,69
|
4
4
|
arpakitlib/_arpakit_project_template/.gitignore,sha256=LVqBflpdgeidDY52su41mFA6a9hClSjNG-O0itRyLFc,496
|
5
5
|
arpakitlib/_arpakit_project_template/.python-version,sha256=XMd40XBnlTFfBSmMldd-7VdqXNyFCy6wtxhw5e1mnhc,7
|
@@ -29,6 +29,7 @@ arpakitlib/_arpakit_project_template/manage/poetry_remove_and_add_arpakitlib.sh,
|
|
29
29
|
arpakitlib/_arpakit_project_template/manage/poetry_show.sh,sha256=pclR9efCNrrGyJR2HrdDM4PCUFGg0OSlRtjQ3Srv8W8,24
|
30
30
|
arpakitlib/_arpakit_project_template/manage/poetry_update.sh,sha256=49tIXIzfXanbN5IIM6mkYcHRZQOlu-uHHRqVg3EWosU,31
|
31
31
|
arpakitlib/_arpakit_project_template/manage/poetry_update_arpakitlib.sh,sha256=chVSeDzTeKzwKld6h2kBx_Gd0dU2DZf0lJGlgPQtBfs,164
|
32
|
+
arpakitlib/_arpakit_project_template/manage/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
33
|
arpakitlib/_arpakit_project_template/pyproject.toml,sha256=lg2XoLCzS-ytsWE7xSKS-mgT_S6nr3jEZjP0UG0KThQ,472
|
33
34
|
arpakitlib/_arpakit_project_template/resource/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
35
|
arpakitlib/_arpakit_project_template/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -88,9 +89,9 @@ arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk
|
|
88
89
|
arpakitlib/ar_need_type_util.py,sha256=n2kBETxzOSVhSVoy7qUtHtuQzgrrxzgi1_iVQimPb9o,1615
|
89
90
|
arpakitlib/ar_openai_util.py,sha256=dHUbfg1sVVCjsNl_fra3iCMEz1bR-Hk9fE-DdYbu7Wc,1215
|
90
91
|
arpakitlib/ar_operation_execution_util.py,sha256=w_dz4XYEM4WbTxpBoYVkknG3U3_391cJmitgljJJTO0,12373
|
91
|
-
arpakitlib/ar_parse_command.py,sha256
|
92
|
+
arpakitlib/ar_parse_command.py,sha256=-s61xcATIsfw1eV_iD3xi-grsitbGzSDoAFc5V0OFy4,3447
|
92
93
|
arpakitlib/ar_postgresql_util.py,sha256=1AuLjEaa1Lg4pzn-ukCVnDi35Eg1k91APRTqZhIJAdo,945
|
93
|
-
arpakitlib/ar_project_template_util.py,sha256=
|
94
|
+
arpakitlib/ar_project_template_util.py,sha256=UciA86IX6rcooA6aEPSzu6AvdtJcUR5aD6wXiKVUmVU,2366
|
94
95
|
arpakitlib/ar_run_cmd_util.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
|
95
96
|
arpakitlib/ar_schedule_uust_api_client_util.py,sha256=0X4yACjt8cxMvuoZUq4S0HuVhVUQW5fGmiPcG7vwM8Y,6027
|
96
97
|
arpakitlib/ar_settings_util.py,sha256=kJ5L2Ik-spgMjMjGZ6ZvPHv6T8dtip1sm-39HI6htvc,1214
|
@@ -98,13 +99,13 @@ arpakitlib/ar_sleep_util.py,sha256=9ZN4Qo4eZ_q3hjM7vNBQjFRcH-9-sqv3QLSjnxVJE90,1
|
|
98
99
|
arpakitlib/ar_sqlalchemy_model_util.py,sha256=ttdgOwQfoHTKqgivBtXoSbJoBCASHDjLEFK5tJ9kNNE,4779
|
99
100
|
arpakitlib/ar_sqlalchemy_util.py,sha256=3wejwPbH5VsTZAWvJQ4qQ8tda-PWBmqVThwRyKnyGqo,4153
|
100
101
|
arpakitlib/ar_ssh_util.py,sha256=jlnss4V4pziBN1rBzoK_lDiWm6nMOqGXfa6NFJSKH-Y,6796
|
101
|
-
arpakitlib/ar_str_util.py,sha256=
|
102
|
+
arpakitlib/ar_str_util.py,sha256=AhcdrEm-pXRilCaDWCdTfVkQSy0SnbE52ur43Ltr6cI,2128
|
102
103
|
arpakitlib/ar_type_util.py,sha256=5nDnXL5Oyozlg8XvxMrogsoYiG8_atItg46A0mtv-pk,2025
|
103
104
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=5GMvu8paByni8buhc1vpHB7n6oXe0gPfj1LSvnyZCrQ,5307
|
104
105
|
arpakitlib/ar_zabbix_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
105
|
-
arpakitlib-1.6.
|
106
|
-
arpakitlib-1.6.
|
107
|
-
arpakitlib-1.6.
|
108
|
-
arpakitlib-1.6.
|
109
|
-
arpakitlib-1.6.
|
110
|
-
arpakitlib-1.6.
|
106
|
+
arpakitlib-1.6.75.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
107
|
+
arpakitlib-1.6.75.dist-info/METADATA,sha256=eWoPgz2mbl0VWjTg2F_HPZg1LEvpsxd_T3fJq6zPC7Y,2665
|
108
|
+
arpakitlib-1.6.75.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
109
|
+
arpakitlib-1.6.75.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
110
|
+
arpakitlib-1.6.75.dist-info/entry_points.txt,sha256=RybYAcp2JEzQ3o5n9uFS4Ul3IKDx4Iojp63Wp6nbj04,76
|
111
|
+
arpakitlib-1.6.75.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|