def main(): week = 4 date = utils.get_week(week) game_ids = data_generator.get_game_ids(verbose=static.verbose, date=date) player_dict = dict() for cnt, game_id in enumerate(game_ids): player_dict = { **player_dict, **data_generator.get_player_stats(game_id["id"], static.stat_list, verbose=False) } # player_set.union(data_generator.get_player_stats(game_id["id"], static.stat_list, verbose=static.verbose)) if static.verbose: print("set len after game {} is {}".format(cnt + 1, len(player_dict))) player_dict = { **player_dict, **data_generator.get_dst_stats(game_id['id'], static.dst_stat_list, verbose=False) } for player_name, player_obj in player_dict.items(): if isinstance(player_obj, dst.dst): player_obj.update_touchdowns(player_dict) with open(os.path.join(static.data_dir, "player_list.txt"), "w+") as f: for player in player_dict: f.write("{}\n".format(player)) g1 = game.Game(player_dict, 1, week, verbose=False) g2 = game.Game(player_dict, 2, week, verbose=False) g1.create_score() g2.create_score()
def release(self, week=None, quarter=None, year=None, dry_run=False): print('==> Duplicate Sheet') request_body = { # The ID of the spreadsheet to copy the sheet to. 'destination_spreadsheet_id': self.PLANNER_SPREADSHEET_ID } request = self.sheet_client.sheets().copyTo( spreadsheetId=self.PLANNER_SPREADSHEET_ID, sheetId=self.PLANNER_WORKSHEET_ID, body=request_body) new_sheet_id = None if not dry_run: response = request.execute() new_sheet_id = response['sheetId'] today = date.today() new_title = "Q{}W{}".format(get_quarter(today), get_week(today) + 1) print('==> Rename New Sheet') self.rename_worksheet(self.PLANNER_SPREADSHEET_ID, new_sheet_id, new_title, dry_run=dry_run)
def main(): tm = TrelloManager() sm = GoogleSheetManager() rm = ReleaseManager(trello_manager=tm, sheet_manager=sm) today = date.today() rm.release(week=get_week(today), quarter=get_quarter(today), year=get_year(today), dry_run=False, )
def get_courses(stu_num, week=0, offset=0): data['stuNum'] = stu_num data['week'] = week response = requests.post(url_course, data=data).json() now_week = get_week(response['nowWeek'], offset) courses = response['data'] courses = filter( lambda x: now_week in x['week'] and is_on_time(x['hash_day'], offset), courses) this_week_course = list( map( lambda x: Course(x['course'], x['teacher'], x['classroom'], x[ 'lesson']), courses)) return ''.join(i.get_course() for i in this_week_course)
def release(self, week=None, quarter=None, year=None, dry_run=False): new_archive = self._create_lists(week, quarter, year, dry_run) completed = self._get_list_by_name("Completed") self._move_all_cards(completed, new_archive, dry_run) self._position_list(new_archive, completed, dry_run) on_deck = self._get_list_by_name("On Deck") self._create_weekly_cards(on_deck, dry_run) icebox = self._get_list_by_name("Icebox") date_next_week = date.today() + datetime.timedelta(weeks=2) self._create_card_in_list(icebox, "{}Q{} W{} Goal Ideas".format( get_year(date_next_week), get_quarter(date_next_week), get_week(date_next_week)), checklist=True, dry_run=dry_run, checklist_name="Goal Ideas")
def show(args, timesheet): today = datetime.today() if args['today']: day = datetime.timetuple(today) today_response = timesheet.get_day(day[7], day[0]) data = [today_response['day_entries']] if args['yesterday']: yesterday = datetime.timetuple(today - timedelta(1)) yesterday_response = timesheet.get_day(yesterday[7], yesterday[0]) data = [yesterday_response['day_entries']] if args['week']: data = [] day = datetime.timetuple(today) for i in range(get_week(), day[7]+1): daily_response = timesheet.get_day(i, day[0]) data.append(daily_response['day_entries']) if args['--date']: date = datetime.timetuple(parse(args['<date>'])) date_response = timesheet.get_day(date[7], date[0]) data = [date_response['day_entries']] if data: for sublist in data: for entry in sublist: print str.format( STATUS_TASK_FORMAT, task = entry['task'], client = entry['client'], note = entry['notes'], hours = entry['hours'], date = entry['spent_at'], indicator = '=' ) else: print "No data found."
def show(args, timesheet): today = datetime.today() if args['today']: day = datetime.timetuple(today) today_response = timesheet.get_day(day[7], day[0]) data = [today_response['day_entries']] if args['yesterday']: yesterday = datetime.timetuple(today - timedelta(1)) yesterday_response = timesheet.get_day(yesterday[7], yesterday[0]) data = [yesterday_response['day_entries']] if args['week']: data = [] day = datetime.timetuple(today) for i in range(get_week(), day[7] + 1): daily_response = timesheet.get_day(i, day[0]) data.append(daily_response['day_entries']) if args['--date']: date = datetime.timetuple(parse(args['<date>'])) date_response = timesheet.get_day(date[7], date[0]) data = [date_response['day_entries']] if data: for sublist in data: for entry in sublist: print str.format(STATUS_TASK_FORMAT, task=entry['task'], client=entry['client'], note=entry['notes'], hours=entry['hours'], date=entry['spent_at'], indicator='=') else: print "No data found."
#! /usr/bin/env python # -*- coding: utf-8 -*- import utils # 活动列表时间类型 TIME_TYPE_TODAY = '1' TIME_TYPE_TOMORROW = '2' TIME_TYPE_WEEKS = '3' TIME_TYPE_MONTH = '4' # 时间类型映射 LIMIT_TIME = { TIME_TYPE_TODAY: utils.get_today(), TIME_TYPE_TOMORROW: utils.get_tomorrow(), TIME_TYPE_WEEKS: utils.get_week(), TIME_TYPE_MONTH: utils.get_month() }
def get_content_table_name(content_id: str): if not check_content_id(content_id): return "" # 得到秒数 year, week_num, _ = utils.get_week(content_id[:-9].split("_")[-1]) return "content_table_{}_{}".format(year, week_num)