From 99fe0407f00b05bdc426042cf06cccfa259e529d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Jun 2021 16:14:30 +0200 Subject: [PATCH] clean --- ereuse_devicehub/cli.py | 21 +++++++++++++++ .../resources/action/views/trade.py | 26 ------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/ereuse_devicehub/cli.py b/ereuse_devicehub/cli.py index b99c0b5e..4c253235 100644 --- a/ereuse_devicehub/cli.py +++ b/ereuse_devicehub/cli.py @@ -7,6 +7,27 @@ import flask.cli from ereuse_devicehub.config import DevicehubConfig from ereuse_devicehub.devicehub import Devicehub +import sys +sys.ps1 = '\001\033[92m\002>>> \001\033[0m\002' +sys.ps2= '\001\033[94m\002... \001\033[0m\002' + +import os, readline, rlcompleter, atexit +history_file = os.path.join(os.environ['HOME'], '.python_history') +try: + readline.read_history_file(history_file) +except IOError: + pass +readline.parse_and_bind("tab: complete") +readline.parse_and_bind('"\e[5~": history-search-backward') +readline.parse_and_bind('"\e[6~": history-search-forward') +readline.parse_and_bind('"\e[5C": forward-word') +readline.parse_and_bind('"\e[5D": backward-word') +readline.parse_and_bind('"\e\e[C": forward-word') +readline.parse_and_bind('"\e\e[D": backward-word') +readline.parse_and_bind('"\e[1;5C": forward-word') +readline.parse_and_bind('"\e[1;5D": backward-word') +readline.set_history_length(100000) +atexit.register(readline.write_history_file, history_file) class DevicehubGroup(flask.cli.FlaskGroup): # todo users cannot make cli to use a custom db this way! diff --git a/ereuse_devicehub/resources/action/views/trade.py b/ereuse_devicehub/resources/action/views/trade.py index 68360713..1f0b0ca3 100644 --- a/ereuse_devicehub/resources/action/views/trade.py +++ b/ereuse_devicehub/resources/action/views/trade.py @@ -224,32 +224,6 @@ class RevokeView(ConfirmMixin): # import pdb; pdb.set_trace() self.model = delete_from_trade(lot, ids) - # devices = set(data['devices']) - # without_confirms = set() # set of devs without confirms of user2 - - # if g.user == lot.trade.author: - # for dev in devices: - # ac = dev.last_action_trading - # if ac.type == 'Confirm' and ac.user == g.user: - # without_confirms.add(dev) - - # # we need to mark one revoke for every devs - # revoke = Revoke(action=lot.trade, user=g.user, devices=devices) - # db.session.add(revoke) - - # if without_confirms: - # confirm_revoke = ConfirmRevoke( - # action=revoke, - # user=g.user, - # devices=without_confirms - # ) - # db.session.add(confirm_revoke) - - # lot.devices.difference_update(without_confirms) - # lot.trade.devices = lot.devices - - # self.model = revoke - class ConfirmRevokeView(ConfirmMixin): """Handler for manager the Confirmation register from post