def api_quick_age(convert, year) : mysql = MySQL.MySQL() if convert == "age" : # 年齢から誕生年 rows = mysql.query("SELECT year, gengo FROM QuickAge WHERE age = {0}".format(year)) if len(rows) == 0 : result = "エラー: 年齢が不正" else : row = rows[0] result = str(row[0]) + "," + row[1] elif convert == "born" : # 誕生年から年齢 if Text.isdigit(year) : # age は西暦 rows = mysql.query("SELECT age FROM QuickAge WHERE year={0}".format(year)) if len(rows) == 0 : result = "エラー: 西暦が不正" else : result = rows[0] else : # year は和暦 if year.startswith('T') : year = "大正" + Text.substring(year, 1) + "年"; elif year.startswith('S') : if Text.substring(year, 1) == '1' : year = "昭和元年"; else : year = "昭和" + Text.substring(year, 1) + "年"; elif year.startswith('H') : if Text.substring(year, 1) == '1' : year = "平成元年"; else : year = "平成" + Text.substring(year, 1) + "年"; elif year.startswith('R') : if Text.substring(year, 1) == '1' : year = "令和元年" else : year = "令和" + Text.substring(year, 1) + "年"; else : result = "エラー: 和暦文字が不正" return result print(year) rows = mysql.query("SELECT age FROM QuickAge WHERE gengo='{0}'".format(year)) if len(rows) == 0 : result = "エラー: 和暦が不正" else : result = rows[0] else : # エラー result = "エラー: 不正な変換" return result
def getMenuItems(): menuitems = "" menuflag = False menufirst = True rows = fs.readCsv(MENU, False) for row in rows: if Text.isdigit(row[0]): # サブタイトル if row[0] != "1": menuitems += "\n</ul>" menuitems += "\n<h2>" + row[0] + ". " + row[1] + "</h2>\n<ul>\n" else: # メニュー項目 url = row[0] text = row[1] link = f'<a href="{url}">' + text + "</a>" menuitems += "<li>" + link + "</li>\n" menuitems += "</ul>\n" return menuitems