feat: make joj3-env commands use options
This commit is contained in:
		
							parent
							
								
									1430b11e45
								
							
						
					
					
						commit
						5b7a102115
					
				|  | @ -225,7 +225,7 @@ def unsubscribe_from_repos(pattern: str = Argument("")) -> None: | |||
| def joj3_scoreboard( | ||||
|     env_path: str = Argument("", help="path to .env file"), | ||||
|     score_file_path: str = Argument( | ||||
|         "", help="path to score json file generated by JOJ3" | ||||
|         "grading", help="path to score json file generated by JOJ3" | ||||
|     ), | ||||
|     submitter: str = Argument("", help="submitter ID"), | ||||
|     repo_name: str = Argument( | ||||
|  | @ -240,7 +240,7 @@ def joj3_scoreboard( | |||
|         "", | ||||
|         help="gitea actions run number", | ||||
|     ), | ||||
|     scoreboard_file_name: str = Argument( | ||||
|     scoreboard_filename: str = Argument( | ||||
|         "scoreboard.csv", help="name of scoreboard file in the gitea repo" | ||||
|     ), | ||||
|     exercise_name: str = Argument( | ||||
|  | @ -284,7 +284,7 @@ def joj3_scoreboard( | |||
|         joj3.generate_scoreboard( | ||||
|             score_file_path, | ||||
|             submitter, | ||||
|             os.path.join(repo_path, scoreboard_file_name), | ||||
|             os.path.join(repo_path, scoreboard_filename), | ||||
|             exercise_name, | ||||
|         ) | ||||
|         actions_link = ( | ||||
|  | @ -297,7 +297,7 @@ def joj3_scoreboard( | |||
|             + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|             + f"gitea actions link: {actions_link}" | ||||
|         ) | ||||
|         tea.pot.git.add_commit(repo_name, [scoreboard_file_name], commit_message) | ||||
|         tea.pot.git.add_commit(repo_name, [scoreboard_filename], commit_message) | ||||
|         tea.pot.git.push(repo_name) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -323,7 +323,7 @@ def joj3_failed_table( | |||
|         "", | ||||
|         help="gitea actions run number", | ||||
|     ), | ||||
|     failed_table_file_name: str = Argument( | ||||
|     failed_table_filename: str = Argument( | ||||
|         "failed-table.md", help="name of failed table file in the gitea repo" | ||||
|     ), | ||||
|     exercise_name: str = Argument( | ||||
|  | @ -377,7 +377,7 @@ def joj3_failed_table( | |||
|             score_file_path, | ||||
|             submitter_repo_name, | ||||
|             submitter_repo_link, | ||||
|             os.path.join(repo_path, failed_table_file_name), | ||||
|             os.path.join(repo_path, failed_table_filename), | ||||
|             actions_link, | ||||
|         ) | ||||
|         commit_message = ( | ||||
|  | @ -385,7 +385,7 @@ def joj3_failed_table( | |||
|             + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|             + f"gitea actions link: {actions_link}" | ||||
|         ) | ||||
|         tea.pot.git.add_commit(repo_name, [failed_table_file_name], commit_message) | ||||
|         tea.pot.git.add_commit(repo_name, [failed_table_filename], commit_message) | ||||
|         tea.pot.git.push(repo_name) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -460,10 +460,10 @@ def joj3_all( | |||
|         "", | ||||
|         help="gitea actions run number", | ||||
|     ), | ||||
|     scoreboard_file_name: str = Argument( | ||||
|     scoreboard_filename: str = Argument( | ||||
|         "scoreboard.csv", help="name of scoreboard file in the gitea repo" | ||||
|     ), | ||||
|     failed_table_file_name: str = Argument( | ||||
|     failed_table_filename: str = Argument( | ||||
|         "failed-table.md", help="name of failed table file in the gitea repo" | ||||
|     ), | ||||
|     exercise_name: str = Argument( | ||||
|  | @ -597,12 +597,12 @@ def joj3_all( | |||
|                 joj3.generate_scoreboard( | ||||
|                     score_file_path, | ||||
|                     submitter, | ||||
|                     os.path.join(repo_path, scoreboard_file_name), | ||||
|                     os.path.join(repo_path, scoreboard_filename), | ||||
|                     exercise_name, | ||||
|                 ) | ||||
|                 tea.pot.git.add_commit( | ||||
|                     repo_name, | ||||
|                     [scoreboard_file_name], | ||||
|                     [scoreboard_filename], | ||||
|                     ( | ||||
|                         f"joj3: update scoreboard for {exercise_name} by @{submitter} in " | ||||
|                         f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|  | @ -616,12 +616,12 @@ def joj3_all( | |||
|                     score_file_path, | ||||
|                     submitter_repo_name, | ||||
|                     submitter_repo_url, | ||||
|                     os.path.join(repo_path, failed_table_file_name), | ||||
|                     os.path.join(repo_path, failed_table_filename), | ||||
|                     gitea_actions_url, | ||||
|                 ) | ||||
|                 tea.pot.git.add_commit( | ||||
|                     repo_name, | ||||
|                     [failed_table_file_name], | ||||
|                     [failed_table_filename], | ||||
|                     ( | ||||
|                         f"joj3: update failed table for {exercise_name} by @{submitter} in " | ||||
|                         f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|  | @ -649,14 +649,14 @@ def joj3_all( | |||
| ) | ||||
| def joj3_all_env( | ||||
|     env_path: str = Argument("", help="path to .env file"), | ||||
|     grading_repo_name: str = Argument( | ||||
|     grading_repo_name: str = Option( | ||||
|         "", | ||||
|         help="name of grading repo to push failed table file", | ||||
|     ), | ||||
|     scoreboard_file_name: str = Argument( | ||||
|     scoreboard_filename: str = Option( | ||||
|         "scoreboard.csv", help="name of scoreboard file in the gitea repo" | ||||
|     ), | ||||
|     failed_table_file_name: str = Argument( | ||||
|     failed_table_filename: str = Option( | ||||
|         "failed-table.md", help="name of failed table file in the gitea repo" | ||||
|     ), | ||||
|     max_total_score: int = Option( | ||||
|  | @ -801,12 +801,12 @@ def joj3_all_env( | |||
|                 joj3.generate_scoreboard( | ||||
|                     score_file_path, | ||||
|                     submitter, | ||||
|                     os.path.join(repo_path, scoreboard_file_name), | ||||
|                     os.path.join(repo_path, scoreboard_filename), | ||||
|                     exercise_name, | ||||
|                 ) | ||||
|                 tea.pot.git.add_commit( | ||||
|                     grading_repo_name, | ||||
|                     [scoreboard_file_name], | ||||
|                     [scoreboard_filename], | ||||
|                     ( | ||||
|                         f"joj3: update scoreboard for {exercise_name} by @{submitter} in " | ||||
|                         f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|  | @ -820,12 +820,12 @@ def joj3_all_env( | |||
|                     score_file_path, | ||||
|                     submitter_repo_name, | ||||
|                     submitter_repo_url, | ||||
|                     os.path.join(repo_path, failed_table_file_name), | ||||
|                     os.path.join(repo_path, failed_table_filename), | ||||
|                     gitea_actions_url, | ||||
|                 ) | ||||
|                 tea.pot.git.add_commit( | ||||
|                     grading_repo_name, | ||||
|                     [failed_table_file_name], | ||||
|                     [failed_table_filename], | ||||
|                     ( | ||||
|                         f"joj3: update failed table for {exercise_name} by @{submitter} in " | ||||
|                         f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|  | @ -862,7 +862,7 @@ def joj3_check( | |||
|         "", | ||||
|         help="repository's name of the submitter", | ||||
|     ), | ||||
|     scoreboard_file_name: str = Argument( | ||||
|     scoreboard_filename: str = Argument( | ||||
|         "scoreboard.csv", help="name of scoreboard file in the gitea repo" | ||||
|     ), | ||||
|     exercise_name: str = Argument( | ||||
|  | @ -895,7 +895,7 @@ def joj3_check( | |||
|         since = now - timedelta(hours=time_period) | ||||
|         since_git_format = since.strftime("%Y-%m-%dT%H:%M:%S") | ||||
|         submit_count = 0 | ||||
|         commits = repo.iter_commits(paths=scoreboard_file_name, since=since_git_format) | ||||
|         commits = repo.iter_commits(paths=scoreboard_filename, since=since_git_format) | ||||
|         for commit in commits: | ||||
|             msg = commit.message.strip() | ||||
|             lines = msg.splitlines() | ||||
|  | @ -945,15 +945,15 @@ def joj3_check( | |||
| ) | ||||
| def joj3_check_env( | ||||
|     env_path: str = Argument("", help="path to .env file"), | ||||
|     grading_repo_name: str = Argument( | ||||
|         "", | ||||
|     grading_repo_name: str = Option( | ||||
|         "grading", | ||||
|         help="name of grading repo to push scoreboard file", | ||||
|     ), | ||||
|     scoreboard_file_name: str = Argument( | ||||
|     scoreboard_filename: str = Option( | ||||
|         "scoreboard.csv", help="name of scoreboard file in the gitea repo" | ||||
|     ), | ||||
|     group_config: str = Option( | ||||
|         ..., | ||||
|         "=100:24", | ||||
|         help=( | ||||
|             "Configuration for groups in the format " | ||||
|             "'group_name=max_count:time_period(in hours)'. " | ||||
|  | @ -990,7 +990,7 @@ def joj3_check_env( | |||
|         since = now - timedelta(hours=time_period) | ||||
|         since_git_format = since.strftime("%Y-%m-%dT%H:%M:%S") | ||||
|         submit_count = 0 | ||||
|         commits = repo.iter_commits(paths=scoreboard_file_name, since=since_git_format) | ||||
|         commits = repo.iter_commits(paths=scoreboard_filename, since=since_git_format) | ||||
|         for commit in commits: | ||||
|             lines = commit.message.strip().splitlines() | ||||
|             pattern = ( | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user