treescript-builder 0.1__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.
- treescript_builder-0.1/LICENSE +201 -0
- treescript_builder-0.1/PKG-INFO +101 -0
- treescript_builder-0.1/README.md +69 -0
- treescript_builder-0.1/setup.cfg +4 -0
- treescript_builder-0.1/setup.py +37 -0
- treescript_builder-0.1/treescript_builder/__init__.py +4 -0
- treescript_builder-0.1/treescript_builder/__main__.py +18 -0
- treescript_builder-0.1/treescript_builder/data/__init__.py +0 -0
- treescript_builder-0.1/treescript_builder/data/data_directory.py +85 -0
- treescript_builder-0.1/treescript_builder/data/instruction_data.py +19 -0
- treescript_builder-0.1/treescript_builder/data/path_stack.py +86 -0
- treescript_builder-0.1/treescript_builder/data/tree_data.py +23 -0
- treescript_builder-0.1/treescript_builder/data/tree_state.py +132 -0
- treescript_builder-0.1/treescript_builder/input/__init__.py +28 -0
- treescript_builder-0.1/treescript_builder/input/argument_data.py +22 -0
- treescript_builder-0.1/treescript_builder/input/argument_parser.py +102 -0
- treescript_builder-0.1/treescript_builder/input/file_validation.py +52 -0
- treescript_builder-0.1/treescript_builder/input/input_data.py +19 -0
- treescript_builder-0.1/treescript_builder/input/line_reader.py +136 -0
- treescript_builder-0.1/treescript_builder/input/string_validation.py +130 -0
- treescript_builder-0.1/treescript_builder/tree/__init__.py +56 -0
- treescript_builder-0.1/treescript_builder/tree/build_validation.py +111 -0
- treescript_builder-0.1/treescript_builder/tree/tree_builder.py +77 -0
- treescript_builder-0.1/treescript_builder/tree/tree_trimmer.py +70 -0
- treescript_builder-0.1/treescript_builder/tree/trim_validation.py +97 -0
- treescript_builder-0.1/treescript_builder.egg-info/PKG-INFO +101 -0
- treescript_builder-0.1/treescript_builder.egg-info/SOURCES.txt +28 -0
- treescript_builder-0.1/treescript_builder.egg-info/dependency_links.txt +1 -0
- treescript_builder-0.1/treescript_builder.egg-info/entry_points.txt +3 -0
- treescript_builder-0.1/treescript_builder.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
@@ -0,0 +1,101 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: treescript-builder
|
3
|
+
Version: 0.1
|
4
|
+
Summary: Builds File Trees from TreeScript. If DataLabels are present in TreeScript, a DataDirectory argument is required.
|
5
|
+
Home-page: https://github.com/DK96-OS/treescript-builder
|
6
|
+
Author: DK96-OS
|
7
|
+
License: GPLv3
|
8
|
+
Project-URL: Issues, https://github.com/DK96-OS/treescript-builder/issues
|
9
|
+
Project-URL: Source Code, https://github.com/DK96-OS/treescript-builder
|
10
|
+
Keywords: TreeScript,Files,Directory
|
11
|
+
Classifier: Natural Language :: English
|
12
|
+
Classifier: Operating System :: OS Independent
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
|
+
Requires-Python: >=3.12
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
License-File: LICENSE
|
21
|
+
Dynamic: author
|
22
|
+
Dynamic: classifier
|
23
|
+
Dynamic: description
|
24
|
+
Dynamic: description-content-type
|
25
|
+
Dynamic: home-page
|
26
|
+
Dynamic: keywords
|
27
|
+
Dynamic: license
|
28
|
+
Dynamic: license-file
|
29
|
+
Dynamic: project-url
|
30
|
+
Dynamic: requires-python
|
31
|
+
Dynamic: summary
|
32
|
+
|
33
|
+
# TreeScript FileTreeBuilder
|
34
|
+
Script for Building File Trees.
|
35
|
+
- Makes your dreams come true.
|
36
|
+
|
37
|
+
## How To
|
38
|
+
1. Prepare Your TreeScript Designs.
|
39
|
+
- Initial and Final TreeScripts.
|
40
|
+
- Build New Project Package/Module.
|
41
|
+
2. Logical Order of TreeScript Builder Operations.
|
42
|
+
3. Run TreeScript Builder from the CommandLine.
|
43
|
+
- Apply combinations of Operations to build TreeScript Workflows.
|
44
|
+
|
45
|
+
# Project Technical Details:
|
46
|
+
|
47
|
+
## File Tree Builder
|
48
|
+
Execute the File Tree Builder with the `ftb` command.
|
49
|
+
- Creates Files and Directories
|
50
|
+
- If DataLabels are present, a DataDirectory is required.
|
51
|
+
|
52
|
+
### File Tree Trimmer (Remover)
|
53
|
+
Execute the File Tree Remover by adding the `--trim` argument.
|
54
|
+
- Removes Files and Empty Directories.
|
55
|
+
- DataLabels require DataDirectory.
|
56
|
+
- Files are exported to the DataDirectory.
|
57
|
+
|
58
|
+
## Default Input Reader
|
59
|
+
Before the Reader receives TreeScript, the input is filtered so comments and empty lines are not ever seen by the Reader.
|
60
|
+
The Default Input Reader processes one line at a time and calculates multiple file tree node properties that it stores in dataclass objects.
|
61
|
+
|
62
|
+
It calculates for each node:
|
63
|
+
- Name
|
64
|
+
- File or directory status
|
65
|
+
- Depth in tree
|
66
|
+
- (optional) DataArgument
|
67
|
+
|
68
|
+
## Builder Data Feature
|
69
|
+
The Builder provides one additional feature that goes beyond creation of the File Tree. This feature enables Files to be created with data inserted immediately.
|
70
|
+
|
71
|
+
### Input Data Argument
|
72
|
+
The Data Argument specifies what will be inserted into the file that is created. The Data Argument is provided in the Input File, immediately after the File Name (separated by a space). There are two types of Data Arguments:
|
73
|
+
- DataLabel
|
74
|
+
- InlineContent
|
75
|
+
|
76
|
+
### Builder DataLabel Feature
|
77
|
+
A `DataLabel` is a link to Text content to be inserted into the file.
|
78
|
+
- DataLabel is present in both the DataDirectory, and the TreeScript File.
|
79
|
+
|
80
|
+
## Tree Trim Data Directory Feature
|
81
|
+
The Remover provides an additional feature beyond the removal of files in the Tree. This feature enables Files to be saved to a Data Directory when they are removed. Rather than destroying the file data, it is moved to a new directory.
|
82
|
+
|
83
|
+
|
84
|
+
## To-Do Features
|
85
|
+
|
86
|
+
### Builder File Inline Content (TODO)
|
87
|
+
`Inline Content` is written in the Tree Node Structure Input file itself. To distinguish `DataContent` from a `DataLabel`, the Content must begin with a special character.
|
88
|
+
|
89
|
+
Options for the DataContent character are under consideration.
|
90
|
+
- Less than bracket is a good option: <
|
91
|
+
- Star char is an alternative: *
|
92
|
+
|
93
|
+
This feature is a neat mid-sized improvement that may open up opportunities for more workflow flexibility.
|
94
|
+
- Adding a new file late in the process.
|
95
|
+
- such as after data directory is already prepared, and you review TS and notice a little thing missing.
|
96
|
+
- value-adding option that helps you build files faster, more convenient than the DataDirectory.
|
97
|
+
- Workflows that use TreeScript.
|
98
|
+
- Easier To Plan, and Communicate What You Did.
|
99
|
+
- Package Restructuring, Migrations.
|
100
|
+
- Test Environment Setup
|
101
|
+
- FileSystem Inventory
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# TreeScript FileTreeBuilder
|
2
|
+
Script for Building File Trees.
|
3
|
+
- Makes your dreams come true.
|
4
|
+
|
5
|
+
## How To
|
6
|
+
1. Prepare Your TreeScript Designs.
|
7
|
+
- Initial and Final TreeScripts.
|
8
|
+
- Build New Project Package/Module.
|
9
|
+
2. Logical Order of TreeScript Builder Operations.
|
10
|
+
3. Run TreeScript Builder from the CommandLine.
|
11
|
+
- Apply combinations of Operations to build TreeScript Workflows.
|
12
|
+
|
13
|
+
# Project Technical Details:
|
14
|
+
|
15
|
+
## File Tree Builder
|
16
|
+
Execute the File Tree Builder with the `ftb` command.
|
17
|
+
- Creates Files and Directories
|
18
|
+
- If DataLabels are present, a DataDirectory is required.
|
19
|
+
|
20
|
+
### File Tree Trimmer (Remover)
|
21
|
+
Execute the File Tree Remover by adding the `--trim` argument.
|
22
|
+
- Removes Files and Empty Directories.
|
23
|
+
- DataLabels require DataDirectory.
|
24
|
+
- Files are exported to the DataDirectory.
|
25
|
+
|
26
|
+
## Default Input Reader
|
27
|
+
Before the Reader receives TreeScript, the input is filtered so comments and empty lines are not ever seen by the Reader.
|
28
|
+
The Default Input Reader processes one line at a time and calculates multiple file tree node properties that it stores in dataclass objects.
|
29
|
+
|
30
|
+
It calculates for each node:
|
31
|
+
- Name
|
32
|
+
- File or directory status
|
33
|
+
- Depth in tree
|
34
|
+
- (optional) DataArgument
|
35
|
+
|
36
|
+
## Builder Data Feature
|
37
|
+
The Builder provides one additional feature that goes beyond creation of the File Tree. This feature enables Files to be created with data inserted immediately.
|
38
|
+
|
39
|
+
### Input Data Argument
|
40
|
+
The Data Argument specifies what will be inserted into the file that is created. The Data Argument is provided in the Input File, immediately after the File Name (separated by a space). There are two types of Data Arguments:
|
41
|
+
- DataLabel
|
42
|
+
- InlineContent
|
43
|
+
|
44
|
+
### Builder DataLabel Feature
|
45
|
+
A `DataLabel` is a link to Text content to be inserted into the file.
|
46
|
+
- DataLabel is present in both the DataDirectory, and the TreeScript File.
|
47
|
+
|
48
|
+
## Tree Trim Data Directory Feature
|
49
|
+
The Remover provides an additional feature beyond the removal of files in the Tree. This feature enables Files to be saved to a Data Directory when they are removed. Rather than destroying the file data, it is moved to a new directory.
|
50
|
+
|
51
|
+
|
52
|
+
## To-Do Features
|
53
|
+
|
54
|
+
### Builder File Inline Content (TODO)
|
55
|
+
`Inline Content` is written in the Tree Node Structure Input file itself. To distinguish `DataContent` from a `DataLabel`, the Content must begin with a special character.
|
56
|
+
|
57
|
+
Options for the DataContent character are under consideration.
|
58
|
+
- Less than bracket is a good option: <
|
59
|
+
- Star char is an alternative: *
|
60
|
+
|
61
|
+
This feature is a neat mid-sized improvement that may open up opportunities for more workflow flexibility.
|
62
|
+
- Adding a new file late in the process.
|
63
|
+
- such as after data directory is already prepared, and you review TS and notice a little thing missing.
|
64
|
+
- value-adding option that helps you build files faster, more convenient than the DataDirectory.
|
65
|
+
- Workflows that use TreeScript.
|
66
|
+
- Easier To Plan, and Communicate What You Did.
|
67
|
+
- Package Restructuring, Migrations.
|
68
|
+
- Test Environment Setup
|
69
|
+
- FileSystem Inventory
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"""Setup Build Configuration
|
2
|
+
"""
|
3
|
+
from setuptools import find_packages, setup
|
4
|
+
|
5
|
+
|
6
|
+
setup(
|
7
|
+
name="treescript-builder",
|
8
|
+
version="0.1",
|
9
|
+
description='Builds File Trees from TreeScript. If DataLabels are present in TreeScript, a DataDirectory argument is required.',
|
10
|
+
long_description=open('README.md').read(),
|
11
|
+
long_description_content_type='text/markdown',
|
12
|
+
author="DK96-OS",
|
13
|
+
url='https://github.com/DK96-OS/treescript-builder',
|
14
|
+
project_urls={
|
15
|
+
"Issues": "https://github.com/DK96-OS/treescript-builder/issues",
|
16
|
+
"Source Code": "https://github.com/DK96-OS/treescript-builder"
|
17
|
+
},
|
18
|
+
license="GPLv3",
|
19
|
+
packages=find_packages(exclude=['test', 'test.*']),
|
20
|
+
entry_points={
|
21
|
+
'console_scripts': [
|
22
|
+
'ftb=tree.__main__:main',
|
23
|
+
'treescript-builder=tree.__main__:main',
|
24
|
+
],
|
25
|
+
},
|
26
|
+
python_requires='>=3.12',
|
27
|
+
keywords=['TreeScript', 'Files', 'Directory'],
|
28
|
+
classifiers=[
|
29
|
+
'Natural Language :: English',
|
30
|
+
'Operating System :: OS Independent',
|
31
|
+
'Intended Audience :: Developers',
|
32
|
+
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
33
|
+
'Programming Language :: Python :: 3',
|
34
|
+
'Programming Language :: Python :: 3.12',
|
35
|
+
'Programming Language :: Python :: 3.13',
|
36
|
+
],
|
37
|
+
)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/python
|
2
|
+
|
3
|
+
|
4
|
+
def main():
|
5
|
+
# Author: DK96-OS 2024 - 2025
|
6
|
+
from treescript_builder.input import validate_input_arguments
|
7
|
+
from treescript_builder.tree import build_tree
|
8
|
+
from sys import argv
|
9
|
+
build_tree(validate_input_arguments(argv[1:]))
|
10
|
+
|
11
|
+
|
12
|
+
if __name__ == "__main__":
|
13
|
+
from sys import path
|
14
|
+
from pathlib import Path
|
15
|
+
# Get the directory of the current file (__file__ is the path to the script being executed)
|
16
|
+
current_directory = Path(__file__).resolve().parent.parent
|
17
|
+
path.append(str(current_directory)) # Add the directory to sys.path
|
18
|
+
main()
|
File without changes
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"""Data Directory Management.
|
2
|
+
Author: DK96-OS 2024 - 2025
|
3
|
+
"""
|
4
|
+
from pathlib import Path
|
5
|
+
from sys import exit
|
6
|
+
|
7
|
+
from treescript_builder.data.tree_data import TreeData
|
8
|
+
from treescript_builder.input.string_validation import validate_data_label
|
9
|
+
|
10
|
+
|
11
|
+
class DataDirectory:
|
12
|
+
""" Manages Access to the Data Directory.
|
13
|
+
- Search for a Data Label, and obtain the Path to the Data File.
|
14
|
+
"""
|
15
|
+
|
16
|
+
def __init__(self, data_dir: Path):
|
17
|
+
if not isinstance(data_dir, Path) or not data_dir.exists():
|
18
|
+
exit('The Data Directory must be a Path that Exists!')
|
19
|
+
self._data_dir = data_dir
|
20
|
+
# todo: Create a map of used Data Labels
|
21
|
+
|
22
|
+
def validate_build(self, node: TreeData) -> Path | None:
|
23
|
+
""" Determine if the Data File supporting this Tree node is available.
|
24
|
+
|
25
|
+
Parameters:
|
26
|
+
- node (TreeData): The TreeData to validate.
|
27
|
+
|
28
|
+
Returns:
|
29
|
+
Path - The Path to the Data File in the Data Directory.
|
30
|
+
|
31
|
+
Raises:
|
32
|
+
SystemExit - When the Data label is invalid, or the Data File does not exist.
|
33
|
+
"""
|
34
|
+
if node.data_label == '' or node.is_dir:
|
35
|
+
return None
|
36
|
+
if node.data_label == '!':
|
37
|
+
data_path = self._search_label(node.name)
|
38
|
+
else:
|
39
|
+
data_path = self._search_label(node.data_label)
|
40
|
+
if data_path is None:
|
41
|
+
exit(f'Data Label ({node.data_label}) not found in Data Directory on line: {node.line_number}')
|
42
|
+
return data_path
|
43
|
+
|
44
|
+
def validate_trim(self, node: TreeData) -> Path | None:
|
45
|
+
""" Determine if the File already exists in the Data Directory.
|
46
|
+
|
47
|
+
Parameters:
|
48
|
+
- node (TreeData): The TreeData to validate.
|
49
|
+
|
50
|
+
Returns:
|
51
|
+
Path - The Path to a new File in the Data Directory.
|
52
|
+
|
53
|
+
Raises:
|
54
|
+
SystemExit - When the Data label is invalid, or the Data File already exists.
|
55
|
+
"""
|
56
|
+
# Ensure that the name of the Label is valid
|
57
|
+
if node.data_label == '' or node.is_dir:
|
58
|
+
return None
|
59
|
+
data_label = node.name if node.data_label == '!' else node.data_label
|
60
|
+
if not validate_data_label(data_label):
|
61
|
+
exit(f'Invalid Data Label on line: {node.line_number}')
|
62
|
+
# Check if the Data File already exists
|
63
|
+
data_path = self._search_label(data_label)
|
64
|
+
if data_path is not None:
|
65
|
+
exit(f'Data File already exists!\n({data_label}) on line: {node.line_number}')
|
66
|
+
# Create the Data Label Path in the Directory
|
67
|
+
return self._data_dir / data_label
|
68
|
+
|
69
|
+
def _search_label(self, data_label: str) -> Path | None:
|
70
|
+
""" Search for a Data Label in this Data Directory.
|
71
|
+
|
72
|
+
Parameters:
|
73
|
+
- data_label (str): The Data Label to search for.
|
74
|
+
|
75
|
+
Returns:
|
76
|
+
Path (optional) - The Path to the Data File, or None.
|
77
|
+
"""
|
78
|
+
if not validate_data_label(data_label):
|
79
|
+
return None
|
80
|
+
# Find the Data Label File
|
81
|
+
data_files = self._data_dir.glob(data_label)
|
82
|
+
try:
|
83
|
+
return next(data_files)
|
84
|
+
except StopIteration as s:
|
85
|
+
return None
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"""The Instruction Data in a Tree Operation.
|
2
|
+
Author: DK96-OS 2024 - 2025
|
3
|
+
"""
|
4
|
+
from dataclasses import dataclass
|
5
|
+
from pathlib import Path
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass(frozen=True)
|
9
|
+
class InstructionData:
|
10
|
+
""" The Data required to execute the Instruction.
|
11
|
+
|
12
|
+
**Fields:**
|
13
|
+
- is_dir (bool): Whether the Instruction relates to a Directory.
|
14
|
+
- path (Path): The Path of the Instruction.
|
15
|
+
- data_path (Path?): The Data Directory Path of the Instruction, if applicable. Default: None.
|
16
|
+
"""
|
17
|
+
is_dir: bool
|
18
|
+
path: Path
|
19
|
+
data_path: Path | None = None
|
@@ -0,0 +1,86 @@
|
|
1
|
+
""" Path Stack Management.
|
2
|
+
Author: DK96-OS 2024 - 2025
|
3
|
+
"""
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
|
7
|
+
class PathStack:
|
8
|
+
""" A Stack of Directory names in a Path.
|
9
|
+
"""
|
10
|
+
|
11
|
+
def __init__(self):
|
12
|
+
# The Stack of Directories in the Path.
|
13
|
+
self._stack = []
|
14
|
+
|
15
|
+
def push(self, directory_name: str):
|
16
|
+
""" Push a directory to the Path Stack.
|
17
|
+
|
18
|
+
Parameters:
|
19
|
+
- directory_name (str): The name of the next directory in the Path Stack.
|
20
|
+
"""
|
21
|
+
self._stack.append(directory_name)
|
22
|
+
|
23
|
+
def pop(self) -> str | None:
|
24
|
+
"""
|
25
|
+
Pop the top of the Stack, and return the directory name.
|
26
|
+
|
27
|
+
Returns:
|
28
|
+
str : The String removed from the top of the Stack.
|
29
|
+
"""
|
30
|
+
if len(self._stack) <= 0:
|
31
|
+
return None
|
32
|
+
return self._stack.pop()
|
33
|
+
|
34
|
+
def join_stack(self) -> Path:
|
35
|
+
"""
|
36
|
+
Combines all elements in the path Stack to form the parent directory.
|
37
|
+
|
38
|
+
Returns:
|
39
|
+
Path representing the current directory.
|
40
|
+
"""
|
41
|
+
if len(self._stack) == 0:
|
42
|
+
return Path("./")
|
43
|
+
return Path(f"./{'/'.join(self._stack)}/")
|
44
|
+
|
45
|
+
def create_path(self, filename: str) -> Path:
|
46
|
+
"""
|
47
|
+
Combines all Elements in the Stack and appends a File name.
|
48
|
+
|
49
|
+
Parameters:
|
50
|
+
- filename (str): The name of the file to append to the end of the path.
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
Path : The Path to the file.
|
54
|
+
"""
|
55
|
+
if type(filename) is not str or len(filename) < 1:
|
56
|
+
return self.join_stack()
|
57
|
+
return self.join_stack() / filename
|
58
|
+
|
59
|
+
def reduce_depth(self, depth: int) -> bool:
|
60
|
+
"""
|
61
|
+
Reduce the Depth of the Path Stack.
|
62
|
+
|
63
|
+
Parameters:
|
64
|
+
- depth (int): The depth to reduce the stack to.
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
boolean : Whether the Reduction was successful, ie 0 or more Stack pops.
|
68
|
+
"""
|
69
|
+
current_depth = self.get_depth()
|
70
|
+
if current_depth < depth or depth < 0:
|
71
|
+
return False
|
72
|
+
if current_depth == depth:
|
73
|
+
return True
|
74
|
+
for _ in range(current_depth, depth, -1):
|
75
|
+
self._stack.pop()
|
76
|
+
return True
|
77
|
+
|
78
|
+
def get_depth(self) -> int:
|
79
|
+
"""
|
80
|
+
Obtain the current Depth of the Stack.
|
81
|
+
The state where the current directory is the path, ie: './' has a depth of 0.
|
82
|
+
|
83
|
+
Returns:
|
84
|
+
int : The number of elements in the Path Stack.
|
85
|
+
"""
|
86
|
+
return len(self._stack)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"""Tree Node DataClass.
|
2
|
+
Author: DK96-OS 2024 - 2025
|
3
|
+
"""
|
4
|
+
from dataclasses import dataclass
|
5
|
+
|
6
|
+
|
7
|
+
@dataclass(frozen=True)
|
8
|
+
class TreeData:
|
9
|
+
""" A DataClass representing a Tree Node.
|
10
|
+
|
11
|
+
Fields:
|
12
|
+
- line_number (int): The line number of this tree node in the TreeScript file.
|
13
|
+
- depth (int): The depth in the tree, from the root. Starts at zero.
|
14
|
+
- is_dir (bool): Whether this Node is a directory.
|
15
|
+
- name (str): The Name of the Tree Node.
|
16
|
+
- data_label (str): The Data Label, may be empty string.
|
17
|
+
"""
|
18
|
+
|
19
|
+
line_number: int
|
20
|
+
depth: int
|
21
|
+
is_dir: bool
|
22
|
+
name: str
|
23
|
+
data_label: str = ''
|