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


Python Page.parse_processing_instructions方法代码示例

本文整理汇总了Python中MoinMoin.Page.Page.parse_processing_instructions方法的典型用法代码示例。如果您正苦于以下问题:Python Page.parse_processing_instructions方法的具体用法?Python Page.parse_processing_instructions怎么用?Python Page.parse_processing_instructions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoinMoin.Page.Page的用法示例。


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

示例1: __init__

# 需要导入模块: from MoinMoin.Page import Page [as 别名]
# 或者: from MoinMoin.Page.Page import parse_processing_instructions [as 别名]
class MoinMoinEntryParser:
#{{{MoinMoinEntryParser class object
    '''
    This class contains evrything in order to parse a file using MoinMoin
    dervied Objects
    '''

    def __init__(self, url = '', pybloxsom_config = None):
#{{{Init method for the MoinMoinEntryParser class
        '''
        init method for MoinMoinEntryParser Object
        '''
        self.PREFORMATTER_ID = PREFORMATTER_ID

        # New MoinMoin request
        self.request = MoinMoinScriptContext(url)
        self.logger = PyblosxomTools.get_logger()
        self.url = url
        self.entryfile=''
        self.entrytitle = ''
        self.page_name = ''

        # Initial parser configuration if config is usable
        if pybloxsom_config is not None:
            self.pybloxsom_config = pybloxsom_config
            # Use moinmoin cache
            self.request.cacheable = self.request.use_cache = self.pybloxsom_config.get('moinmoin_use_cache', '0') == '1'
            #self.request.cacheable = self.request.use_cache = False

            # moinmoin encoding 
            self.output_charset = self.pybloxsom_config.get('blog_encoding', 'utf-8')
        # We don't have the config, using default
        else:
            self.request.cacheable = False
            self.output_charset = 'utf-8'
#}}}
        self.logger.debug('Moinmoin parser Object created')

    def create_page(self, entryfile = '', load_from_disk = True):
#{{{Here we create a moinmoin page object
        '''Creates a new MoinMoin Page Object.'''

        '''
        If load_from_disk is true, then the file is loaded from the disk using the entryfile as the filename.
        If not, we use the entryfile string as the raw file body
        '''
        # New MoinMoinPage
        if load_from_disk:
            page_dir, self.page_name = os.path.split(entryfile)
        else:
            self.page_name = str(hashlib.md5(entryfile).hexdigest())
        
        self.page = MoinMoinPage(self.request, page_name=self.page_name, formatter=None)

        # Load New page from file
        if load_from_disk:
            self.page.__body = None
            self.page._text_filename_force = entryfile
            self.logger.debug('Entry file to convert: %s' % entryfile)
        # Extracting page title
            tmp_body = self.page.get_body()
            self.entrytitle = tmp_body.split('\n')[0]
            self.page.set_raw_body(tmp_body[len(self.entrytitle)+1:])
            del tmp_body
        else:
            self.page.set_raw_body(entryfile)
            self.logger.debug('Using data got from pyblosxom')

        self.page.hilite_re = None
        self.page.output_charset = self.output_charset
        self.parser = None
        self.formatter = None
        self.default_parser = 'wiki'
        self.output_format = u'text/html'
        self.request.page = self.page
        self.page.__pi = self.page.parse_processing_instructions()
        self.logger.debug('New moinmoin page created')
#}}}

    def create_parser(self, line_anchors = False):
#{{{Here we create a moinmoin paser object
        '''Creating parser object'''
        
        Parser = MoinMoinWikiutil.searchAndImportPlugin(self.request.cfg, 'parser', self.request.getPragma('format', self.default_parser.lower()))
        self.parser = Parser(self.page.get_body(), self.request, line_anchors = line_anchors)
        self.logger.debug('New moinmoin parser created')
#}}}

    def create_formatter(self):
#{{{Here we create a moinmoin formatter object
        '''Creating formatter object'''

        Formatter = MoinMoinWikiutil.searchAndImportPlugin(self.request.cfg, 'formatter', self.request.getPragma('output-format', self.output_format).lower())

        self.formatter = Formatter(self.request)
        self.formatter.setPage(self.page)
        self.request.formatter = self.page.formatter = self.formatter
        self.logger.debug('New moinmoin formatter created')
#}}}

#.........这里部分代码省略.........
开发者ID:glennie,项目名称:pyblosxom,代码行数:103,代码来源:moinmoin.py


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