當前位置: 首頁>>代碼示例>>Python>>正文


Python timeline.Timeline類代碼示例

本文整理匯總了Python中timeline.Timeline的典型用法代碼示例。如果您正苦於以下問題:Python Timeline類的具體用法?Python Timeline怎麽用?Python Timeline使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Timeline類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: timeline_json

def timeline_json():
    headline = "Timeline Photo Headline"
    text = "this is the text"
    start_date = '2012,4,12'

    # find settings
    settings = Setting.query.order_by(desc(Setting.id)).all()
    if len(settings) > 0:
        setting = settings[0]
        headline = setting.headline
        text = setting.setting_text
        start_date = setting.start_date.replace("-", ",")

    # convert timeline's start date to datetime obj
    album_start_date = datetime.datetime.strptime(start_date, "%Y,%m,%d")

    # collect all photos
    tl = Timeline(headline, text, start_date)
    photos = Photo.query.filter(Photo.visibility == True).all()
    for photo in photos:
        dt = photo.start_date.replace("-", ",")

        # convert photo's start date to datetime obj
        photo_start_date = datetime.datetime.strptime(dt, "%Y,%m,%d")
        days_in_album = (photo_start_date - album_start_date).days + 1
        # get No.D after timeline's start date
        asset_caption = _("Day %(value)d", value=days_in_album)

        text = photo.photo_text + "<BR/><BR/><A href='%s'><i class='icon-zoom-in'></i>%s</A>" % (url_for("photos.show_html", filename=photo.filename), photo.filename)

        tl.add_date(startDate=dt, headline=photo.headline, asset_media=url_for("photos.show_thumb", filename=photo.filename), text=text, asset_caption=asset_caption)
    return tl.get_json()
開發者ID:ChinaHackers,項目名稱:timeline-gallery-in-openshift,代碼行數:32,代碼來源:index.py

示例2: test_daily

    def test_daily(self):
        n_days = 10
        data = get_timed_data(n_days)

        timeline = Timeline(data)
        daily = timeline.split_daily()

        self.assertEqual(len(daily), n_days, msg='Testing with {} days should yield dictionary with {} items'.format(daily, daily))
開發者ID:CakeBrewery,項目名稱:pyutils,代碼行數:8,代碼來源:test.py

示例3: test_get_merged_timeline__single_timeline

    def test_get_merged_timeline__single_timeline(self):
        """Verify merged timeline of exactly one partial timeline.
        """
        partial_timeline = ['one', 'two', 'three', 'four']
        timeline = Timeline(partial_timelines=[partial_timeline])

        # Verify get_merged_timelines return value
        merged_timelines = timeline.get_merged_timelines()
        self.assertEqual([partial_timeline], merged_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:9,代碼來源:test_timeline.py

示例4: singlebeat

def singlebeat(beat, *args, **kwargs):
    beat_timeline = Timeline()
    time = 0.0
    beat_timeline.add(time+0.0, beat)

    print "Rendering beat audio..."
    beat_data = beat_timeline.render()

    return beat_data
開發者ID:Slater-Victoroff,項目名稱:BerkleeMusicHack,代碼行數:9,代碼來源:sounds.py

示例5: test_get_merged_timelines__full_merge__interleaved

    def test_get_merged_timelines__full_merge__interleaved(self):
        """Verify that unambiguous interleaved timelines merge correctly.
        """
        partial_timelines = [['two', 'three', 'seven'],
                             ['three', 'four', 'five', 'seven']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        self.assertEqual([['two', 'three', 'four', 'five', 'seven']],
                         merged_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:10,代碼來源:test_timeline.py

示例6: test_get_all_subsequent_events__simple

 def test_get_all_subsequent_events__simple(self):
     """Verify behavior of _get_all_subsequent_events.
     """
     timeline = Timeline()
     timeline._subsequent_events = {'one': set(['two']),
                                   'two': set(['three']),
                                   'three': set(['four']),
                                   'four': set()}
     subsequent_events = timeline._get_all_subsequent_events('one')
     self.assertEqual(set(['two', 'three', 'four']), subsequent_events)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:10,代碼來源:test_timeline.py

示例7: test_get_merged_timelines__full_merge__start_and_end_overlap

    def test_get_merged_timelines__full_merge__start_and_end_overlap(self):
        """Verify that unambiguous overlapping timelines merge correctly.
        """
        partial_timelines = [['two', 'three', 'six'],
                             ['six', 'seven'],
                             ['one', 'two']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        self.assertEqual([['one', 'two', 'three', 'six', 'seven']],
                         merged_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:11,代碼來源:test_timeline.py

示例8: test_get_merged_timelines__full_merge__shooting_example

    def test_get_merged_timelines__full_merge__shooting_example(self):
        """Verify that full merge is possible for shooting example.
        """
        partial_timelines = [
            ['shouting', 'fight', 'fleeing'],
            ['fight', 'gunshot', 'panic', 'fleeing'],
            ['anger', 'shouting']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        self.assertEqual([['anger', 'shouting', 'fight', 'gunshot', 'panic', 'fleeing']],
                         merged_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:12,代碼來源:test_timeline.py

示例9: singlenote

def singlenote(note_number, *args, **kwargs):
    singlenote_timeline = Timeline()
    time = 0.0 # Keep track of currect note placement time in seconds

    # Strum out root chord to finish
    chord = kwargs['progression'][0]
    singlenote_timeline.add(time + 0.0, Hit(chord.notes[note_number], 3.0))

    print "Rendering singlenote audio..."
    singlenote_data = singlenote_timeline.render()

    return singlenote_data
開發者ID:Slater-Victoroff,項目名稱:BerkleeMusicHack,代碼行數:12,代碼來源:sounds.py

示例10: test_add_partial_timeline__simple

    def test_add_partial_timeline__simple(self):
        """Verify side-effects of single call to add_partial_timeline.
        """
        partial_timeline = ['one', 'two', 'three', 'four']
        timeline = Timeline()
        timeline.add_partial_timeline(partial_timeline)

        # Verify internal timeline data
        expected_subsequent_events = {'one': set(['two']),
                                      'two': set(['three']),
                                      'three': set(['four']),
                                      'four': set()}
        self.assertEqual(expected_subsequent_events, timeline._subsequent_events)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:13,代碼來源:test_timeline.py

示例11: test_add_partial_timeline__contradiction

 def test_add_partial_timeline__contradiction(self):
     """Verify that order contradiction is detected and avoided.
     """
     partial_timelines = [
         ['one', 'two', 'three'],
         ['three', 'two']]
     timeline = Timeline()
     timeline.add_partial_timeline(partial_timelines[0])
     self.assertRaisesRegexp(
         ValueError,
         "Contradiction detected: event 'three' comes before and after event 'two'",
         timeline.add_partial_timeline,
         partial_timelines[1])
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:13,代碼來源:test_timeline.py

示例12: test_get_all_subsequent_events__branching

 def test_get_all_subsequent_events__branching(self):
     """Verify behavior of _get_all_subsequent_events when events overlap.
     """
     timeline = Timeline()
     timeline._subsequent_events = {'one': set(['two']),
                                    'two': set(['three']),
                                    'three': set(['six', 'four']),
                                    'four': set(['five']),
                                    'five': set(['six']),
                                    'six': set(['seven']),
                                    'seven': set()}
     subsequent_events = timeline._get_all_subsequent_events('one')
     self.assertEqual(set(['two', 'three', 'four', 'five', 'six', 'seven']), subsequent_events)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:13,代碼來源:test_timeline.py

示例13: test_get_merged_timelines__partial_merge

    def test_get_merged_timelines__partial_merge(self):
        """Verify that ambiguous partial timelines are merged as far as possible.
        """
        partial_timelines = [['two', 'three', 'four', 'seven', 'eight'],
                             ['one', 'two', 'five', 'six', 'seven']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        expected_timelines = [
            ['one', 'two', 'three', 'four', 'seven', 'eight'],
            ['one', 'two', 'five', 'six', 'seven', 'eight']]
        self.assertEqual(len(expected_timelines), len(merged_timelines))
        for merged_timeline in merged_timelines:
            self.assertTrue(merged_timeline in expected_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:14,代碼來源:test_timeline.py

示例14: test_get_merged_timelines__no_merge__scandal_example

    def test_get_merged_timelines__no_merge__scandal_example(self):
        """Verify that no merge is possible for scandal example.
        """
        partial_timelines = [
            ['argument', 'coverup', 'pointing'],
            ['press brief', 'scandal', 'pointing'],
            ['argument', 'bribe']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        expected_timelines = partial_timelines
        self.assertEqual(len(expected_timelines), len(merged_timelines))
        for merged_timeline in merged_timelines:
            self.assertTrue(merged_timeline in expected_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:14,代碼來源:test_timeline.py

示例15: test_get_merged_timelines__partial_merge__arson_example

    def test_get_merged_timelines__partial_merge__arson_example(self):
        """Verify that partial merge is possible for arson example.
        """
        partial_timelines = [
            ['pouring gas', 'laughing', 'lighting match', 'fire'],
            ['buying gas', 'pouring gas', 'crying', 'fire', 'smoke']]
        timeline = Timeline(partial_timelines=partial_timelines)

        merged_timelines = timeline.get_merged_timelines()
        expected_timelines = [
            ['buying gas', 'pouring gas', 'crying', 'fire', 'smoke'],
            ['buying gas', 'pouring gas', 'laughing', 'lighting match', 'fire', 'smoke']]
        self.assertEqual(len(expected_timelines), len(merged_timelines))
        for merged_timeline in merged_timelines:
            self.assertTrue(merged_timeline in expected_timelines)
開發者ID:jpowerwa,項目名稱:coding-examples,代碼行數:15,代碼來源:test_timeline.py


注:本文中的timeline.Timeline類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。