from datetime import datetime from icalendar import Calendar, Event, LocalTimezone from myExcelerator import * from CourseIcal import master_course_schedule_factory from csvtool import gslCsv tzinfo = LocalTimezone() rex1 = re.compile('.*(([0-9]{2}):([0-9]{2}).*'.decode('utf8')) ws = WrappedWorkbook(sys.argv[1]) ws.dump_csv( gp.csv.src('faculty_meetings_raw.csv') ,sheetoffset=0, sheets=12, rowoffset=3) base_year = int(re.sub('^([0-9]*).*','\\1',ws.data[0][1][(0,0)])) cal = master_course_schedule_factory('Faculty meetings') count = 1 oldday = 1 fh = open( gp.csv.src('faculty_meetings_raw.csv') ) c = gslCsv( fh, offset=0 ) for entry in c: #print sheet.encode('utf8') month = int(re.sub('^([0-9]*).*','\\1',entry['sheetname'])) year = base_year if month < 4: year = base_year + 1 if entry['法学研究科'].count('教授会'.decode('utf8')):
translation = tx[pos].strip() translations[key] = translation cal = Calendar() cal.add('prodid', '-//Faculty calendar//gsl-nagoya-u.net//') cal.add('version', '2.0') count = 1 data = ws.get_sheet(sheet_names[0],keyrow=None) #print sheet.encode('utf8') year = int(re.sub('^([0-9]*).*','\\1',data[(0,0)])) cal = master_course_schedule_factory('Postgraduate calendar',dates=False) #if month < 4: # year = year + 1 for d in data.keys(): print '%d:%d %s' % (d[0],d[1],data[d]) if d[1] == 2: s = data[d].strip() r = re.match('(?:([0-9]*)月([0-9]*)日)((?:月|火|水|木|金))(?:[・~](?:([0-9]+)月)*([0-9]+)日)*(?:.*)'.decode('utf8'),s) if r: key = data[(d[0],1)] title = translations[key] if title.startswith('*'): fulltitle = title title = title[title.find('*',1):]
ifh = open( gp.pickle.src('binran_translations.txt'), 'r') tx = ifh.read() ifh.close() translations = {} tx = re.split("\n",tx) for pos in range(len(tx)-1,-1,-1): if tx[pos].startswith(' '): key = tx[pos-1].decode('utf8') translation = tx[pos].strip() translations[key] = translation ws = WrappedWorkbook(sys.argv[1]) ws.dump_csv( gp.csv.src('events_raw.csv') ,rowoffset=1) cal = master_course_schedule_factory('Events') fh = open( gp.csv.src('events_raw.csv') ) c = gslCsv( fh, offset=0 ) for entry in c: if translations.has_key(entry['行事の種類'].decode('utf8')): e_type = translations[entry['行事の種類'].decode('utf8')] else: e_type = entry['行事の種類'] # Get the time set, if any ## Normalize if rex5.match(entry['時間']): entry['時間'] = '%0.2f' % (24 * float(entry['時間']),) entry['時間'] = str(entry['時間']).replace('.',':') ## Try for 4 numbers, then try for 2