99import click
1010
1111from ontobot_change_agent import __version__
12- from ontobot_change_agent .api import (
13- get_all_labels_from_repo ,
14- get_issues ,
15- process_issue_via_oak ,
16- )
12+ from ontobot_change_agent .api import get_all_labels_from_repo , get_issues , process_issue_via_oak
1713
1814__all__ = [
1915 "main" ,
@@ -136,9 +132,7 @@ def get_labels(repo: str):
136132@issue_number_option
137133@state_option
138134@output_option
139- def process_issue (
140- input : str , repo : str , label : str , number : int , state : str , output : str
141- ):
135+ def process_issue (input : str , repo : str , label : str , number : int , state : str , output : str ):
142136 """Run processes based on issue label.
143137
144138 :param repo: GitHub repository name [org/repo_name]
@@ -147,9 +141,7 @@ def process_issue(
147141 """
148142 formatted_body = "The following commands were executed: </br>"
149143
150- for issue in get_issues (
151- repository_name = repo , label = label , number = number , state = state
152- ):
144+ for issue in get_issues (repository_name = repo , label = label , number = number , state = state ):
153145 issue_body = issue [BODY ].replace ("\n " , " " )
154146 begin_match = re .match (r"(.*)ontobot(.*)apply(.*):(.*)\*" , issue_body )
155147 end_match = re .match (r"(.*)---" , issue_body )
@@ -159,10 +151,15 @@ def process_issue(
159151 else :
160152 begin_index = 0
161153
162- if end_match is not None :
163- end_index = end_match .end () - 3
154+ if end_match is None :
155+ end_match = re .match (r"(.*):\d+" , issue_body )
156+ if end_match is None :
157+ end_index = 0
158+ click .echo (f"""Cannot find end of command: { issue_body [begin_index :]} """ )
159+ else :
160+ end_index = end_match .end ()
164161 else :
165- end_index = 0
162+ end_index = end_match . end () - 3
166163
167164 if output :
168165 new_output = output
@@ -172,10 +169,7 @@ def process_issue(
172169 if begin_index < end_index :
173170 KGCL_COMMANDS = issue_body [begin_index :end_index ].split ("* " )[1 :]
174171 KGCL_COMMANDS = [x .strip () for x in KGCL_COMMANDS ]
175- if (
176- issue ["number" ] == number # noqa W503
177- and len (KGCL_COMMANDS ) > 0 # noqa W503
178- ):
172+ if issue ["number" ] == number and len (KGCL_COMMANDS ) > 0 : # noqa W503 # noqa W503
179173 process_issue_via_oak (
180174 input = input ,
181175 commands = KGCL_COMMANDS ,
@@ -192,9 +186,7 @@ def process_issue(
192186 """
193187 )
194188 else :
195- click .echo (
196- f"""{ issue [TITLE ]} does not need ontobot's attention."""
197- )
189+ click .echo (f"""{ issue [TITLE ]} does not need ontobot's attention.""" )
198190
199191
200192def _list_to_markdown (list : list ) -> str :
0 commit comments