Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make widget browser work with py3k #11

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'tw2.core>=2.1.0a',
'gearbox',
'weberror',
'webhelpers',
'markupsafe',
'docutils',
"tw2.jquery",
"tw2.jqplugins.ui",
Expand Down
9 changes: 7 additions & 2 deletions tw2/devtools/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import pygments
import subprocess
import sys
import xmlrpclib
try:
# Python 3
from xmlrpc.client import ServerProxy
except ImportError:
# Python 2
from xmlrpclib import ServerProxy

import warnings
from . import memoize
Expand All @@ -32,7 +37,7 @@ def prepare(self):
self.modules = sorted(ep.module_name
for ep in pr.iter_entry_points('tw2.widgets')
if not ep.module_name.endswith('.samples'))
self.pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
self.pypi = ServerProxy('http://pypi.python.org/pypi')

@memoize.memoize
def _pypi_versions(self, module):
Expand Down
11 changes: 7 additions & 4 deletions tw2/devtools/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pygments.lexers
import pygments.formatters
import warnings
import webhelpers.html
import markupsafe

import tw2.core as twc
import tw2.core.templating as twt
Expand Down Expand Up @@ -76,7 +76,7 @@ def rst2html(rst):
'template': os.path.dirname(__file__) + '/rststub.txt'
}
)
html = html.replace('<blockquote>', '').replace('</blockquote>', '')
html = html.replace(b'<blockquote>', b'').replace(b'</blockquote>', b'')
return gsi.HTML(html.decode('utf-8'))


Expand Down Expand Up @@ -135,7 +135,6 @@ def _make_tmpl(widget):

funcs = [_make_demo, _make_docs, _make_params, _make_source, _make_tmpl]


def make_tabs(widget):
_items = [func(widget) for func in funcs]
_items = filter(lambda item: item, _items)
Expand All @@ -147,4 +146,8 @@ class Tabs(tw2.jqplugins.ui.TabsWidget):
id = widget.compound_id.replace(':', '-') + "-tabs"
items = _items

return webhelpers.html.literal(Tabs.display())
tabs = Tabs.display()
if tabs is not None:
return markupsafe.Markup(tabs)
else:
return markupsafe.Markup(u"")