本文整理汇总了Python中Channel.fromXml方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.fromXml方法的具体用法?Python Channel.fromXml怎么用?Python Channel.fromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.fromXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromXml
# 需要导入模块: import Channel [as 别名]
# 或者: from Channel import fromXml [as 别名]
def fromXml( lineupXml ):
Log( "Lineup.py fromXml ..." )
"""
Parses a snippet of the XML returned from the SiliconDust site for a
given country and postal code. The XML for a single channel looks like
this:
<Lineup>
<DisplayName>Grande Cable: Austin, TX, 78750</DisplayName>
<ProviderName>Grande Cable</ProviderName>
<DatabaseID>2262080</DatabaseID>
<Program>
....
</Program>
</Lineup>
"""
lineup = Lineup()
lineup.DisplayName = Util.XPathSelectOne( lineupXml, 'DisplayName' )
lineup.ProviderName = Util.XPathSelectOne( lineupXml, 'ProviderName' )
lineup.DatabaseId = Util.XPathSelectOne( lineupXml, 'DatabaseID' )
# ProvideName is used for equality comparison, so we want to work hard
# to make sure it has some value.
if not lineup.ProviderName:
prefixRe = re.compile( r'^([^\:]+)\:' )
reMatch = prefixRe.match( lineup.DisplayName )
if reMatch:
lineup.ProviderName = reMatch.group(1)
if not lineup.ProviderName:
lineup.ProviderName = lineup.DisplayName
if not lineup.ProviderName:
lineup.ProviderName = lineup.DatabaseId
for programXml in lineupXml.xpath('Program'):
lineup.channelList.append( Channel.fromXml( programXml ))
return lineup