本文整理汇总了Python中xpath.find函数的典型用法代码示例。如果您正苦于以下问题:Python find函数的具体用法?Python find怎么用?Python find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getProfileEndpointType
def getProfileEndpointType(self):
'''Retrieve all profile nodes and get information of EDP type'''
rst_data = []
for profile_node in xpath.find('//profile', self.__xmldoc):
profile_id = profile_node.getAttribute('id')
profile_name = profile_node.getAttribute('name')
for edp_type_node in xpath.find('//profile[@id=$id][@name=$nm]/data/endpoint_type', self.__xmldoc, id=profile_id, nm=profile_name):
edp_type = {}
edp_type['Device_ID'] = self.device_id
edp_type['Profile'] = profile_id
edp_type['Endpoint_Type'] = edp_type_node.getAttribute('id')
edp_type['calibration_boost'] = edp_type_node.getElementsByTagName('calibration-boost')[0].getAttribute('value')
edp_type['dialog_enhancer_enable'] = edp_type_node.getElementsByTagName('dialog-enhancer-enable')[0].getAttribute('value')
edp_type['dialog_enhancer_amount'] = edp_type_node.getElementsByTagName('dialog-enhancer-amount')[0].getAttribute('value')
edp_type['dialog_enhancer_ducking'] = edp_type_node.getElementsByTagName('dialog-enhancer-ducking')[0].getAttribute('value')
edp_type['surround_boost'] = edp_type_node.getElementsByTagName('surround-boost')[0].getAttribute('value')
edp_type['volmax_boost'] = edp_type_node.getElementsByTagName('volmax-boost')[0].getAttribute('value')
edp_type['volume_leveler_enable'] = edp_type_node.getElementsByTagName('volume-leveler-enable')[0].getAttribute('value')
edp_type['volume_leveler_amount'] = edp_type_node.getElementsByTagName('volume-leveler-amount')[0].getAttribute('value')
edp_type['intermediate_profile_partial_virtualizer_enable'] = edp_type_node.getElementsByTagName('intermediate_profile_partial_virtualizer_enable')[0].getAttribute('value')
self.__convertBoolToInt(edp_type)
rst_data.append(edp_type)
return rst_data
开发者ID:holphi,项目名称:Miscellaneous,代码行数:27,代码来源:dttparser.py
示例2: get_free_lst
def get_free_lst(cookies):
import xpath
import xml.dom.minidom
global round_cnt
global request_cnt
#request_cnt = 0
request_cnt += 1
print 'Request %d of round %d begin.'%(request_cnt, round_cnt)
res = requests.get(free_url, cookies = cookies)
html = res.text
tbody = html[html.index('<tbody'):html.index('</tbody>') + len('</tbody>')]
doc = xml.dom.minidom.parseString(tbody)
entries = xpath.find('tr', doc.documentElement)
#print len(entries)
frees = []
i = 1
for entry in entries:
tds = xpath.find('td/text()', entry)
#print len(tds)
free = [i]
i += 1
for td in tds:
free.append(str(td.toxml()))
frees.append(free)
#print_frees(frees)
return frees
开发者ID:betterenvi,项目名称:ss-link,代码行数:27,代码来源:get_ss_link.py
示例3: __fetchInheritedValue
def __fetchInheritedValue(lineage, property, searchpath):
# Attempt to open every xml file in the search path, yuck, and if the
# file contains a list of objects, then search that file for the current
# class.
for c in lineage:
for p in searchpath:
if (os.path.isdir(p)):
for d in os.listdir(p):
(f, ext) = os.path.splitext(p)
if ext in (".xml"):
dom = parse(d)
## we have a parse dom, check to see if the file entity is objects
node = xpath.find("/objects/object[id='" + c + "']/property[id='" + property + "']")
if node != None:
# Found the class and property we are looking for so return the value
# The value of the node should be its text node
return node.getTextNode()
else:
# not a directory, just a file
dom = parse(p)
## we have a parse dom, check to see if the file entity is objects
node = xpath.find("/objects/object[id='" + c + "']/property[id='" + property + "']")
if node != None:
# Found the class and property we are looking for so return the value
# The value of the node should be its text node
return node.getTextNode()
log.debug("Inherited property value request, none found")
return None
开发者ID:davidkbainbridge,项目名称:zails,代码行数:28,代码来源:add_object_property.py
示例4: __addSessionToCommandFile
def __addSessionToCommandFile(self, nBI, sessionID, initDate):
try:
doc = parse(self.commandsFilePath)
node = xpath.find("/commandsLog/user[@nBI='" + nBI + "']", doc)
if len(node) > 0:
userElement = node[0]
sessionElement = doc.createElement("session")
userElement.appendChild(sessionElement)
sessionElement.setAttribute("sessionID", sessionID)
sessionElement.setAttribute("sessionStart", initDate)
sessionElement.setAttribute("sessionEnd", "")
else:
topElement = xpath.find("/commandsLog", doc)[0]
newElement = doc.createElement("user")
topElement.appendChild(newElement)
newElement.setAttribute("nBI", nBI)
sessionElement = doc.createElement("session")
newElement.appendChild(sessionElement)
sessionElement.setAttribute("sessionID", sessionID)
sessionElement.setAttribute("sessionStart", initDate)
sessionElement.setAttribute("sessionEnd", "")
self.__writeToXMLFile(doc)
except:
raise Exception("It was not possible to add the user to de command file")
开发者ID:CCardosoDev,项目名称:LinuxActivityLog,代码行数:28,代码来源:ActiveUsers.py
示例5: test_self
def test_self(self):
doc = xml.dom.minidom.parseString("""
<doc>
<para />
</doc>
""").documentElement
para_node = xpath.findnode('para', doc)
self.failUnlessEqual(len(xpath.find('self::para', doc)), 0)
self.failUnlessEqual(len(xpath.find('self::para', para_node)), 1)
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:9,代码来源:paths.py
示例6: test_partition
def test_partition(self):
"""Test that the ancestor, descendant, following, preceding, and
self axes partition the document.
"""
a = xpath.find('//*', self.doc)
a.sort()
b = []
node = xpath.findnode('//*[@id="2.2"]', self.doc)
for axis in ('ancestor','descendant','following','preceding','self'):
b.extend(xpath.find('%s::*' % axis, node))
b.sort()
self.failUnlessEqual(a, b)
开发者ID:davidkbainbridge,项目名称:zails,代码行数:15,代码来源:axes.py
示例7: getDeviceTuning
def getDeviceTuning(self):
'''Retrieve all tuning data'''
rst_data = []
for tuning_node in xpath.find('//tuning', self.__xmldoc):
tuning_data = {}
tuning_data['Device_ID'] = self.device_id
tuning_data['name'] = tuning_node.getAttribute('name')
tuning_data['profile_restrictions'] = tuning_node.hasAttribute('profile_restrictions') and tuning_node.getAttribute('profile_restrictions') or 'none'
tuning_data['classification'] = tuning_node.getAttribute('classification')
tuning_data['endpoint_type'] = tuning_node.getAttribute('endpoint_type')
tuning_data['mono_device'] = tuning_node.getAttribute('mono_device')
tuning_data['has_sub'] = tuning_node.getAttribute('has_sub')
tuning_data['tuned_rate']= tuning_node.getAttribute('tuned_rate')
#Reserverd field
tuning_data['preGain'] = ''
#Reserverd field
tuning_data['postGain'] = ''
#Retrieve tuning parameters under //tuning/data
self.__processTuningParams(tuning_data['name'], tuning_data['profile_restrictions'], tuning_data)
#Format values, convert bool value to int value
self.__convertBoolToInt(tuning_data)
rst_data.append(tuning_data)
return rst_data
开发者ID:holphi,项目名称:Miscellaneous,代码行数:29,代码来源:dttparser.py
示例8: _ensure_items_parsed
def _ensure_items_parsed(self):
self.ensure_loaded()
if self._items is None:
self._items = dict([(item.getAttribute('name'),
item.getAttribute('href'))
for item in xpath.find('//Catalog/CatalogItems/CatalogItem',
self.doc)])
开发者ID:AnneCarpenter,项目名称:CellProfiler-build,代码行数:7,代码来源:vcloud.py
示例9: catalogs
def catalogs(self):
self.ensure_loaded()
els = xpath.find('//Org/Link[@type="%s"]' % Catalog.content_type,
self.doc)
return dict([(el.getAttribute('name'),
Catalog(self.session, el.getAttribute('href')))
for el in els])
开发者ID:AnneCarpenter,项目名称:CellProfiler-build,代码行数:7,代码来源:vcloud.py
示例10: _get_attribute
def _get_attribute(self, xq, attr, default=None):
self.ensure_loaded()
els = xpath.find(xq, self.doc)
if els:
return els[0].getAttribute(attr)
else:
return default
开发者ID:AnneCarpenter,项目名称:CellProfiler-build,代码行数:7,代码来源:vcloud.py
示例11: _get_text_children
def _get_text_children(self, xq):
self.ensure_loaded()
els = xpath.find(xq, self.doc)
if els:
return get_text(els[0].childNodes)
else:
return None
开发者ID:AnneCarpenter,项目名称:CellProfiler-build,代码行数:7,代码来源:vcloud.py
示例12: test_text_children
def test_text_children(self):
doc = xml.dom.minidom.parseString("""
<doc>This is <i>some</i> text.</doc>
""").documentElement
result = xpath.find('child::text()', doc)
self.failUnlessEqual([x.data for x in result],
["This is ", " text."])
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:7,代码来源:paths.py
示例13: getGEQBands
def getGEQBands(self):
'''Get all IEQ bands information'''
rst_data = []
for geqInst in xpath.find('//preset[@type="geq"]/@id', self.__xmldoc):
rst_data.append(self.__getGEQRecord(geqInst.value))
#return geq band info
return rst_data
开发者ID:holphi,项目名称:Miscellaneous,代码行数:7,代码来源:dttparser.py
示例14: test_all_attributes
def test_all_attributes(self):
doc = xml.dom.minidom.parseString("""
<doc name="foo" value="bar" />
""").documentElement
result = xpath.find('attribute::*', doc)
self.failUnlessEqual([(x.name, x.value) for x in result],
[('name', 'foo'), ('value', 'bar')])
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:7,代码来源:paths.py
示例15: refresh_movie_source
def refresh_movie_source(request):
if 'source_key' not in request.REQUEST:
return HttpResponseServerError('No source key specified in request params')
source = models.MovieListingSource.get(request.REQUEST['source_key'])
if not source:
logging.error('Unable to find MovieListingSource: %s', request.REQUEST['source_key'])
return HttpResponse('Error unable to find Source')
elif not source.yql:
logging.error('No yql for MovieListingSource: %s' % str(source))
return HttpResponse('No YQL for source')
elif not source.settings:
logging.error('No settings for MovieListingSource: %s' % str(source))
return HttpResponse('No settings for source')
logging.info('Refreshing movie from source %s', str(source))
yql = source.yql
if 'offset' in request.REQUEST:
query_offset = int(request.REQUEST['offset']) + 1
yql = '%s limit %d offset %d' % (yql, settings.MOVIE_REFRESH_QUERY_SIZE, query_offset)
form_data = urllib.urlencode({"q": yql, "format": "xml", "diagnostics": "false"})
result = urlfetch.fetch(url=settings.YQL_BASE_URL,payload=form_data,method=urlfetch.POST)
dom = minidom.parseString(result.content)
result_nodes = dom.getElementsByTagName('results')[0].childNodes
name_nodes = xpath.find(source.settings.name_xpath, dom)
leaches_nodes = xpath.find(source.settings.leaches_xpath, dom)
logging.info('Found %d raw names', len(name_nodes))
strip_white_pattern = re.compile(r"\s+")
source_results = []
for index, name_node in enumerate(name_nodes):
logging.debug('Node: ' + result_nodes[index].toxml())
raw_name = strip_white_pattern.sub(' ', getText(name_node))
leaches = strip_white_pattern.sub(' ', getText(leaches_nodes[index]))
logging.info('Raw Name: %s, Leaches: %s', raw_name, leaches)
source_results.append(models.MovieListEntry(raw_movie_name=raw_name, leaches=int(leaches), active=False))
db.put(source_results)
#Refresh done using map/reduce. First we map to find the movie details
for source_result in source_results:
taskqueue.add(url=reverse('topmovies.task_handler.find_movie'), params={'source_entry_key': source_result.key()})
return HttpResponse("Loaded results for source: %s" % str(source))
开发者ID:frankk00,项目名称:movgae,代码行数:47,代码来源:task_handler.py
示例16: getIEQBands
def getIEQBands(self):
'''Get all IEQ bands information.'''
rst_data = []
for ieqInst in xpath.find('//preset[@type="ieq"]/@id', self.__xmldoc):
#Pass ieq ID & append the result to the list
rst_data.append(self.__getIEQRecord(ieqInst.value))
#return ieq band info
return rst_data
开发者ID:holphi,项目名称:Miscellaneous,代码行数:8,代码来源:dttparser.py
示例17: test_root
def test_root(self):
doc = xml.dom.minidom.parseString("""
<doc><a><b><context /></b></a></doc>
""").documentElement
node = xpath.findnode('//context', doc)
result = xpath.find('/', node)
self.failUnlessEqual([x.nodeType for x in result],
[xml.dom.Node.DOCUMENT_NODE])
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:8,代码来源:paths.py
示例18: test_pi_element
def test_pi_element(self):
doc = xml.dom.minidom.parseString("""
<doc>
<processing-instruction id="1">text</processing-instruction>
</doc>
""")
result = xpath.find("//processing-instruction", doc)
self.failUnlessEqual([x.getAttribute("id") for x in result], ["1"])
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:8,代码来源:paths.py
示例19: test_comment_element
def test_comment_element(self):
doc = xml.dom.minidom.parseString("""
<doc>
<comment id="1">text</comment>
</doc>
""")
result = xpath.find("//comment", doc)
self.failUnlessEqual([x.getAttribute("id") for x in result], ["1"])
开发者ID:dhbradshaw,项目名称:py-xpath2,代码行数:8,代码来源:paths.py
示例20: test_self
def test_self(self):
doc = xml.dom.minidom.parseString("""
<doc id="0">
<para id="1"/>
</doc>
""").documentElement
result = xpath.find('.', doc)
self.failUnlessEqual([x.getAttribute("id") for x in result],
["0"])
开发者ID:davidkbainbridge,项目名称:zails,代码行数:9,代码来源:abbreviations.py
注:本文中的xpath.find函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论