make_cards.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from optparse import OptionParser
  2. from cardgenerator import CardGenerator
  3. ### Card Configuration
  4. CONFIG = {
  5. #"card_dimensions_px": (822, 1122),
  6. "card_dimensions_px": (639, 576),
  7. "card_padding_px": 64,
  8. }
  9. def munge_text(text):
  10. return text.replace("_", "__________")
  11. def main():
  12. parser = OptionParser()
  13. parser.add_option("-c", "--color", type="string", default="white",
  14. help="color scheme. white or black")
  15. parser.add_option("-f", "--footer_text", type="string", default="Humanity Against Cards",
  16. help="text for footer.")
  17. parser.add_option("-i", "--input_file", type="string", default="input/demo_cards",
  18. help="file to read from")
  19. parser.add_option("-l", "--footer_logo", type="string", default="source/logo.png",
  20. help="logo for footer.")
  21. parser.add_option("-s", "--save_folder", type="string", default="cards",
  22. help="folder to save output to")
  23. options, args = parser.parse_args()
  24. config = CONFIG
  25. config["color"] = options.color
  26. config["save_folder"] = options.save_folder
  27. config["footer_text"] = options.footer_text
  28. config["footer_logo"] = options.footer_logo
  29. cg = CardGenerator(config)
  30. with open(options.input_file, 'r') as f:
  31. for card in f.readlines():
  32. text = munge_text(card)
  33. cg.writeCard(text)
  34. cg.writeBack()
  35. print("Created {} cards from {}, saved to {}".format(options.color, options.input_file, options.save_folder))
  36. if __name__ == '__main__':
  37. main()