Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5965918

Browse filesBrowse files
committed
Make pastebin URL really configurable.
This closes issue #67.
1 parent 62c6137 commit 5965918
Copy full SHA for 5965918

2 files changed

+10-5Lines changed: 10 additions & 5 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/config.py‎

Copy file name to clipboardExpand all lines: bpython/config.py
+4-1Lines 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

Collapse file

‎bpython/repl.py‎

Copy file name to clipboardExpand all lines: bpython/repl.py
+6-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.