Skip to content

Commit

Permalink
Use some logging stuff instead of print
Browse files Browse the repository at this point in the history
I'll clean this up later by making shared.logger able to set log level.
  • Loading branch information
bakert committed Sep 14, 2024
1 parent a850890 commit 35e7d3d
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions untracked_bugs.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
import logging

from decksite.data import playability
from shared import fetch_tools

# A little script to run to try and marry up our (modo-bugs) bugs with their (Darybreak MTGO bug form) bugs
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
logger.addHandler(console_handler)


# A little script to run to try and marry up our (modo-bugs) bugs with their (Darybreak MTGO bug form) bugs

def main() -> None:
their_bugs = fetch_tools.fetch_json('https://raw.githubusercontent.com/PennyDreadfulMTG/modo-bugs/master/forums.json')
their_untracked_bugs = [bug for bug in their_bugs.values() if not bug['tracked'] and bug['status'] not in ['Fixed', 'Not A Bug', 'No Fix Planned', 'Could Not Reproduce']]
our_bugs = fetch_tools.fetch_json('https://raw.githubusercontent.com/PennyDreadfulMTG/modo-bugs/master/bugs.json')
our_untracked_bugs = [bug for bug in our_bugs if not bug['support_thread']]
print('= Possible missing linkage:\n')
logger.info('= Possible missing linkage:\n')
for our_bug in our_untracked_bugs:
for their_bug in their_untracked_bugs:
if our_bug['card'] in their_bug['title']:
print('Maybe\n', our_bug['description'], '\nis tracked by them as\n', their_bug['title'])
print(their_bug['url'])
print(our_bug['url'] + '\n')
print(f"= All of their bugs we aren't tracking ({len(their_untracked_bugs)}):\n")
logger.info('Maybe')
logger.info(our_bug['description'])
logger.info('is tracked by them as')
logger.info(their_bug['title'])
logger.info(their_bug['url'])
logger.info(our_bug['url'] + '\n')
logger.info(f"= All of their bugs we aren't tracking ({len(their_untracked_bugs)}):\n")
for their_bug in their_untracked_bugs:
print(f'[{their_bug["status"]}] {their_bug["title"]}\n{their_bug["url"]}\n')
print(f"= All of our bugs they aren't tracking ({len(our_untracked_bugs)}):\n")
logger.info(f'[{their_bug["status"]}] {their_bug["title"]}\n{their_bug["url"]}\n')
logger.info(f"= All of our bugs they aren't tracking ({len(our_untracked_bugs)}):\n")
ranks = playability.rank()
our_untracked_bugs.sort(key=lambda bug: (not bug['pd_legal'], ranks.get(bug['card'], float('inf')) or float('inf')))
for our_bug in our_untracked_bugs:
print(f'[{our_bug["card"]}][{"LEGAL" if our_bug["pd_legal"] else "NOT LEGAL"}][Rank {ranks.get(our_bug["card"], float("inf"))}] {our_bug["description"]}\n{our_bug["url"]}\n')
logger.info(f'[{our_bug["card"]}][{"LEGAL" if our_bug["pd_legal"] else "NOT LEGAL"}][Rank {ranks.get(our_bug["card"], float("inf"))}] {our_bug["description"]}\n{our_bug["url"]}\n')


if __name__ == '__main__':
Expand Down

0 comments on commit 35e7d3d

Please sign in to comment.