How My Heart Sings

Sun, 06 Jul 2008

はじめてのpyblosxomプラグイン、swatchbeatそのに

…欲しいものは、最初からタプルの中に、望んだ形式で入っているのが分ったんだよ、だよ。


import time


def get_beat(entry):
    if not entry:
        return ""

    local_time_tuple = entry['timetuple']

    beat_tmp_hour = int(local_time_tuple[3])
    if beat_tmp_hour == 24:
        beat_tmp_hour = 0
    beat_tmp_hour = beat_tmp_hour * 60 * 60
    
    beat_tmp_min = int(local_time_tuple[4]) * 60

    beat_tmp_sec = int(local_time_tuple[5])

    beat_tmp = int((beat_tmp_hour + beat_tmp_min + beat_tmp_sec) / 86.4)

    beat = "#" + str(beat_tmp)
    return beat

def cb_story(args):
    entry = args['entry']
    entry["beat"] = get_beat(entry)

これで、少しマシな感じに。

Meta Infomation of this entry

You can add this Entry to your  はてなブックマーク and Delicious

Comments

Add Comment...

スパム対策のため、一ヶ月を経過したエントリにはコメントを書き込めないのです…後、http:と書くこともできません。

Name:

Comment:

Le violon intérieur....
Yasuo Yamashita
vaiorinnhiATTOnaDOTrimDOTorjye-pi-
Y.A.S.U.O Ytterbium Artificial Sabotage and Utility Organism Y.A.S.U.O Yelling Abomination from the Sunless Underground Oasis

Pyblosxom and plugins. For detail, see http://viole.sakura.ne.jp/blosxom/blosxom.cgi/plugin_info