-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip actions] [optimization] 2023-07-16T13:21:46+03:00
- Loading branch information
Showing
9 changed files
with
114 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,75 @@ | ||
from dataclasses import dataclass | ||
from functools import cached_property | ||
from typing import List, Optional | ||
|
||
from credsweeper.file_handler.descriptor import Descriptor | ||
|
||
|
||
@dataclass(frozen=True) | ||
class AnalysisTarget: | ||
"""AnalysisTarget""" | ||
line: str | ||
line_num: int | ||
lines: List[str] | ||
descriptor: Descriptor | ||
|
||
def __init__(self, | ||
line_pos: int, | ||
lines: List[str], | ||
line_nums: List[int], | ||
descriptor: Descriptor, | ||
): | ||
self.__line_pos = line_pos | ||
self.__lines = lines | ||
self.__line_nums = line_nums | ||
self.__descriptor = descriptor | ||
|
||
@cached_property | ||
def line(self) -> str: | ||
"""cached value""" | ||
return self.__lines[self.__line_pos] | ||
|
||
@cached_property | ||
def line_len(self) -> int: | ||
"""cached value""" | ||
return len(self.line) | ||
# use indirectly "line" to prevent caching skipped line | ||
return len(self.__lines[self.__line_pos]) | ||
|
||
@cached_property | ||
def lines(self) -> List[str]: | ||
"""cached value""" | ||
return self.__lines | ||
|
||
@cached_property | ||
def lines_len(self) -> int: | ||
"""cached value""" | ||
return len(self.lines) | ||
return len(self.__lines) | ||
|
||
@cached_property | ||
def line_pos(self) -> int: | ||
"""cached value""" | ||
return self.__line_pos | ||
|
||
@cached_property | ||
def line_num(self) -> int: | ||
"""cached value""" | ||
return self.__line_nums[self.__line_pos] | ||
|
||
@cached_property | ||
def line_nums(self) -> List[int]: | ||
"""cached value""" | ||
return self.__line_nums | ||
|
||
@cached_property | ||
def file_path(self) -> Optional[str]: | ||
return self.descriptor.path | ||
"""cached value""" | ||
return self.__descriptor.path | ||
|
||
@cached_property | ||
def file_type(self) -> Optional[str]: | ||
return self.descriptor.extension | ||
"""cached value""" | ||
return self.__descriptor.extension | ||
|
||
@cached_property | ||
def info(self) -> Optional[str]: | ||
return self.descriptor.info | ||
"""cached value""" | ||
return self.__descriptor.info | ||
|
||
@cached_property | ||
def descriptor(self) -> Descriptor: | ||
"""cached value""" | ||
return self.__descriptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters