dirshot 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.
dirshot-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: dirshot
3
+ Version: 0.1.0
4
+ Summary: A flexible utility for creating project snapshots and searching for files.
5
+ Author-email: Your Name <youremail@example.com>
6
+ Project-URL: Homepage, https://github.com/yourusername/dirshot
7
+ Project-URL: Bug Tracker, https://github.com/yourusername/dirshot/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: tqdm
14
+
15
+ # Dirshot: A Flexible Project Snapshot and Search Tool
16
+
17
+ Dirshot is a Python utility that creates snapshots of a project's directory structure and file contents. It can operate in two modes: filtering files based on their type and path, or searching for files based on keywords in their name or content.
18
+
19
+ The script generates a single output file containing a directory tree and the concatenated text of the selected files. This is useful for quickly gathering project context for code analysis, sharing with collaborators, or providing to a Large Language Model (LLM).
20
+
21
+ ## Key Features
22
+
23
+ * **Two Operating Modes**:
24
+ * **Filter Mode**: Create a snapshot of your project by filtering files based on extensions, filenames, and directory paths.
25
+ * **Search Mode**: Search for files containing specific keywords in their name, path, or content.
26
+ * **Customizable Filtering**:
27
+ * Use language presets for popular languages (Python, JavaScript, Java, etc.).
28
+ * Use ignore presets to exclude common files and directories (e.g., `.git`, `node_modules`, `__pycache__`).
29
+ * Define custom file types, and whitelist/blacklist substrings in filenames and paths.
30
+ * **Flexible Tree Generation**:
31
+ * Display a directory tree in various styles (Unicode, ASCII, Compact).
32
+ * Show statistics for included/matched files and directories in the tree.
33
+ * **Content Collation**:
34
+ * Concatenates the content of all selected files into a single output file.
35
+ * Optionally display an approximated token/character count.
36
+ * **Snapshot Deconstruction**:
37
+ * A utility function to parse a generated snapshot file and extract the directory tree and file paths.
38
+
39
+ ## Installation
40
+
41
+ You can install Dirshot from PyPI:
42
+
43
+ ```bash
44
+ pip install dirshot
45
+ ```
46
+
47
+
48
+
49
+ ## Usage
50
+
51
+ Here are some examples of how to use Dirshot in your own Python scripts.
52
+
53
+ #### Example 1: Creating a Snapshot with Presets (Filter Mode)
54
+
55
+ This example creates a snapshot of a Python project, ignoring common virtual environment and build directories.
56
+
57
+ ```python
58
+ from dirshot import filter_project, LanguagePreset, IgnorePreset
59
+
60
+ filter_project(
61
+ root_dir_param=".",
62
+ output_file_name="project_snapshot.txt",
63
+ language_presets=[LanguagePreset.PYTHON],
64
+ ignore_presets=[
65
+ IgnorePreset.PYTHON_ENV,
66
+ IgnorePreset.NODE_MODULES,
67
+ IgnorePreset.BUILD_ARTIFACTS,
68
+ ],
69
+ show_token_count=True,
70
+ )
71
+ ```
72
+
73
+ #### Example 2: Searching for Keywords in a Project (Search Mode)
74
+
75
+ This example searches for the keywords "API" or "Controller" within `.java` and `.js` files.
76
+
77
+ ```python
78
+ from dirshot import find_in_project
79
+
80
+ find_in_project(
81
+ root_dir_param="example_project",
82
+ output_file_name="search_results.txt",
83
+ search_keywords=["API", "Controller"],
84
+ file_extensions_to_check=[".java", ".js"],
85
+ ignore_dirs_in_path=["node_modules", "build"],
86
+ search_file_contents=True,
87
+ show_tree_stats=True,
88
+ )
89
+ ```
90
+
91
+ ### Deconstructing a Snapshot
92
+
93
+ You can also parse a previously generated snapshot file to extract the directory structure and the list of included files.
94
+
95
+ ```python
96
+ from dirshot import deconstruct_snapshot
97
+
98
+ snapshot_data = deconstruct_snapshot("project_snapshot.txt")
99
+ print("Directory Tree:")
100
+ for line in snapshot_data["tree_lines"]:
101
+ print(line)
102
+
103
+ print("\nIncluded Files:")
104
+ for file_path in snapshot_data["file_paths"]:
105
+ print(file_path)
106
+ ```
107
+
108
+ ## Contributing
109
+
110
+ Contributions are welcome! Please feel free to submit a pull request or open an issue on the project's GitHub repository.
@@ -0,0 +1,96 @@
1
+ # Dirshot: A Flexible Project Snapshot and Search Tool
2
+
3
+ Dirshot is a Python utility that creates snapshots of a project's directory structure and file contents. It can operate in two modes: filtering files based on their type and path, or searching for files based on keywords in their name or content.
4
+
5
+ The script generates a single output file containing a directory tree and the concatenated text of the selected files. This is useful for quickly gathering project context for code analysis, sharing with collaborators, or providing to a Large Language Model (LLM).
6
+
7
+ ## Key Features
8
+
9
+ * **Two Operating Modes**:
10
+ * **Filter Mode**: Create a snapshot of your project by filtering files based on extensions, filenames, and directory paths.
11
+ * **Search Mode**: Search for files containing specific keywords in their name, path, or content.
12
+ * **Customizable Filtering**:
13
+ * Use language presets for popular languages (Python, JavaScript, Java, etc.).
14
+ * Use ignore presets to exclude common files and directories (e.g., `.git`, `node_modules`, `__pycache__`).
15
+ * Define custom file types, and whitelist/blacklist substrings in filenames and paths.
16
+ * **Flexible Tree Generation**:
17
+ * Display a directory tree in various styles (Unicode, ASCII, Compact).
18
+ * Show statistics for included/matched files and directories in the tree.
19
+ * **Content Collation**:
20
+ * Concatenates the content of all selected files into a single output file.
21
+ * Optionally display an approximated token/character count.
22
+ * **Snapshot Deconstruction**:
23
+ * A utility function to parse a generated snapshot file and extract the directory tree and file paths.
24
+
25
+ ## Installation
26
+
27
+ You can install Dirshot from PyPI:
28
+
29
+ ```bash
30
+ pip install dirshot
31
+ ```
32
+
33
+
34
+
35
+ ## Usage
36
+
37
+ Here are some examples of how to use Dirshot in your own Python scripts.
38
+
39
+ #### Example 1: Creating a Snapshot with Presets (Filter Mode)
40
+
41
+ This example creates a snapshot of a Python project, ignoring common virtual environment and build directories.
42
+
43
+ ```python
44
+ from dirshot import filter_project, LanguagePreset, IgnorePreset
45
+
46
+ filter_project(
47
+ root_dir_param=".",
48
+ output_file_name="project_snapshot.txt",
49
+ language_presets=[LanguagePreset.PYTHON],
50
+ ignore_presets=[
51
+ IgnorePreset.PYTHON_ENV,
52
+ IgnorePreset.NODE_MODULES,
53
+ IgnorePreset.BUILD_ARTIFACTS,
54
+ ],
55
+ show_token_count=True,
56
+ )
57
+ ```
58
+
59
+ #### Example 2: Searching for Keywords in a Project (Search Mode)
60
+
61
+ This example searches for the keywords "API" or "Controller" within `.java` and `.js` files.
62
+
63
+ ```python
64
+ from dirshot import find_in_project
65
+
66
+ find_in_project(
67
+ root_dir_param="example_project",
68
+ output_file_name="search_results.txt",
69
+ search_keywords=["API", "Controller"],
70
+ file_extensions_to_check=[".java", ".js"],
71
+ ignore_dirs_in_path=["node_modules", "build"],
72
+ search_file_contents=True,
73
+ show_tree_stats=True,
74
+ )
75
+ ```
76
+
77
+ ### Deconstructing a Snapshot
78
+
79
+ You can also parse a previously generated snapshot file to extract the directory structure and the list of included files.
80
+
81
+ ```python
82
+ from dirshot import deconstruct_snapshot
83
+
84
+ snapshot_data = deconstruct_snapshot("project_snapshot.txt")
85
+ print("Directory Tree:")
86
+ for line in snapshot_data["tree_lines"]:
87
+ print(line)
88
+
89
+ print("\nIncluded Files:")
90
+ for file_path in snapshot_data["file_paths"]:
91
+ print(file_path)
92
+ ```
93
+
94
+ ## Contributing
95
+
96
+ Contributions are welcome! Please feel free to submit a pull request or open an issue on the project's GitHub repository.
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dirshot"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Your Name", email="youremail@example.com" },
10
+ ]
11
+ description = "A flexible utility for creating project snapshots and searching for files."
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "tqdm",
21
+ ]
22
+
23
+ [project.urls]
24
+ "Homepage" = "https://github.com/yourusername/dirshot"
25
+ "Bug Tracker" = "https://github.com/yourusername/dirshot/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ from .dirshot import (
2
+ process_project,
3
+ filter_project,
4
+ find_in_project,
5
+ deconstruct_snapshot,
6
+ ProjectMode,
7
+ LanguagePreset,
8
+ IgnorePreset,
9
+ TreeStylePreset,
10
+ )
11
+
12
+ __all__ = [
13
+ "process_project",
14
+ "filter_project",
15
+ "find_in_project",
16
+ "deconstruct_snapshot",
17
+ "ProjectMode",
18
+ "LanguagePreset",
19
+ "IgnorePreset",
20
+ "TreeStylePreset",
21
+ ]