/ゴミ
Last active
December 9, 2015 15:00
生成すくりぷと
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
coreTime = "~~:~~ 〜 ~~:~~" | |
breakTime = "~~:~~ 〜 ~~:~~" | |
def generate(times,month,startDay,endDay,content, file): | |
print("generating...") | |
file.write(""" | |
\\documentclass[11pt,a4j]{jarticle} | |
\\usepackage{setspace} | |
\\usepackage[top=22truemm,bottom=0truemm,left=31truemm,right=26truemm]{geometry} | |
\\pagestyle{myheadings} | |
\\date{} | |
\\title{実施日時及び業務内容等(~~~~~"""+ month +"""月)} | |
\\setlength{\\tabcolsep}{2mm} | |
\\begin{document} | |
\\maketitle | |
\\vspace{-18mm} | |
{\\renewcommand\\arraystretch{2} | |
\\begin{tabular}{|c|c|c|c|c|c|} | |
\\hline | |
& & & | |
\\multicolumn{3}{|c|}{確認欄} \\\\ \\cline{4-6} | |
日付 & \\rule{10mm}{0mm} 業務内容 \\rule{1mm}{0mm} \\rule[-7mm]{10mm}{0mm} & \\rule{0mm}{17mm} \\shortstack{ 勤務時間\\\\\\\\(休憩時間)\\\\\\\\ \\small □30分単位で記入のこと } & | |
\\shortstack{業務者\\\\\\\\印} & \\shortstack{研究\\\\\\\\代表者\\\\\\\\印} & \\shortstack{研究代表者\\\\\\\\確認\\\\\\\\年月日} \\\\ \\hline | |
\n""") | |
count = 0 | |
for i in range(startDay,endDay+1): | |
file.write(""" | |
\\shortstack{~\\\\"""+ str(i) +"""\\\\~\\\\~\\\\~\\\\~\\\\~\\\\日\\\\~} \\rule[-5mm]{0mm}{20mm} & """+ content +""" & \\shortstack{"""+times[count][0]+""" \\\\~\\\\~\\\\( """ +times[count][1]+""")}& | |
~ & ~ & ~ \\\\ \\hline | |
""") | |
count += 1 | |
file.write(""" | |
\\end{tabular} | |
} | |
\\end{document} | |
""") | |
file.close() | |
def parseTime(s): | |
times = re.findall(r"[1-2]?[0-9]:[0-5][0-9]~[1-2]?[0-9]:[0-5]?[0-9]",s) | |
if times: | |
return times[0] | |
raise ValueError() | |
def getInterval(time): | |
times = re.findall(r"[0-5][0-9]",time) | |
if len(times) == 4: | |
hour = int(times[2]) - int(times[0]) | |
minutes = int(times[3]) - int(times[1]) | |
return hour, minutes | |
raise ValueError() | |
if __name__ == "__main__": | |
print("働いた月を入れてね -> ", end="") | |
month = input() | |
print("ファイルの名前を入れてね(拡張子は含めない'.tex') -> ", end="") | |
filename = input() | |
# **************************** # | |
# ファイルの使い方の例(非推奨) # | |
# **************************** # | |
print("働いた総時間を入れてね(120時間まで)-> ", end="") | |
time = int(input()) | |
print("何をしたの? -> ", end="") | |
content = input() | |
print("勤務時間を入れてね ex)'10:00~18:00' -> ", end="") | |
row_coretime = input() | |
coretime = parseTime(row_coretime) | |
print(coretime) | |
print("休憩時間を入れてね(勤務時間に含まれている事)-> ", end="") | |
row_breaktime = input() | |
breaktime = parseTime(row_breaktime) | |
print(breaktime) | |
core = getInterval(coretime) | |
bre = getInterval(breaktime) | |
workingInday = core[0]-bre[0] | |
if workingInday > 8: | |
print("働きすぎです") | |
raise ValueError() | |
streak = 0 | |
times = [] | |
print("総勤務時間:"+str(time)) | |
count = 0 | |
intervals = [(1,10),(11,20),(21,31)] | |
while time > 0: | |
if streak > 5: | |
times.append(("~~:~~ 〜 ~~:~~","~~:~~ 〜 ~~:~~")) | |
streak = 0 | |
times.append((coretime, breaktime)) | |
streak += 1 | |
time -= workingInday | |
if len(times) == 10: | |
generate(times,month,intervals[count][0],intervals[count][1],content, open(filename + "1.tex",'a')) | |
times = [] | |
count += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment