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
sudo: true
sudo: false
python:
- "2.7"
- pypy
before_install:
- "sudo apt-get install -y xclip"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- "pip install --upgrade --src . -r requirements.txt"

View File

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

View File

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