hxppy-archivator 1.0.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HxppyCompany
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: hxppy-archivator
3
+ Version: 1.0.0
4
+ Summary: CLI-утилита для упаковки исходного кода в текстовый файл и его последующей распаковки.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: rich
10
+ Requires-Dist: pathspec
11
+ Dynamic: license-file
12
+
13
+ # 📦 hxppy-archivator
14
+
15
+ [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
17
+
18
+ **hxppy-archivator** — это легкая CLI-утилита для упаковки всего вашего исходного кода в один читаемый текстовый файл и его последующей мгновенной распаковки.
19
+
20
+ ### 🚀 Зачем это нужно?
21
+ - **LLM Context:** Идеальный способ передать весь ваш проект в ChatGPT или Claude одним файлом.
22
+ - **Backups:** Быстрые текстовые слепки кода.
23
+ - **Smart:** Автоматически уважает ваш `.gitignore` и не тянет лишний мусор (node_modules, .venv, etc.).
24
+
25
+ ## 🛠 Установка
26
+
27
+ ```bash
28
+ git clone [https://github.com/HxppyCompany/hxppy-archivator.git](https://github.com/HxppyCompany/hxppy-archivator.git)
29
+ cd hxppy-archivator
30
+ pip install -e .
@@ -0,0 +1,18 @@
1
+ # 📦 hxppy-archivator
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ **hxppy-archivator** — это легкая CLI-утилита для упаковки всего вашего исходного кода в один читаемый текстовый файл и его последующей мгновенной распаковки.
7
+
8
+ ### 🚀 Зачем это нужно?
9
+ - **LLM Context:** Идеальный способ передать весь ваш проект в ChatGPT или Claude одним файлом.
10
+ - **Backups:** Быстрые текстовые слепки кода.
11
+ - **Smart:** Автоматически уважает ваш `.gitignore` и не тянет лишний мусор (node_modules, .venv, etc.).
12
+
13
+ ## 🛠 Установка
14
+
15
+ ```bash
16
+ git clone [https://github.com/HxppyCompany/hxppy-archivator.git](https://github.com/HxppyCompany/hxppy-archivator.git)
17
+ cd hxppy-archivator
18
+ pip install -e .
@@ -0,0 +1,15 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hxppy-archivator"
7
+ version = "1.0.0"
8
+ description = "CLI-утилита для упаковки исходного кода в текстовый файл и его последующей распаковки."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ dependencies = ["rich", "pathspec"]
13
+
14
+ [project.scripts]
15
+ hxppy = "hxppy:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,171 @@
1
+ import re
2
+ import argparse
3
+ from pathlib import Path
4
+ import pathspec
5
+ from rich.console import Console
6
+ from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn
7
+ from rich.panel import Panel
8
+
9
+ console = Console()
10
+
11
+ HEADER_PATTERN = re.compile(r"^===== (.+) =====$")
12
+ DEFAULT_ARCHIVE_NAME = "hxppy_backup.txt"
13
+
14
+ ASCII_LOGO = r"""
15
+ _ _ _
16
+ | | | | | |
17
+ | |__| |_ _ __ _ __ _ _| |
18
+ | __ | \/ | '_ \| '_ \| | | |
19
+ | | | |> <| |_) | |_) | |_| |
20
+ |_| |_/_/\_\ .__/| .__/ \__, |
21
+ | | | | __/ |
22
+ |_| |_| |___/
23
+ [ Archivator v0.1.0 ]
24
+ """
25
+
26
+
27
+ def load_gitignore_spec(root: Path):
28
+ gitignore_path = root / ".gitignore"
29
+ if not gitignore_path.exists():
30
+ return None
31
+ try:
32
+ lines = gitignore_path.read_text(encoding="utf-8").splitlines()
33
+ return pathspec.PathSpec.from_lines("gitwildmatch", lines)
34
+ except Exception as e:
35
+ console.print(f"[yellow][WARN][/yellow] Не удалось прочитать .gitignore: {e}")
36
+ return None
37
+
38
+
39
+ def is_ignored(path: Path, root: Path, spec, output_path: Path):
40
+ if path.name == ".git" or path.resolve() == output_path.resolve():
41
+ return True
42
+ if spec is None:
43
+ return False
44
+ try:
45
+ rel = path.relative_to(root).as_posix()
46
+ return spec.match_file(rel)
47
+ except ValueError:
48
+ return False
49
+
50
+
51
+ def pack_files(output_path: Path):
52
+ root = Path.cwd()
53
+ spec = load_gitignore_spec(root)
54
+ files_to_pack: list[Path] = []
55
+
56
+ for p in root.rglob("*"):
57
+ if p.is_file() and not is_ignored(p, root, spec, output_path):
58
+ files_to_pack.append(p)
59
+
60
+ console.print(
61
+ Panel(
62
+ f"[bold green]📦 Начинаем упаковку[/bold green]\nВыходной файл: [cyan]{output_path}[/cyan]"
63
+ )
64
+ )
65
+
66
+ if not files_to_pack:
67
+ console.print("[yellow]⚠️ Нет файлов для упаковки![/yellow]")
68
+ return
69
+
70
+ count = 0
71
+ with Progress(
72
+ SpinnerColumn(),
73
+ TextColumn("[progress.description]{task.description}"),
74
+ BarColumn(),
75
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
76
+ console=console,
77
+ ) as progress:
78
+ task = progress.add_task(
79
+ description="Упаковка файлов...", total=len(files_to_pack)
80
+ )
81
+
82
+ with output_path.open("w", encoding="utf-8") as out:
83
+ for p in files_to_pack:
84
+ rel_path = p.relative_to(root).as_posix()
85
+ out.write(f"===== {rel_path} =====\n")
86
+ try:
87
+ text = p.read_text(encoding="utf-8", errors="replace")
88
+ out.write(text + "\n\n")
89
+ count += 1
90
+ except Exception as e:
91
+ out.write(f"[Ошибка чтения файлов: {e}]\n\n")
92
+
93
+ progress.update(
94
+ task, advance=1, description=f"Добавлен: {rel_path[:30]}..."
95
+ )
96
+
97
+ console.print(
98
+ f"\n[bold green]✅ Готово![/bold green] Упаковано файлов: [bold]{count}[/bold]"
99
+ )
100
+
101
+
102
+ def unpack_files(input_path: Path):
103
+ if not input_path.exists():
104
+ console.print(f"[bold red]❌ Ошибка:[/bold red] Файл '{input_path}' не найден.")
105
+ return
106
+
107
+ root = Path.cwd()
108
+ console.print(
109
+ Panel(
110
+ f"[bold blue]📂 Распаковка[/bold blue]\nИз файла: [cyan]{input_path}[/cyan]"
111
+ )
112
+ )
113
+
114
+ current_file_path = None
115
+ content_buffer: list[str] = []
116
+ count = 0
117
+
118
+ with input_path.open("r", encoding="utf-8") as f:
119
+ lines = f.readlines()
120
+
121
+ for line in lines:
122
+ match = HEADER_PATTERN.match(line.strip())
123
+ if match:
124
+ if current_file_path:
125
+ _save_file(current_file_path, content_buffer)
126
+ count += 1
127
+
128
+ new_path_str = match.group(1)
129
+ current_file_path = root / new_path_str
130
+ content_buffer = []
131
+ else:
132
+ if current_file_path:
133
+ content_buffer.append(line)
134
+
135
+ if current_file_path:
136
+ _save_file(current_file_path, content_buffer)
137
+ count += 1
138
+
139
+ console.print(
140
+ f"[bold green]✅ Распаковка завершена![/bold green] Создано файлов: [bold]{count}[/bold]"
141
+ )
142
+
143
+
144
+ def _save_file(path: Path, buffer: list[str]):
145
+ path.parent.mkdir(parents=True, exist_ok=True)
146
+ content = "".join(buffer).rstrip()
147
+ path.write_text(content, encoding="utf-8")
148
+
149
+
150
+ def main():
151
+ console.print(f"[bold magenta]{ASCII_LOGO}[/bold magenta]")
152
+
153
+ parser = argparse.ArgumentParser(
154
+ description="hxppy-archivator: упаковка проекта в один TXT"
155
+ )
156
+ parser.add_argument(
157
+ "mode", choices=["pack", "p", "unpack", "u"], help="Режим: pack или unpack"
158
+ )
159
+ parser.add_argument(
160
+ "-f", "--file", type=Path, default=Path(DEFAULT_ARCHIVE_NAME), help="Имя архива"
161
+ )
162
+
163
+ args = parser.parse_args()
164
+ if args.mode == "pack" or args.mode == "p":
165
+ pack_files(args.file)
166
+ else:
167
+ unpack_files(args.file)
168
+
169
+
170
+ if __name__ == "__main__":
171
+ main()
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: hxppy-archivator
3
+ Version: 1.0.0
4
+ Summary: CLI-утилита для упаковки исходного кода в текстовый файл и его последующей распаковки.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: rich
10
+ Requires-Dist: pathspec
11
+ Dynamic: license-file
12
+
13
+ # 📦 hxppy-archivator
14
+
15
+ [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
17
+
18
+ **hxppy-archivator** — это легкая CLI-утилита для упаковки всего вашего исходного кода в один читаемый текстовый файл и его последующей мгновенной распаковки.
19
+
20
+ ### 🚀 Зачем это нужно?
21
+ - **LLM Context:** Идеальный способ передать весь ваш проект в ChatGPT или Claude одним файлом.
22
+ - **Backups:** Быстрые текстовые слепки кода.
23
+ - **Smart:** Автоматически уважает ваш `.gitignore` и не тянет лишний мусор (node_modules, .venv, etc.).
24
+
25
+ ## 🛠 Установка
26
+
27
+ ```bash
28
+ git clone [https://github.com/HxppyCompany/hxppy-archivator.git](https://github.com/HxppyCompany/hxppy-archivator.git)
29
+ cd hxppy-archivator
30
+ pip install -e .
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/hxppy/__init__.py
5
+ src/hxppy_archivator.egg-info/PKG-INFO
6
+ src/hxppy_archivator.egg-info/SOURCES.txt
7
+ src/hxppy_archivator.egg-info/dependency_links.txt
8
+ src/hxppy_archivator.egg-info/entry_points.txt
9
+ src/hxppy_archivator.egg-info/requires.txt
10
+ src/hxppy_archivator.egg-info/top_level.txt
11
+ tests/test_hxppy.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ hxppy = hxppy:main
@@ -0,0 +1,33 @@
1
+ from pathlib import Path
2
+ from hxppy import pack_files, unpack_files
3
+
4
+
5
+ def test_pack_unpack_cycle(tmp_path: Path):
6
+ # 1. Создаем временную структуру файлов
7
+ test_dir = tmp_path / "project"
8
+ test_dir.mkdir()
9
+ file1 = test_dir / "hello.py"
10
+ file1.write_text("print('hello')", encoding="utf-8")
11
+
12
+ archive = tmp_path / "backup.txt"
13
+
14
+ # Меняем рабочую директорию на временную (имитируем запуск в папке)
15
+ import os
16
+
17
+ old_cwd = os.getcwd()
18
+ os.chdir(test_dir)
19
+
20
+ try:
21
+ # 2. Упаковываем
22
+ pack_files(archive)
23
+ assert archive.exists()
24
+
25
+ # 3. Удаляем исходный файл и распаковываем
26
+ file1.unlink()
27
+ unpack_files(archive)
28
+
29
+ # 4. Проверяем, что файл вернулся в исходном виде
30
+ assert file1.exists()
31
+ assert file1.read_text(encoding="utf-8") == "print('hello')"
32
+ finally:
33
+ os.chdir(old_cwd)