python类describe()的实例源码

commands.py 文件源码 项目:vspheretools 作者: devopshq 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _writedoc(doc, thing, forceload=0):
    """Write HTML documentation to a file in the current directory.
    """
    try:
        obj, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(obj), pydoc.html.document(obj, name))
        fname = os.path.join(doc, name + '.html')
        fd = open(fname, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport):
        traceback.print_exc(sys.stderr)
    else:
        return name + '.html'
commands.py 文件源码 项目:vspheretools 作者: devopshq 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _writeclientdoc(doc, thing, forceload=0):
    """Write HTML documentation to a file in the current directory.
    """
    docmodule = pydoc.HTMLDoc.docmodule
    def strongarm(self, obj, name=None, mod=None, *ignored):
        result = docmodule(self, obj, name, mod, *ignored)

        # Grab all the aliases to pyclasses and create links.
        nonmembers = []
        push = nonmembers.append
        for k,v in inspect.getmembers(obj, inspect.isclass):
            if inspect.getmodule(v) is not obj and getattr(v,'typecode',None) is not None:
                push('<a href="%s.html">%s</a>: pyclass alias<br/>' %(v.__name__,k))

        result += self.bigsection('Aliases', '#ffffff', '#eeaa77', ''.join(nonmembers))
        return result

    pydoc.HTMLDoc.docmodule = strongarm
    try:
        obj, name = pydoc.resolve(thing, forceload)
        page = pydoc.html.page(pydoc.describe(obj), pydoc.html.document(obj, name))
        name = os.path.join(doc, name + '.html')
        fd = open(name, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))

    pydoc.HTMLDoc.docmodule = docmodule
commands.py 文件源码 项目:vspheretools 作者: devopshq 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _writebrokedoc(doc, ex, name, forceload=0):
    try:
        fname = os.path.join(doc, name + '.html')
        page = pydoc.html.page(pydoc.describe(ex), pydoc.html.document(str(ex), fname))
        fd = open(fname, 'w')
        fd.write(page)
        fd.close()
    except (ImportError, pydoc.ErrorDuringImport), value:
        log.debug(str(value))

    return name + '.html'
test_pydoc.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_classic_class(self):
        class C: "Classic class"
        c = C()
        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'instance of C')
        expected = 'instance of C in module %s' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_classic_class(self):
        class C: "Classic class"
        c = C()
        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'instance of C')
        expected = 'instance of C in module %s' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_classic_class(self):
        class C: "Classic class"
        c = C()
        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'instance of C')
        expected = 'instance of C in module %s' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_classic_class(self):
        class C: "Classic class"
        c = C()
        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'instance of C')
        expected = 'instance of C in module %s' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_class(self):
        class C(object): "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
test_pydoc.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_class(self):
        class C: "New-style class"
        c = C()

        self.assertEqual(pydoc.describe(C), 'class C')
        self.assertEqual(pydoc.describe(c), 'C')
        expected = 'C in module %s object' % __name__
        self.assertIn(expected, pydoc.render_doc(c))
pydoc2.py 文件源码 项目:pypydispatcher 作者: scrapy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def process( self ):
        """Having added all of the base and/or interesting modules,
        proceed to generate the appropriate documentation for each
        module in the appropriate directory, doing the recursion
        as we go."""
        try:
            while self.pending:
                try:
                    if self.completed.has_key( self.pending[0] ):
                        raise AlreadyDone( self.pending[0] )
                    self.info( """Start %s"""% (repr(self.pending[0])))
                    object = pydoc.locate ( self.pending[0] )
                    self.info( """   ... found %s"""% (repr(object.__name__)))
                except AlreadyDone:
                    pass
                except pydoc.ErrorDuringImport, value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                except (SystemError, SystemExit), value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                except Exception, value:
                    self.info( """   ... FAILED %s"""% (repr( value)))
                    self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                else:
                    page = self.formatter.page(
                        pydoc.describe(object),
                        self.formatter.docmodule(
                            object,
                            object.__name__,
                            packageContext = self,
                        )
                    )
                    file = open (
                        os.path.join(
                            self.destinationDirectory,
                            self.pending[0] + ".html",
                        ),
                        'w',
                    )
                    file.write(page)
                    file.close()
                    self.completed[ self.pending[0]] = object
                del self.pending[0]
        finally:
            for item in self.warnings:
                print item


问题


面经


文章

微信
公众号

扫码关注公众号