def create_file(filepath: str, info: ArticleInfo) -> None: # テンプレートファイルのパスを指定 file_loader = FileSystemLoader(config.TEMPLATE_ROOT_PATH) env = Environment(loader=file_loader) tex_template = env.get_template(config.DOCUMENT_PARTS_TEX_TEMPLATE) if is_subsection_path(filepath): section: str = get_section_from_subsection_path(filepath) subsection_filepath: str = path.join(config.SRC_ROOT_PATH, filepath) # ファイルがあれば何もしない if path.exists(subsection_filepath): print(msg.ERROR_FILE_EXIST(subsection_filepath)) return positions: list = get_positions(section) # ファイル生成 with open(subsection_filepath, mode='w') as f: f.write( tex_template.render(title=info.get_title(), positions=positions, assignee=info.get_assignee(), is_newfile=True)) print(msg.CREATED_FILE_MSG(subsection_filepath)) elif is_kaisei_tex(filepath) or is_hajimeni_tex(filepath): # 回生別 または はじめに の場合 subsection_filepath: str = path.join(config.SRC_ROOT_PATH, filepath) type_name: str = None if is_hajimeni_tex(filepath) else 'kaisei' print(msg.WORNING_FILE_CHANGE(subsection_filepath)) positions: list = get_positions(type_name) # ファイルを上書き with open(subsection_filepath, mode='a') as f: f.write( tex_template.render(title=info.get_title(), positions=positions, assignee=info.get_assignee(), is_newfile=False)) print(msg.OVERWRITTEN_FILE_MSG(subsection_filepath)) else: print(msg.ERROR_UNSUPPORTED_FILE_PATH) return
def create_issue(filepath: str, info: ArticleInfo, project_id: int, private_token: str,\ created_issue_titles: list) -> None: assignee: Assignee = info.get_assignee() if assignee.get_gitlab_id() is None: print(msg.ERROR_MISSING_GITLAB_ID(filepath)) return # 情報をセットする title: str = filepath + ':' + info.get_title() description: str = '担当者は、' + assignee.get_family() + ' ' + assignee.get_name() + 'さんです。\n' +\ 'src/' + filepath + 'を編集してください。' assignee_id: str = assignee.get_gitlab_id() # 既にissueが作られていたらworningを出して終了 if is_issue_already_created(title, created_issue_titles): print(msg.WORNING_ISSUE_DUPLICATED(title)) return result_title: str = post_issue(project_id, private_token, title, description, assignee_id) print(msg.CREATED_ISSUE_MSG(result_title))