tea_cah/dump_deck.py
2020-07-20 22:34:40 +03:00

38 lines
652 B
Python

import sys
import cardcast_api
def main():
if len(sys.argv) == 3:
url = sys.argv[1]
code = sys.argv[2]
elif len(sys.argv) == 2:
code = sys.argv[1]
url = None
else:
print(f'Usage {sys.argv[0]} [url] code', file = sys.stderr)
sys.exit(1)
info = cardcast_api.info(code, base_url = url)
print('%s: %s by %s (%s black, %s white)' % (
info['code'],
info['name'],
info['author']['username'],
info['call_count'],
info['response_count']
))
print()
calls, responses = cardcast_api.cards(code, base_url = url)
for i in calls:
print('_'.join(i))
print()
for i in responses:
print(i)
if __name__ == '__main__':
main()