本文整理汇总了Python中babelsubs.tests.utils.get_subs函数的典型用法代码示例。如果您正苦于以下问题:Python get_subs函数的具体用法?Python get_subs怎么用?Python get_subs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_subs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_end_time
def test_update_end_time(self):
dfxp = utils.get_subs("pre-drm.dfxp").to_internal()
dfxp_updated = utils.get_subs("pre-drm.dfxp").to_internal()
for i in xrange(0, len(dfxp)):
dfxp_updated.update(i, to_ms=1000*i)
for i,sub in enumerate(dfxp_updated.subtitle_items()):
self.assertEqual(i * 1000, sub.end_time)
示例2: test_ttfa
def test_ttfa(self):
subs = utils.get_subs("pre-dmr.dfxp")
self.assertEquals(len(subs), 419)
# make sure the right namespace is in
subs.subtitle_set._ttml.tag = '{http://www.w3.org/ns/ttml}tt'
self.assertEqual(subs.subtitle_set._ttml.nsmap[None] , TTML_NAMESPACE_URI)
subs = utils.get_subs("pre-dmr2.dfxp")
self.assertEquals(len(subs), 19)
# make sure the right namespace is in
subs.subtitle_set._ttml.tag = '{http://www.w3.org/ns/ttml}tt'
示例3: test_internal_format
def test_internal_format(self):
subs = utils.get_subs("simple.sbv")
parsed = subs.to_internal()
sub_data = [x for x in parsed.subtitle_items()]
self.assertEquals(sub_data[0][0], 48)
self.assertEquals(sub_data[0][1], 2932)
self.assertEquals(sub_data[0][2], 'We started Universal Subtitles because we believe')
示例4: test_internal_format
def test_internal_format(self):
subs = utils.get_subs("simple.dfxp")
parsed = subs.to_internal()
sub_data = [x for x in parsed.subtitle_items()]
self.assertEquals(sub_data[0][0], 1200)
self.assertEquals(sub_data[0][1], 4467)
self.assertEquals(sub_data[3][2], 'at least 7,000 years ago.')
示例5: test_regions
def test_regions(self):
subs = utils.get_subs("regions.vtt")
items = subs.to_internal().subtitle_items()
for sub in items[:4]:
self.assertEquals(sub.region, "top")
for sub in items[4:]:
self.assertEquals(sub.region, None)
示例6: test_with_information_headers
def test_with_information_headers(self):
# we ignore those headers for now, but at least we shouldn't fail on them
subs = utils.get_subs("with-information-header.sbv")
parsed = subs.to_internal()
sub_data = [x for x in parsed.subtitle_items()]
self.assertEquals(sub_data[0][0], 48)
self.assertEquals(sub_data[0][1], 2932)
self.assertEquals(sub_data[0][2], 'We started Universal Subtitles because we believe')
示例7: test_basic
def test_basic(self):
subs = utils.get_subs("simple.srt")
self.assertEquals(len(subs), 19)
json_subs = JSONGenerator.generate(subs.to_internal())
json_subs = json.loads(json_subs)
self.assertEquals(len(json_subs), 19)
示例8: test_nested_with_markup
def test_nested_with_markup(self):
dfxp = utils.get_subs("simple.dfxp").to_internal()
# FIXME: actually this is wrong, as it's nested and we should have
# the same text with underline and italics. At least we're not
# loosing any text, and that's good enough for now, should be
# fixed though.
self.assertEqual( dfxp.get_content_with_markup(dfxp.get_subtitles()[38], SRTGenerator.MAPPINGS),
'a <u>word on </u><i>nested spans</i>')
示例9: test_round_trip
def test_round_trip(self):
subs1 = utils.get_subs("simple.sbv")
parsed1 = subs1.to_internal()
output = unicode(SBVGenerator(parsed1))
subs2 = SBVParser(output, 'en')
parsed2 = subs2.to_internal()
self.assertEquals(len(subs1), len(subs2))
for x1, x2 in zip([x for x in parsed1.subtitle_items()], [x for x in parsed2.subtitle_items()]):
self.assertEquals(x1, x2)
示例10: test_pre_drm_dfxp
def test_pre_drm_dfxp(self):
# tests a pretty feature rich dfpx file
dfxp = utils.get_subs("pre-drm.dfxp").to_internal()
self.assertEqual(len(dfxp), 419)
dfxp = utils.get_subs("pre-drm2.dfxp").to_internal()
self.assertEqual(len(dfxp), 19)
示例11: setUp
def setUp(self):
subs = utils.get_subs("simple.srt")
self.parsed = subs.to_internal()
self.sub_data = [x for x in self.parsed.subtitle_items(HTMLGenerator.MAPPINGS)]
示例12: test_nested_tags
def test_nested_tags(self):
dfxp = utils.get_subs("simple.dfxp").to_internal()
self.assertEqual( storage.get_contents(dfxp.get_subtitles()[37]), 'nested spans')
self.assertEqual( storage.get_contents(dfxp.get_subtitles()[38]), 'a word on nested spans')
示例13: test_self_generate
def test_self_generate(self):
parsed_subs1 = utils.get_subs("simple.dfxp")
parsed_subs2 = DFXPParser(DFXPGenerator(parsed_subs1.subtitle_set, 'en').__unicode__())
for x1, x2 in zip([x for x in parsed_subs1.to_internal()], [x for x in parsed_subs2.to_internal()]):
self.assertEquals(x1, x2)
示例14: test_unsynced
def test_unsynced(self):
sset = utils.get_subs('i-2376.dfxp').subtitle_set
self.assertFalse(sset.fully_synced)
示例15: test_basic
def test_basic(self):
subs = utils.get_subs("simple.dfxp")
self.assertEquals(len(subs), 76)