本文整理汇总了Python中frontik.doc.Doc.put方法的典型用法代码示例。如果您正苦于以下问题:Python Doc.put方法的具体用法?Python Doc.put怎么用?Python Doc.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frontik.doc.Doc
的用法示例。
在下文中一共展示了Doc.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put_block
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def put_block(name, query_suffix=''):
text = verstka_query + query_suffix;
block = Doc(name)
block.put(Doc('text').put(urllib.quote(text.encode('utf-8'))))
block.put(Doc('last').put(self.get_url_retry(config.api_host + '/1/xml/vacancy/search/', {'text': text, 'items': '5', 'order':'0', 'area':'1', 'professionalAreaId':'1'})))
def put_median(m):
median_block = Doc('median')
median_block.put(str(m))
block.put(median_block)
def count_median_cb(xml, response):
if xml:
m = count_median(xml)
if m:
storage.store_today(name, m)
put_median(m)
if storage.has_today(name):
self.log.debug('show median using cached value')
put_median(storage.get_today(name))
else:
self.log.debug('make search request to count median')
self.get_url_retry(config.api_host + '/1/xml/vacancy/search/', {'text': text, 'order':'0', 'notWithoutSalary': 'true', 'items': '40', 'area':'1', 'professionalAreaId':'1'}, callback=count_median_cb)
self.doc.put(block)
示例2: test_future_etree_element
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_future_etree_element(self):
d = Doc('a')
f = Future()
f.set_result(etree.Element('b'))
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a><b/></a>""")
示例3: get_page
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def get_page(self):
self.set_header('Content-Type', 'application/rss+xml; charset=UTF-8')
self.set_xsl('rss/search.xsl')
handler.do_pagedata(self)
if (self.get_argument('salary', None)):
salary = 'true'
else:
salary = None
search = Doc('search')
search.put(self.get_url_retry(self.config.api_host + '/1/xml/vacancy/search/',
{
'text': utils.parse_text(self.get_argument('text', None)),
'salary': self.get_argument('salary', None),
'field': '1',
'onlysalary': self.get_argument('onlysalary', None),
'area':'1',
'items': '20',
'metro': self.get_argument('metro', None),
'specialization': self.get_argument('specialization', None),
'employment': self.get_argument('employment', None),
'order': self.get_argument('order', None),
})
)
self.doc.put(search)
示例4: get_page
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def get_page(self):
self.set_xsl('search.xsl')
handler.do_pagedata(self)
if (self.get_argument('salary', None)):
salary = 'true'
else:
salary = None
search = Doc('search')
search.put(self.get_url_retry(self.config.api_host + '/1/xml/vacancy/search/',
{
'text': utils.parse_text(self.get_argument('text', None)),
'page': self.get_argument('page', None),
'salary': self.get_argument('salary', None),
'currency': 'RUR',
'field': '1',
'onlysalary': self.get_argument('onlysalary', None),
'area':'1',
'items': '20',
'metro': self.get_argument('metro', None),
'specialization': self.get_argument('specialization', None),
'employment': self.get_argument('employment', None),
'order': self.get_argument('order', None),
'clusters': 'true'
})
)
self.doc.put(search)
示例5: test_future_list
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_future_list(self):
d = Doc('a')
f = Future()
f.set_result([etree.Comment('ccc'), etree.Element('bbb')])
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0'?>\n<a><!--ccc--><bbb/></a>""")
示例6: test_root_node
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_root_node(self):
d = Doc(root_node=etree.Element('doc'))
d.put(etree.Element('test1'))
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<doc><test1/></doc>"""
)
示例7: test_doc_nested
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_doc_nested(self):
a = Doc('a')
b = Doc('b')
a.put(b)
self.assertXmlEqual(
a.to_etree_element(), b"""<?xml version='1.0' encoding='utf-8'?>\n<a><b/></a>"""
)
示例8: test_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_simple(self):
d = Doc('a')
self.assertTrue(d.is_empty())
d.put('test')
self.assertFalse(d.is_empty())
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>test</a>""")
示例9: test_root_node_doc
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_root_node_doc(self):
d1 = Doc('a')
d1.put(etree.Comment('1'))
d2 = Doc(root_node=d1)
d2.put(etree.Comment('2'))
self.assertXmlEqual(
d2.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a><!--1--><!--2--></a>"""
)
示例10: test_future_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_future_simple(self):
d = Doc('a')
f = Future()
d.put(f)
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a/>""")
f.set_result('test')
self.assertXmlEqual(d.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>test</a>""")
示例11: test_failed_future
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_failed_future(self):
d = Doc('a')
f = Future()
result = self.get_test_request_result()
result._data_parse_error = DataParseError(reason='error', code='code')
f.set_result(result)
d.put(f)
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0'?>\n<a><error reason="error" code="code"/></a>"""
)
示例12: test_nodes_and_text
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_nodes_and_text(self):
a = Doc('a')
a.put('1')
a.put(Doc('b'))
a.put('2')
a.put(Doc('c'))
a.put('3')
self.assertXmlAlmostEqual(
a.to_etree_element(), """<?xml version='1.0' encoding='utf-8'?>\n<a>1<b/>2<c/>3</a>"""
)
示例13: test_future_string_value
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_future_string_value(self):
d = Doc('a')
f = Future()
result = self.get_test_request_result()
result._content_type = 'text'
result._data = 'plain_text'
f.set_result(result)
d.put(f)
self.assertXmlEqual(
d.to_etree_element(), """<?xml version='1.0'?>\n<a></a>"""
)
示例14: test_serializable
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_serializable(self):
class Serializable(object):
def __init__(self, tag, value):
self.tag = tag
self.value = value
def to_etree_element(self):
result = etree.Element(self.tag)
result.text = self.value
return result
a = Doc('a')
a.put(Serializable('testNode', 'vally'))
self.assertEqual(a.to_string(), """<?xml version='1.0' encoding='utf-8'?>\n<a><testNode>vally</testNode></a>""")
示例15: test_simple
# 需要导入模块: from frontik.doc import Doc [as 别名]
# 或者: from frontik.doc.Doc import put [as 别名]
def test_simple(self):
d = Doc('a')
self.assertTrue(d.is_empty())
d.put(None)
self.assertXmlEqual(d.to_etree_element(), b'<a/>')
node = etree.Element('b')
node.text = 'тест'
d.put(node)
self.assertFalse(d.is_empty())
self.assertXmlEqual(
d.to_etree_element(),
b"""<?xml version='1.0' encoding='utf-8'?>\n<a><b>\xd1\x82\xd0\xb5\xd1\x81\xd1\x82</b></a>"""
)