Isoraqathedh

Abusing the List Exploding Asterisk for Fun and Profit

Jan 27th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. def getname(name_type, **kwargs):
  2.     """Automatically calculates the output filename for all file types,
  3. largely smoothing over the differences that the classes above makes."""
  4.     # Extremely repetitive code!
  5.     def fromkwargs(*keys):
  6.         return [kwargs[key] for key in keys]
  7.     if name_type == "den":
  8.         page_outname = TheDen().autoname(*fromkwargs('original_file_name'))
  9.     elif name_type == "boc":
  10.         page_outname = (BocPage().autoname(*fromkwargs(
  11.             'title', 'book', 'page', 'subpage', 'categories', 'genre')))
  12.     elif name_type == "purple":
  13.         page_outname = (BocPurplePage().autoname(*fromkwargs(
  14.             'title', 'book', 'page', 'subpage', 'categories', 'genre')))
  15.     elif name_type == "nboc":
  16.         page_outname = (BocNonbookPage().autoname(*fromkwargs(
  17.             'title', 'page', 'categories', 'genre')))
  18.     elif name_type == "uncategorised":
  19.         page_outname = NonBocPage().autoname()
  20.     else: raise CaseFallthroughException()
  21.     return page_outname
Advertisement
Add Comment
Please, Sign In to add comment