ATmulti-file-handler


NameATmulti-file-handler JSON
Version 2.0.2 PyPI version JSON
download
home_pageNone
SummaryA unified file handling abstraction layer for multiple file formats.
upload_time2025-08-30 17:28:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords file txt json csv yaml xml dill binary database vardb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# ATmulti_file_handler

A unified **file handling abstraction layer** for multiple file formats. This Python package provides a consistent interface to work with various file types including text, JSON, CSV, YAML, XML, Dill, binary files, and a custom VariableDB database.  

## Features

- Unified `File` base class with consistent interface.
- Format-specific subclasses:
  - `TxtFile`   → `.txt`
  - `JsonFile`  → `.json`
  - `CsvFile`   → `.csv`
  - `DillFile`  → `.dill`
  - `XmlFile`   → `.xml`
  - `YamlFile`  → `.yml` / `.yaml`
  - `ByteFile`  → `.bin` / `.exe` / `.img` / `.jpg`
  - `VarDBFile` → `.db` (requires `avi_tools` package)
- Common operations: `read`, `write`, `append`, `exist`, `copy`, `move`, `delete`.
- Automatic directory and file creation if missing.
- Factory function `file()` to automatically choose the right subclass based on extension.

---

## Installation

You can install the package directly from **PyPI**:

```bash
pip install ATmulti_file_handler
````

This will also install all required dependencies:
`dill`, `PyYAML`, `avi_tools`.

---

## Usage

### Import the package

```python
from ATmulti_file_handler import file
```

---

### Working with Text Files

```python
f = file("notes.txt")
f.write("Hello World")
print(f.read())   # -> "Hello World"
f.append("\nAppended text")
```

---

### Working with JSON

```python
f = file("data.json")
f.write({"a": 1})
print(f.read())   # -> {"a": 1}
f.append({"b": 2})
print(f.read())   # -> {"a": 1, "b": 2}
```

---

### Working with CSV

```python
f = file("table.csv")
f.write([["Name","Age"],["Alice","30"]])
f.append(["Bob","25"])
print(f.read())   # -> [["Name","Age"],["Alice","30"],["Bob","25"]]
```

---

### Working with Dill (Python objects)

```python
f = file("data.dill")
f.write([1,2,3])
f.append(4)
print(f.read())   # -> [1,2,3,4]
```

---

### Working with YAML

```python
f = file("config.yaml")
f.write({"setting": True})
f.append({"debug": False})
print(f.read())   # -> {"setting": True, "debug": False}
```

---

### Working with XML

```python
import xml.etree.ElementTree as ET

f = file("data.xml")
root = ET.Element("root")
f.write(root)
child = ET.Element("child")
root.append(child)
f.append(ET.Element("another_child"))
```

---

### Working with Binary Files

```python
f = file("data.bin")
f.write(b"Hello")
f.append(b" World")
print(f.read())  # -> b"Hello World"
```

---

### Working with VariableDB Files

```python
b = 20
f = file("config.db", scope=globals(), data={"a": 10})
f.append(b)
print(f.read())   # -> {"a": 10, "b": 20}
```

---

### Common Operations

```python
f = file("notes.txt")
print(f.exist())           # True/False
f.copy("/tmp")             # Copies file to /tmp
f.move("/tmp")             # Moves file to /tmp
f.delete()                 # Deletes the file
```

---

## Author

**Avi Twil**

GitHub: [https://github.com/avitwil/ATmulti\_file\_handler](https://github.com/avitwil/ATmulti_file_handler)

---

## License

MIT License


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ATmulti-file-handler",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "file, txt, json, csv, yaml, xml, dill, binary, database, VarDB",
    "author": null,
    "author_email": "Avi Twil <avitwil@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/49/fb/7414799004d7d70d4200bddb877d6ebc2c89734213e3a139f0a1aee3c4b0/atmulti_file_handler-2.0.2.tar.gz",
    "platform": null,
    "description": "\r\n# ATmulti_file_handler\r\n\r\nA unified **file handling abstraction layer** for multiple file formats. This Python package provides a consistent interface to work with various file types including text, JSON, CSV, YAML, XML, Dill, binary files, and a custom VariableDB database.  \r\n\r\n## Features\r\n\r\n- Unified `File` base class with consistent interface.\r\n- Format-specific subclasses:\r\n  - `TxtFile`   \u2192 `.txt`\r\n  - `JsonFile`  \u2192 `.json`\r\n  - `CsvFile`   \u2192 `.csv`\r\n  - `DillFile`  \u2192 `.dill`\r\n  - `XmlFile`   \u2192 `.xml`\r\n  - `YamlFile`  \u2192 `.yml` / `.yaml`\r\n  - `ByteFile`  \u2192 `.bin` / `.exe` / `.img` / `.jpg`\r\n  - `VarDBFile` \u2192 `.db` (requires `avi_tools` package)\r\n- Common operations: `read`, `write`, `append`, `exist`, `copy`, `move`, `delete`.\r\n- Automatic directory and file creation if missing.\r\n- Factory function `file()` to automatically choose the right subclass based on extension.\r\n\r\n---\r\n\r\n## Installation\r\n\r\nYou can install the package directly from **PyPI**:\r\n\r\n```bash\r\npip install ATmulti_file_handler\r\n````\r\n\r\nThis will also install all required dependencies:\r\n`dill`, `PyYAML`, `avi_tools`.\r\n\r\n---\r\n\r\n## Usage\r\n\r\n### Import the package\r\n\r\n```python\r\nfrom ATmulti_file_handler import file\r\n```\r\n\r\n---\r\n\r\n### Working with Text Files\r\n\r\n```python\r\nf = file(\"notes.txt\")\r\nf.write(\"Hello World\")\r\nprint(f.read())   # -> \"Hello World\"\r\nf.append(\"\\nAppended text\")\r\n```\r\n\r\n---\r\n\r\n### Working with JSON\r\n\r\n```python\r\nf = file(\"data.json\")\r\nf.write({\"a\": 1})\r\nprint(f.read())   # -> {\"a\": 1}\r\nf.append({\"b\": 2})\r\nprint(f.read())   # -> {\"a\": 1, \"b\": 2}\r\n```\r\n\r\n---\r\n\r\n### Working with CSV\r\n\r\n```python\r\nf = file(\"table.csv\")\r\nf.write([[\"Name\",\"Age\"],[\"Alice\",\"30\"]])\r\nf.append([\"Bob\",\"25\"])\r\nprint(f.read())   # -> [[\"Name\",\"Age\"],[\"Alice\",\"30\"],[\"Bob\",\"25\"]]\r\n```\r\n\r\n---\r\n\r\n### Working with Dill (Python objects)\r\n\r\n```python\r\nf = file(\"data.dill\")\r\nf.write([1,2,3])\r\nf.append(4)\r\nprint(f.read())   # -> [1,2,3,4]\r\n```\r\n\r\n---\r\n\r\n### Working with YAML\r\n\r\n```python\r\nf = file(\"config.yaml\")\r\nf.write({\"setting\": True})\r\nf.append({\"debug\": False})\r\nprint(f.read())   # -> {\"setting\": True, \"debug\": False}\r\n```\r\n\r\n---\r\n\r\n### Working with XML\r\n\r\n```python\r\nimport xml.etree.ElementTree as ET\r\n\r\nf = file(\"data.xml\")\r\nroot = ET.Element(\"root\")\r\nf.write(root)\r\nchild = ET.Element(\"child\")\r\nroot.append(child)\r\nf.append(ET.Element(\"another_child\"))\r\n```\r\n\r\n---\r\n\r\n### Working with Binary Files\r\n\r\n```python\r\nf = file(\"data.bin\")\r\nf.write(b\"Hello\")\r\nf.append(b\" World\")\r\nprint(f.read())  # -> b\"Hello World\"\r\n```\r\n\r\n---\r\n\r\n### Working with VariableDB Files\r\n\r\n```python\r\nb = 20\r\nf = file(\"config.db\", scope=globals(), data={\"a\": 10})\r\nf.append(b)\r\nprint(f.read())   # -> {\"a\": 10, \"b\": 20}\r\n```\r\n\r\n---\r\n\r\n### Common Operations\r\n\r\n```python\r\nf = file(\"notes.txt\")\r\nprint(f.exist())           # True/False\r\nf.copy(\"/tmp\")             # Copies file to /tmp\r\nf.move(\"/tmp\")             # Moves file to /tmp\r\nf.delete()                 # Deletes the file\r\n```\r\n\r\n---\r\n\r\n## Author\r\n\r\n**Avi Twil**\r\n\r\nGitHub: [https://github.com/avitwil/ATmulti\\_file\\_handler](https://github.com/avitwil/ATmulti_file_handler)\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT License\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A unified file handling abstraction layer for multiple file formats.",
    "version": "2.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/avitwil/ATmulti_file_handler/issues",
        "Homepage": "https://github.com/avitwil/ATmulti_file_handler",
        "Source": "https://github.com/avitwil/ATmulti_file_handler"
    },
    "split_keywords": [
        "file",
        " txt",
        " json",
        " csv",
        " yaml",
        " xml",
        " dill",
        " binary",
        " database",
        " vardb"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b3f5699bf176665f44a8fda853037e0f4cb61a4165e98a1cba782fbb18eeb3dd",
                "md5": "4ef8ccb4fc5c664b5942375fefb08ee6",
                "sha256": "670854a489bc2e4fb05f04c2ddb8ac1cdd8eda1167750f02b9bcdbb8d70ac92a"
            },
            "downloads": -1,
            "filename": "atmulti_file_handler-2.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4ef8ccb4fc5c664b5942375fefb08ee6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8764,
            "upload_time": "2025-08-30T17:28:51",
            "upload_time_iso_8601": "2025-08-30T17:28:51.072085Z",
            "url": "https://files.pythonhosted.org/packages/b3/f5/699bf176665f44a8fda853037e0f4cb61a4165e98a1cba782fbb18eeb3dd/atmulti_file_handler-2.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "49fb7414799004d7d70d4200bddb877d6ebc2c89734213e3a139f0a1aee3c4b0",
                "md5": "bebdcbba681192a1d9e6ec55ef647574",
                "sha256": "1144280ab9a79dbe72885bd67c48a203e52844de28983d778bcce0b81aa34f9b"
            },
            "downloads": -1,
            "filename": "atmulti_file_handler-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "bebdcbba681192a1d9e6ec55ef647574",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7401,
            "upload_time": "2025-08-30T17:28:52",
            "upload_time_iso_8601": "2025-08-30T17:28:52.340241Z",
            "url": "https://files.pythonhosted.org/packages/49/fb/7414799004d7d70d4200bddb877d6ebc2c89734213e3a139f0a1aee3c4b0/atmulti_file_handler-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-30 17:28:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "avitwil",
    "github_project": "ATmulti_file_handler",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "atmulti-file-handler"
}
        
Elapsed time: 0.97625s