Skip to content
Permalink
Browse files

migrate from python2 to python3 of rst2man.py

  • Loading branch information...
yetist authored and monsta committed Feb 12, 2019
1 parent 4eab52b commit 3d48c5e516b5c1ab5d68def01ee5e8d9ad1df893
Showing with 37 additions and 38 deletions.
  1. +37 −38 rst2man.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Author:
# Contact: grubert@users.sf.net
@@ -72,7 +72,6 @@
import os
import time
import re
from types import ListType

import docutils
from docutils import nodes, utils, writers, languages
@@ -334,20 +333,20 @@ def append_header(self):
self.header_written = 1

def visit_address(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.visit_docinfo_item(node, 'address', meta=None)

def depart_address(self, node):
self.depart_docinfo_item()

def visit_admonition(self, node, name):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'div', CLASS=name))
self.body.append('<p class="admonition-title">'
+ self.language.labels[name] + '</p>\n')

def depart_admonition(self):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</div>\n')

def visit_attention(self, node):
@@ -388,11 +387,11 @@ def depart_bullet_list(self, node):
self.list_end()

def visit_caption(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'p', '', CLASS='caption'))

def depart_caption(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</p>\n')

def visit_caution(self, node):
@@ -402,7 +401,7 @@ def depart_caution(self, node):
self.depart_admonition()

def visit_citation(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'table', CLASS='citation',
frame="void", rules="none"))
self.body.append('<colgroup><col class="label" /><col /></colgroup>\n'
@@ -412,12 +411,12 @@ def visit_citation(self, node):
self.footnote_backrefs(node)

def depart_citation(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</td></tr>\n'
'</tbody>\n</table>\n')

def visit_citation_reference(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
href = ''
if node.has_key('refid'):
href = '#' + node['refid']
@@ -427,16 +426,16 @@ def visit_citation_reference(self, node):
CLASS='citation-reference'))

def depart_citation_reference(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(']</a>')

def visit_classifier(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(' <span class="classifier-delimiter">:</span> ')
self.body.append(self.starttag(node, 'span', '', CLASS='classifier'))

def depart_classifier(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</span>')

def visit_colspec(self, node):
@@ -524,11 +523,11 @@ def depart_docinfo_item(self):
pass

def visit_doctest_block(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'pre', CLASS='doctest-block'))

def depart_doctest_block(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('\n</pre>\n')

def visit_document(self, node):
@@ -613,16 +612,16 @@ def depart_field_name(self, node):
self.body.append(self.defs['field_name'][1])

def visit_figure(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())

def depart_figure(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())

def visit_footer(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())

def depart_footer(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
start = self.context.pop()
footer = (['<hr class="footer"/>\n',
self.starttag(node, 'div', CLASS='footer')]
@@ -631,7 +630,7 @@ def depart_footer(self, node):
del self.body[start:]

def visit_footnote(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'table', CLASS='footnote',
frame="void", rules="none"))
self.body.append('<colgroup><col class="label" /><col /></colgroup>\n'
@@ -640,7 +639,7 @@ def visit_footnote(self, node):
self.footnote_backrefs(node)

def footnote_backrefs(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
if self.settings.footnote_backlinks and node.hasattr('backrefs'):
backrefs = node['backrefs']
if len(backrefs) == 1:
@@ -661,12 +660,12 @@ def footnote_backrefs(self, node):
self.context.append('<a name="%s">' % node['id'])

def depart_footnote(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</td></tr>\n'
'</tbody>\n</table>\n')

def visit_footnote_reference(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
href = ''
if node.has_key('refid'):
href = '#' + node['refid']
@@ -686,7 +685,7 @@ def visit_footnote_reference(self, node):
CLASS='footnote-reference'))

def depart_footnote_reference(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.context.pop() + '</a>')

def visit_generated(self, node):
@@ -696,11 +695,11 @@ def depart_generated(self, node):
pass

def visit_header(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.context.append(len(self.body))

def depart_header(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
start = self.context.pop()
self.body_prefix.append(self.starttag(node, 'div', CLASS='header'))
self.body_prefix.extend(self.body[start:])
@@ -714,7 +713,7 @@ def depart_hint(self, node):
self.depart_admonition()

def visit_image(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
atts = node.attributes.copy()
atts['src'] = atts['uri']
del atts['uri']
@@ -728,7 +727,7 @@ def visit_image(self, node):
self.body.append(self.emptytag(node, 'img', '', **atts))

def depart_image(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.context.pop())

def visit_important(self, node):
@@ -738,20 +737,20 @@ def depart_important(self, node):
self.depart_admonition()

def visit_label(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'td', '%s[' % self.context.pop(),
CLASS='label'))

def depart_label(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(']</a></td><td>%s' % self.context.pop())

def visit_legend(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append(self.starttag(node, 'div', CLASS='legend'))

def depart_legend(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</div>\n')

def visit_line_block(self, node):
@@ -788,7 +787,7 @@ def depart_literal_block(self, node):
self.body.append(self.defs['literal_block'][1])

def visit_meta(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.head.append(self.emptytag(node, 'meta', **node.attributes))

def depart_meta(self, node):
@@ -876,11 +875,11 @@ def depart_option_argument(self, node):
pass

def visit_organization(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.visit_docinfo_item(node, 'organization')

def depart_organization(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.depart_docinfo_item()

def visit_paragraph(self, node):
@@ -931,7 +930,7 @@ def depart_section(self, node):
self.section_level -= 1

def visit_status(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.visit_docinfo_item(node, 'status', meta=None)

def depart_status(self, node):
@@ -1009,15 +1008,15 @@ def depart_tgroup(self, node):
pass

def visit_thead(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.write_colspecs()
self.body.append(self.context.pop()) # '</colgroup>\n'
# There may or may not be a <thead>; this is for <tbody> to use:
self.context.append('')
self.body.append(self.starttag(node, 'thead', valign='bottom'))

def depart_thead(self, node):
raise NotImplementedError, node.astext()
raise NotImplementedError(node.astext())
self.body.append('</thead>\n')

def visit_tip(self, node):

0 comments on commit 3d48c5e

Please sign in to comment.
You can’t perform that action at this time.