Beispiel #1
0
def datetimesortkey_chapter_number(x):
    """concatenates chapter number with the time.
    pads the chapter number if necessary."""

    #
    # example keys:
    # _________________________081021_165843
    # 01.English00000000000000_081022_154011
    # 01.Hindi0000000000000000_081022_154008
    #

    if x.has_key("chapter_number"):
        chapter = x["chapter_number"]
        chapter = chapter.strip()
        chapter = chapter[:maxChapterDigits]
        # if chapter.isdigit():
        #    chapter = int(chapter)
        #    chapter = ('%(#)0' + str(maxChapterDigits) + 'd') % {'#': chapter}
        # else:
        #    chapter = chapter.ljust(maxChapterDigits, '0')
        chapter = chapter.ljust(maxChapterDigits, "0")
    else:
        chapter = "".ljust(maxChapterDigits, "_")

    db_print("datetimesortkey_chapter_number, chapter: " + chapter, 38)

    timeVal = Search.changed_time_key(x)
    timeStr = timeVal.strftime("%y%m%d_%H%M%S")
    answer = chapter + "_" + timeStr

    db_print("datetimesortkey_chapter_number, answer: " + answer, 41)
    return answer
Beispiel #2
0
def datetimesortkey(meta):
    return Search.changed_time_key(meta)