Skip to content

Commit 33d695a

Browse files
committed
Make pastebin URL really configurable.
This closes issue bpython#67.
1 parent a6339f3 commit 33d695a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

bpython/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def loadini(struct, configfile):
4444
'paste_time': 0.02,
4545
'syntax': True,
4646
'tab_length': 4,
47-
'pastebin_url': 'http://bpaste.net'},
47+
'pastebin_url': 'http://bpaste.net/xmlrpc/',
48+
'pastebin_show_url': 'http://bpaste.net/show/$paste_id/',
49+
},
4850
'keyboard': {
4951
'clear_line': 'C-u',
5052
'clear_screen': 'C-l',
@@ -87,6 +89,7 @@ def loadini(struct, configfile):
8789
struct.last_output_key = config.get('keyboard', 'last_output')
8890

8991
struct.pastebin_url = config.get('general', 'pastebin_url')
92+
struct.pastebin_show_url = config.get('general', 'pastebin_show_url')
9093

9194
color_scheme_name = config.get('general', 'color_scheme')
9295

bpython/repl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
from glob import glob
3636
from itertools import takewhile
3737
from locale import getpreferredencoding
38-
from urlparse import urljoin
38+
from string import Template
39+
from urllib import quote as urlquote
3940
from xmlrpclib import ServerProxy, Error as XMLRPCError
4041

4142
from pygments.lexers import PythonLexer
@@ -589,8 +590,7 @@ def write2file(self):
589590
def pastebin(self):
590591
"""Upload to a pastebin and display the URL in the status bar."""
591592

592-
pasteservice_url = OPTS.pastebin_url
593-
pasteservice = ServerProxy(urljoin(pasteservice_url, '/xmlrpc/'))
593+
pasteservice = ServerProxy(OPTS.pastebin_url)
594594

595595
s = self.getstdout()
596596

@@ -601,7 +601,9 @@ def pastebin(self):
601601
self.statusbar.message('Upload failed: %s' % (str(e), ) )
602602
return
603603

604-
paste_url = urljoin(pasteservice_url, '/show/%s/' % (paste_id, ))
604+
paste_url_template = Template(OPTS.pastebin_show_url)
605+
paste_id = urlquote(paste_id)
606+
paste_url = paste_url_template.safe_substitute(paste_id=paste_id)
605607
self.statusbar.message('Pastebin URL: %s' % (paste_url, ), 10)
606608

607609
def make_list(self, items):

0 commit comments

Comments
 (0)