pydoc2.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pypydispatcher 作者: scrapy 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号