Skip to content

Commit

Permalink
Make MVTModule.get_slug() a classmethod (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
roaree authored Nov 22, 2023
1 parent 7310481 commit 1d075ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mvt/common/cmd_check_iocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(self) -> None:
if self.module_name and iocs_module.__name__ != self.module_name:
continue

if iocs_module().get_slug() != name_only:
if iocs_module.get_slug() != name_only:
continue

log.info(
Expand Down
9 changes: 5 additions & 4 deletions mvt/common/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ def from_json(cls, json_path: str, log: logging.Logger):
log.info('Loaded %d results from "%s"', len(results), json_path)
return cls(results=results, log=log)

def get_slug(self) -> str:
@classmethod
def get_slug(cls) -> str:
"""Use the module's class name to retrieve a slug"""
if self.slug:
return self.slug
if cls.slug:
return cls.slug

sub = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", self.__class__.__name__)
sub = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", cls.__name__)
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", sub).lower()

def check_indicators(self) -> None:
Expand Down

0 comments on commit 1d075ab

Please sign in to comment.