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


Python XMLHelpers.buildCrisis方法代码示例

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


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

示例1: test_exportlinks3

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildCrisis [as 别名]
    def test_exportlinks3(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        crisis1 = Crisis(elemid = "hunger",
                    name = "hunger",
                    misc = "na",
                    
                    info_history = "this year",
                    info_help = "help",
                    info_resources = "awareness",
                    info_type = "hunger attack",
                    
                    date_time = "11 am",
                    date_day = 18,
                    date_month = 03,
                    date_year = 2012,
                    date_misc = "still alive",
                    
                    location_city = "houston",
                    location_region = "texas",
                    location_country = "USA",
                    
                    impact_human_deaths = 200,
                    impact_human_displaced = 20,
                    impact_human_injured = 1,
                    impact_human_missing = 32,
                    impact_human_misc = "none",
                    
                    impact_economic_amount = 400,
                    impact_economic_currency = "yen",
                    impact_economic_misc = "misc",
                    
                    orgrefs = ["dea", "cia"],
                    personrefs = ["you", "me"])
                                
         
                                
                                
        ctree = SubElement(tree, "crisis", {"id" : "hunger"})     
        XMLHelpers.buildCrisis(ctree, crisis1)
        
        
        link1 = Link(link_parent = "hunger",
                    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(crisis1, ctree)
        
        for ref in ctree.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 = ctree.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,代码行数:77,代码来源:jromeem-TestWC1.py

示例2: test_buildcrisis2

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildCrisis [as 别名]
    def test_buildcrisis2(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        crisis1 = Crisis(

                elemid = "plagues",
                name = "plagues",
                misc = "aids virus",
                
                info_history = "last year",
                info_help = "help",
                info_resources = "aids awareness",
                info_type = "virus attack",


                
                date_time = "1 pm",
                date_day = 1,
                date_month = 8,
                date_year = 1966,
                date_misc = "still happening",
                

                location_city = "LA",
                location_region = "California",

                location_country = "USA",
                
                impact_human_deaths = 20000,
                impact_human_displaced = 2540,
                impact_human_injured = 1123,

                impact_human_missing = 332,
                impact_human_misc = "none",
                
                impact_economic_amount = 442100,
                impact_economic_currency = "dollars",
                impact_economic_misc = "misc",
                
                orgrefs = ["dea", "cia"],
                personrefs = ["Magic Johnson", "me"]


                )
        ctree = SubElement(tree, "crisis", {"id" : "plagues"})
        XMLHelpers.buildCrisis(ctree, crisis1)


        elemid = ctree.attrib['id']
        name = ctree.find('.//name').text
        misc = ctree.find('.//misc').text
        info_history = ctree.find('.//history').text
        info_help = ctree.find('.//help').text
        info_resources = ctree.find('.//resources').text
        info_type = ctree.find('.//type').text
        date_time = ctree.find('.//time').find('.//time').text
        date_day = int(ctree.find('.//time').find('.//day').text)
        date_month = int(ctree.find('.//time').find('.//month').text)
        date_year = int(ctree.find('.//time').find('.//year').text)
        date_misc = ctree.find('.//time').find('.//misc').text
        location_city = ctree.find('.//loc').find('.//city').text
        location_region = ctree.find('.//loc').find('.//region').text
        location_country = ctree.find('.//loc').find('.//country').text
        impact_human_deaths = int(ctree.find('.//impact').find('.//human').find('.//deaths').text)
        impact_human_displaced = int(ctree.find('.//impact').find('.//human').find('.//displaced').text)
        impact_human_injured = int(ctree.find('.//impact').find('.//human').find('.//injured').text)
        impact_human_missing = int(ctree.find('.//impact').find('.//human').find('.//missing').text)
        impact_human_misc = ctree.find('.//impact').find('.//human').find('.//misc').text
        impact_economic_amount = int(ctree.find('.//impact').find('.//economic').find('.//amount').text)
        impact_economic_currency = ctree.find('.//impact').find('.//economic').find('.//currency').text
        impact_economic_misc = ctree.find('.//impact').find('.//economic').find('.//misc').text
        orgrefs = [x.attrib['idref'] for x in ctree.findall('.//org')]
        personrefs = [x.attrib['idref'] for x in ctree.findall('.//person')]


        self.assert_(elemid == crisis1.elemid)
        self.assert_(name == crisis1.name)
        #self.assert_(misc == crisis1.misc)
        self.assert_(info_history == crisis1.info_history)
        self.assert_(info_help == crisis1.info_help)
        self.assert_(info_resources == crisis1.info_resources)
        self.assert_(info_type == crisis1.info_type)
        self.assert_(date_time == crisis1.date_time)
        self.assert_(date_day == crisis1.date_day)
        self.assert_(date_month == crisis1.date_month)
        self.assert_(date_year == crisis1.date_year)
        self.assert_(date_misc == crisis1.date_misc)
        self.assert_(location_city == crisis1.location_city)

        self.assert_(location_region == crisis1.location_region)
        self.assert_(location_country == crisis1.location_country)
        self.assert_(impact_human_deaths == crisis1.impact_human_deaths)
        self.assert_(impact_human_displaced == crisis1.impact_human_displaced)
        self.assert_(impact_human_injured == crisis1.impact_human_injured)
        self.assert_(impact_human_missing == crisis1.impact_human_missing)
        self.assert_(impact_human_misc == crisis1.impact_human_misc)
        #self.assert_(impact_economic_amount == crisis1.impact_econmic_amount)
        self.assert_(impact_economic_currency == crisis1.impact_economic_currency)
        self.assert_(impact_economic_misc == crisis1.impact_economic_misc)
        self.assert_(orgrefs == crisis1.orgrefs)
        self.assert_(personrefs == crisis1.personrefs)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:102,代码来源:jromeem-TestWC1.py

示例3: test_buildcrisis3

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildCrisis [as 别名]
    def test_buildcrisis3(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        crisis1 = Crisis(

                elemid = "blank",
                name = "",
                misc = "",
                
                info_history = "",
                info_help = "",
                info_resources = "",
                info_type = "",


                
                date_time = "",
                date_day = 0,
                date_month = 0,
                date_year = 20,
                date_misc = "",
                

                location_city = "",
                location_region = "",

                location_country = "",
                
                impact_human_deaths = 0,
                impact_human_displaced = 0,
                impact_human_injured = 0,

                impact_human_missing = 0,
                impact_human_misc = "",
                
                impact_economic_amount = 0,
                impact_economic_currency = "",
                impact_economic_misc = "",
                
                orgrefs = ["", ""],
                personrefs = ["", ""]


                )
        ctree = SubElement(tree, "crisis", {"id" : "blank"})
        XMLHelpers.buildCrisis(ctree, crisis1)


        elemid = ctree.attrib['id']
        name = ctree.find('.//name').text
        misc = ctree.find('.//misc').text
        info_history = ctree.find('.//history').text
        info_help = ctree.find('.//help').text
        info_resources = ctree.find('.//resources').text
        info_type = ctree.find('.//type').text
        date_time = ctree.find('.//time').find('.//time').text
        date_day = int(ctree.find('.//time').find('.//day').text)
        date_month = int(ctree.find('.//time').find('.//month').text)
        date_year = int(ctree.find('.//time').find('.//year').text)
        date_misc = ctree.find('.//time').find('.//misc').text
        location_city = ctree.find('.//loc').find('.//city').text
        location_region = ctree.find('.//loc').find('.//region').text
        location_country = ctree.find('.//loc').find('.//country').text
        impact_human_deaths = int(ctree.find('.//impact').find('.//human').find('.//deaths').text)
        impact_human_displaced = int(ctree.find('.//impact').find('.//human').find('.//displaced').text)
        impact_human_injured = int(ctree.find('.//impact').find('.//human').find('.//injured').text)
        impact_human_missing = int(ctree.find('.//impact').find('.//human').find('.//missing').text)
        impact_human_misc = ctree.find('.//impact').find('.//human').find('.//misc').text
        impact_economic_amount = int(ctree.find('.//impact').find('.//economic').find('.//amount').text)
        impact_economic_currency = ctree.find('.//impact').find('.//economic').find('.//currency').text
        impact_economic_misc = ctree.find('.//impact').find('.//economic').find('.//misc').text
        orgrefs = [x.attrib['idref'] for x in ctree.findall('.//org')]
        personrefs = [x.attrib['idref'] for x in ctree.findall('.//person')]


        self.assert_(elemid == crisis1.elemid)
        self.assert_(name == crisis1.name)
        self.assert_(misc == crisis1.misc)
        self.assert_(info_history == crisis1.info_history)
        self.assert_(info_help == crisis1.info_help)
        self.assert_(info_resources == crisis1.info_resources)
        self.assert_(info_type == crisis1.info_type)
        self.assert_(date_time == crisis1.date_time)
        self.assert_(date_day == crisis1.date_day)
        self.assert_(date_month == crisis1.date_month)
        self.assert_(date_year == crisis1.date_year)
        self.assert_(date_misc == crisis1.date_misc)
        self.assert_(location_city == crisis1.location_city)

        self.assert_(location_region == crisis1.location_region)
        self.assert_(location_country == crisis1.location_country)
        self.assert_(impact_human_deaths == crisis1.impact_human_deaths)
        self.assert_(impact_human_displaced == crisis1.impact_human_displaced)
        self.assert_(impact_human_injured == crisis1.impact_human_injured)
        self.assert_(impact_human_missing == crisis1.impact_human_missing)
        self.assert_(impact_human_misc == crisis1.impact_human_misc)
        #self.assert_(impact_economic_amount == crisis1.impact_econmic_amount)
        self.assert_(impact_economic_currency == crisis1.impact_economic_currency)
        self.assert_(impact_economic_misc == crisis1.impact_economic_misc)
        self.assert_(orgrefs == crisis1.orgrefs)
        self.assert_(personrefs == crisis1.personrefs)
开发者ID:hychyc071,项目名称:cs373-wc1-tests,代码行数:102,代码来源:jromeem-TestWC1.py

示例4: test_buildcrisis1

# 需要导入模块: import XMLHelpers [as 别名]
# 或者: from XMLHelpers import buildCrisis [as 别名]
    def test_buildcrisis1(self):
        tree = Element("worldCrises", {"xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" : "wc.xsd"})
        crisis1 = Crisis(

                    elemid = "hunger",
                    name = "hunger",
                    misc = "na",
                    
                    info_history = "this year",
                    info_help = "help",
                    info_resources = "awareness",
                    info_type = "hunger attack",

                    date_time = "11 am",
                    date_day = 18,
                    date_month = 03,
                    date_year = 2012,
                    date_misc = "still alive",
                    
                    location_city = "houston",
                    location_region = "texas",

                    location_country = "USA",
                    
                    impact_human_deaths = 200,
                    impact_human_displaced = 20,
                    impact_human_injured = 1,

                    impact_human_missing = 32,
                    impact_human_misc = "none",
                    
                    impact_economic_amount = 400,
                    impact_economic_currency = "yen",
                    impact_economic_misc = "misc",
                    
                    orgrefs = ["dea", "cia"],
                    personrefs = ["you", "me"]
                    )
        
        ctree = SubElement(tree, "crisis", {"id" : "hunger"})
        XMLHelpers.buildCrisis(ctree, crisis1)


        elemid = ctree.attrib['id']
        name = ctree.find('.//name').text
        misc = ctree.find('./misc').text
        info_history = ctree.find('.//history').text
        info_help = ctree.find('.//help').text
        info_resources = ctree.find('.//resources').text
        info_type = ctree.find('.//type').text
        date_time = ctree.find('.//time').find('.//time').text
        date_day = int(ctree.find('.//time').find('.//day').text)
        date_month = int(ctree.find('.//time').find('.//month').text)
        date_year = int(ctree.find('.//time').find('.//year').text)
        date_misc = ctree.find('.//time').find('.//misc').text
        location_city = ctree.find('.//loc').find('.//city').text
        location_region = ctree.find('.//loc').find('.//region').text
        location_country = ctree.find('.//loc').find('.//country').text
        impact_human_deaths = int(ctree.find('.//impact').find('.//human').find('.//deaths').text)
        impact_human_displaced = int(ctree.find('.//impact').find('.//human').find('.//displaced').text)
        impact_human_injured = int(ctree.find('.//impact').find('.//human').find('.//injured').text)
        impact_human_missing = int(ctree.find('.//impact').find('.//human').find('.//missing').text)
        impact_human_misc = ctree.find('.//impact').find('.//human').find('.//misc').text
        impact_economic_amount = int(ctree.find('.//impact').find('.//economic').find('.//amount').text)
        impact_economic_currency = ctree.find('.//impact').find('.//economic').find('.//currency').text
        impact_economic_misc = ctree.find('.//impact').find('.//economic').find('.//misc').text
        orgrefs = [x.attrib['idref'] for x in ctree.findall('.//org')]
        personrefs = [x.attrib['idref'] for x in ctree.findall('.//person')]


        self.assert_(elemid == crisis1.elemid)
        self.assert_(name == crisis1.name)
        self.assertEqual(misc , crisis1.misc)
        self.assert_(info_history == crisis1.info_history)
        self.assert_(info_help == crisis1.info_help)
        self.assert_(info_resources == crisis1.info_resources)
        self.assert_(info_type == crisis1.info_type)
        self.assert_(date_time == crisis1.date_time)
        self.assert_(date_day == crisis1.date_day)
        self.assert_(date_month == crisis1.date_month)
        self.assert_(date_year == crisis1.date_year)
        self.assert_(date_misc == crisis1.date_misc)
        self.assert_(location_city == crisis1.location_city)

        self.assert_(location_region == crisis1.location_region)
        self.assert_(location_country == crisis1.location_country)
        self.assert_(impact_human_deaths == crisis1.impact_human_deaths)
        self.assert_(impact_human_displaced == crisis1.impact_human_displaced)
        self.assert_(impact_human_injured == crisis1.impact_human_injured)
        self.assert_(impact_human_missing == crisis1.impact_human_missing)
        self.assert_(impact_human_misc == crisis1.impact_human_misc)
        self.assert_(impact_economic_amount == crisis1.impact_economic_amount)
        self.assert_(impact_economic_currency == crisis1.impact_economic_currency)
        self.assert_(impact_economic_misc == crisis1.impact_economic_misc)
        self.assert_(orgrefs == crisis1.orgrefs)
        self.assert_(personrefs == crisis1.personrefs)
开发者ID:jromeem,项目名称:cs373-wc,代码行数:98,代码来源:TestWC1.py


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