当前位置: 首页>>代码示例>>Python>>正文


Python XMLHelpers.buildOrganization方法代码示例

本文整理汇总了Python中XMLHelpers.buildOrganization方法的典型用法代码示例。如果您正苦于以下问题:Python XMLHelpers.buildOrganization方法的具体用法?Python XMLHelpers.buildOrganization怎么用?Python XMLHelpers.buildOrganization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLHelpers的用法示例。


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

示例1: test_exportlinks2

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildOrganization [as 别名]
    def test_exportlinks2(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        
        organization1 = Organization(elemid = "Franch",
    
                                    name = "French pride",
    
                                    info_type = "non-existant",
                                    info_history = "white flags",
                                    info_contacts_phone = "1234567890",
                                    info_contacts_email = "[email protected]",
                                    info_contacts_address = "French",
                                    info_contacts_city = "Paris",
                                    info_contacts_state = "Canada",
                                    info_contacts_country = "USA",
                                    info_contacts_zip = "7890",
    
                                    info_loc_city = "Alaska",
                                    info_loc_region = "Ukraine",
                                    info_loc_country = "Antarctica",
    
                                    personrefs = ["baquettes", "crumpets"],
                                    crisisrefs = ["war", "nazis"],
    
                                    misc = "")

        otree = SubElement(tree, "organization", {"id" : "Franch"})
        XMLHelpers.buildOrganization(otree, organization1)
        
        
        link1 = Link(link_parent = "Franch",
                    link_type = "salad",
                    title = "don't click me!!!",
                    link_url = "http://www.nevergohere.com",
                    description = "you really shouldn't go there...",
                    link_site = "a bad place")
        XMLHelpers.link_list = []
        XMLHelpers.link_list.append(link1)
        
        XMLHelpers.exportLinks(organization1, otree)
        
        for ref in otree.findall('.//ref'):
            for l in ref:
                new_link = Link()
                if (l.tag):
                    new_link.link_type = l.tag
                if (l.find('./site') != None):
                    new_link.link_site = l.find('./site').text
                if (l.find('./title') != None):
                    new_link.title = l.find('./title').text
                if (l.find('./url') != None):
                    new_link.link_url = db.Link(l.find('./url').text)
                if (l.find('./description') != None):
                    new_link.description = l.find('./description').text
                new_link.link_parent = otree.attrib['id']
                
                self.assert_(new_link.link_type == link1.link_type)
                self.assert_(new_link.link_site == link1.link_site)
                self.assert_(new_link.title == link1.title)
                self.assert_(new_link.link_url == link1.link_url)
                self.assert_(new_link.description == link1.description)
                self.assertEqual(new_link.link_parent, link1.link_parent)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:64,代码来源:jromeem-TestWC1.py

示例2: test_buildorg2

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildOrganization [as 别名]
    def test_buildorg2(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        
        organization2 = Organization(elemid = "crap",
    
                                    name = "crap",
    
                                    info_type = "",
                                    info_history = "",
                                    info_contacts_phone = "",
                                    info_contacts_email = "",
                                    info_contacts_address = "",
                                    info_contacts_city = "",
                                    info_contacts_state = "",
                                    info_contacts_country = "",
                                    info_contacts_zip = "",
    
                                    info_loc_city = "",
                                    info_loc_region = "",
                                    info_loc_country = "",
    
                                    personrefs = [],
                                    crisisrefs = [],
    
                                    misc = "")

        otree = SubElement(tree, "organization", {"id" : "crap"})     
        XMLHelpers.buildOrganization(otree, organization2)
        
        elemid = otree.attrib['id'],
        name = otree.find('.//name').text
        info_type = otree.find('.//info').find('.//type').text
        info_history = otree.find('.//info').find('.//history').text
        info_contacts_phone = otree.find('.//info').find('.//contact').find('.//phone').text
        info_contacts_email = otree.find('.//info').find('.//contact').find('.//email').text
        info_contacts_address = otree.find('.//info').find('.//contact').find('.//mail').find('.//address').text
        info_contacts_city = otree.find('.//info').find('.//contact').find('.//mail').find('.//city').text
        info_contacts_state = otree.find('.//info').find('.//contact').find('.//mail').find('.//state').text
        info_contacts_country = otree.find('.//info').find('.//contact').find('.//mail').find('.//country').text
        info_contacts_zip = otree.find('.//info').find('.//contact').find('.//mail').find('.//zip').text
        info_loc_city = otree.find('.//info').find('.//loc').find('.//city').text
        info_loc_region = otree.find('.//info').find('.//loc').find('.//region').text
        info_loc_country = otree.find('.//info').find('.//loc').find('.//country').text

        personrefs = [x.attrib['idref'] for x in otree.findall('.//person')]
        crisisrefs = [x.attrib['idref'] for x in otree.findall('.//crisis')]
        misc = otree.find('.//misc').text
        
        #self.assert_(elemid == organization2.elemid)
        self.assert_(name == organization2.name)
        self.assert_(info_type == organization2.info_type)
        self.assert_(info_history == organization2.info_history)
        self.assert_(info_contacts_phone == organization2.info_contacts_phone)
        self.assert_(info_contacts_email == organization2.info_contacts_email)
        self.assert_(info_contacts_address == organization2.info_contacts_address)
        self.assert_(info_contacts_city == organization2.info_contacts_city)
        self.assert_(info_contacts_state == organization2.info_contacts_state)
        self.assert_(info_contacts_country == organization2.info_contacts_country)
        self.assert_(info_contacts_zip == organization2.info_contacts_zip)
        self.assert_(info_loc_city == organization2.info_loc_city)
        self.assert_(info_loc_region == organization2.info_loc_region)
        self.assert_(info_loc_country == organization2.info_loc_country)
        self.assert_(misc == organization2.misc)
        self.assert_(personrefs == organization2.personrefs)
        self.assert_(crisisrefs == organization2.crisisrefs)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:67,代码来源:jromeem-TestWC1.py

示例3: test_buildorg3

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildOrganization [as 别名]
    def test_buildorg3(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        
        organization3 = Organization(elemid = "new1",
    
                                    name = "n2123",
    
                                    info_type = "stant",
                                    info_history = "sadvass",
                                    info_contacts_phone = "sdfasdc2345",
                                    info_contacts_email = "asdjhkch234",
                                    info_contacts_address = "Japan",
                                    info_contacts_city = "hates",
                                    info_contacts_state = "baka",
                                    info_contacts_country = "gaijins",
                                    info_contacts_zip = "who",
    
                                    info_loc_city = "act",
                                    info_loc_region = "like",
                                    info_loc_country = "weaboos",
    
                                    personrefs = ["sushi", "fish"],
                                    crisisrefs = ["perl harbor", "atom bombs"],
    
                                    misc = "")

        otree = SubElement(tree, "organization", {"id" : "new1"})     
        XMLHelpers.buildOrganization(otree, organization3)
        
        elemid = otree.attrib['id'],
        name = otree.find('.//name').text
        info_type = otree.find('.//info').find('.//type').text
        info_history = otree.find('.//info').find('.//history').text
        info_contacts_phone = otree.find('.//info').find('.//contact').find('.//phone').text
        info_contacts_email = otree.find('.//info').find('.//contact').find('.//email').text
        info_contacts_address = otree.find('.//info').find('.//contact').find('.//mail').find('.//address').text
        info_contacts_city = otree.find('.//info').find('.//contact').find('.//mail').find('.//city').text
        info_contacts_state = otree.find('.//info').find('.//contact').find('.//mail').find('.//state').text
        info_contacts_country = otree.find('.//info').find('.//contact').find('.//mail').find('.//country').text
        info_contacts_zip = otree.find('.//info').find('.//contact').find('.//mail').find('.//zip').text
        info_loc_city = otree.find('.//info').find('.//loc').find('.//city').text
        info_loc_region = otree.find('.//info').find('.//loc').find('.//region').text
        info_loc_country = otree.find('.//info').find('.//loc').find('.//country').text

        personrefs = [x.attrib['idref'] for x in otree.findall('.//person')]
        crisisrefs = [x.attrib['idref'] for x in otree.findall('.//crisis')]
        misc = otree.find('.//misc').text
        
        #self.assert_(elemid == organization3.elemid)
        self.assert_(name == organization3.name)
        self.assert_(info_type == organization3.info_type)
        self.assert_(info_history == organization3.info_history)
        self.assert_(info_contacts_phone == organization3.info_contacts_phone)
        self.assert_(info_contacts_email == organization3.info_contacts_email)
        self.assert_(info_contacts_address == organization3.info_contacts_address)
        self.assert_(info_contacts_city == organization3.info_contacts_city)
        self.assert_(info_contacts_state == organization3.info_contacts_state)
        self.assert_(info_contacts_country == organization3.info_contacts_country)
        self.assert_(info_contacts_zip == organization3.info_contacts_zip)
        self.assert_(info_loc_city == organization3.info_loc_city)
        self.assert_(info_loc_region == organization3.info_loc_region)
        self.assert_(info_loc_country == organization3.info_loc_country)
        self.assert_(misc == organization3.misc)
        self.assert_(personrefs == organization3.personrefs)
        self.assert_(crisisrefs == organization3.crisisrefs)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:67,代码来源:jromeem-TestWC1.py

示例4: test_buildorg1

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildOrganization [as 别名]
    def test_buildorg1(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        
        organization1 = Organization(elemid = "Franch",
    
                                    name = "French pride",
    
                                    info_type = "non-existant",
                                    info_history = "white flags",
                                    info_contacts_phone = "1234567890",
                                    info_contacts_email = "[email protected]",
                                    info_contacts_address = "French",
                                    info_contacts_city = "Paris",
                                    info_contacts_state = "Canada",
                                    info_contacts_country = "USA",
                                    info_contacts_zip = "7890",
    
                                    info_loc_city = "Alaska",
                                    info_loc_region = "Ukraine",
                                    info_loc_country = "Antarctica",
    
                                    personrefs = ["baquettes", "crumpets"],
                                    crisisrefs = ["war", "nazis"],
    
                                    misc = "")

        otree = SubElement(tree, "organization", {"id" : "Franch"})     
        XMLHelpers.buildOrganization(otree, organization1)
        
        elemid = otree.attrib['id'],
        name = otree.find('.//name').text
        info_type = otree.find('.//info').find('.//type').text
        info_history = otree.find('.//info').find('.//history').text
        info_contacts_phone = otree.find('.//info').find('.//contact').find('.//phone').text
        info_contacts_email = otree.find('.//info').find('.//contact').find('.//email').text
        info_contacts_address = otree.find('.//info').find('.//contact').find('.//mail').find('.//address').text
        info_contacts_city = otree.find('.//info').find('.//contact').find('.//mail').find('.//city').text
        info_contacts_state = otree.find('.//info').find('.//contact').find('.//mail').find('.//state').text
        info_contacts_country = otree.find('.//info').find('.//contact').find('.//mail').find('.//country').text
        info_contacts_zip = otree.find('.//info').find('.//contact').find('.//mail').find('.//zip').text
        info_loc_city = otree.find('.//info').find('.//loc').find('.//city').text
        info_loc_region = otree.find('.//info').find('.//loc').find('.//region').text
        info_loc_country = otree.find('.//info').find('.//loc').find('.//country').text

        personrefs = [x.attrib['idref'] for x in otree.findall('.//person')]
        crisisrefs = [x.attrib['idref'] for x in otree.findall('.//crisis')]
        misc = otree.find('.//misc').text
        
        #self.assert_(elemid == organization1.elemid)
        self.assert_(name == organization1.name)
        self.assert_(info_type == organization1.info_type)
        self.assert_(info_history == organization1.info_history)
        self.assert_(info_contacts_phone == organization1.info_contacts_phone)
        self.assert_(info_contacts_email == organization1.info_contacts_email)
        self.assert_(info_contacts_address == organization1.info_contacts_address)
        self.assert_(info_contacts_city == organization1.info_contacts_city)
        self.assert_(info_contacts_state == organization1.info_contacts_state)
        self.assert_(info_contacts_country == organization1.info_contacts_country)
        self.assert_(info_contacts_zip == organization1.info_contacts_zip)
        self.assert_(info_loc_city == organization1.info_loc_city)
        self.assert_(info_loc_region == organization1.info_loc_region)
        self.assert_(info_loc_country == organization1.info_loc_country)
        self.assert_(misc == organization1.misc)
        self.assert_(personrefs == organization1.personrefs)
        self.assert_(crisisrefs == organization1.crisisrefs)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:67,代码来源:jromeem-TestWC1.py


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