Spaces:
Running
Running
File size: 3,384 Bytes
5e16fc6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """One-time developer utility for the two supplied Excel sources (read only)."""
from datetime import datetime, timedelta
from pathlib import Path
from zipfile import ZipFile
import xml.etree.ElementTree as ET
import json
import re
import shutil
ROOT=Path(__file__).resolve().parent
NS={'s':'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
names=['Kishan H M','Harshitha P','Gokul M','Manish J','Madhan D','Honey S P','Madhav S',
'Shravan','Kamlakant','Vinay','Sunny','Rikki','Niranjan','Pavan Sai']
aliases={name.split()[0].lower():name for name in names}
def owner(value):
return aliases[value.strip().split()[0].lower()]
def prepare(source_directory):
reports=[]
(ROOT/'sources').mkdir(exist_ok=True)
for path in Path(source_directory).glob('MOM_Technical Report on *.xlsx'):
with ZipFile(path) as z:
strings=[''.join(n.itertext()) for n in ET.fromstring(z.read('xl/sharedStrings.xml')).findall('s:si',NS)]
cells={}
for cell in ET.fromstring(z.read('xl/worksheets/sheet1.xml')).findall('.//s:sheetData/s:row/s:c',NS):
v=cell.find('s:v',NS)
if v is not None and v.text:
cells[cell.attrib['r']]=strings[int(v.text)] if cell.attrib.get('t')=='s' else v.text
meeting_date=datetime.strptime(re.search(r'(\d{2}-\d{2}-\d{4})',path.name)[1],'%d-%m-%Y').date().isoformat()
# User clarified that the newer file was reused for Monday 21 September.
if path.name=='MOM_Technical Report on 15-09-2026.xlsx':
meeting_date='2026-09-21'
report=dict(file=path.name,date=meeting_date,title=cells.get('C9','Weekly Technical Meeting'),
location=cells.get('C5',''),presenter=cells.get('C6',''),minutes_by=cells.get('C10',''),
participants=cells.get('C7',''),updates=[],actions=[])
current=None
action_section=False
for row in range(12,max(int(re.search(r'\d+',key)[0]) for key in cells)+1):
a,b,c,d=[cells.get(f'{col}{row}','').strip() for col in 'ABCD']
match=re.match(r'Updates from\s+(.+)',a,re.I)
if match:
current=owner(match[1])
action_section=False
elif b.lower()=='actions':
action_section=True
current=None
elif action_section and b and d and a.isdigit():
due=(datetime(1899,12,30)+timedelta(days=float(c))).date().isoformat() if re.fullmatch(r'\d+(\.\d+)?',c) else None
report['actions'].append(dict(owner=owner(d),body=b,due_date=due,due_note='' if due else c))
elif current and b and a.isdigit():
report['updates'].append(dict(owner=current,body=b))
reports.append(report)
shutil.copy2(path,ROOT/'sources'/path.name)
reports.sort(key=lambda r:r['date'])
data=dict(users=[dict(name=n,username=n.split()[0].lower()) for n in names],reports=reports)
(ROOT/'seed_data.json').write_text(json.dumps(data,ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps({'users':len(names),'reports':[{k:r[k] for k in ['file','date','participants']} | {'updates':len(r['updates']),'actions':len(r['actions'])} for r in reports]},indent=2))
if __name__=='__main__':
import sys
prepare(sys.argv[1] if len(sys.argv)>1 else ROOT.parent)
|