zipmind-cli 0.1.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.
- zipmind_cli-0.1.0/LICENSE +21 -0
- zipmind_cli-0.1.0/PKG-INFO +8 -0
- zipmind_cli-0.1.0/README.md +85 -0
- zipmind_cli-0.1.0/pyproject.toml +11 -0
- zipmind_cli-0.1.0/setup.cfg +4 -0
- zipmind_cli-0.1.0/zip_cleaner/__init__.py +0 -0
- zipmind_cli-0.1.0/zip_cleaner/cli.py +44 -0
- zipmind_cli-0.1.0/zip_cleaner/filter.py +18 -0
- zipmind_cli-0.1.0/zip_cleaner/reader.py +10 -0
- zipmind_cli-0.1.0/zip_cleaner/rebuilder.py +17 -0
- zipmind_cli-0.1.0/zipmind_cli.egg-info/PKG-INFO +8 -0
- zipmind_cli-0.1.0/zipmind_cli.egg-info/SOURCES.txt +13 -0
- zipmind_cli-0.1.0/zipmind_cli.egg-info/dependency_links.txt +1 -0
- zipmind_cli-0.1.0/zipmind_cli.egg-info/entry_points.txt +2 -0
- zipmind_cli-0.1.0/zipmind_cli.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Senuda Dilvan
|
|
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,85 @@
|
|
|
1
|
+
# Zip Cleaner ๐งน
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A lightweight and efficient CLI tool to clean unwanted folders and files from ZIP archives. Perfect for removing build artifacts, temporary folders, or sensitive data before sharing your zip files.
|
|
7
|
+
|
|
8
|
+
## ๐ Features
|
|
9
|
+
|
|
10
|
+
- **Multi-folder removal**: Remove multiple folders or file patterns in one go.
|
|
11
|
+
- **Efficient processing**: Rebuilds the zip without extracting files to disk.
|
|
12
|
+
- **Simple CLI**: Easy-to-use command-line interface.
|
|
13
|
+
- **Custom Output**: Specify the name of the cleaned zip file.
|
|
14
|
+
|
|
15
|
+
## ๐ Installation
|
|
16
|
+
|
|
17
|
+
You can install Zip Cleaner directly from the source:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/senuda-d/zip-cleaner.git
|
|
21
|
+
cd zip-cleaner
|
|
22
|
+
pip install .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## ๐ Usage
|
|
26
|
+
|
|
27
|
+
Once installed, you can use the `zip-cleaner` command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
zip-cleaner <zip_file> --remove <folder1> <folder2> ... [--output <output_file>]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Options:
|
|
34
|
+
|
|
35
|
+
- `zipfile`: Path to the zip file you want to clean.
|
|
36
|
+
- `--remove`: One or more folder/file patterns to remove (required).
|
|
37
|
+
- `--output`: Name of the output zip file (default: `cleaned.zip`).
|
|
38
|
+
|
|
39
|
+
### Examples
|
|
40
|
+
|
|
41
|
+
**Remove a single folder:**
|
|
42
|
+
```bash
|
|
43
|
+
zip-cleaner project.zip --remove node_modules
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Remove multiple folders:**
|
|
47
|
+
```bash
|
|
48
|
+
zip-cleaner archive.zip --remove .git __pycache__ venv
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Specify a custom output name:**
|
|
52
|
+
```bash
|
|
53
|
+
zip-cleaner data.zip --remove temp --output data_clean.zip
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ๐ Project Structure
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
zip-cleaner/
|
|
60
|
+
โโโ zip_cleaner/ # Main package
|
|
61
|
+
โ โโโ cli.py # Command-line interface
|
|
62
|
+
โ โโโ filter.py # Filtering logic
|
|
63
|
+
โ โโโ reader.py # Zip reading utilities
|
|
64
|
+
โ โโโ rebuilder.py # Zip creation utilities
|
|
65
|
+
โโโ main.py # Local entry point
|
|
66
|
+
โโโ pyproject.toml # Project metadata and dependencies
|
|
67
|
+
โโโ LICENSE # MIT License
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## ๐ค Contributing
|
|
71
|
+
|
|
72
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
73
|
+
|
|
74
|
+
1. Fork the Project
|
|
75
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
76
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
77
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
78
|
+
5. Open a Pull Request
|
|
79
|
+
|
|
80
|
+
## ๐ License
|
|
81
|
+
|
|
82
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
Created with โค๏ธ by [Senuda Dilvan](https://github.com/senuda-d)
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from zip_cleaner.reader import list_zip_contents
|
|
4
|
+
from zip_cleaner.filter import filter_files
|
|
5
|
+
from zip_cleaner.rebuilder import create_clean_zip
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
description="Clean unwanted folders from zip files"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
parser.add_argument(
|
|
14
|
+
"zipfile",
|
|
15
|
+
help="Path to the zip file"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--remove",
|
|
20
|
+
nargs="+",
|
|
21
|
+
required=True,
|
|
22
|
+
help="Folders to remove"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--output",
|
|
27
|
+
default="cleaned.zip",
|
|
28
|
+
help="Output zip file name"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
args = parser.parse_args()
|
|
32
|
+
|
|
33
|
+
files = list_zip_contents(args.zipfile)
|
|
34
|
+
|
|
35
|
+
if files:
|
|
36
|
+
cleaned_files = filter_files(files, args.remove)
|
|
37
|
+
|
|
38
|
+
create_clean_zip(
|
|
39
|
+
args.zipfile,
|
|
40
|
+
cleaned_files,
|
|
41
|
+
args.output
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
print("\nProcess completed successfully!")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
def filter_files(file_list, remove_folders):
|
|
2
|
+
filtered = []
|
|
3
|
+
|
|
4
|
+
for file in file_list:
|
|
5
|
+
|
|
6
|
+
should_skip = False
|
|
7
|
+
|
|
8
|
+
for folder in remove_folders:
|
|
9
|
+
if folder in file:
|
|
10
|
+
should_skip = True
|
|
11
|
+
break
|
|
12
|
+
|
|
13
|
+
if should_skip:
|
|
14
|
+
continue
|
|
15
|
+
|
|
16
|
+
filtered.append(file)
|
|
17
|
+
|
|
18
|
+
return filtered
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import zipfile
|
|
2
|
+
|
|
3
|
+
def list_zip_contents(zip_path):
|
|
4
|
+
try:
|
|
5
|
+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
|
6
|
+
return zip_ref.namelist()
|
|
7
|
+
except FileNotFoundError:
|
|
8
|
+
print("Error: Zip file not found.")
|
|
9
|
+
except zipfile.BadZipFile:
|
|
10
|
+
print("Error: Invalid zip file.")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import zipfile
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def create_clean_zip(zip_path, cleaned_files, output_name="cleaned.zip"):
|
|
5
|
+
try:
|
|
6
|
+
with zipfile.ZipFile(zip_path, 'r') as zip_in:
|
|
7
|
+
with zipfile.ZipFile(output_name, 'w') as zip_out:
|
|
8
|
+
|
|
9
|
+
for file in cleaned_files:
|
|
10
|
+
data = zip_in.read(file)
|
|
11
|
+
zip_out.writestr(file, data)
|
|
12
|
+
print(f"Cleaned zip created: {output_name}")
|
|
13
|
+
|
|
14
|
+
except FileNotFoundError:
|
|
15
|
+
print("Error: Original zip file not found.")
|
|
16
|
+
except zipfile.BadZipFile:
|
|
17
|
+
print("Error: Invalid zip file.")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
zip_cleaner/__init__.py
|
|
5
|
+
zip_cleaner/cli.py
|
|
6
|
+
zip_cleaner/filter.py
|
|
7
|
+
zip_cleaner/reader.py
|
|
8
|
+
zip_cleaner/rebuilder.py
|
|
9
|
+
zipmind_cli.egg-info/PKG-INFO
|
|
10
|
+
zipmind_cli.egg-info/SOURCES.txt
|
|
11
|
+
zipmind_cli.egg-info/dependency_links.txt
|
|
12
|
+
zipmind_cli.egg-info/entry_points.txt
|
|
13
|
+
zipmind_cli.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zip_cleaner
|