parms = tmparms.tmparms() parms.add_argument('--outfile', default='${workdir}/districtcredit.html') parms.add_argument( '--creditfile', default= 'https://docs.google.com/spreadsheets/d/1p0IEPYW4BWL2BKXSwo6cQBie2hfYjXUsMiVDFC5alSQ/' ) parms.add_argument('--sheetname', default='D101_RecognitionCredits') # Do global setup myglobals.setup(parms) curs = myglobals.curs conn = myglobals.conn # Get the spreadsheet gc = gspread.authorize(getGoogleCredentials()) book = gc.open_by_url(parms.creditfile) sheet = book.worksheet(parms.sheetname) outfile = open(parms.outfile, 'w') ### We are dependent on the format of the spreadsheet # Last updated value is in 'B1' - let's convert it to English text asof = sheet.acell('B1', value_render_option='UNFORMATTED_VALUE').value asof = datetime(1899, 12, 30) + timedelta(days=asof) asof = asof.strftime("%B %-d, %Y") # Bring in the dataTables resources outfile.write(""" <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
# Establish parameters parms = tmparms.tmparms() parms.add_argument( '--featured', default= 'https://docs.google.com/spreadsheets/d/19-imepV9YNq5N_g9GcBP5Ynq9BjTZP7kC_rLPnFAK7w/' ) parms.add_argument('--outfile', default='${workdir}/featuredclubs.shtml') # Add other parameters here # Do global setup myglobals.setup(parms) allclubs = Club.getClubsOn(myglobals.curs) # Open the spreadsheet gc = gspread.authorize(tmutil.getGoogleCredentials()) book = gc.open_by_url(parms.featured) # Get totals sheet = book.sheet1 clubs = [] for row in sheet.get_all_records(): if (not row['Club Name'].strip()): break clubs.append(FeaturedClub(row)) # Sort by points, then name: clubs.sort(key=lambda c: c.clubname.lower())
if __name__ == "__main__": import tmparms # Establish parameters parms = tmparms.tmparms() parms.add_argument('--featured', default='https://docs.google.com/spreadsheets/d/19-imepV9YNq5N_g9GcBP5Ynq9BjTZP7kC_rLPnFAK7w/') parms.add_argument('--outfile', default='featuredclubs.shtml') # Add other parameters here # Do global setup globals.setup(parms) allclubs = Club.getClubsOn(globals.curs) # Open the spreadsheet gc = gspread.authorize(tmutil.getGoogleCredentials()) book = gc.open_by_url(parms.featured) # Get totals sheet = book.sheet1 clubs = [] for row in sheet.get_all_records(): if (not row['Club Name'].strip()): break clubs.append(FeaturedClub(row)) # Sort by points, then name: clubs.sort(key=lambda c:c.clubname.lower())