Skip to content

Commit b62f300

Browse files
committed
moved .util to .core
1 parent 8d763eb commit b62f300

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

src/passwordlib/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
__version__ = '.'.join(str(_) for _ in __version_info__)
3636

3737
from . import config
38-
from . import util
39-
from .util import hash_password, compare_password
38+
from . import core
39+
from .core import hash_password, compare_password

src/passwordlib/attr/attribute_class.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
"""
55
import typing as t
6-
from .. import util
6+
from ..core import hash_password
77

88

99
class PasswordAttribute:
@@ -54,8 +54,8 @@ def __set__(self, instance, value):
5454
if self._allow_reset and value is None:
5555
self.__delete__(instance=instance)
5656
elif isinstance(value, (str, bytes)):
57-
dumped = util.hash_password(password=value, algorithm=self._algorithm,
58-
iterations=self._iterations, salt=self._salt)
57+
dumped = hash_password(password=value, algorithm=self._algorithm,
58+
iterations=self._iterations, salt=self._salt)
5959
setattr(instance, self._instance_attribute_name, dumped)
6060
else:
6161
raise TypeError(f"Value of type {type(value)} is not password-hashable")

src/passwordlib/util/__init__.py src/passwordlib/core/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#!/usr/bin/python3
21
# -*- coding=utf-8 -*-
32
r"""
4-
various utility functions to generate hashed from password and compare them
3+
core functions
54
"""
65
from .functions import (
76
generate_salt,
File renamed without changes.

src/passwordlib/util/functions.py src/passwordlib/core/functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import hashlib
88
import typing as t
9-
from .. import config
9+
from passwordlib import config
1010

1111

1212
__all__ = ['generate_salt', 'get_password_bytes', 'get_algorithm', 'get_iterations', 'get_salt']

src/passwordlib/util/hashing.py src/passwordlib/core/hashing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import hmac
77
import hashlib
88
import typing as t
9-
from . import functions as fn
9+
from ..core import functions as fn
1010
from .dumping import dumps, loads
1111

1212

tests/test_attribute.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_import(self):
1111
import passwordlib.attr # noqa
1212

1313
def test_set(self):
14-
from passwordlib.util import compare_password
14+
from passwordlib.core import compare_password
1515
from passwordlib.attr import PasswordAttribute
1616

1717
class User:

tests/test_util.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88

99
class TestUtil(unittest.TestCase):
1010
def test_import_util(self):
11-
import passwordlib.util # noqa
11+
# noinspection PyUnresolvedReferences
12+
import passwordlib.core
1213

1314
def test_salt_generation(self):
14-
from passwordlib.util import generate_salt
15+
from passwordlib.core import generate_salt
1516
self.assertIsInstance(generate_salt(), bytes)
1617
self.assertEqual(len(generate_salt(length=32)), 32)
1718
self.assertEqual(len(generate_salt(length=64)), 64)
1819

1920
def test_dumping(self):
20-
from passwordlib.util import (
21+
from passwordlib.core import (
2122
dumps,
2223
get_algorithm, get_iterations, get_salt
2324
)
@@ -31,7 +32,7 @@ def test_dumping(self):
3132
self.assertIsInstance(dumped, bytes)
3233

3334
def test_loading(self):
34-
from passwordlib.util import (
35+
from passwordlib.core import (
3536
dumps, loads,
3637
get_algorithm, get_iterations, get_salt
3738
)
@@ -49,7 +50,7 @@ def test_loading(self):
4950
self.assertEqual(loaded.hashed, hashed)
5051

5152
def test_redumping(self):
52-
from passwordlib.util import (
53+
from passwordlib.core import (
5354
dumps, loads,
5455
get_algorithm, get_iterations, get_salt,
5556
)
@@ -67,7 +68,7 @@ def test_redumping(self):
6768
self.assertEqual(dumped, dumped2)
6869

6970
def test_extraction(self):
70-
from passwordlib.util import (
71+
from passwordlib.core import (
7172
dumps,
7273
extract_algorythm, extract_iterations, extract_salt, extract_hashed,
7374
get_algorithm, get_iterations, get_salt,

0 commit comments

Comments
 (0)