Skip to content

Commit

Permalink
Break out a helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Aug 28, 2023
1 parent c1d3030 commit bdefcca
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tcms/issuetracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

RE_ENDS_IN_INT = re.compile(r"[\d]+$")

def _function_from_path(fully_qualified_dotted_path):
"""
Helper function which returns a callable object from a
fully qualified dotted path string!
"""
function_name = fully_qualified_dotted_path.split(".")[-1]
module_name = fully_qualified_dotted_path.replace(f".{function_name}", "")

module_object = import_module(module_name)
function_object = getattr(module_object, function_name)
return function_object


class IssueTrackerType:
"""
Expand Down Expand Up @@ -136,11 +148,7 @@ def post_process_new_issue(self, new_issue, execution, user):
.. versionadded:: 11.4
"""
for fully_qualified_dotted_path in settings.EXTERNAL_ISSUE_POST_PROCESSORS:
function_name = fully_qualified_dotted_path.split(".")[-1]
module_name = fully_qualified_dotted_path.replace(f".{function_name}", "")

processor_module = import_module(module_name)
processor_function = getattr(processor_module, function_name)
processor_function = _function_from_path(fully_qualified_dotted_path)
processor_function(self.rpc, new_issue, execution, user)

def add_testexecution_to_issue(self, executions, issue_url):
Expand Down

0 comments on commit bdefcca

Please sign in to comment.