def pre_rendering(self): """ Prepares the header and footer information """ # Raw textwriters preprocessing will replace unicode with safe ascii RawTextRfcWriter.pre_rendering(self) # Discard hints and marks from indexing pass self.break_hints = {} self.heading_marks = {} if self.pis['private']: self.left_header = '' elif self.draft: self.left_header = 'Internet-Draft' else: self.left_header = 'RFC %s' % self.r.attrib.get('number', '') title = self.r.find('front/title') if title is not None: self.center_header = title.attrib.get('abbrev', title.text) date = self.r.find('front/date') if date is not None: month = date.attrib.get('month', '') year = date.attrib.get('year', '') self.right_header = month + ' ' + year authors = self.r.findall('front/author') surnames = [ a.attrib.get('surname') for a in authors if a.attrib.get('surname', None) ] if len(surnames) == 1: self.left_footer = surnames[0] elif len(surnames) == 2: self.left_footer = '%s & %s' % ( surnames[0], surnames[1], ) elif len(surnames) > 2: self.left_footer = '%s, et al.' % surnames[0] if self.draft: self.center_footer = 'Expires %s' % self.expire_string else: self.center_footer = self.boilerplate.get( self.r.attrib.get('category', ''), '(Category') # Check for PI override self.center_footer = self.pis.get('footer', self.center_footer) self.left_header = self.pis.get('header', self.left_header)
def pre_rendering(self): """ Prepares the header and footer information """ # Raw textwriters preprocessing will replace unicode with safe ascii RawTextRfcWriter.pre_rendering(self) # Discard hints and marks from indexing pass self.break_hints = {} self.heading_marks = {} if self.pis['private']: self.left_header = '' elif self.draft: self.left_header = 'Internet-Draft' else: self.left_header = 'RFC %s' % self.r.attrib.get('number', '') title = self.r.find('front/title') if title is not None: self.center_header = title.attrib.get('abbrev', title.text) date = self.r.find('front/date') if date is not None: month = date.attrib.get('month', '') year = date.attrib.get('year', '') self.right_header = month + ' ' + year authors = self.r.findall('front/author') surnames = [ a.attrib.get('surname') for a in authors if a.attrib.get('surname', None) ] if len(surnames) == 1: self.left_footer = surnames[0] elif len(surnames) == 2: self.left_footer = '%s & %s' % (surnames[0], surnames[1],) elif len(surnames) > 2: self.left_footer = '%s, et al.' % surnames[0] if self.draft: self.center_footer = 'Expires %s' % self.expire_string else: self.center_footer = self.boilerplate.get( self.r.attrib.get('category', ''), '(Category') # Check for PI override self.center_footer = self.pis.get('footer', self.center_footer) self.left_header = self.pis.get('header', self.left_header)