diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..11595fd --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,37 @@ +# This workflow will install Python dependencies, run tests, and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install --upgrade pip + pip install wheel + pip install setuptools + pip install twine + pip install pytest==8.2.2 + pip install pytest-runner==6.0.1 + - name: Test with pytest + run: | + pytest diff --git a/.gitignore b/.gitignore index 1e94382..9938ac3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,9 @@ venv dist build *.egg-info -.eggs \ No newline at end of file +.eggs +*.csv +*.pickle +tmp +*.json +*.pyc \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d9a653e --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +.PHONY: init +# init development +init: + python3 -m venv venv + +.PHONY: deps +# deps development +deps: + pip install --upgrade pip + pip install wheel + pip install setuptools + pip install twine + pip install pytest==8.2.2 + pip install pytest-runner==6.0.1 + +# show help +help: + @echo '' + @echo 'Usage:' + @echo ' make [target]' + @echo '' + @echo 'Targets:' + @awk '/^[a-zA-Z\-0-9]+:/ { \ + helpMessage = match(lastLine, /^# (.*)/); \ + if (helpMessage) { \ + helpCommand = substr($$1, 0, index($$1, ":")-1); \ + helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \ + printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) + +.DEFAULT_GOAL := help \ No newline at end of file diff --git a/README.ar.md b/README.ar.md index a67415e..26d25fe 100644 --- a/README.ar.md +++ b/README.ar.md @@ -1,6 +1,6 @@
-![Zakat Tracker Logo](images/logo.png) +![Zakat Tracker Logo](images/logo.jpg)
diff --git a/README.md b/README.md index 1698551..4571415 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
-![Zakat Tracker Logo](images/logo.png) +![Zakat Tracker Logo](images/logo.jpg) # ZakatTracker: A Python Library for Islamic Financial Management diff --git a/images/logo.jpg b/images/logo.jpg new file mode 100644 index 0000000..cb0340c Binary files /dev/null and b/images/logo.jpg differ diff --git a/tests/test_zakat_tracker.py b/tests/test_zakat_tracker.py new file mode 100644 index 0000000..6f59e8a --- /dev/null +++ b/tests/test_zakat_tracker.py @@ -0,0 +1,6 @@ +import pytest +from zakat import ZakatTracker + +def test_zakat_tracker(): + ledger = ZakatTracker("test.pickle") + ledger.test(True) \ No newline at end of file diff --git a/zakat/zakat_tracker.py b/zakat/zakat_tracker.py index 191ae2a..4302a5e 100644 --- a/zakat/zakat_tracker.py +++ b/zakat/zakat_tracker.py @@ -1048,9 +1048,10 @@ def load(self, _path: str = None) -> bool: """ if _path is None: _path = self.path() - with open(_path, "rb") as f: - self._vault = pickle.load(f) - return True + if os.path.exists(_path): + with open(_path, "rb") as f: + self._vault = pickle.load(f) + return True return False def import_csv(self, _path: str = 'file.csv') -> tuple: