Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of Initial Codebase #43

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,3 @@ jobs:
POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }}
run: |
poetry publish --build --username $POETRY_PYPI_USERNAME --password $POETRY_PYPI_TOKEN

- name: Save as Artifact
uses: actions/upload-artifact@v3
with:
name: python-package-artifact
path: ./dist/

- name: Upload dist directory as Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/pyfilehandling-${{ github.event.release.name }}.tar.gz
asset_name: pyfilehandling-${{ github.event.release.name }}.tar.gz
asset_content_type: application/gzip
163 changes: 2 additions & 161 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyfilehandling/jsonfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def read(self) -> Dict:
def write(self, data: Dict, indent: int = 4):
if self.file.writable:
json.dump(data, self.file, indent)
raise WriteNotPermitted(self.file.name)
else:
raise WriteNotPermitted(self.file.name)

def read_key(self, key: str) -> Any:
if self.data is None:
Expand Down
77 changes: 77 additions & 0 deletions pyfilehandling/jsonfile.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from typing import Dict, Any


class jsonFile:
file: Any # Placeholder for file object, type inferred

def __init__(self, filename: str, mode: str = "r") -> None:
"""
Initialize a jsonFile instance.

Parameters:
- filename (str): The name of the JSON file.
- mode (str): The mode to open the file in (default is 'r' for read-only).

Returns:
- None
"""

def __enter__(self) -> Any:
"""
Enter the context manager and return the file object.

Returns:
- Any: The file object.
"""

def __exit__(self, exc_type, exc_value, exc_traceback) -> None:
"""
Exit the context manager and close the file.

Parameters:
- exc_type: The exception type.
- exc_value: The exception value.
- exc_traceback: The traceback.

Returns:
- None
"""

def read(self) -> Dict:
"""
Read JSON data from the file and return it as a dictionary.

Returns:
- Dict: The JSON data.
"""

def write(self, data: Dict, indent: int = 4) -> None:
"""
Write JSON data to the file.

Parameters:
- data (Dict): The data to write to the file.
- indent (int): The number of spaces to use for indentation (default is 4).

Returns:
- None
"""

def read_key(self, key: str) -> Any:
"""
Read a specific key from the JSON data.

Parameters:
- key (str): The key to read from the JSON data.

Returns:
- Any: The value associated with the key.
"""

def close(self) -> None:
"""
Close the file.

Returns:
- None
"""
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyfilehandling"
version = "3.2.1"
version = "3.2.2"
description = "A Python package for file manipulation operations."
authors = ["Jeel Dobariya <dobariyaj34@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -32,10 +32,6 @@ packages = [
[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.group.test.dependencies]
pytest = ">=7.4.3,<9.0.0"
coverage = "^7.3.2"

[tool.poetry.group.lint.dependencies]
flake8 = ">=6.1,<8.0"

Expand Down
8 changes: 0 additions & 8 deletions tests/conftest.py

This file was deleted.

43 changes: 0 additions & 43 deletions tests/mocking.py

This file was deleted.

Loading
Loading