Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getname(name_type, **kwargs):
- """Automatically calculates the output filename for all file types,
- largely smoothing over the differences that the classes above makes."""
- # Extremely repetitive code!
- def fromkwargs(*keys):
- return [kwargs[key] for key in keys]
- if name_type == "den":
- page_outname = TheDen().autoname(*fromkwargs('original_file_name'))
- elif name_type == "boc":
- page_outname = (BocPage().autoname(*fromkwargs(
- 'title', 'book', 'page', 'subpage', 'categories', 'genre')))
- elif name_type == "purple":
- page_outname = (BocPurplePage().autoname(*fromkwargs(
- 'title', 'book', 'page', 'subpage', 'categories', 'genre')))
- elif name_type == "nboc":
- page_outname = (BocNonbookPage().autoname(*fromkwargs(
- 'title', 'page', 'categories', 'genre')))
- elif name_type == "uncategorised":
- page_outname = NonBocPage().autoname()
- else: raise CaseFallthroughException()
- return page_outname
Advertisement
Add Comment
Please, Sign In to add comment