def __init__(self) -> None: super().__init__() self.playability = card.playability() until_full_rotation = rotation.next_rotation() - dtutil.now() until_supplemental_rotation = rotation.next_supplemental( ) - dtutil.now() in_rotation = False if until_full_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Full rotation is in progress, ends ' + dtutil.display_date( rotation.next_rotation(), 2) elif until_supplemental_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Supplemental rotation is in progress, ends ' + dtutil.display_date( rotation.next_supplemental(), 2) elif until_full_rotation < until_supplemental_rotation: self.rotation_msg = 'Full rotation is ' + dtutil.display_date( rotation.next_rotation(), 2) else: self.rotation_msg = 'Supplemental rotation is ' + dtutil.display_date( rotation.next_supplemental(), 2) self.cards: List[Card] = [] if in_rotation: self.read_rotation_files() self.show_interesting = True
def __init__(self, interestingness: Optional[str] = None, rotation_query: Optional[str] = None, only_these: Optional[List[str]] = None) -> None: super().__init__() self.playability = card.playability() until_full_rotation = rotation.next_rotation() - dtutil.now() until_supplemental_rotation = rotation.next_supplemental() - dtutil.now() in_rotation = configuration.get_bool('always_show_rotation') if until_full_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Full rotation is in progress, ends ' + dtutil.display_date(rotation.next_rotation(), 2) elif until_supplemental_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Supplemental rotation is in progress, ends ' + dtutil.display_date(rotation.next_supplemental(), 2) elif until_full_rotation < until_supplemental_rotation: self.rotation_msg = 'Full rotation is ' + dtutil.display_date(rotation.next_rotation(), 2) else: self.rotation_msg = 'Supplemental rotation is ' + dtutil.display_date(rotation.next_supplemental(), 2) self.cards: List[Card] = [] if in_rotation: self.read_rotation_files() self.show_interesting = True if interestingness: self.cards = [c for c in self.cards if c.get('interestingness') == interestingness] if only_these: self.cards = [c for c in self.cards if c.name in only_these] self.num_cards = len(self.cards) self.rotation_query = rotation_query or ''
def __init__(self): until_full_rotation = rotation.next_rotation() - dtutil.now() until_supplemental_rotation = rotation.next_supplemental() - dtutil.now() in_rotation = False if until_full_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Full rotation is in progress, ends ' + dtutil.display_date(rotation.next_rotation(), 2) elif until_supplemental_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Supplemental rotation is in progress, ends ' + dtutil.display_date(rotation.next_supplemental(), 2) elif until_full_rotation < until_supplemental_rotation: self.rotation_msg = 'Full rotation is ' + dtutil.display_date(rotation.next_rotation(), 2) else: self.rotation_msg = 'Supplemental rotation is ' + dtutil.display_date(rotation.next_supplemental(), 2) if in_rotation: self.read_rotation_files() self.show_interesting = True
def build_menu() -> List[Dict[str, Union[str, Dict[str, str]]]]: archetypes_badge = None archetypes_badge = {'url': url_for('edit_archetypes'), 'text': '', 'badge_class': 'edit_archetypes'} resources_submenu: List[Dict[str, str]] = [] if (rotation.next_rotation() - dtutil.now()) < datetime.timedelta(7) or (rotation.next_supplemental() - dtutil.now()) < datetime.timedelta(7): resources_submenu += [{'name': gettext('Rotation Tracking'), 'url': url_for('rotation')}] resources_submenu += [ {'name': gettext('Rotation Changes'), 'url': url_for('rotation_changes')}, {'name': gettext('Rotation Speculation'), 'url': url_for('rotation_speculation')}, {'name': gettext('Deck Check'), 'url': url_for('deck_check')}, {'name': gettext('Discord Chat'), 'url': 'https://discord.gg/H6EHdHu'}, {'name': gettext('External Links'), 'url': url_for('resources')}, {'name': gettext('Link Accounts'), 'url': url_for('link')}, {'name': gettext('Bugs'), 'url': url_for('bugs')} ] menu = [ {'name': gettext('Metagame'), 'url': url_for('home'), 'badge': archetypes_badge, 'submenu': [ {'name': gettext('Latest Decks'), 'url': url_for('.decks')}, {'name': gettext('Archetypes'), 'url': url_for('archetypes'), 'badge': archetypes_badge}, {'name': gettext('People'), 'url': url_for('people')}, {'name': gettext('Cards'), 'url': url_for('cards')}, {'name': gettext('Past Seasons'), 'url': url_for('seasons')}, {'name': gettext('Matchups'), 'url': url_for('matchups')}, ]}, {'name': gettext('League'), 'url': url_for('league'), 'submenu': [ {'name': gettext('League Info'), 'url': url_for('league')}, {'name': gettext('Sign Up'), 'url': url_for('signup')}, {'name': gettext('Report'), 'url': url_for('report')}, {'name': gettext('Records'), 'url': url_for('current_league')}, {'name': gettext('Retire'), 'url': url_for('retire')}, ]}, {'name': gettext('Competitions'), 'url': url_for('competitions'), 'submenu': [ {'name': gettext('Competition Results'), 'url': url_for('competitions')}, {'name': gettext('Tournament Info'), 'url': url_for('tournaments')}, {'name': gettext('Leaderboards'), 'url': url_for('tournament_leaderboards')}, {'name': gettext('Gatherling'), 'url': 'https://gatherling.one/'}, {'name': gettext('Achievements'), 'url': url_for('achievements')}, {'name': gettext('Hosting'), 'url': url_for('hosting')} ]}, {'name': gettext('Resources'), 'url': url_for('resources'), 'submenu': resources_submenu}, {'name': gettext('About'), 'url': url_for('about'), 'submenu': [ {'name': gettext('What is Penny Dreadful?'), 'url': url_for('about')}, {'name': gettext('About pennydreadfulmagic.com'), 'url': url_for('about_pdm')}, {'name': gettext('FAQs'), 'url': url_for('faqs')}, {'name': gettext('Community Guidelines'), 'url': url_for('community_guidelines')} ]}, {'name': gettext('Admin'), 'admin_only': True, 'url': url_for('admin_home'), 'submenu': admin.admin_menu()} ] for item in menu: item['has_submenu'] = item.get('submenu') is not None item['is_external'] = item.get('url', '').startswith('http') and '://pennydreadfulmagic.com/' not in item['url'] for subitem in item.get('submenu', []): subitem['is_external'] = subitem.get('url', '').startswith('http') and '://pennydreadfulmagic.com/' not in subitem['url'] return menu
def build_menu() -> List[Dict[str, Union[str, Dict[str, str]]]]: current_template = (request.endpoint or '').replace('seasons.', '') archetypes_badge = {'endpoint': 'edit_archetypes', 'text': '', 'badge_class': 'edit_archetypes'} resources_submenu: List[Dict[str, str]] = [] if (rotation.next_rotation() - dtutil.now()) < datetime.timedelta(7) or (rotation.next_supplemental() - dtutil.now()) < datetime.timedelta(7): resources_submenu += [{'name': gettext('Rotation Tracking'), 'endpoint': 'rotation'}] resources_submenu += [ {'name': gettext('Rotation Changes'), 'endpoint': 'rotation_changes'}, {'name': gettext('Rotation Speculation'), 'endpoint': 'rotation_speculation'}, {'name': gettext('Deck Check'), 'endpoint': 'deck_check'}, {'name': gettext('Discord Chat'), 'url': 'https://discord.gg/H6EHdHu'}, {'name': gettext('External Links'), 'endpoint': 'resources'}, {'name': gettext('Link Accounts'), 'endpoint': 'link'}, {'name': gettext('Bugs'), 'endpoint': 'bugs'} ] menu = [ {'name': gettext('Metagame'), 'endpoint': 'home', 'badge': archetypes_badge, 'submenu': [ {'name': gettext('Decks'), 'endpoint': '.decks'}, {'name': gettext('Archetypes'), 'endpoint': 'archetypes', 'badge': archetypes_badge}, {'name': gettext('People'), 'endpoint': 'people'}, {'name': gettext('Cards'), 'endpoint': 'cards'}, {'name': gettext('Past Seasons'), 'endpoint': 'seasons'}, {'name': gettext('Matchups'), 'endpoint': 'matchups'}, ]}, {'name': gettext('League'), 'endpoint': 'league', 'submenu': [ {'name': gettext('League Info'), 'endpoint': 'league'}, {'name': gettext('Sign Up'), 'endpoint': 'signup'}, {'name': gettext('Report'), 'endpoint': 'report'}, {'name': gettext('Records'), 'endpoint': 'current_league'}, {'name': gettext('Retire'), 'endpoint': 'retire'}, ]}, {'name': gettext('Competitions'), 'endpoint': 'competitions', 'submenu': [ {'name': gettext('Competition Results'), 'endpoint': 'competitions'}, {'name': gettext('Tournament Info'), 'endpoint': 'tournaments'}, {'name': gettext('Leaderboards'), 'endpoint': 'tournament_leaderboards'}, {'name': gettext('Gatherling'), 'url': 'https://gatherling.com/'}, {'name': gettext('Achievements'), 'endpoint': 'achievements'}, {'name': gettext('Hosting'), 'endpoint': 'hosting'} ]}, {'name': gettext('Resources'), 'endpoint': 'resources', 'submenu': resources_submenu}, {'name': gettext('About'), 'endpoint': 'about', 'submenu': [ {'name': gettext('What is Penny Dreadful?'), 'endpoint': 'about'}, {'name': gettext('About pennydreadfulmagic.com'), 'endpoint': 'about_pdm'}, {'name': gettext('FAQs'), 'endpoint': 'faqs'}, {'name': gettext('Community Guidelines'), 'endpoint': 'community_guidelines'} ]}, {'name': gettext('Admin'), 'admin_only': True, 'endpoint': 'admin_home', 'submenu': admin.admin_menu()} ] setup_links(menu) for item in menu: item['current'] = item.get('endpoint', '').replace('seasons', '').replace('.', '') == current_template or current_template in [entry.get('endpoint', '') for entry in item.get('submenu', [])] item['has_submenu'] = item.get('submenu') is not None return menu
def __init__(self, interestingness: Optional[str] = None, query: Optional[str] = '') -> None: super().__init__() until_full_rotation = rotation.next_rotation() - dtutil.now() until_supplemental_rotation = rotation.next_supplemental() - dtutil.now() in_rotation = configuration.get_bool('always_show_rotation') if until_full_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Full rotation is in progress, ends ' + dtutil.display_date(rotation.next_rotation(), 2) elif until_supplemental_rotation < datetime.timedelta(7): in_rotation = True self.rotation_msg = 'Supplemental rotation is in progress, ends ' + dtutil.display_date(rotation.next_supplemental(), 2) elif until_full_rotation < until_supplemental_rotation: self.rotation_msg = 'Full rotation is ' + dtutil.display_date(rotation.next_rotation(), 2) else: self.rotation_msg = 'Supplemental rotation is ' + dtutil.display_date(rotation.next_supplemental(), 2) if in_rotation: self.in_rotation = in_rotation self.show_interestingness_filter = True self.runs, self.runs_percent, self.cards = rotation.read_rotation_files() # Now add interestingness to the cards, which only decksite knows not magic.rotation. playability = card.playability() c: Card for c in self.cards: c.interestingness = rotation.interesting(playability, c) else: self.cards = [] self.show_interesting = True if interestingness: self.cards = [c for c in self.cards if c.get('interestingness') == interestingness] self.num_cards = len(self.cards) self.query = query for c in self.cards: if c.status != 'Undecided': continue c.hits = redact(c.hits) c.hits_needed = redact(c.hits_needed) c.percent = redact(c.percent) c.percent_needed = redact(c.percent_needed) self.show_filters_toggle = True
def menu(self): archetypes_badge = None n = len(deck.load_decks('NOT d.reviewed')) if n > 0: archetypes_badge = {'url': url_for('edit_archetypes'), 'text': n} resources_submenu = [] if (rotation.next_rotation() - dtutil.now()) < datetime.timedelta( 7) or (rotation.next_supplemental() - dtutil.now()) < datetime.timedelta(7): resources_submenu += [{ 'name': gettext('Rotation Tracking'), 'url': url_for('rotation') }] resources_submenu += [{ 'name': gettext('Rotation Changes'), 'url': url_for('rotation_changes') }, { 'name': gettext('Rotation Speculation'), 'url': url_for('rotation_speculation') }, { 'name': gettext('Discord Chat'), 'url': 'https://discord.gg/H6EHdHu' }, { 'name': gettext('External Links'), 'url': url_for('resources') }, { 'name': gettext('Log In'), 'url': url_for('authenticate', target=request.url) }, { 'name': gettext('Log Out'), 'url': url_for('logout') }] menu = [{ 'name': gettext('Metagame'), 'url': url_for('home'), 'badge': archetypes_badge, 'submenu': [{ 'name': gettext('Latest Decks'), 'url': url_for('decks') }, { 'name': gettext('Archetypes'), 'url': url_for('archetypes'), 'badge': archetypes_badge }, { 'name': gettext('People'), 'url': url_for('people') }, { 'name': gettext('Cards'), 'url': url_for('cards') }, { 'name': gettext('Past Seasons'), 'url': url_for('seasons') }] }, { 'name': gettext('League'), 'url': url_for('league'), 'submenu': [ { 'name': gettext('League Info'), 'url': url_for('league') }, { 'name': gettext('Sign Up'), 'url': url_for('signup') }, { 'name': gettext('Report'), 'url': url_for('report') }, { 'name': gettext('Records'), 'url': url_for('current_league') }, { 'name': gettext('Retire'), 'url': url_for('retire') }, ] }, { 'name': gettext('Competitions'), 'url': url_for('competitions'), 'submenu': [{ 'name': gettext('Competition Results'), 'url': url_for('competitions') }, { 'name': gettext('Tournament Info'), 'url': url_for('tournaments') }, { 'name': gettext('Leaderboards'), 'url': url_for('tournament_leaderboards') }, { 'name': gettext('Gatherling'), 'url': 'https://gatherling.com/' }, { 'name': gettext('Hosting'), 'url': url_for('hosting') }] }, { 'name': gettext('Resources'), 'url': url_for('resources'), 'submenu': resources_submenu }, { 'name': gettext('About'), 'url': url_for('about'), 'submenu': [{ 'name': gettext('What is Penny Dreadful?'), 'url': url_for('about') }, { 'name': gettext('About pennydreadfulmagic.com'), 'url': url_for('about_pdm') }, { 'name': gettext('FAQs'), 'url': url_for('faqs') }, { 'name': gettext('Community Guidelines'), 'url': url_for('community_guidelines') }] }, { 'name': gettext('Admin'), 'admin_only': True, 'url': url_for('admin'), 'submenu': admin.menu() }] for item in menu: item['has_submenu'] = item.get('submenu') is not None item['is_external'] = item.get('url', '').startswith( 'http') and '://pennydreadfulmagic.com/' not in item['url'] for subitem in item.get('submenu', []): subitem['is_external'] = subitem.get('url', '').startswith( 'http' ) and '://pennydreadfulmagic.com/' not in subitem['url'] return menu
import os from collections import Counter from typing import Dict, List, Set import ftfy from magic import fetcher, rotation from price_grabber.parser import (PriceListType, parse_cardhoarder_prices, parse_mtgotraders_prices) from shared import configuration, dtutil, fetch_tools, text BLACKLIST: Set[str] = set() WHITELIST: Set[str] = set() TIME_UNTIL_FULL_ROTATION = rotation.next_rotation() - dtutil.now() TIME_UNTIL_SUPPLEMENTAL_ROTATION = rotation.next_supplemental() - dtutil.now() TIME_SINCE_SUPPLEMENTAL_ROTATION = dtutil.now() - rotation.this_supplemental() def run() -> None: files = rotation.files() n = len(files) time_until = min( TIME_UNTIL_FULL_ROTATION, TIME_UNTIL_SUPPLEMENTAL_ROTATION) - datetime.timedelta(weeks=1) if n >= rotation.TOTAL_RUNS: print( 'It is the moment of discovery, the triumph of the mind, and the end of this rotation.' ) return