def export(deck_id): d = ds.load_deck(deck_id) if d.is_in_current_run(): if not auth.person_id() or auth.person_id() != d.person_id: abort(403) safe_name = deck_name.file_name(d) return (mc.to_mtgo_format(str(d)), 200, {'Content-type': 'text/plain; charset=utf-8', 'Content-Disposition': 'attachment; filename={name}.txt'.format(name=safe_name)})
def cardhoarder_url(self) -> str: # This should be a Deck, but we can't import it from here. d = self.deck cs: Dict[str, int] = {} for entry in d.maindeck + d.sideboard: name = entry['card'].name cs[name] = cs.get(name, 0) + entry['n'] deck_s = '||'.join([str(v) + ' ' + card.to_mtgo_format(k).replace('"', '') for k, v in cs.items()]) return 'https://www.cardhoarder.com/decks/upload?deck={deck}'.format(deck=fetcher.internal.escape(deck_s))
def rotation_speculation_files(changes_type: str) -> Response: out = changes_type != 'new' changes = oracle.if_todays_prices(out=out) s = '\n'.join('4 {name}'.format(name=card.to_mtgo_format(c.name)) for c in changes) return make_response( s, 200, { 'Content-type': 'text/plain; charset=utf-8', 'Content-Disposition': f'attachment; filename={changes_type}.txt' })
def rotation_changes_files(changes_type: str) -> Response: changes = oracle.pd_rotation_changes( get_season_id())[0 if changes_type == 'new' else 1] s = '\n'.join('4 {name}'.format(name=card.to_mtgo_format(c.name)) for c in changes) return make_response( s, 200, { 'Content-type': 'text/plain; charset=utf-8', 'Content-Disposition': f'attachment; filename={changes_type}.txt' })
def cardhoarder_url(d): cs = {} for entry in d.maindeck + d.sideboard: name = entry['card'].name cs[name] = cs.get(name, 0) + entry['n'] deck_s = '||'.join([ str(v) + ' ' + mc.to_mtgo_format(k).replace('"', '') for k, v in cs.items() ]) return 'https://www.cardhoarder.com/decks/upload?deck={deck}'.format( deck=internal.escape(deck_s))