本文整理汇总了Python中timeline.Timeline类的典型用法代码示例。如果您正苦于以下问题:Python Timeline类的具体用法?Python Timeline怎么用?Python Timeline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timeline类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_get_merged_timelines__partial_merge__foiled_mugging_example
def test_get_merged_timelines__partial_merge__foiled_mugging_example(self):
"""Verify that partial merge is possible for foiled_mugging example.
"""
partial_timelines = [
['shadowy figure', 'demands', 'scream', 'siren'],
['shadowy figure', 'pointed gun', 'scream']]
timeline = Timeline(partial_timelines=partial_timelines)
merged_timelines = timeline.get_merged_timelines()
expected_timelines = [
['shadowy figure', 'demands', 'scream', 'siren'],
['shadowy figure', 'pointed gun', 'scream', 'siren']]
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
示例17: OnInit
def OnInit(self):
try:
if self.options.record:
# Connect to ROS master
if not self.connect_to_ros():
raise Exception('recording requires connection to master')
# Get filename to record to
record_filename = time.strftime('%Y-%m-%d-%H-%M-%S.bag', time.localtime(time.time()))
if self.options.name:
record_filename = self.options.name
if not record_filename.endswith('.bag'):
record_filename += '.bag'
elif self.options.prefix:
prefix = self.options.prefix
if prefix.endswith('.bag'):
prefix = prefix[:-len('.bag')]
if prefix:
record_filename = '%s_%s' % (prefix, record_filename)
rospy.loginfo('Recording to %s.' % record_filename)
# Create main timeline frame
self.frame = BaseFrame(None, 'rxbag', 'Timeline')
self.frame.BackgroundColour = wx.WHITE
self.frame.Bind(wx.EVT_CLOSE, lambda e: wx.Exit())
scroll = wx.ScrolledWindow(self.frame, -1)
scroll.BackgroundColour = wx.WHITE
timeline = Timeline(scroll, -1)
timeline.Size = (100, 100)
self.frame.Show()
self.SetTopWindow(self.frame)
timeline.SetFocus()
if self.options.record:
timeline.record_bag(record_filename, all=self.options.all, topics=self.args, regex=self.options.regex, limit=self.options.limit)
else:
RxBagInitThread(self, timeline)
except Exception, ex:
print >> sys.stderr, 'Error initializing application:', ex
#import traceback
#traceback.print_exc()
return False
开发者ID:strawlab,项目名称:rx,代码行数:48,代码来源:rxbag_app.py
示例18: to_page
def to_page(self, w, direction):
'''
Slide to given page.
@param w: gtk.Widget to slide.
@param direction: The direction of slide animation, can use below value:
- \"right\" slide from right to left
- \"left\" slide from left to right
- None no animation effect, slide directly
'''
if self.in_sliding:
return
if w != self.active_widget:
w.set_size_request(self.page_width, self.page_height)
if w.parent != self.fixed:
self.fixed.put(w, self.page_width, 0)
self.active_widget = w
self.timeline = Timeline(self.slide_time, CURVE_SINE)
if direction == "right":
self.timeline.connect('update', lambda source, status: self._to_right(status))
elif direction == "left":
self.timeline.connect('update', lambda source, status: self._to_left(status))
else:
self._no_effect()
self.timeline.connect("start", lambda source: self._start())
self.timeline.connect("completed", lambda source: self._completed())
self.timeline.run()
self.in_sliding = True
self.show_all()
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:33,代码来源:slider.py
示例19: object_hook
def object_hook(d):
"""
Usage
-----
>>> import simplejson as json
>>> with open('file.json', 'r') as f:
... json.load(f, object_hook=object_hook)
"""
from segment import Segment
from timeline import Timeline
from annotation import Annotation
from transcription import Transcription
if PYANNOTE_JSON_SEGMENT in d:
return Segment.from_json(d)
if PYANNOTE_JSON_TIMELINE in d:
return Timeline.from_json(d)
if PYANNOTE_JSON_ANNOTATION in d:
return Annotation.from_json(d)
if PYANNOTE_JSON_TRANSCRIPTION in d:
return Transcription.from_json(d)
return d
开发者ID:Parisson,项目名称:pyannote-core,代码行数:27,代码来源:json.py
示例20: set_value
def set_value(self, value):
if (not self.in_animation) and value != self.value:
self.start_value = self.value
self.range = value - self.value
times = int(abs(self.range)) * 10
from timeline import Timeline, CURVE_SINE
timeline = Timeline(times * 10, CURVE_SINE)
timeline.connect("start", self.start_animation)
timeline.connect("stop", self.stop_animation)
timeline.connect("update", self.update_animation)
timeline.run()
return False
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:13,代码来源:box.py
注:本文中的timeline.Timeline类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论