Skip to content

Commit

Permalink
Merge pull request #7 from sampingantech/enhancement/migrate-to-poetry
Browse files Browse the repository at this point in the history
enchancement: migrate to poetry and upgrade depedencies
  • Loading branch information
isasetiawan committed Jan 9, 2023
2 parents d738f8f + a0b6b69 commit a1f9162
Show file tree
Hide file tree
Showing 8 changed files with 581 additions and 11 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.13
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ This is an Adapter for [PyCasbin](https://github.com/casbin/pycasbin) that imple

## Commands

* `make install` to install all required depedencies writtern in `requirements.txt` and `requirements-test.txt`
* `make check` to run mypy
* `make test` to run unit test that written using pytest
4 changes: 2 additions & 2 deletions casbin_databases_adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def load_policy(self, model: Model):
rows = await self.db.fetch_all(query)
for row in rows:
# convert row from tuple to csv format and removing the first column (id)
line = [v for k, v in row.items() if k in self.cols and v is not None]
line = [v for k, v in row._mapping.items() if k in self.cols and v is not None]
persist.load_policy_line(", ".join(line), model)

async def save_policy(self, model: Model):
Expand Down Expand Up @@ -83,7 +83,7 @@ async def load_filtered_policy(self, model: Model, filter_: Filter) -> None:
rows = await self.db.fetch_all(query)
for row in rows:
# convert row from tuple to csv format and removing the first column (id)
line = [v for k, v in row.items() if k in self.cols and v is not None]
line = [v for k, v in row._mapping.items() if k in self.cols and v is not None]
persist.load_policy_line(", ".join(line), model)

def is_filtered(self):
Expand Down
549 changes: 549 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[virtualenvs]
in-project = true
prefer-active-python = true
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tool.poetry]
name = "databases-casbin-adapter"
version = "0.1.0"
description = "An adapter for PyCasbin that implemented by Databases library which support async process"
authors = ["isasetiawan <10252610+isasetiawan@users.noreply.github.com>"]
license = "MIT"
readme = "README.md"
packages = [{include = "databases_casbin_adapter"}]

[tool.poetry.dependencies]
python = "^3.9"
SQLAlchemy = "1.4.46"
databases = "0.7.0"
asynccasbin = "1.1.8"


[tool.poetry.group.test.dependencies]
pytest = "7.2.0"
pytest-cov = "4.0.0"
alt-pytest-asyncio = "0.6.0"
aiosqlite = "0.18.0"
mypy = "0.991"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 0 additions & 5 deletions requirements-test.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

0 comments on commit a1f9162

Please sign in to comment.