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

Python utils.root函数代码示例

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

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



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

示例1: test_store_and_retrieve

    def test_store_and_retrieve(self):
        with patch.multiple("sys", exit=self.sys_exit, stdout=StreamCapturing(sys.stdout)):
            tmpdir = tempfile.mkdtemp()
            os.rmdir(tmpdir)  # lets make sure 'store' can recreate it
            try:
                self.exec_pipeline("""
- load:
   - file://%s/metadata/test01.xml
- select
- store:
   directory: %s
""" % (self.datadir, tmpdir))
                t1 = parse_xml(resource_filename("metadata/test01.xml", self.datadir))
                assert t1 is not None
                entity_id = 'https://idp.example.com/saml2/idp/metadata.php'
                sha1id = hash_id(entity_id, prefix=False)
                fn = "%s/%s.xml" % (tmpdir, sha1id)
                assert os.path.exists(fn)
                t2 = parse_xml(fn)
                assert t2 is not None
                assert root(t1).get('entityID') == root(t2).get('entityID')
                assert root(t2).get('entityID') == entity_id
            except IOError:
                raise Skip
            finally:
                shutil.rmtree(tmpdir)
开发者ID:br00k,项目名称:pyFF,代码行数:26,代码来源:test_pipeline.py


示例2: test_utils

    def test_utils(self):
        entity_id = root(self.t).get('entityID')
        self.md.store.update(root(self.t), entity_id)
        e = self.md.lookup(entity_id)[0]
        assert (is_idp(e))
        assert (not is_sp(e))
        icon = entity_icon_url(e)
        assert ('url' in icon)
        assert ('https://www.example.com/static/images/umu_logo.jpg' in icon['url'])
        assert ('width' in icon)
        assert ('358' == icon['width'])
        assert ('height' in icon)
        assert ('63' == icon['height'])
        assert ('62' != icon['height'])

        domains = entity_domains(e)
        assert ('example.com' in domains)
        assert ('example.net' in domains)
        assert ('idp.example.com' not in domains)
        assert ('foo.com' not in domains)

        edup = deepcopy(e)
        name, desc = entity_extended_display(e)
        assert(name == 'Example University')
        assert(desc == 'Identity Provider for Example University')

        disp = entity_display_name(e)
        assert (disp == 'Example University')
        for elt in e.findall(".//{%s}DisplayName" % NS['mdui']):
            elt.getparent().remove(elt)

        disp = entity_display_name(e)
        assert (disp == 'The Example University')
        for elt in e.findall(".//{%s}OrganizationDisplayName" % NS['md']):
            elt.getparent().remove(elt)

        disp = entity_display_name(e)
        assert (disp == 'ExampleU')
        for elt in e.findall(".//{%s}OrganizationName" % NS['md']):
            elt.getparent().remove(elt)

        disp = entity_display_name(e)
        assert (disp == entity_id)

        e = edup

        subs = entity_domains(e)
        assert ('example.com' in subs)
        assert ('example.net' in subs)
        assert ('idp.example.com' not in subs)

        summary = entity_simple_summary(e)
        assert (summary['title'] == 'Example University')
        assert (summary['descr'] == 'Identity Provider for Example University')
        assert (summary['entityID'] == entity_id)
        assert ('domains' in summary)
        assert ('id' in summary)

        empty = entity_simple_summary(None)
        assert (not empty)
开发者ID:leifj,项目名称:pyFF,代码行数:60,代码来源:test_repo.py


示例3: test_entity_attribute

 def test_entity_attribute(self):
     entity_id = root(self.t).get('entityID')
     self.md.set_entity_attributes(root(self.t), {"http://ns.example.org": "foo"})
     self.md.store.update(root(self.t), entity_id)
     e = self.md.lookup("{%s}%s" % ("http://ns.example.org", 'foo'))[0]
     assert (e is not None)
     assert (e.get('entityID') == entity_id)
开发者ID:pmeulen,项目名称:pyFF,代码行数:7,代码来源:test_repo.py


示例4: test_first_select_as

    def test_first_select_as(self):
        with patch.multiple("sys", exit=self.sys_exit, stdout=StreamCapturing(sys.stdout)):
            tmpfile = tempfile.NamedTemporaryFile('w').name
            try:
                self.exec_pipeline("""
- load:
   - file://%s/metadata/test01.xml
- select as FOO
- first
- publish: %s
""" % (self.datadir, tmpfile))
                t1 = parse_xml(resource_filename("metadata/test01.xml", self.datadir))
                assert t1 is not None
                entity_id = 'https://idp.example.com/saml2/idp/metadata.php'
                t2 = parse_xml(tmpfile)
                assert t2 is not None
                assert root(t1).get('entityID') == root(t2).get('entityID')
                assert root(t2).get('entityID') == entity_id
            except PipeException:
                pass
            except IOError:
                raise Skip
            finally:
                try:
                    os.unlink(tmpfile)
                except:
                    pass
开发者ID:br00k,项目名称:pyFF,代码行数:27,代码来源:test_pipeline.py


示例5: import_metadata

    def import_metadata(self, t, url=None):
        """
:param t: An EntitiesDescriptor element
:param url: An optional URL to used to identify the EntitiesDescriptor in the MDRepository

Import an EntitiesDescriptor element using the @Name attribute (or the supplied url parameter). All
EntityDescriptor elements are stripped of any @ID attribute and are then indexed before the collection
is stored in the MDRepository object.
        """
        if url is None:
            top = t.xpath("//md:EntitiesDescriptor", namespaces=NS)
            if top is not None and len(top) == 1:
                url = top[0].get("Name", None)
        if url is None:
            raise ValueError("No collection name found")
        self[url] = t
        # we always clean incoming ID
        # add to the index
        ne = 0

        if t is not None:
            if root(t).tag == "{%s}EntityDescriptor" % NS['md']:
                if root(t).attrib.has_key('ID'):
                    del root(t).attrib['ID']
                self.index.add(root(t))
                ne += 1
            else:
                for e in t.findall(".//{%s}EntityDescriptor" % NS['md']):
                    if e.attrib.has_key('ID'):
                        del e.attrib['ID']
                    self.index.add(e)
                    ne += 1

        return ne
开发者ID:salaun-renater,项目名称:pyFF,代码行数:34,代码来源:mdrepo.py


示例6: import_metadata

    def import_metadata(self, t, url=None):
        """
:param t: An EntitiesDescriptor element
:param url: An optional URL to used to identify the EntitiesDescriptor in the MDRepository

Import an EntitiesDescriptor element using the @Name attribute (or the supplied url parameter). All
EntityDescriptor elements are stripped of any @ID attribute and are then indexed before the collection
is stored in the MDRepository object.
        """
        if url is None:
            top = t.xpath("//md:EntitiesDescriptor", namespaces=NS)
            if top is not None and len(top) == 1:
                url = top[0].get("Name", None)
        if url is None:
            raise MetadataException("No collection name found")
        self[url] = t
        # we always clean incoming ID
        # add to the index
        ne = 0

        if t is not None:
            if root(t).tag == "{%s}EntityDescriptor" % NS['md']:
                self._index_entity(root(t))
                ne += 1
            else:
                for e in t.findall(".//{%s}EntityDescriptor" % NS['md']):
                    self._index_entity(e)
                    ne += 1

        self.fire(type=EVENT_IMPORTED_METADATA, size=ne, url=url)
        return ne
开发者ID:GEANT,项目名称:met,代码行数:31,代码来源:mdrepo.py


示例7: test_utils

    def test_utils(self):
        entity_id = root(self.t).get("entityID")
        self.md.store.update(root(self.t), entity_id)
        e = self.md.lookup(entity_id)[0]
        assert self.md.is_idp(e)
        assert not self.md.is_sp(e)
        assert self.md.icon(e) in [
            "https://www.example.com/static/images/logo.jpg",
            "https://www.example.com/static/images/logo_eng.jpg",
        ]
        domains = self.md.domains(e)
        assert "example.com" in domains
        assert "example.net" in domains
        assert "idp.example.com" in domains
        assert "foo.com" not in domains

        edup = deepcopy(e)
        name, desc = self.md.ext_display(e)
        assert name == "Example University"
        assert desc == "Identity Provider for Example University"

        disp = self.md.display(e)
        assert disp == "Example University"
        for elt in e.findall(".//{%s}DisplayName" % NS["mdui"]):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert disp == "The Example University"
        for elt in e.findall(".//{%s}OrganizationDisplayName" % NS["md"]):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert disp == "ExampleU"
        for elt in e.findall(".//{%s}OrganizationName" % NS["md"]):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert disp == entity_id

        e = edup

        subs = self.md.sub_domains(e)
        assert "example.com" in subs
        assert "example.net" in subs
        assert "idp.example.com" not in subs

        summary = self.md.simple_summary(e)
        assert summary["title"] == "Example University"
        assert summary["descr"] == "Identity Provider for Example University"
        assert summary["value"] == entity_id
        assert "icon" in summary
        assert "icon_url" in summary and summary["icon"] == summary["icon_url"]
        assert "domains" in summary
        assert "id" in summary

        empty = self.md.simple_summary(None)
        assert not empty
开发者ID:peter-,项目名称:pyFF,代码行数:57,代码来源:test_repo.py


示例8: test_utils

    def test_utils(self):
        entity_id = root(self.t).get('entityID')
        self.md.store.update(root(self.t), entity_id)
        e = self.md.lookup(entity_id)[0]
        assert (self.md.is_idp(e))
        assert (not self.md.is_sp(e))
        assert (self.md.icon(e) in ['https://www.example.com/static/images/logo.jpg',
                                    'https://www.example.com/static/images/logo_eng.jpg'] )
        domains = self.md.domains(e)
        assert ('example.com' in domains)
        assert ('example.net' in domains)
        assert ('idp.example.com' not in domains)
        assert ('foo.com' not in domains)

        edup = deepcopy(e)
        name, desc = self.md.ext_display(e)
        assert(name == 'Example University')
        assert(desc == 'Identity Provider for Example University')

        disp = self.md.display(e)
        assert (disp == 'Example University')
        for elt in e.findall(".//{%s}DisplayName" % NS['mdui']):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert (disp == 'The Example University')
        for elt in e.findall(".//{%s}OrganizationDisplayName" % NS['md']):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert (disp == 'ExampleU')
        for elt in e.findall(".//{%s}OrganizationName" % NS['md']):
            elt.getparent().remove(elt)

        disp = self.md.display(e)
        assert (disp == entity_id)

        e = edup

        subs = self.md.sub_domains(e)
        assert ('example.com' in subs)
        assert ('example.net' in subs)
        assert ('idp.example.com' not in subs)

        summary = self.md.simple_summary(e)
        assert (summary['title'] == 'Example University')
        assert (summary['descr'] == 'Identity Provider for Example University')
        assert (summary['value'] == entity_id)
        assert ('icon' in summary)
        assert ('icon_url' in summary and summary['icon'] == summary['icon_url'])
        assert ('domains' in summary)
        assert ('id' in summary)

        empty = self.md.simple_summary(None)
        assert (not empty)
开发者ID:pmeulen,项目名称:pyFF,代码行数:55,代码来源:test_repo.py


示例9: entities

    def entities(self, t=None):
        """
:param t: An EntitiesDescriptor element

Returns the list of contained EntityDescriptor elements
        """
        if t is None:
            return []
        elif root(t).tag == "{%s}EntityDescriptor" % NS['md']:
            return [root(t)]
        else:
            return t.findall(".//{%s}EntityDescriptor" % NS['md'])
开发者ID:GEANT,项目名称:met,代码行数:12,代码来源:mdrepo.py


示例10: update

    def update(self, t, tid=None, ts=None, merge_strategy=None):
        # log.debug("memory store update: %s: %s" % (repr(t), tid))
        relt = root(t)
        assert (relt is not None)
        ne = 0
        if relt.tag == "{%s}EntityDescriptor" % NS['md']:
            # log.debug("memory store setting entity descriptor")
            self._unindex(relt)
            self._index(relt)
            self.entities[relt.get('entityID')] = relt  # TODO: merge?
            if tid is not None:
                self.md[tid] = [relt.get('entityID')]
            ne += 1
            # log.debug("keys %s" % self.md.keys())
        elif relt.tag == "{%s}EntitiesDescriptor" % NS['md']:
            if tid is None:
                tid = relt.get('Name')
            lst = []
            for e in iter_entities(t):
                self.update(e)
                lst.append(e.get('entityID'))
                ne += 1
            self.md[tid] = lst

        return ne
开发者ID:identinetics,项目名称:pyFF,代码行数:25,代码来源:store.py


示例11: test_replace_ndn

 def test_replace_ndn(self):
     idp = find_entity(root(self.t2), 'https://idp.nordu.net/idp/shibboleth')
     assert (idp is not None)
     idp2 = copy.deepcopy(idp)
     assert idp2 is not None
     for o in idp2.findall(".//{%s}OrganizationName" % NS['md']):
         o.text = "FOO"
     idp2.set('ID', 'kaka4711')
     replace_existing(idp, idp2)
     idp3 = find_entity(root(self.t2), 'kaka4711', attr='ID')
     assert (idp3 is not None)
     for o in idp2.findall(".//{%s}OrganizationName" % NS['md']):
         assert (o.text == "FOO")
     remove(idp3, None)
     idp = find_entity(root(self.t2), 'kaka4711', attr='ID')
     assert (idp3 is not None)
开发者ID:Razumain,项目名称:pyFF,代码行数:16,代码来源:test_utils.py


示例12: test_lookup_intersect_empty_test01

 def test_lookup_intersect_empty_test01(self):
     store = self._redis_store()
     store.update(self.test01)
     entity_id = root(self.test01).get('entityID')
     assert (entity_id is not None)
     e = store.lookup("{%s}%s+{%s}%s" % (ATTRS['domain'], 'example.com', ATTRS['role'], 'sp'))
     assert (len(e) == 0)
开发者ID:Razumain,项目名称:pyFF,代码行数:7,代码来源:test_store.py


示例13: test_display

 def test_display(self):
     swamid = root(self.swamid)
     self.md.store.update(swamid, swamid.get('Name'))
     funet_connect = self.md.lookup('https://connect.funet.fi/shibboleth')[0]
     name, desc = self.md.ext_display(funet_connect)
     assert(name == 'FUNET E-Meeting Service')
     dn = self.md.display(funet_connect)
开发者ID:pmeulen,项目名称:pyFF,代码行数:7,代码来源:test_repo.py


示例14: test_alias_ndn

 def test_alias_ndn(self):
     r = requests.get("http://127.0.0.1:%s/ndn.xml" % self.port)
     assert r.status_code == 200
     # assert (r.encoding == 'utf8')
     t = parse_xml(StringIO(r.content))
     assert t is not None
     assert root(t).get("entityID") == "https://idp.nordu.net/idp/shibboleth"
     validate_document(t)
开发者ID:Razumain,项目名称:pyFF,代码行数:8,代码来源:test_md_main.py


示例15: test_alias_ndn

 def test_alias_ndn(self):
     r = requests.get("http://127.0.0.1:%s/ndn.xml" % self.port)
     assert (r.status_code == 200)
     # assert (r.encoding == 'utf8')
     t = parse_xml(six.BytesIO(r.content))
     assert (t is not None)
     assert (root(t).get('entityID') == 'https://idp.nordu.net/idp/shibboleth')
     validate_document(t)
开发者ID:leifj,项目名称:pyFF,代码行数:8,代码来源:test_md_main.py


示例16: setUp

 def setUp(self):
     self.md = MDRepository(store=MemoryStore)
     self.datadir = resource_filename('metadata', 'test/data')
     self.xml_source = os.path.join(self.datadir, 'test01.xml')
     self.swamid_source = os.path.join(self.datadir, 'swamid-2.0-test.xml')
     self.swamid = root(parse_xml(self.swamid_source))
     self.t = parse_xml(self.xml_source)
     self.non_metadata = parse_xml(resource_filename("not-metadata.xml", self.datadir))
开发者ID:pmeulen,项目名称:pyFF,代码行数:8,代码来源:test_repo.py


示例17: test_maintain_test01

 def test_maintain_test01(self):
     store = self._redis_store()
     store.update(self.test01)
     entity_id = root(self.test01).get('entityID')
     assert (entity_id is not None)
     d = dict()
     store.periodic(d)
     assert('Last Periodic Maintenance' in d)
开发者ID:Razumain,项目名称:pyFF,代码行数:8,代码来源:test_store.py


示例18: test_non_metadata

 def test_non_metadata(self):
     e = root(self.non_metadata)
     assert self.md.expiration(e) is None
     try:
         self.md.annotate(e,"kaka","x","y")
         self.md.set_entity_attributes(e, dict(a=1))
         assert False
     except MetadataException:
         pass
开发者ID:pmeulen,项目名称:pyFF,代码行数:9,代码来源:test_repo.py


示例19: test_md_query_single

 def test_md_query_single(self):
     q = quote_plus('https://idp.nordu.net/idp/shibboleth')
     r = requests.get("http://127.0.0.1:%s/entities/%s" % (self.port, q))
     assert (r.status_code == 200)
     assert ('application/xml' in r.headers['Content-Type'])
     t = parse_xml(six.BytesIO(r.content))
     assert (t is not None)
     e = root(t)
     assert (e.get('entityID') == 'https://idp.nordu.net/idp/shibboleth')
开发者ID:leifj,项目名称:pyFF,代码行数:9,代码来源:test_md_main.py


示例20: test_lookup_test01

 def test_lookup_test01(self):
     store = MemoryStore()
     store.update(self.test01)
     entity_id = root(self.test01).get('entityID')
     e = store.lookup(entity_id)
     assert (len(e) == 1)
     assert (e[0] is not None)
     assert (e[0].get('entityID') is not None)
     assert (e[0].get('entityID') == entity_id)
开发者ID:Razumain,项目名称:pyFF,代码行数:9,代码来源:test_store.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyfftw.byte_align函数代码示例发布时间:2022-05-25
下一篇:
Python log.debug函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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