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


Python doc.Doc类代码示例

本文整理汇总了Python中frontik.doc.Doc的典型用法代码示例。如果您正苦于以下问题:Python Doc类的具体用法?Python Doc怎么用?Python Doc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_page

 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)
开发者ID:AndrewSumin,项目名称:hephaestus,代码行数:29,代码来源:search.py

示例2: test_future_list

    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>""")
开发者ID:hhru,项目名称:frontik,代码行数:7,代码来源:test_doc.py

示例3: test_root_node

    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>"""
        )
开发者ID:strogo,项目名称:frontik,代码行数:7,代码来源:test_doc.py

示例4: put_block

        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)
开发者ID:elephantum,项目名称:hephaestus,代码行数:27,代码来源:index.py

示例5: test_future_etree_element

    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>""")
开发者ID:strogo,项目名称:frontik,代码行数:7,代码来源:test_doc.py

示例6: get_page

 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)
开发者ID:AndrewSumin,项目名称:hephaestus,代码行数:27,代码来源:search.py

示例7: test_doc_nested

    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>"""
        )
开发者ID:hhru,项目名称:frontik,代码行数:8,代码来源:test_doc.py

示例8: test_future_simple

    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>""")
开发者ID:strogo,项目名称:frontik,代码行数:10,代码来源:test_doc.py

示例9: test_failed_future

    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>"""
        )
开发者ID:hhru,项目名称:frontik,代码行数:11,代码来源:test_doc.py

示例10: test_future_string_value

    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>"""
        )
开发者ID:hhru,项目名称:frontik,代码行数:12,代码来源:test_doc.py

示例11: test_other_types

    def test_other_types(self):
        a = Doc('a')
        a.put(1)
        a.put(2.0)
        a.put((3, 4, 5))

        self.assertEqual(a.to_string(), """<?xml version='1.0' encoding='utf-8'?>\n<a>12.0(3, 4, 5)</a>""")
开发者ID:strogo,项目名称:frontik,代码行数:7,代码来源:test_doc.py

示例12: test_serializable

    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>""")
开发者ID:strogo,项目名称:frontik,代码行数:14,代码来源:test_doc.py

示例13: put_block

        def put_block(id, name, query_suffix=''):
            text = verstka_query + query_suffix;
            block = Doc('tab')

            block.put(Doc('name').put(name))
            block.put(Doc('text').put(urllib.quote(text.encode('utf-8'))))
            block.put(Doc('last').put(self.get_url_retry(self.config.api_host + '/1/xml/vacancy/search/', {'text': utils.parse_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 is not None:
                    m = count_median(xml)
                    if m:
                        #median_storage.store_today(id, m, self)
                        put_median(m)
                        
            
#            self.log.debug('+++++++++++++++++++++++++++++++++++++++')
#            self.log.debug(storage.get_last_week_salaries(id))
            # if median_storage.has_today(id):
            #     self.log.debug('show median using cached value')
            #     put_median(storage.get_today(id))
            # else:
            self.log.debug('make search request to count median')
            self.get_url_retry(self.config.api_host + '/1/xml/vacancy/search/', {'text': utils.parse_text(text), 'order':'0', 'notWithoutSalary': 'true', 'items': '40', 'area':'1', 'professionalAreaId':'1'}, callback=count_median_cb)
            
            tabs.put(block)
开发者ID:AndrewSumin,项目名称:hephaestus,代码行数:31,代码来源:index.py

示例14: test_root_node_doc

    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>"""
        )
开发者ID:strogo,项目名称:frontik,代码行数:10,代码来源:test_doc.py

示例15: test_simple

    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>"""
        )
开发者ID:hhru,项目名称:frontik,代码行数:18,代码来源:test_doc.py


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