Skip to content

Commit

Permalink
fix non-relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Mar 19, 2024
1 parent fbf906c commit 14ef68e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion django_crypto_fields/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.apps import AppConfig as DjangoAppConfig
from django.core.management.color import color_style

from django_crypto_fields.key_path import KeyPath
from .key_path import KeyPath


class AppConfig(DjangoAppConfig):
Expand Down
17 changes: 8 additions & 9 deletions django_crypto_fields/key_path/persist_key_path_or_raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ def read_last_used(folder: Path) -> tuple[PurePath | None, Path]:
"""Opens file `django_crypto_fields` and read last path."""
last_used_path = None
filepath = Path(folder / "django_crypto_fields")
if filepath.exists():
if "runtests.py" in sys.argv:
filepath.unlink()
else:
with filepath.open(mode="r") as f:
reader = csv.DictReader(f)
for row in reader:
last_used_path = PurePath(row.get("path"))
break
if "runtests.py" in sys.argv:
filepath.unlink(missing_ok=True)
elif filepath.exists():
with filepath.open(mode="r") as f:
reader = csv.DictReader(f)
for row in reader:
last_used_path = PurePath(row.get("path"))
break
if last_used_path and not Path(last_used_path).exists():
raise DjangoCryptoFieldsKeyPathError(
style.ERROR(
Expand Down
12 changes: 4 additions & 8 deletions django_crypto_fields/keys/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
from Cryptodome.Util import number
from django.core.management.color import color_style

from django_crypto_fields.constants import AES, PRIVATE, PUBLIC, RSA, RSA_KEY_SIZE, SALT
from django_crypto_fields.exceptions import (
from ..constants import AES, PRIVATE, PUBLIC, RSA, RSA_KEY_SIZE, SALT
from ..exceptions import (
DjangoCryptoFieldsError,
DjangoCryptoFieldsKeyAlreadyExist,
DjangoCryptoFieldsKeyError,
DjangoCryptoFieldsKeysAlreadyLoaded,
DjangoCryptoFieldsKeysDoNotExist,
)
from django_crypto_fields.key_path import KeyPath, persist_key_path_or_raise
from django_crypto_fields.utils import (
get_auto_create_keys_from_settings,
get_key_prefix_from_settings,
)

from ..key_path import KeyPath, persist_key_path_or_raise
from ..utils import get_auto_create_keys_from_settings, get_key_prefix_from_settings
from .utils import get_filenames, get_template, key_files_exist, write_msg

style = color_style()
Expand Down
10 changes: 1 addition & 9 deletions django_crypto_fields/keys/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
from pathlib import Path, PurePath
from typing import Iterator

from django_crypto_fields.constants import (
AES,
LOCAL_MODE,
PRIVATE,
PUBLIC,
RESTRICTED_MODE,
RSA,
SALT,
)
from ..constants import AES, LOCAL_MODE, PRIVATE, PUBLIC, RESTRICTED_MODE, RSA, SALT


def get_template(path: PurePath, key_prefix: str) -> dict[str, dict[str, dict[str, PurePath]]]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
path,date
/Users/erikvw/source/edc_source/django-crypto-fields/django_crypto_fields/tests/crypto_keys,2024-03-19 04:06:39.385684+00:00
/Users/erikvw/source/edc_source/django-crypto-fields/django_crypto_fields/tests/crypto_keys,2024-03-19 04:17:34.681606+00:00
2 changes: 1 addition & 1 deletion django_crypto_fields/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def has_valid_value_or_raise(


def is_valid_ciphertext_or_raise(ciphertext: bytes, hash_size: int | None = None):
"""Returns an unchanged ciphertext after verifying format cipher_prefix +
"""Returns an unchanged ciphertext after verifying format hash_prefix +
hash + cipher_prefix + secret.
"""
try:
Expand Down

0 comments on commit 14ef68e

Please sign in to comment.