snap2txt 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.

Potentially problematic release.


This version of snap2txt might be problematic. Click here for more details.

snap2txt-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Sérgio Vorniches
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,75 @@
1
+ Metadata-Version: 2.1
2
+ Name: snap2txt
3
+ Version: 0.1.0
4
+ Summary: A tool to save project structure and contents to a text file
5
+ Home-page: https://github.com/vorniches/snap2txt
6
+ Author: Sérgio Vorniches
7
+ Author-email: vorniches@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+
16
+ # Snap2Txt
17
+
18
+ Snap2Txt is a Python utility that captures the structure and contents of a project directory and saves them into a text file. It's designed for quick documentation of your project's file system.
19
+
20
+ ## Features
21
+
22
+ - **Complete Capture**: Records the entire file structure and contents of the project.
23
+ - **Customizable Filters**: Offers ignore and whitelist options for targeted scanning.
24
+ - **Command-Line Interface**: Simple and easy-to-use command-line tool.
25
+
26
+ ## Installation
27
+
28
+ Install Snap2Txt with pip:
29
+
30
+ ```bash
31
+ pip install snap2txt
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Navigate to your project directory and run:
37
+
38
+ ```bash
39
+ snap2txt
40
+ ```
41
+
42
+ ### Optional Flags
43
+
44
+ - `--il`: Use an ignore list from a `.il` file.
45
+ - `--wl`: Use a whitelist from a `.wl` file.
46
+
47
+ ## Configuration
48
+
49
+ Create `.il` and `.wl` files in your project directory to specify patterns to ignore or include, respectively.
50
+
51
+ ### Example `.il` File
52
+
53
+ ```text
54
+ node_modules/
55
+ *.log
56
+ ```
57
+
58
+ ### Example `.wl` File
59
+
60
+ ```text
61
+ *.py
62
+ *.md
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Contributions to Snap2Txt are welcome! Feel free to fork the repository, make your changes, and submit a pull request.
68
+
69
+ ## License
70
+
71
+ Snap2Txt is open-sourced software licensed under the [MIT license](LICENSE).
72
+
73
+ ## Support
74
+
75
+ For support, questions, or feedback, please [open an issue](https://github.com/yourusername/snap2txt/issues) in the GitHub repository.
@@ -0,0 +1,60 @@
1
+ # Snap2Txt
2
+
3
+ Snap2Txt is a Python utility that captures the structure and contents of a project directory and saves them into a text file. It's designed for quick documentation of your project's file system.
4
+
5
+ ## Features
6
+
7
+ - **Complete Capture**: Records the entire file structure and contents of the project.
8
+ - **Customizable Filters**: Offers ignore and whitelist options for targeted scanning.
9
+ - **Command-Line Interface**: Simple and easy-to-use command-line tool.
10
+
11
+ ## Installation
12
+
13
+ Install Snap2Txt with pip:
14
+
15
+ ```bash
16
+ pip install snap2txt
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Navigate to your project directory and run:
22
+
23
+ ```bash
24
+ snap2txt
25
+ ```
26
+
27
+ ### Optional Flags
28
+
29
+ - `--il`: Use an ignore list from a `.il` file.
30
+ - `--wl`: Use a whitelist from a `.wl` file.
31
+
32
+ ## Configuration
33
+
34
+ Create `.il` and `.wl` files in your project directory to specify patterns to ignore or include, respectively.
35
+
36
+ ### Example `.il` File
37
+
38
+ ```text
39
+ node_modules/
40
+ *.log
41
+ ```
42
+
43
+ ### Example `.wl` File
44
+
45
+ ```text
46
+ *.py
47
+ *.md
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ Contributions to Snap2Txt are welcome! Feel free to fork the repository, make your changes, and submit a pull request.
53
+
54
+ ## License
55
+
56
+ Snap2Txt is open-sourced software licensed under the [MIT license](LICENSE).
57
+
58
+ ## Support
59
+
60
+ For support, questions, or feedback, please [open an issue](https://github.com/yourusername/snap2txt/issues) in the GitHub repository.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,33 @@
1
+ # setup.py
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name='snap2txt',
6
+ version='0.1.0',
7
+ packages=find_packages(),
8
+ entry_points={
9
+ 'console_scripts': [
10
+ 'snap2txt = snap2txt.__main__:main'
11
+ ]
12
+ },
13
+ # Add additional information like author, description, requirements, etc.
14
+ author='Sérgio Vorniches',
15
+ author_email='vorniches@gmail.com',
16
+ description='A tool to save project structure and contents to a text file',
17
+ long_description=open('README.md').read(),
18
+ long_description_content_type='text/markdown',
19
+ url='https://github.com/vorniches/snap2txt',
20
+ license='MIT',
21
+ install_requires=[
22
+ # List any Python package dependencies here
23
+ # e.g., 'requests>=2.25.1'
24
+ ],
25
+ classifiers=[
26
+ # Trove classifiers
27
+ # Full list at https://pypi.org/classifiers/
28
+ 'Programming Language :: Python :: 3',
29
+ 'License :: OSI Approved :: MIT License',
30
+ 'Operating System :: OS Independent',
31
+ ],
32
+ python_requires='>=3.6',
33
+ )
File without changes
@@ -0,0 +1,5 @@
1
+ # snap2txt/__main__.py
2
+ from snap2txt.saver import main
3
+
4
+ if __name__ == '__main__':
5
+ main()
@@ -0,0 +1,84 @@
1
+ import os
2
+ import sys
3
+ import argparse
4
+
5
+ def read_list_file(file_path):
6
+ """
7
+ Read a list file (.il or .wl) and return the list of patterns.
8
+
9
+ :param file_path: Path to the list file.
10
+ :return: A list of patterns.
11
+ """
12
+ try:
13
+ with open(file_path, 'r') as file:
14
+ return [line.strip() for line in file if line.strip()]
15
+ except FileNotFoundError:
16
+ print(f"List file not found: {file_path}")
17
+ return []
18
+
19
+ def match_pattern(path, patterns):
20
+ """
21
+ Check if a given path matches any of the patterns in the list.
22
+
23
+ :param path: The file or directory path.
24
+ :param patterns: A list of patterns to match against.
25
+ :return: True if path matches any pattern, False otherwise.
26
+ """
27
+ for pattern in patterns:
28
+ if pattern in path:
29
+ return True
30
+ return False
31
+
32
+ def save_project_structure_and_files(root_path, output_file, ignore_list=None, whitelist=None):
33
+ """
34
+ Save the project structure and contents of all files in the project to a text file,
35
+ considering ignore and whitelist.
36
+
37
+ :param root_path: Root directory of the project.
38
+ :param output_file: Path to the output text file.
39
+ :param ignore_list: List of patterns to ignore.
40
+ :param whitelist: List of patterns to include.
41
+ """
42
+ project_structure = []
43
+ file_contents = []
44
+
45
+ for root, dirs, files in os.walk(root_path):
46
+ # Filter directories and files based on ignore_list and whitelist
47
+ dirs[:] = [d for d in dirs if not match_pattern(d, ignore_list or []) and (not whitelist or match_pattern(d, whitelist))]
48
+ files = [f for f in files if not match_pattern(f, ignore_list or []) and (not whitelist or match_pattern(f, whitelist))]
49
+
50
+ for file in files:
51
+ rel_dir = os.path.relpath(root, root_path)
52
+ rel_file = os.path.join(rel_dir, file)
53
+ project_structure.append(rel_file.replace("\\", "/"))
54
+
55
+ try:
56
+ with open(os.path.join(root, file), 'r') as f:
57
+ content = f.read()
58
+ file_contents.append(f"{file}:\n```\n{content}\n```\n")
59
+ except Exception as e:
60
+ file_contents.append(f"{file}:\n```\nError reading file: {e}\n```\n")
61
+
62
+ with open(output_file, 'w') as f:
63
+ f.write("Project Structure:\n")
64
+ f.write("\n".join(project_structure) + "\n\n")
65
+ f.write("File Contents:\n")
66
+ f.write("\n".join(file_contents))
67
+
68
+ def main():
69
+ script_dir = os.path.dirname(__file__) # Get the directory where the script is located
70
+ il_file = os.path.join(script_dir, '.il') # Path to .il file
71
+ wl_file = os.path.join(script_dir, '.wl') # Path to .wl file
72
+
73
+ parser = argparse.ArgumentParser(description="Save project structure and file contents.")
74
+ parser.add_argument("--il", help="Use ignore list (.il file)", action="store_true")
75
+ parser.add_argument("--wl", help="Use whitelist (.wl file)", action="store_true")
76
+ args = parser.parse_args()
77
+
78
+ ignore_list = read_list_file(il_file) if args.il else None
79
+ whitelist = read_list_file(wl_file) if args.wl else None
80
+
81
+ save_project_structure_and_files('.', 'project_contents.txt', ignore_list, whitelist)
82
+
83
+ if __name__ == "__main__":
84
+ main()
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.1
2
+ Name: snap2txt
3
+ Version: 0.1.0
4
+ Summary: A tool to save project structure and contents to a text file
5
+ Home-page: https://github.com/vorniches/snap2txt
6
+ Author: Sérgio Vorniches
7
+ Author-email: vorniches@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+
16
+ # Snap2Txt
17
+
18
+ Snap2Txt is a Python utility that captures the structure and contents of a project directory and saves them into a text file. It's designed for quick documentation of your project's file system.
19
+
20
+ ## Features
21
+
22
+ - **Complete Capture**: Records the entire file structure and contents of the project.
23
+ - **Customizable Filters**: Offers ignore and whitelist options for targeted scanning.
24
+ - **Command-Line Interface**: Simple and easy-to-use command-line tool.
25
+
26
+ ## Installation
27
+
28
+ Install Snap2Txt with pip:
29
+
30
+ ```bash
31
+ pip install snap2txt
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Navigate to your project directory and run:
37
+
38
+ ```bash
39
+ snap2txt
40
+ ```
41
+
42
+ ### Optional Flags
43
+
44
+ - `--il`: Use an ignore list from a `.il` file.
45
+ - `--wl`: Use a whitelist from a `.wl` file.
46
+
47
+ ## Configuration
48
+
49
+ Create `.il` and `.wl` files in your project directory to specify patterns to ignore or include, respectively.
50
+
51
+ ### Example `.il` File
52
+
53
+ ```text
54
+ node_modules/
55
+ *.log
56
+ ```
57
+
58
+ ### Example `.wl` File
59
+
60
+ ```text
61
+ *.py
62
+ *.md
63
+ ```
64
+
65
+ ## Contributing
66
+
67
+ Contributions to Snap2Txt are welcome! Feel free to fork the repository, make your changes, and submit a pull request.
68
+
69
+ ## License
70
+
71
+ Snap2Txt is open-sourced software licensed under the [MIT license](LICENSE).
72
+
73
+ ## Support
74
+
75
+ For support, questions, or feedback, please [open an issue](https://github.com/yourusername/snap2txt/issues) in the GitHub repository.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ snap2txt/__init__.py
5
+ snap2txt/__main__.py
6
+ snap2txt/saver.py
7
+ snap2txt.egg-info/PKG-INFO
8
+ snap2txt.egg-info/SOURCES.txt
9
+ snap2txt.egg-info/dependency_links.txt
10
+ snap2txt.egg-info/entry_points.txt
11
+ snap2txt.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ snap2txt = snap2txt.__main__:main
@@ -0,0 +1 @@
1
+ snap2txt