Skip to content

Commit

Permalink
short functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaZakharova committed Aug 2, 2023
1 parent 1f94b15 commit ee9025d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions dl/annotation_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,12 @@ def remove_class(
filename (str, optional): remove class(es) for specific
file. Defaults to '*'.
"""
keep = self.update_classes(to_remove)

def remover(line: str, keep: Dict[int, int]) -> str:
line_new = self.upd_line(line, keep)
return line_new

read_and_update(self.txt_path, filename, remover, {'keep': keep})
read_and_update(
self.txt_path,
filename,
self.upd_line,
{'config': self.update_classes(to_remove)},
)

def replace_classes(
self, to_replace_with: Dict[int, int], filename: str = '*'
Expand All @@ -203,11 +202,9 @@ def replace_classes(
file. Defaults to '*'.
"""
self.classes_config = to_replace_with

def replace(line: str, replacer: Dict[int, int]) -> str:
return self.upd_line(line, replacer)

read_and_update(self.txt_path, filename, replace, {'replacer': to_replace_with})
read_and_update(
self.txt_path, filename, self.upd_line, {'config': to_replace_with}
)


class JSON2TXT(TXTAnnotations):
Expand Down

0 comments on commit ee9025d

Please sign in to comment.