• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python scrape.ScrapedViewFeature类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mdn.scrape.ScrapedViewFeature的典型用法代码示例。如果您正苦于以下问题:Python ScrapedViewFeature类的具体用法?Python ScrapedViewFeature怎么用?Python ScrapedViewFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ScrapedViewFeature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_load_specification_row_empty_resources

 def test_load_specification_row_empty_resources(self):
     scraped_data = self.empty_scrape()
     scraped_spec = {
         'section.note': '',
         'section.subpath': '',
         'section.name': '',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None}
     scraped_data['specs'].append(scraped_spec)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     spec_content, mat_content = view.new_specification(scraped_spec)
     section_content = view.new_section(scraped_spec, spec_content['id'])
     # TODO: bug 1251252 - Empty string should mean omittied name, subpath
     section_content['name']['en'] = ''
     section_content['subpath']['en'] = ''
     reference_content = view.load_or_new_reference(section_content['id'])
     reference_content['note'] = None
     expected = self.empty_view(scraped_data)
     expected['features']['links']['references'] = [reference_content['id']]
     expected['linked']['maturities'] = [mat_content]
     expected['linked']['specifications'] = [spec_content]
     expected['linked']['sections'] = [section_content]
     expected['linked']['references'] = [reference_content]
     self.assertDataEqual(expected, out)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:26,代码来源:test_scrape.py


示例2: test_load_compat_table_basic_support

 def test_load_compat_table_basic_support(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     browser = version.browser
     feature = self.feature
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = '_%s-%s' % (feature_id, version_id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         'name': 'desktop',
         'browsers': [{
             'id': browser_id, 'name': browser.name['en'],
             'slug': browser.slug}],
         'versions': [{
             'id': version_id, 'browser': browser_id, 'version': '1.0'}],
         'features': [{
             'id': feature_id, 'name': 'Basic Support',
             'slug': feature.slug}],
         'supports': [{
             'id': support_id, 'feature': feature_id, 'version': version_id,
             'support': 'yes'}]}
     scraped_data['compat'].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected_tabs = [
         {'name': {'en': 'Desktop Browsers'}, 'browsers': [browser_id]}]
     self.assertEqual(expected_tabs, out['meta']['compat_table']['tabs'])
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:28,代码来源:test_scrape.py


示例3: test_load_specification_row_existing_resources

 def test_load_specification_row_existing_resources(self):
     reference = self.get_instance(
         'Reference', ('web-css-background-size', 'background-size'))
     section = reference.section
     spec = section.specification
     scraped_spec = {
         'section.note': 'new note',
         'section.subpath': section.subpath['en'],
         'section.name': section.name['en'],
         'specification.mdn_key': spec.mdn_key,
         'section.id': section.id,
         'specification.id': spec.id}
     scraped_data = self.empty_scrape()
     scraped_data['specs'].append(scraped_spec)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected = self.empty_view(scraped_data)
     spec_content, mat_content = view.load_specification(spec.id)
     section_content = view.load_section(section.id)
     reference_content = view.load_or_new_reference(section.id)
     reference_content['note'] = {'en': 'new note'}
     expected['features']['links']['references'] = [reference_content['id']]
     expected['linked']['maturities'] = [mat_content]
     expected['linked']['specifications'] = [spec_content]
     expected['linked']['sections'] = [section_content]
     expected['linked']['references'] = [reference_content]
     self.assertDataEqual(expected, out)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:27,代码来源:test_scrape.py


示例4: test_load_compat_table_new_support_with_note

 def test_load_compat_table_new_support_with_note(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     browser = version.browser
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = '_%s-%s' % (feature_id, version_id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         'name': 'desktop',
         'browsers': [{
             'id': browser_id, 'name': browser.name['en'],
             'slug': browser.slug}],
         'versions': [{
             'id': version_id, 'browser': browser_id, 'version': '1.0'}],
         'features': [{
             'id': feature_id, 'name': feature.name['en'],
             'slug': feature.slug}],
         'supports': [{
             'id': support_id, 'feature': feature_id, 'version': version_id,
             'support': 'yes', 'footnote': 'Footnote'}]}
     scraped_data['compat'].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     self.assertEqual(1, out['meta']['compat_table']['notes'][support_id])
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:27,代码来源:test_scrape.py


示例5: test_load_compat_table_basic_support

 def test_load_compat_table_basic_support(self):
     version = self.get_instance("Version", ("firefox_desktop", "1.0"))
     browser = version.browser
     feature = self.feature
     browser_id = str(browser.id)
     version_id = str(version.id)
     feature_id = str(feature.id)
     support_id = "_%s-%s" % (feature_id, version_id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         "name": "desktop",
         "browsers": [{"id": browser_id, "name": browser.name["en"], "slug": browser.slug}],
         "versions": [{"id": version_id, "browser": browser_id, "version": "1.0"}],
         "features": [{"id": feature_id, "name": "Basic Support", "slug": feature.slug}],
         "supports": [{"id": support_id, "feature": feature_id, "version": version_id, "support": "yes"}],
     }
     scraped_data["compat"].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     expected = self.empty_view(scraped_data)
     expected["linked"]["browsers"].append(view.load_browser(browser.id))
     expected["linked"]["versions"].append(view.load_version(version.id))
     support_content = view.new_support(scraped_table["supports"][0])
     expected["linked"]["supports"].append(support_content)
     expected["meta"]["compat_table"]["supports"][feature_id] = {browser_id: [support_id]}
     expected["meta"]["compat_table"]["tabs"].append({"name": {"en": "Desktop Browsers"}, "browsers": [browser_id]})
     self.assertDataEqual(expected, out)
开发者ID:renoirb,项目名称:browsercompat,代码行数:27,代码来源:test_scrape.py


示例6: test_load_compat_table_unicode_feature_name

 def test_load_compat_table_unicode_feature_name(self):
     # https://developer.mozilla.org/en-US/docs/Web/CSS/timing-function
     browser_id = '_Firefox (Gecko)'
     version_id = '_Firefox-1.0'
     feature_id = '_cubic-bezier() w/ ordinate ∉[0,1]'
     support_id = '_%s-%s' % (feature_id, version_id)
     scraped_data = self.empty_scrape()
     scraped_table = {
         'name': 'desktop',
         'browsers': [{
             'id': browser_id, 'name': 'Firefox',
             'slug': '_Firefox (Gecko)'}],
         'versions': [{
             'id': version_id, 'browser': browser_id, 'version': '1.0'}],
         'features': [{
             'id': feature_id,
             'name': '<code>cubic-bezier()</code> w/ ordinate ∉[0,1]',
             'slug': 'web-css-background-size_unicode'}],
         'supports': [{
             'id': support_id, 'feature': feature_id, 'version': version_id,
             'support': 'yes'}]}
     scraped_data['compat'].append(scraped_table)
     view = ScrapedViewFeature(self.page, scraped_data)
     out = view.generate_data()
     self.assertEqual(feature_id, out['linked']['features'][0]['id'])
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:25,代码来源:test_scrape.py


示例7: test_load_browser

 def test_load_browser(self):
     browser = self.get_instance('Browser', 'firefox_desktop')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     browser_content = view.load_browser(browser.id)
     expected = {
         'id': str(browser.id), 'name': {'en': 'Firefox for Desktop'},
         'note': None, 'slug': browser.slug}
     self.assertDataEqual(expected, browser_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:8,代码来源:test_scrape.py


示例8: test_load_section

 def test_load_section(self):
     section = self.get_instance('Section', 'background-size')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.load_section(section.id)
     expected = {
         'id': str(section.id), 'name': section.name,
         'number': None, 'subpath': section.subpath,
         'links': {'specification': str(section.specification.id)}}
     self.assertDataEqual(expected, section_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:9,代码来源:test_scrape.py


示例9: test_load_version

 def test_load_version(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.load_version(version.id)
     expected = {
         'id': str(version.id), 'version': '1.0', 'status': 'unknown',
         'note': None, 'release_day': None, 'retirement_day': None,
         'release_notes_uri': None, 'order': 0,
         'links': {'browser': str(version.browser_id)}}
     self.assertDataEqual(expected, version_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:10,代码来源:test_scrape.py


示例10: test_new_browser

 def test_new_browser(self):
     browser_entry = {
         'id': '_Firefox (Gecko)', 'name': 'Firefox',
         'slug': '_Firefox (Gecko)'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     browser_content = view.new_browser(browser_entry)
     expected = {
         'id': '_Firefox (Gecko)', 'name': {'en': 'Firefox'}, 'note': None,
         'slug': ''}
     self.assertDataEqual(expected, browser_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:10,代码来源:test_scrape.py


示例11: test_new_nightly_version

 def test_new_nightly_version(self):
     version_entry = {
         'id': '_version', 'browser': '_browser', 'version': 'nightly'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.new_version(version_entry)
     expected = {
         'id': '_version', 'version': 'nightly', 'status': 'future',
         'note': None, 'release_day': None, 'retirement_day': None,
         'release_notes_uri': None,
         'links': {'browser': '_browser'}}
     self.assertDataEqual(expected, version_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:11,代码来源:test_scrape.py


示例12: test_load_section

 def test_load_section(self):
     section = self.get_instance("Section", "background-size")
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.load_section(section.id)
     expected = {
         "id": str(section.id),
         "name": section.name,
         "note": {},
         "number": None,
         "subpath": section.subpath,
         "links": {"specification": str(section.specification.id)},
     }
     self.assertDataEqual(expected, section_content)
开发者ID:renoirb,项目名称:browsercompat,代码行数:13,代码来源:test_scrape.py


示例13: test_new_support_with_note

 def test_new_support_with_note(self):
     support_entry = {
         'id': '_support', 'feature': '_feature', 'version': '_version',
         'support': 'yes', 'footnote': 'The Footnote'}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.new_support(support_entry)
     expected = {
         'id': '_support', 'support': 'yes', 'note': {'en': 'The Footnote'},
         'prefix': None, 'prefix_mandatory': False, 'protected': False,
         'requires_config': None, 'default_config': None,
         'alternate_name': None, 'alternate_mandatory': False,
         'links': {'feature': '_feature', 'version': '_version'}}
     self.assertDataEqual(expected, support_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:13,代码来源:test_scrape.py


示例14: test_load_support

 def test_load_support(self):
     version = self.get_instance('Version', ('firefox_desktop', '1.0'))
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     support = self.create(Support, version=version, feature=feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     support_content = view.load_support(support.id)
     expected = {
         'id': str(support.id), 'support': 'yes', 'note': None,
         'prefix': None, 'prefix_mandatory': False, 'protected': False,
         'requires_config': None, 'default_config': None,
         'alternate_name': None, 'alternate_mandatory': False,
         'links': {'feature': str(feature.id), 'version': str(version.id)}}
     self.assertDataEqual(expected, support_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:14,代码来源:test_scrape.py


示例15: test_load_feature

 def test_load_feature(self):
     feature = self.get_instance(
         'Feature', 'web-css-background-size-contain_and_cover')
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id),
         'name': {'en': '<code>contain</code> and <code>cover</code>'},
         'slug': feature.slug, 'mdn_uri': None, 'obsolete': False,
         'stable': True, 'standardized': True, 'experimental': False,
         'links': {
             'children': [], 'parent': str(self.feature.id),
             'references': [], 'supports': []}}
     self.assertDataEqual(expected, feature_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:14,代码来源:test_scrape.py


示例16: test_load_specification

 def test_load_specification(self):
     spec = self.get_instance('Specification', 'css3_backgrounds')
     maturity = spec.maturity
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.load_specification(spec.id)
     expected_spec = {
         'id': str(spec.id), 'slug': spec.slug, 'mdn_key': spec.mdn_key,
         'uri': spec.uri, 'name': spec.name,
         'links': {'maturity': str(maturity.id)}}
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {
         'id': str(maturity.id), 'slug': maturity.slug,
         'name': maturity.name}
     self.assertDataEqual(expected_mat, mat_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:14,代码来源:test_scrape.py


示例17: test_load_feature_canonical_name

 def test_load_feature_canonical_name(self):
     feature = self.create(
         Feature, slug='web-css-background-size_list-item',
         name={'zxx': 'list-item'}, parent=self.feature)
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     feature_content = view.load_feature(feature.id)
     expected = {
         'id': str(feature.id), 'name': 'list-item',
         'slug': feature.slug, 'mdn_uri': None, 'obsolete': False,
         'stable': True, 'standardized': True, 'experimental': False,
         'links': {
             'children': [], 'parent': str(self.feature.id),
             'references': [], 'supports': []}}
     self.assertDataEqual(expected, feature_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:14,代码来源:test_scrape.py


示例18: test_new_specification

 def test_new_specification(self):
     spec_row = {
         "section.note": "section note",
         "section.subpath": "#section",
         "section.name": "section",
         "specification.mdn_key": "CSS3 UI",
         "section.id": None,
         "specification.id": None,
     }
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     spec_content, mat_content = view.new_specification(spec_row)
     expected_spec = {"id": "_CSS3 UI", "mdn_key": "CSS3 UI", "links": {"maturity": "_unknown", "sections": []}}
     self.assertDataEqual(expected_spec, spec_content)
     expected_mat = {"id": "_unknown", "slug": "", "name": {"en": "Unknown"}, "links": {"specifications": []}}
     self.assertDataEqual(expected_mat, mat_content)
开发者ID:renoirb,项目名称:browsercompat,代码行数:15,代码来源:test_scrape.py


示例19: test_new_nightly_version

 def test_new_nightly_version(self):
     version_entry = {"id": "_version", "browser": "_browser", "version": "nightly"}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     version_content = view.new_version(version_entry)
     expected = {
         "id": "_version",
         "version": "nightly",
         "status": "future",
         "note": None,
         "release_day": None,
         "retirement_day": None,
         "release_notes_uri": None,
         "links": {"browser": "_browser"},
     }
     self.assertDataEqual(expected, version_content)
开发者ID:renoirb,项目名称:browsercompat,代码行数:15,代码来源:test_scrape.py


示例20: test_new_section

 def test_new_section(self):
     spec_row = {
         'section.note': 'section note',
         'section.subpath': '#section',
         'section.name': 'section',
         'specification.mdn_key': 'CSS3 UI',
         'section.id': None,
         'specification.id': None}
     view = ScrapedViewFeature(self.page, self.empty_scrape())
     section_content = view.new_section(spec_row, '_CSS3_UI')
     expected = {
         'id': '__CSS3_UI_#section', 'name': {'en': 'section'},
         'number': None, 'subpath': {'en': '#section'},
         'links': {'specification': '_CSS3_UI'}}
     self.assertDataEqual(expected, section_content)
开发者ID:MatonAnthony,项目名称:browsercompat,代码行数:15,代码来源:test_scrape.py



注:本文中的mdn.scrape.ScrapedViewFeature类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mdp.activate_extension函数代码示例发布时间:2022-05-27
下一篇:
Python mdlaccesscontrol.clsAccessControl函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap