Skip to content

Commit

Permalink
Improve Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
dynobo committed Apr 18, 2021
1 parent b240278 commit 31cdf87
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions normcap/common/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class NormcapData:
transformed: str = "" # Transformed result

def __repr__(self):
"""
"""Format dataclass for debug outputs.
Returns:
str -- Representation of class
"""
Expand All @@ -74,7 +75,7 @@ def __repr__(self):

@property
def mean_conf(self) -> float:
"""Helper to calculate mean confidence value of OCR.
"""Calculate mean confidence value of OCR.
Returns:
float -- Avg confidence value
Expand All @@ -86,7 +87,7 @@ def mean_conf(self) -> float:

@property
def selected_area(self) -> int:
"""Helper to calculate area of cropped image in px².
"""Calculate area of cropped image in px².
Returns:
int -- Area of this.image in px²
Expand All @@ -95,7 +96,7 @@ def selected_area(self) -> int:

@property
def text(self) -> str:
"""Helper to return concatenated OCR text in single line.
"""Concatenated OCR text into single line.
Returns:
str -- stripped OCR lines concatenated to single string
Expand All @@ -104,7 +105,7 @@ def text(self) -> str:

@property
def lines(self) -> str:
"""Helper to return concatenated OCR text in multiple lines.
"""Concatenated OCR text into multiple lines.
Returns:
str -- stripped OCR lines concatenated using newline as separater
Expand All @@ -123,7 +124,7 @@ def lines(self) -> str:

@property
def num_lines(self) -> int:
"""Helper to return number of lines.
"""Get number of lines.
Returns:
int -- number of detected lines
Expand All @@ -133,7 +134,7 @@ def num_lines(self) -> int:

@property
def num_pars(self) -> int:
"""Helper to return number of paragraphs.
"""Get number of paragraphs.
Returns:
int -- number of detected paragraphs
Expand All @@ -143,7 +144,7 @@ def num_pars(self) -> int:

@property
def num_blocks(self) -> int:
"""Helper to return number of blocks.
"""Get number of blocks.
Returns:
int -- number of detected blocks
Expand Down
4 changes: 2 additions & 2 deletions normcap/handlers/abstract_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class Handler(abc.ABC):
"""
The Handler interface declares a method for building the chain of handlers.
"""The Handler interface declares a method for building the chain of handlers.
It also declares a method for executing a request.
"""

Expand Down
1 change: 1 addition & 0 deletions normcap/handlers/enhance_img_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def _most_frequent_colour(self, img):

def _enlarge_dpi(self, img: Image.Image) -> Image.Image:
"""Resize image to get equivalent of 300dpi.
Reason: Most display are around ~100dpi, while Tesseract works best ~300dpi.
Arguments:
Expand Down
6 changes: 2 additions & 4 deletions normcap/normcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def init_logging(log_level: int, to_file: bool = False) -> logging.Logger:
Returns:
logging.Logger -- Formatted logger with desired level
"""

if to_file:
logging.basicConfig(
filename="normcap.log",
Expand All @@ -110,7 +109,7 @@ def init_logging(log_level: int, to_file: bool = False) -> logging.Logger:


def client_code(handler: Handler, normcap_data) -> NormcapData:
"""Wrapper around Chain of Responsibility classes.
"""Wrap Chain of Responsibility classes.
Arguments:
handler {Handler} -- Most outer handler
Expand All @@ -124,8 +123,7 @@ def client_code(handler: Handler, normcap_data) -> NormcapData:


def main(test_data: NormcapData = None):
"""Main program logic."""

"""Run main program logic."""
# Init Logger
logger = init_logging(logging.INFO, to_file=False)
logger.info("Starting NormCap v%s ...", __version__)
Expand Down

0 comments on commit 31cdf87

Please sign in to comment.