removed pyperclip hard dependencies

This commit is contained in:
Marcelo Glezer 2015-01-15 08:46:10 -03:00
parent c97fe68230
commit 0a2d2d9390
3 changed files with 35 additions and 25 deletions

View File

@ -1,10 +1,8 @@
language: python language: python
sudo: true sudo: false
python: python:
- "2.7" - "2.7"
- pypy - pypy
before_install:
- "sudo apt-get install -y xclip"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: install:
- "pip install --upgrade --src . -r requirements.txt" - "pip install --upgrade --src . -r requirements.txt"

View File

@ -1,7 +1,10 @@
from __future__ import absolute_import from __future__ import absolute_import
import urwid import urwid
import pyperclip
from . import common from . import common
try:
import pyperclip
except:
pyperclip = False
def _mkhelp(): def _mkhelp():
text = [] text = []
@ -139,16 +142,19 @@ class ConnectionItem(common.WWrap):
self.master.server_playback_path self.master.server_playback_path
) )
def server_copy_response(self, k): def server_copy_response(self, k):
if k == "c": if pyperclip:
try: if k == "c":
pyperclip.copy(self.flow.response.get_decoded_content()) try:
except TypeError: pyperclip.copy(self.flow.response.get_decoded_content())
self.master.statusbar.message("Content is binary or can be converted to text") except TypeError:
elif k == "h": self.master.statusbar.message("Content is binary or can be converted to text")
try: elif k == "h":
pyperclip.copy(str(self.flow.response.headers)) try:
except TypeError: pyperclip.copy(str(self.flow.response.headers))
self.master.statusbar.message("Error converting headers to text") except TypeError:
self.master.statusbar.message("Error converting headers to text")
else:
self.master.statusbar.message("No clipboard support on your system, sorry.")
def keypress(self, (maxcol,), key): def keypress(self, (maxcol,), key):
key = common.shortcuts(key) key = common.shortcuts(key)

View File

@ -4,7 +4,10 @@ import urwid
from . import common, grideditor, contentview from . import common, grideditor, contentview
from .. import utils, flow, controller from .. import utils, flow, controller
from ..protocol.http import HTTPResponse, CONTENT_MISSING, decoded from ..protocol.http import HTTPResponse, CONTENT_MISSING, decoded
import pyperclip try:
import pyperclip
except:
pyperclip = False
class SearchError(Exception): pass class SearchError(Exception): pass
@ -650,16 +653,19 @@ class FlowView(common.WWrap):
self.master.refresh_flow(self.flow) self.master.refresh_flow(self.flow)
def server_copy_response(self, k): def server_copy_response(self, k):
if k == "c": if pyperclip:
try: if k == "c":
pyperclip.copy(self.flow.response.get_decoded_content()) try:
except TypeError: pyperclip.copy(self.flow.response.get_decoded_content())
self.master.statusbar.message("Content is binary or can be converted to text") except TypeError:
elif k == "h": self.master.statusbar.message("Content is binary or can be converted to text")
try: elif k == "h":
pyperclip.copy(str(self.flow.response.headers)) try:
except TypeError: pyperclip.copy(str(self.flow.response.headers))
self.master.statusbar.message("Error converting headers to text") except TypeError:
self.master.statusbar.message("Error converting headers to text")
else:
self.master.statusbar.message("No clipboard support on your system, sorry.")
def delete_body(self, t): def delete_body(self, t):
if t == "m": if t == "m":