Skip to content

Commit

Permalink
code formatting and typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daveoncode committed Mar 4, 2020
1 parent 391edf4 commit 6df42b4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
4 changes: 2 additions & 2 deletions string_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

__version__ = '1.0.0'

# makes all the functions available at string_utils level
# as the where in older versions (before 1.0.0) when it was a single python module
# makes all the functions available at `string_utils` level
# as they were in older versions (before 1.0.0) when it was a single python module
from .validation import *
from .manipulation import *
from .generation import *
1 change: 1 addition & 0 deletions string_utils/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

from typing import Any


Expand Down
19 changes: 11 additions & 8 deletions string_utils/generation.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import binascii
import os
import random
from typing import Generator
from uuid import uuid4
import string

from string_utils import is_integer, roman_encode
# -*- coding: utf-8 -*-

# public api to export
__all__ = [
'uuid',
'random_string',
'secure_random_hex',
'roman_range',
]

import binascii
import os
import random
import string
from typing import Generator
from uuid import uuid4

from string_utils import is_integer, roman_encode


def uuid(as_hex: bool = False) -> str:
"""
Expand Down
22 changes: 11 additions & 11 deletions string_utils/manipulation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# -*- coding: utf-8 -*-

import base64
import random
import unicodedata
from typing import Union
from uuid import uuid4

# public api to export
__all__ = [
'camel_case_to_snake',
'snake_case_to_camel',
Expand All @@ -23,7 +18,12 @@
'roman_decode',
]

import base64
import random
import unicodedata
import zlib
from typing import Union
from uuid import uuid4

from ._regex import *
from .errors import InvalidInputError
Expand Down Expand Up @@ -156,7 +156,7 @@ def decode(cls, input_string: str) -> int:
return output


class _StringCompressor:
class __StringCompressor:

@staticmethod
def __require_valid_input_and_encoding(input_string: str, encoding: str):
Expand Down Expand Up @@ -209,7 +209,7 @@ def decompress(cls, input_string: str, encoding: str = 'utf-8') -> str:
return original_string


class _StringFormatter:
class __StringFormatter:
def __init__(self, input_string):
if not is_string(input_string):
raise InvalidInputError(input_string)
Expand Down Expand Up @@ -426,7 +426,7 @@ def prettify(input_string: str) -> str:
:param input_string: String to manipulate
:return: Prettified string.
"""
formatted = _StringFormatter(input_string).format()
formatted = __StringFormatter(input_string).format()
return formatted


Expand Down Expand Up @@ -592,7 +592,7 @@ def compress(input_string: str, encoding: str = 'utf-8', compression_level: int
:type compression_level: int
:return: Compressed string.
"""
return _StringCompressor.compress(input_string, encoding, compression_level)
return __StringCompressor.compress(input_string, encoding, compression_level)


def decompress(input_string: str, encoding: str = 'utf-8') -> str:
Expand All @@ -605,7 +605,7 @@ def decompress(input_string: str, encoding: str = 'utf-8') -> str:
:type encoding: str
:return: Decompressed string.
"""
return _StringCompressor.decompress(input_string, encoding)
return __StringCompressor.decompress(input_string, encoding)


def roman_encode(input_number: Union[str, int]) -> str:
Expand Down
19 changes: 10 additions & 9 deletions string_utils/validation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

import json
import string
from typing import Any, Optional, List

# public api to export
__all__ = [
'is_string',
'is_full_string',
Expand Down Expand Up @@ -31,14 +28,18 @@
'words_count',
]

import json
import string
from typing import Any, Optional, List

from ._regex import *
from string_utils.errors import InvalidInputError
from .errors import InvalidInputError


# PRIVATE API


class _ISBNChecker:
class __ISBNChecker:
def __init__(self, input_string: str, normalize: bool = True):
if not is_string(input_string):
raise InvalidInputError(input_string)
Expand Down Expand Up @@ -613,7 +614,7 @@ def is_isbn_10(input_string: str, normalize: bool = True) -> bool:
:param normalize: True to ignore hyphens ("-") in the string (default), false otherwise.
:return: True if valid ISBN 10, false otherwise.
"""
checker = _ISBNChecker(input_string, normalize)
checker = __ISBNChecker(input_string, normalize)
return checker.is_isbn_10()


Expand All @@ -633,7 +634,7 @@ def is_isbn_13(input_string: str, normalize: bool = True) -> bool:
:param normalize: True to ignore hyphens ("-") in the string (default), false otherwise.
:return: True if valid ISBN 13, false otherwise.
"""
checker = _ISBNChecker(input_string, normalize)
checker = __ISBNChecker(input_string, normalize)
return checker.is_isbn_13()


Expand All @@ -652,5 +653,5 @@ def is_isbn(input_string: str, normalize: bool = True) -> bool:
:param normalize: True to ignore hyphens ("-") in the string (default), false otherwise.
:return: True if valid ISBN (10 or 13), false otherwise.
"""
checker = _ISBNChecker(input_string, normalize)
checker = __ISBNChecker(input_string, normalize)
return checker.is_isbn_13() or checker.is_isbn_10()

0 comments on commit 6df42b4

Please sign in to comment.