try: clubs[clubnumber].charterdate = charterdate.strftime('%m/%d/%y') except KeyError: print('Club %s (%d) not in performance reports, ignored.' % (clubname, clubnumber)) # Test alignment processing if parms.testalignment: # If any clubs get created by overrideClubs, they are of the standard # simpleclub.Club type. We need to create objects of the local Club # type instead, but keep the values. from simpleclub import Club as sClub sClub.getClubsOn(curs) # Ensure everything is defined from tmutil import overrideClubs oldkeys = set(clubs.keys()) clubs = overrideClubs(clubs, parms.testalignment) for c in list(clubs.keys()): if c not in oldkeys: nclub = clubs[c] # We must replace this with a club of the local type clubs[c] = Club(nclub.clubnumber, nclub.clubname, nclub.area, nclub.division, nclub.district, nclub.suspenddate) # And now, finish setting up the structure (creating Areas and Divisions, for example) for club in list(clubs.values()): club.finishSettingUp() # Now, get information from the Area/Division performance table. We only need the latest one. # Now we need the information from the latest Area/Division report for each club: curs.execute(
parms = tmparms.tmparms(description=__doc__) parms.add_argument('--outfile', dest='outfile', default='areasanddivisions.html') parms.add_argument('--newAlignment', dest='newAlignment', default=None, help='Overrides area/division data from the CLUBS table.') parms.add_argument('--officers', dest='officers', help='URL of the CSV export form of a Google Spreadsheet with Area/Division Directors') parms.parse() # Connect to the database conn = dbconn.dbconn(parms.dbhost, parms.dbuser, parms.dbpass, parms.dbname) curs = conn.cursor() # Get all clubs clubs = Club.getClubsOn(curs) if parms.newAlignment: overrideClubs(clubs, parms.newAlignment) # Remove suspended clubs clubs = removeSuspendedClubs(clubs, curs) # Now, assign clubs to Areas and Divisions for c in sorted(clubs): club = clubs[c] Area.find(club.division, club.area).addclub(club)
'--mapoverride', dest='mapoverride', default=None, help='Google spreadsheet with overriding address and coordinate information' ) # Do global setup globals.setup(parms) conn = globals.conn curs = globals.curs # Get all clubs clubs = Club.getClubsOn(curs) if parms.newAlignment: overrideClubs(clubs, parms.newAlignment, exclusive=False) # Remove suspended clubs clubs = removeSuspendedClubs(clubs, curs) # Remove clubs from outside our District for c in list(clubs.keys()): try: if int(clubs[c].district) != parms.district: del clubs[c] except ValueError: print((clubs[c])) # Add current coordinates and remove clubs without coordinates (unless there's a new alignment) setClubCoordinatesFromGEO(clubs, curs, removeNotInGeo=not parms.newAlignment)
parms.date = cleandate(parms.date) # Promote information from parms.makemap if not already specified parms.mapoverride = parms.mapoverride if parms.mapoverride else parms.makemap.get('mapoverride',None) # Get the club information for the specified date clubs = Club.getClubsOn(curs, parms.date) # And remove suspended clubs. clubs = removeSuspendedClubs(clubs, curs) # And override it if needed. if parms.newAlignment: overrideClubs(clubs, parms.newAlignment, exclusive=False) # If there are overrides to club positioning, handle them now if parms.mapoverride: overrideClubPositions(clubs, parms.mapoverride, parms.googlemapsapikey) cities = {} for c in clubs: club = clubs[c] club.city = club.city.title() if club.city not in cities: cities[club.city] = [] cities[club.city].append(club)