Truncate generated comic names.

This commit is contained in:
Bastian Kleineidam 2013-01-09 22:20:03 +01:00
parent 28b5d5e554
commit 39c83b8968
9 changed files with 26 additions and 16 deletions

View file

@ -4,6 +4,10 @@ Features:
- comics: Added AmazingSuperPowers strip.
- comics: Added PandyLand strip.
Fixes:
- scripts: Ensure the generated comic names do not exceed 100 characters so they do
not cause problems with path length restrictions.
Dosage 1.8 (released 20.12.2012)

View file

@ -76,7 +76,7 @@ add('A_Jagged_Mind', 'A_Jagged_Mind')
add('A_Loonatics_Tale', 'A_Loonatics_Tale')
add('A_Note_On_My_Life', 'A_Note_On_My_Life')
add('A_Paige_Comic', 'A_Paige_Comic')
add('A_PoKeMoN_comic_that_everyone_will_ignore_even_though_the_author_puts_way_more_work_into_it_than_some_other_very_popular_PoKeMoN_comics_that_get_over_nine_thousand_views_on_days_they_DONT_update_What_the_hell', 'A_PoKeMoN_comic_that_everyone_will_ignore_even_though_the_author_puts_way_more_work_into_it_than_some_other_very_popular_PoKeMoN_comics_that_get_over_nine_thousand_views_on_days_they_DONT_update_What_the_hell')
add('A_PoKeMoN_comic_that_everyone_will_ignore_even_though_the_author_puts_way_more_work_into_it_than_som', 'A_PoKeMoN_comic_that_everyone_will_ignore_even_though_the_author_puts_way_more_work_into_it_than_some_other_very_popular_PoKeMoN_comics_that_get_over_nine_thousand_views_on_days_they_DONT_update_What_the_hell')
add('A_Roll_of_the_Dice', 'A_Roll_of_the_Dice')
add('A_Step_Out_of_Phase', 'A_Step_Out_of_Phase')
add('A_Tale_of_Two_Sprites', 'A_Tale_of_Two_Sprites')
@ -816,7 +816,7 @@ add('Outer_Space_Alien_Nazis_From_Outer_Space', 'Outer_Space_Alien_Nazis_From_Ou
add('Outlawed', 'Outlawed')
add('Overshadow', 'Overshadow')
add('Oyer', 'Oyer')
add('POKETTO_MONSUTAA_SPECIAL_SUPER_EX_ADVENTURE_XXXVX_THE_CHRONICLES_OF_RED_BLUE_GREEN_AND_A_BUNCH_OF_OTHER_KIDS_WITH_COLORS_FOR_NAMES', 'POKETTO_MONSUTAA_SPECIAL_SUPER_EX_ADVENTURE_XXXVX_THE_CHRONICLES_OF_RED_BLUE_GREEN_AND_A_BUNCH_OF_OTHER_KIDS_WITH_COLORS_FOR_NAMES')
add('POKETTO_MONSUTAA_SPECIAL_SUPER_EX_ADVENTURE_XXXVX_THE_CHRONICLES_OF_RED_BLUE_GREEN_AND_A_BUNCH_OF_OT', 'POKETTO_MONSUTAA_SPECIAL_SUPER_EX_ADVENTURE_XXXVX_THE_CHRONICLES_OF_RED_BLUE_GREEN_AND_A_BUNCH_OF_OTHER_KIDS_WITH_COLORS_FOR_NAMES')
add('PSI', 'PSI')
add('PUTRID_MEAT', 'PUTRID_MEAT')
add('Pagan_Zoetrope', 'Pagan_Zoetrope')
@ -997,7 +997,7 @@ add('Solar_Salvage', 'Solar_Salvage')
add('Something_Else_Anime_Theater', 'Something_Else_Anime_Theater')
add('Something_Like_Life', 'Something_Like_Life')
add('Something_To_Do', 'Something_To_Do')
add('Somewhere_in_San_Fransisco_Half_Way_Beyond_The_Bridge_and_The_Tower_Lies_A_Place_Where_Nothing_is_Ever_What_It_Seems_On_A_Day_to_Day_Basis_Because_That_Is_What_Happens_in_This_Kinda_Place', 'Somewhere_in_San_Fransisco_Half_Way_Beyond_The_Bridge_and_The_Tower_Lies_A_Place_Where_Nothing_is_Ever_What_It_Seems_On_A_Day_to_Day_Basis_Because_That_Is_What_Happens_in_This_Kinda_Place')
add('Somewhere_in_San_Fransisco_Half_Way_Beyond_The_Bridge_and_The_Tower_Lies_A_Place_Where_Nothing_is_Ev', 'Somewhere_in_San_Fransisco_Half_Way_Beyond_The_Bridge_and_The_Tower_Lies_A_Place_Where_Nothing_is_Ever_What_It_Seems_On_A_Day_to_Day_Basis_Because_That_Is_What_Happens_in_This_Kinda_Place')
add('Songs_of_An_Angel', 'Songs_of_An_Angel')
add('Sonic_A_Heroes_Tail', 'Sonic_A_Heroes_Tail')
add('Sonic_Advance_The_Real_Story', 'Sonic_Advance_The_Real_Story')

View file

@ -9,7 +9,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import getPageContent, asciify, unescape, tagre
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -54,7 +54,7 @@ def print_results(args):
for name, url in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
print("add(%r, %r)" % (str(name), str(url)))
print("add(%r, %r)" % (str(truncate_name(name)), str(url)))
if __name__ == '__main__':

View file

@ -9,7 +9,7 @@ import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import tagre, getPageContent, unquote, unescape, asciify
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -203,7 +203,7 @@ def print_results(min_strips):
continue
path, num = entry
if num >= min_strips:
print("add(%r, %r)" % (str(name), str(path)))
print("add(%r, %r)" % (str(truncate_name(name)), str(path)))
if __name__ == '__main__':

View file

@ -10,7 +10,7 @@ import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import tagre, getPageContent, asciify, unescape
from dosagelib.scraper import get_scrapers
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -91,7 +91,7 @@ def print_results(args):
prefix = '#'
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(name), str(shortname)))
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(shortname)))
if __name__ == '__main__':

View file

@ -10,7 +10,7 @@ import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import getPageContent, asciify, unescape, tagre
from dosagelib.scraper import get_scrapers
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -424,7 +424,7 @@ def print_results(args):
prefix = '#'
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(name), str(url)))
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(url)))
if __name__ == '__main__':

View file

@ -38,5 +38,11 @@ def save_result(res, json_file):
def load_result(json_file):
"""Load contents of a json file."""
with open(json_file, "rb") as f:
return json.load(f)
def truncate_name(text):
"""Ensure the comic name does not exceed 100 characters."""
return text[:100]

View file

@ -11,7 +11,7 @@ import urlparse
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import getPageContent, asciify, unescape, tagre, unquote
from dosagelib.scraper import get_scrapers
from scriptutil import contains_case_insensitive, remove_html_tags, capfirst, compact_whitespace, save_result, load_result
from scriptutil import contains_case_insensitive, remove_html_tags, capfirst, compact_whitespace, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -306,7 +306,7 @@ def print_results(args):
else:
prefix = ''
print("%sadd(%r, %r, %r, %s, %s)" % (
prefix, str(name), str(url), desc, adult, bounce
prefix, str(truncate_name(name)), str(url), desc, adult, bounce
))

View file

@ -10,7 +10,7 @@ import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from dosagelib.util import getPageContent, asciify, unescape
from dosagelib.scraper import get_scrapers
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result
from scriptutil import contains_case_insensitive, capfirst, save_result, load_result, truncate_name
json_file = __file__.replace(".py", ".json")
@ -79,14 +79,14 @@ def has_comic(name):
def print_results(args):
"""Print all comics that have at least the given number of minimum comic strips."""
for name, shortname in sorted(load_result().items()):
for name, shortname in sorted(load_result(json_file).items()):
if name in exclude_comics:
continue
if has_comic(name):
prefix = '#'
else:
prefix = ''
print("%sadd(%r, %r)" % (prefix, str(name), str(shortname)))
print("%sadd(%r, %r)" % (prefix, str(truncate_name(name)), str(shortname)))
if __name__ == '__main__':