pathpilot 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.
- pathpilot-0.1.0/LICENSE +21 -0
- pathpilot-0.1.0/PKG-INFO +94 -0
- pathpilot-0.1.0/README.md +71 -0
- pathpilot-0.1.0/pathpilot/__init__.py +4 -0
- pathpilot-0.1.0/pathpilot/pathpilot.py +2440 -0
- pathpilot-0.1.0/pyproject.toml +20 -0
pathpilot-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Zachary Einck
|
|
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.
|
pathpilot-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pathpilot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Library that facilitates file and folder manipulation in Python.
|
|
5
|
+
Home-page: https://github.com/zteinck/pathpilot
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: Zachary Einck
|
|
8
|
+
Author-email: zacharyeinck@gmail.com
|
|
9
|
+
Requires-Python: >=3.8,<4.0
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Dist: clockwork
|
|
18
|
+
Requires-Dist: iterlab
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: pandas
|
|
21
|
+
Project-URL: Repository, https://github.com/zteinck/pathpilot
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# pathpilot
|
|
25
|
+
`pathpilot` is a library that facilitates file and folder manipulation in Python. It was designed with an emphasis on `pandas` compatibility to ensure smooth workflows.
|
|
26
|
+
|
|
27
|
+
### Core Utilities
|
|
28
|
+
`pathpilot` has two core utilities:
|
|
29
|
+
- `File`: Function that assigns new file instances to the correct child class. Many file types are supported natively including: `.xlsx`, `.csv`, `.txt`, `.pickle`, etc. The mapping of file extensions to their respective classes is managed using the `extension_mapping` global dictionary. Unmapped extensions are assigned to the `FileBase` class.
|
|
30
|
+
- `Folder`: Class for interacting with folders. It is important to be mindful of the `read_only` parameter which, if set to `True`, allows folders to be created or deleted programically.
|
|
31
|
+
|
|
32
|
+
## Example Usage
|
|
33
|
+
Please note the examples below represent a small fraction of the functionality offered by `pathpilot`. Please refer to the documentation within the code for more information.
|
|
34
|
+
|
|
35
|
+
### Imports
|
|
36
|
+
```python
|
|
37
|
+
from pathpilot import Folder, File
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Folders
|
|
41
|
+
First, we create an instance of the `Folder` class. Passing `read_only=False` causes the folder to be created if it does not already exist.
|
|
42
|
+
```python
|
|
43
|
+
# initiate a folder instance
|
|
44
|
+
folder = Folder(r'C:\Users\MyID\Documents\MyFolder', read_only=False)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Moreover, any subfolders that are referenced while interacting with the folder instance will also be created automatically. Let's use the `join` method to create a couple subfolders.
|
|
48
|
+
```python
|
|
49
|
+
# create subfolders (i.e. C:\Users\MyID\Documents\MyFolder\Year\2025\Month\)
|
|
50
|
+
month_folder = folder.join('Year', '2025', 'Month')
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Alternatively, you can access subfolders by referencing attributes that may or may not already exist.
|
|
54
|
+
```python
|
|
55
|
+
# create a new subfolder called "January" by accessing it via attribute
|
|
56
|
+
january_folder = month_folder.january
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Joining to a file will return a file object instead.
|
|
60
|
+
```python
|
|
61
|
+
new_years_file = january_folder.join('Happy New Year.txt')
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Files
|
|
65
|
+
First, we create an instance of the `ExcelFile` class using the `File` function. This occurs automatically by virtue of the `.xlsx` file extension.
|
|
66
|
+
```python
|
|
67
|
+
# create ExcelFile instance
|
|
68
|
+
file = File(r'C:\Users\MyID\Documents\MyFolder\MyFile.xlsx')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Next, let's check if the file exists. If not, let's save a `pandas` `DataFrame` as an Excel file.
|
|
72
|
+
```python
|
|
73
|
+
# export a pd.DataFrame to the file, if it does not already exist
|
|
74
|
+
if not file.exists:
|
|
75
|
+
df = pd.DataFrame({'id': [1, 2, 3], 'data': ['a', 'b', 'c']})
|
|
76
|
+
file.save(df)
|
|
77
|
+
```
|
|
78
|
+
<pre>
|
|
79
|
+
Creating MyFile.xlsx
|
|
80
|
+
writing 72.00 B to 'Sheet1' tab... DONE
|
|
81
|
+
writing 80.00 B to 'Sheet1' tab... DONE
|
|
82
|
+
</pre>
|
|
83
|
+
|
|
84
|
+
Now let's read the file we created as a `DataFrame`.
|
|
85
|
+
```python
|
|
86
|
+
# read the file we created as a pd.DataFrame
|
|
87
|
+
df = file.read()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
On second thought, let's delete the file.
|
|
91
|
+
```python
|
|
92
|
+
# delete the file we created
|
|
93
|
+
file.delete()
|
|
94
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# pathpilot
|
|
2
|
+
`pathpilot` is a library that facilitates file and folder manipulation in Python. It was designed with an emphasis on `pandas` compatibility to ensure smooth workflows.
|
|
3
|
+
|
|
4
|
+
### Core Utilities
|
|
5
|
+
`pathpilot` has two core utilities:
|
|
6
|
+
- `File`: Function that assigns new file instances to the correct child class. Many file types are supported natively including: `.xlsx`, `.csv`, `.txt`, `.pickle`, etc. The mapping of file extensions to their respective classes is managed using the `extension_mapping` global dictionary. Unmapped extensions are assigned to the `FileBase` class.
|
|
7
|
+
- `Folder`: Class for interacting with folders. It is important to be mindful of the `read_only` parameter which, if set to `True`, allows folders to be created or deleted programically.
|
|
8
|
+
|
|
9
|
+
## Example Usage
|
|
10
|
+
Please note the examples below represent a small fraction of the functionality offered by `pathpilot`. Please refer to the documentation within the code for more information.
|
|
11
|
+
|
|
12
|
+
### Imports
|
|
13
|
+
```python
|
|
14
|
+
from pathpilot import Folder, File
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Folders
|
|
18
|
+
First, we create an instance of the `Folder` class. Passing `read_only=False` causes the folder to be created if it does not already exist.
|
|
19
|
+
```python
|
|
20
|
+
# initiate a folder instance
|
|
21
|
+
folder = Folder(r'C:\Users\MyID\Documents\MyFolder', read_only=False)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Moreover, any subfolders that are referenced while interacting with the folder instance will also be created automatically. Let's use the `join` method to create a couple subfolders.
|
|
25
|
+
```python
|
|
26
|
+
# create subfolders (i.e. C:\Users\MyID\Documents\MyFolder\Year\2025\Month\)
|
|
27
|
+
month_folder = folder.join('Year', '2025', 'Month')
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Alternatively, you can access subfolders by referencing attributes that may or may not already exist.
|
|
31
|
+
```python
|
|
32
|
+
# create a new subfolder called "January" by accessing it via attribute
|
|
33
|
+
january_folder = month_folder.january
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Joining to a file will return a file object instead.
|
|
37
|
+
```python
|
|
38
|
+
new_years_file = january_folder.join('Happy New Year.txt')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Files
|
|
42
|
+
First, we create an instance of the `ExcelFile` class using the `File` function. This occurs automatically by virtue of the `.xlsx` file extension.
|
|
43
|
+
```python
|
|
44
|
+
# create ExcelFile instance
|
|
45
|
+
file = File(r'C:\Users\MyID\Documents\MyFolder\MyFile.xlsx')
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Next, let's check if the file exists. If not, let's save a `pandas` `DataFrame` as an Excel file.
|
|
49
|
+
```python
|
|
50
|
+
# export a pd.DataFrame to the file, if it does not already exist
|
|
51
|
+
if not file.exists:
|
|
52
|
+
df = pd.DataFrame({'id': [1, 2, 3], 'data': ['a', 'b', 'c']})
|
|
53
|
+
file.save(df)
|
|
54
|
+
```
|
|
55
|
+
<pre>
|
|
56
|
+
Creating MyFile.xlsx
|
|
57
|
+
writing 72.00 B to 'Sheet1' tab... DONE
|
|
58
|
+
writing 80.00 B to 'Sheet1' tab... DONE
|
|
59
|
+
</pre>
|
|
60
|
+
|
|
61
|
+
Now let's read the file we created as a `DataFrame`.
|
|
62
|
+
```python
|
|
63
|
+
# read the file we created as a pd.DataFrame
|
|
64
|
+
df = file.read()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
On second thought, let's delete the file.
|
|
68
|
+
```python
|
|
69
|
+
# delete the file we created
|
|
70
|
+
file.delete()
|
|
71
|
+
```
|