PyMyForing 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.
- pymyforing-0.1.0/LICENSE +21 -0
- pymyforing-0.1.0/PKG-INFO +448 -0
- pymyforing-0.1.0/PyMyForing.egg-info/PKG-INFO +448 -0
- pymyforing-0.1.0/PyMyForing.egg-info/SOURCES.txt +11 -0
- pymyforing-0.1.0/PyMyForing.egg-info/dependency_links.txt +1 -0
- pymyforing-0.1.0/PyMyForing.egg-info/requires.txt +1 -0
- pymyforing-0.1.0/PyMyForing.egg-info/top_level.txt +1 -0
- pymyforing-0.1.0/README.md +433 -0
- pymyforing-0.1.0/foring/__init__.py +3 -0
- pymyforing-0.1.0/foring/core.py +113 -0
- pymyforing-0.1.0/pyproject.toml +26 -0
- pymyforing-0.1.0/setup.cfg +4 -0
pymyforing-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shayan Saha
|
|
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,448 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyMyForing
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple, wrapper for effortless file reading and writing.
|
|
5
|
+
Author-email: Shayan Saha <shayan851997@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/shayansaha85/foring
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: PyYAML>=6.0
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
<p>
|
|
18
|
+
<img src = 'https://img.shields.io/badge/python-3.14.5-blue'>
|
|
19
|
+
<img src = 'https://img.shields.io/badge/foring-0.1.0-green'>
|
|
20
|
+
<img src = 'https://img.shields.io/badge/license-MIT-red'>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
<br>
|
|
27
|
+
|
|
28
|
+
`foring` is a lightweight, intuitive Python utility designed to take the friction out of file I/O operations. Inspired by the simplicity of `pandas` data loading routines, `foring` lets you read and write virtually any file format using just two clean, highly smart top-level functions: `read()` and `write()`.
|
|
29
|
+
|
|
30
|
+
No more managing context managers (`with open...`), manually choosing between text or binary modes (`'r'`, `'wb'`), parsing formats, or handling complex serialization formats like `pickle` or `plist` manually. `foring` auto-detects the extension and takes care of the heavy lifting.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 🚀 Installation
|
|
35
|
+
|
|
36
|
+
You can install `foring` directly from PyPI using `pip`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install foring
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Dependencies
|
|
43
|
+
|
|
44
|
+
foring relies entirely on Python's built-in standard library, with the single exception of PyYAML (which is automatically fetched and configured during the pip install process to parse YAML profiles cleanly).
|
|
45
|
+
|
|
46
|
+
## 🛠️ Quick Start & Core Usage
|
|
47
|
+
|
|
48
|
+
The entire power of the library resides in a highly focused import structure:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import foring.core as fc
|
|
52
|
+
```
|
|
53
|
+
---
|
|
54
|
+
### 1. JSON Files
|
|
55
|
+
|
|
56
|
+
JSON is perfect for structured, human-readable data serialization.
|
|
57
|
+
|
|
58
|
+
**Writing JSON:**
|
|
59
|
+
```python
|
|
60
|
+
import foring.core as fc
|
|
61
|
+
|
|
62
|
+
user_data = {"name": "Shayan Saha", "role": "Developer", "verified": True}
|
|
63
|
+
fc.write(user_data, "profile.json")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**File content (`profile.json`):**
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"name": "Shayan Saha",
|
|
70
|
+
"role": "Developer",
|
|
71
|
+
"verified": true
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Reading JSON:**
|
|
76
|
+
```python
|
|
77
|
+
import foring.core as fc
|
|
78
|
+
|
|
79
|
+
data = fc.read("profile.json")
|
|
80
|
+
print(data["name"]) # Output: Shayan Saha
|
|
81
|
+
```
|
|
82
|
+
---
|
|
83
|
+
### 2. CSV Files
|
|
84
|
+
|
|
85
|
+
CSV files are ideal for tabular data and spreadsheets. Automatically detects delimiters.
|
|
86
|
+
|
|
87
|
+
**Writing CSV:**
|
|
88
|
+
```python
|
|
89
|
+
import foring.core as fc
|
|
90
|
+
|
|
91
|
+
matrix = [["ID", "Item"], ["101", "Laptop"], ["102", "Monitor"]]
|
|
92
|
+
fc.write(matrix, "inventory.csv")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**File content (`inventory.csv`):**
|
|
96
|
+
```csv
|
|
97
|
+
ID,Item
|
|
98
|
+
101,Laptop
|
|
99
|
+
102,Monitor
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Reading CSV:**
|
|
103
|
+
```python
|
|
104
|
+
import foring.core as fc
|
|
105
|
+
|
|
106
|
+
rows = fc.read("inventory.csv")
|
|
107
|
+
print(rows[1]) # Output: ['101', 'Laptop']
|
|
108
|
+
```
|
|
109
|
+
---
|
|
110
|
+
### 3. YAML Files
|
|
111
|
+
|
|
112
|
+
YAML is perfect for configuration files and human-readable hierarchical data. Supports both `.yaml` and `.yml` extensions.
|
|
113
|
+
|
|
114
|
+
**Writing YAML:**
|
|
115
|
+
```python
|
|
116
|
+
import foring.core as fc
|
|
117
|
+
|
|
118
|
+
yaml_config = {
|
|
119
|
+
"server": {
|
|
120
|
+
"host": "localhost",
|
|
121
|
+
"ports": [8000, 8080]
|
|
122
|
+
},
|
|
123
|
+
"database": {
|
|
124
|
+
"enabled": True
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
fc.write(yaml_config, "config.yaml")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**File content (`config.yaml`):**
|
|
131
|
+
```yaml
|
|
132
|
+
database:
|
|
133
|
+
enabled: true
|
|
134
|
+
server:
|
|
135
|
+
host: localhost
|
|
136
|
+
ports:
|
|
137
|
+
- 8000
|
|
138
|
+
- 8080
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Reading YAML:**
|
|
142
|
+
```python
|
|
143
|
+
import foring.core as fc
|
|
144
|
+
|
|
145
|
+
config = fc.read("config.yaml")
|
|
146
|
+
print(config["server"]["ports"]) # Output: [8000, 8080]
|
|
147
|
+
```
|
|
148
|
+
---
|
|
149
|
+
### 4. INI Files
|
|
150
|
+
|
|
151
|
+
INI files are commonly used for configuration with sections and key-value pairs.
|
|
152
|
+
|
|
153
|
+
**Writing INI:**
|
|
154
|
+
```python
|
|
155
|
+
import foring.core as fc
|
|
156
|
+
|
|
157
|
+
ini_data = {
|
|
158
|
+
"DATABASE": {"Host": "localhost", "User": "root", "Password": "secret"},
|
|
159
|
+
"LOGGING": {"Level": "DEBUG", "File": "app.log"}
|
|
160
|
+
}
|
|
161
|
+
fc.write(ini_data, "settings.ini")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**File content (`settings.ini`):**
|
|
165
|
+
```ini
|
|
166
|
+
[DATABASE]
|
|
167
|
+
host = localhost
|
|
168
|
+
user = root
|
|
169
|
+
password = secret
|
|
170
|
+
|
|
171
|
+
[LOGGING]
|
|
172
|
+
level = DEBUG
|
|
173
|
+
file = app.log
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Reading INI:**
|
|
177
|
+
```python
|
|
178
|
+
import foring.core as fc
|
|
179
|
+
|
|
180
|
+
settings = fc.read("settings.ini")
|
|
181
|
+
print(settings["DATABASE"]["User"]) # Output: root
|
|
182
|
+
```
|
|
183
|
+
---
|
|
184
|
+
### 5. XML Files
|
|
185
|
+
|
|
186
|
+
XML is ideal for hierarchical, structured data with attributes and nested elements.
|
|
187
|
+
|
|
188
|
+
**Writing XML:**
|
|
189
|
+
```python
|
|
190
|
+
import xml.etree.ElementTree as ET
|
|
191
|
+
import foring.core as fc
|
|
192
|
+
|
|
193
|
+
# Build standard XML tree structural elements
|
|
194
|
+
root = ET.Element("project")
|
|
195
|
+
child = ET.SubElement(root, "name")
|
|
196
|
+
child.text = "foring"
|
|
197
|
+
child.set("version", "1.0")
|
|
198
|
+
|
|
199
|
+
# Writes as an XML element hierarchy tree
|
|
200
|
+
fc.write(root, "meta.xml")
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**File content (`meta.xml`):**
|
|
204
|
+
```xml
|
|
205
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
206
|
+
<project><name version="1.0">foring</name></project>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Reading XML:**
|
|
210
|
+
```python
|
|
211
|
+
import foring.core as fc
|
|
212
|
+
|
|
213
|
+
parsed_root = fc.read("meta.xml")
|
|
214
|
+
print(parsed_root.find("name").text) # Output: foring
|
|
215
|
+
print(parsed_root.find("name").get("version")) # Output: 1.0
|
|
216
|
+
```
|
|
217
|
+
---
|
|
218
|
+
### 6. Text Files (TXT)
|
|
219
|
+
|
|
220
|
+
Plain text files for logs, notes, and unformatted content.
|
|
221
|
+
|
|
222
|
+
**Writing Text:**
|
|
223
|
+
```python
|
|
224
|
+
import foring.core as fc
|
|
225
|
+
|
|
226
|
+
content = "This is a plain text file.\nLine 2 of content."
|
|
227
|
+
fc.write(content, "notes.txt")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**File content (`notes.txt`):**
|
|
231
|
+
```text
|
|
232
|
+
This is a plain text file.
|
|
233
|
+
Line 2 of content.
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Reading Text:**
|
|
237
|
+
```python
|
|
238
|
+
import foring.core as fc
|
|
239
|
+
|
|
240
|
+
text = fc.read("notes.txt")
|
|
241
|
+
print(text) # Output: This is a plain text file. Line 2 of content.
|
|
242
|
+
```
|
|
243
|
+
---
|
|
244
|
+
### 7. Markdown Files (MD)
|
|
245
|
+
|
|
246
|
+
Markdown files for documentation and formatted text content.
|
|
247
|
+
|
|
248
|
+
**Writing Markdown:**
|
|
249
|
+
```python
|
|
250
|
+
import foring.core as fc
|
|
251
|
+
|
|
252
|
+
markdown_content = """# My Project
|
|
253
|
+
|
|
254
|
+
This is a **bold** statement.
|
|
255
|
+
|
|
256
|
+
- Item 1
|
|
257
|
+
- Item 2
|
|
258
|
+
"""
|
|
259
|
+
fc.write(markdown_content, "README.md")
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**File content (`README.md`):**
|
|
263
|
+
```markdown
|
|
264
|
+
# My Project
|
|
265
|
+
|
|
266
|
+
This is a **bold** statement.
|
|
267
|
+
|
|
268
|
+
- Item 1
|
|
269
|
+
- Item 2
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Reading Markdown:**
|
|
273
|
+
```python
|
|
274
|
+
import foring.core as fc
|
|
275
|
+
|
|
276
|
+
content = fc.read("README.md")
|
|
277
|
+
print(content)
|
|
278
|
+
```
|
|
279
|
+
---
|
|
280
|
+
### 8. Log Files (LOG)
|
|
281
|
+
|
|
282
|
+
Log files for application events and diagnostics.
|
|
283
|
+
|
|
284
|
+
**Writing Logs:**
|
|
285
|
+
```python
|
|
286
|
+
import foring.core as fc
|
|
287
|
+
|
|
288
|
+
log_message = "2026-06-17 10:45:32: Operation completed successfully.\n2026-06-17 10:46:00: Process finished."
|
|
289
|
+
fc.write(log_message, "app.log")
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**File content (`app.log`):**
|
|
293
|
+
```log
|
|
294
|
+
2026-06-17 10:45:32: Operation completed successfully.
|
|
295
|
+
2026-06-17 10:46:00: Process finished.
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Reading Logs:**
|
|
299
|
+
```python
|
|
300
|
+
import foring.core as fc
|
|
301
|
+
|
|
302
|
+
logs = fc.read("app.log")
|
|
303
|
+
print(logs)
|
|
304
|
+
```
|
|
305
|
+
---
|
|
306
|
+
### 9. Pickle Files (PKL & PICKLE)
|
|
307
|
+
|
|
308
|
+
Python pickle format for serializing complex Python objects, including tuples, lists, and custom objects.
|
|
309
|
+
|
|
310
|
+
**Writing Pickle:**
|
|
311
|
+
```python
|
|
312
|
+
import foring.core as fc
|
|
313
|
+
|
|
314
|
+
# Store a tuple with mixed data types
|
|
315
|
+
state_packet = (1, "active", [10, 20, 30], {"key": "value"})
|
|
316
|
+
fc.write(state_packet, "state.pkl")
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**File content (`state.pkl`):**
|
|
320
|
+
```
|
|
321
|
+
(Binary pickled Python object - not human-readable)
|
|
322
|
+
Size: ~50 bytes (varies by content)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Reading Pickle:**
|
|
326
|
+
```python
|
|
327
|
+
import foring.core as fc
|
|
328
|
+
|
|
329
|
+
loaded_packet = fc.read("state.pkl")
|
|
330
|
+
print(loaded_packet[1]) # Output: active
|
|
331
|
+
print(loaded_packet[2]) # Output: [10, 20, 30]
|
|
332
|
+
```
|
|
333
|
+
---
|
|
334
|
+
### 10. PList Files (PLIST)
|
|
335
|
+
|
|
336
|
+
Property list files commonly used on macOS for storing structured data.
|
|
337
|
+
|
|
338
|
+
**Writing PList:**
|
|
339
|
+
```python
|
|
340
|
+
import foring.core as fc
|
|
341
|
+
|
|
342
|
+
plist_data = {
|
|
343
|
+
"Name": "MyApp",
|
|
344
|
+
"Version": "1.0",
|
|
345
|
+
"Enabled": True,
|
|
346
|
+
"Settings": {"Theme": "dark", "AutoSave": True}
|
|
347
|
+
}
|
|
348
|
+
fc.write(plist_data, "app.plist")
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**File content (`app.plist`):**
|
|
352
|
+
```xml
|
|
353
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
354
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
355
|
+
<plist version="1.0">
|
|
356
|
+
<dict>
|
|
357
|
+
<key>Name</key>
|
|
358
|
+
<string>MyApp</string>
|
|
359
|
+
<key>Version</key>
|
|
360
|
+
<string>1.0</string>
|
|
361
|
+
<key>Enabled</key>
|
|
362
|
+
<true/>
|
|
363
|
+
<key>Settings</key>
|
|
364
|
+
<dict>
|
|
365
|
+
<key>Theme</key>
|
|
366
|
+
<string>dark</string>
|
|
367
|
+
<key>AutoSave</key>
|
|
368
|
+
<true/>
|
|
369
|
+
</dict>
|
|
370
|
+
</dict>
|
|
371
|
+
</plist>
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
**Reading PList:**
|
|
375
|
+
```python
|
|
376
|
+
import foring.core as fc
|
|
377
|
+
|
|
378
|
+
plist_content = fc.read("app.plist")
|
|
379
|
+
print(plist_content["Settings"]["Theme"]) # Output: dark
|
|
380
|
+
```
|
|
381
|
+
---
|
|
382
|
+
### 11. HTML Files (HTML)
|
|
383
|
+
|
|
384
|
+
HTML markup for web content and structured markup.
|
|
385
|
+
|
|
386
|
+
**Writing HTML:**
|
|
387
|
+
```python
|
|
388
|
+
import foring.core as fc
|
|
389
|
+
|
|
390
|
+
html_content = """<html>
|
|
391
|
+
<body>
|
|
392
|
+
<h1>Welcome to foring</h1>
|
|
393
|
+
<p>A lightweight file I/O utility.</p>
|
|
394
|
+
</body>
|
|
395
|
+
</html>"""
|
|
396
|
+
fc.write(html_content, "index.html")
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**File content (`index.html`):**
|
|
400
|
+
```html
|
|
401
|
+
<html>
|
|
402
|
+
<body>
|
|
403
|
+
<h1>Welcome to foring</h1>
|
|
404
|
+
<p>A lightweight file I/O utility.</p>
|
|
405
|
+
</body>
|
|
406
|
+
</html>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Reading HTML:**
|
|
410
|
+
```python
|
|
411
|
+
import foring.core as fc
|
|
412
|
+
|
|
413
|
+
html = fc.read("index.html")
|
|
414
|
+
print(html)
|
|
415
|
+
```
|
|
416
|
+
---
|
|
417
|
+
### 12. Binary & Media Files (PNG, PDF, ZIP, etc.)
|
|
418
|
+
|
|
419
|
+
For unsupported extensions, foring automatically handles binary files. It tries text decoding first, then falls back to raw bytes for binary formats.
|
|
420
|
+
|
|
421
|
+
**Writing Binary:**
|
|
422
|
+
```python
|
|
423
|
+
import foring.core as fc
|
|
424
|
+
|
|
425
|
+
# Read binary image
|
|
426
|
+
raw_image = open("original.png", "rb").read()
|
|
427
|
+
|
|
428
|
+
# Write as backup
|
|
429
|
+
fc.write(raw_image, "backup.png")
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Reading Binary:**
|
|
433
|
+
```python
|
|
434
|
+
import foring.core as fc
|
|
435
|
+
|
|
436
|
+
# Read any binary file
|
|
437
|
+
raw_data = fc.read("image.png")
|
|
438
|
+
print(f"File size: {len(raw_data)} bytes")
|
|
439
|
+
|
|
440
|
+
# Works seamlessly with images, PDFs, ZIP archives, etc.
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
## 📄 License
|
|
445
|
+
This project is open-source software licensed under the terms of the MIT License. Feel free to use, modify, and distribute it as needed!
|
|
446
|
+
|
|
447
|
+
## Attributions
|
|
448
|
+
Logo : <a href="https://www.flaticon.com/free-icons/dragonfly" title="dragonfly icons">Dragonfly icons created by Khadija Arif - Flaticon</a>
|