summaryrefslogtreecommitdiff
path: root/alot/commands
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-13 14:36:56 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-13 14:36:56 +0100
commit765fa19c38e5f5c9c60d8046bb6120b9fcdc7a79 (patch)
treeea14f04e59456bcfb9338fedf0ca484ad55d90d5 /alot/commands
parentc97102f22c1d19f0e67af878e720710a4cc592ae (diff)
fix imports
Diffstat (limited to 'alot/commands')
-rw-r--r--alot/commands/bufferlist.py3
-rw-r--r--alot/commands/envelope.py25
-rw-r--r--alot/commands/globals.py32
-rw-r--r--alot/commands/search.py15
-rw-r--r--alot/commands/taglist.py32
-rw-r--r--alot/commands/thread.py25
6 files changed, 34 insertions, 98 deletions
diff --git a/alot/commands/bufferlist.py b/alot/commands/bufferlist.py
index e5f9d936..52d33de1 100644
--- a/alot/commands/bufferlist.py
+++ b/alot/commands/bufferlist.py
@@ -1,5 +1,2 @@
-from commands import Command, registerCommand
-from twisted.internet import defer
-
MODE = 'bufferlist'
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index db7b55ef..601372a7 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -3,33 +3,20 @@ from twisted.internet import defer
import os
import re
-import code
import glob
import logging
-import threading
-import subprocess
-import shlex
import email
import tempfile
from email import Charset
-from email.header import Header
-from email.mime.text import MIMEText
-from email.mime.multipart import MIMEMultipart
-import urwid
-from twisted.internet import defer
-import buffer
import settings
-import widgets
-import completion
import helper
-from db import DatabaseROError
-from db import DatabaseLockedError
-from completion import ContactsCompleter
-from completion import AccountCompleter
from message import decode_to_unicode
from message import decode_header
from message import encode_header
+import commands
+
+
MODE = 'envelope'
@registerCommand(MODE, 'attach', {})
@@ -104,7 +91,7 @@ class EnvelopeSendCommand(Command):
reason = account.send_mail(mail)
ui.clear_notify([clearme])
if not reason: # sucessfully send mail
- cmd = BufferCloseCommand(buffer=envelope)
+ cmd = commands.globals.BufferCloseCommand(buffer=envelope)
ui.apply_command(cmd)
ui.notify('mail send successful')
else:
@@ -171,7 +158,7 @@ class EnvelopeEditCommand(Command):
f.close()
os.unlink(tf.name)
if self.openNew:
- ui.apply_command(EnvelopeOpenCommand(mail=self.mail))
+ ui.apply_command(commands.globals.EnvelopeOpenCommand(mail=self.mail))
else:
ui.current_buffer.set_email(self.mail)
@@ -206,7 +193,7 @@ class EnvelopeEditCommand(Command):
tf.write(content.encode('utf-8'))
tf.flush()
tf.close()
- cmd = EditCommand(tf.name, on_success=openEnvelopeFromTmpfile,
+ cmd = commands.globals.EditCommand(tf.name, on_success=openEnvelopeFromTmpfile,
refocus=False)
ui.apply_command(cmd)
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 32376378..881a1d2b 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -2,34 +2,24 @@ from commands import Command, registerCommand
from twisted.internet import defer
import os
-import re
import code
-import glob
-import logging
import threading
import subprocess
import shlex
import email
-import tempfile
-from email import Charset
-from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import urwid
-from twisted.internet import defer
-import buffer
+import buffers
import settings
import widgets
-import completion
import helper
-from db import DatabaseROError
from db import DatabaseLockedError
from completion import ContactsCompleter
from completion import AccountCompleter
-from message import decode_to_unicode
-from message import decode_header
from message import encode_header
+import commands
MODE = 'global'
@@ -62,7 +52,7 @@ class SearchCommand(Command):
s = 'really search for all threads? This takes a while..'
if (yield ui.choice(s, select='yes', cancel='no')) == 'no':
return
- open_searches = ui.get_buffers_of_type(buffer.SearchBuffer)
+ open_searches = ui.get_buffers_of_type(buffers.SearchBuffer)
to_be_focused = None
for sb in open_searches:
if sb.querystring == self.query:
@@ -70,7 +60,7 @@ class SearchCommand(Command):
if to_be_focused:
ui.buffer_focus(to_be_focused)
else:
- ui.buffer_open(buffer.SearchBuffer(ui, self.query))
+ ui.buffer_open(buffers.SearchBuffer(ui, self.query))
else:
ui.notify('empty query string')
@@ -194,7 +184,7 @@ class BufferCloseCommand(Command):
def __init__(self, buffer=None, focussed=False, **kwargs):
"""
:param buffer: the selected buffer
- :type buffer: `alot.buffer.Buffer`
+ :type buffer: `alot.buffers.Buffer`
"""
self.buffer = buffer
self.focussed = focussed
@@ -218,7 +208,7 @@ class BufferFocusCommand(Command):
def __init__(self, buffer=None, offset=0, **kwargs):
"""
:param buffer: the buffer to focus
- :type buffer: `alot.buffer.Buffer`
+ :type buffer: `alot.buffers.Buffer`
"""
self.buffer = buffer
self.offset = offset
@@ -243,11 +233,11 @@ class OpenBufferlistCommand(Command):
Command.__init__(self, **kwargs)
def apply(self, ui):
- blists = ui.get_buffers_of_type(buffer.BufferlistBuffer)
+ blists = ui.get_buffers_of_type(buffers.BufferlistBuffer)
if blists:
ui.buffer_focus(blists[0])
else:
- ui.buffer_open(buffer.BufferlistBuffer(ui, self.filtfun))
+ ui.buffer_open(buffers.BufferlistBuffer(ui, self.filtfun))
@registerCommand(MODE, 'taglist', {})
@@ -259,7 +249,7 @@ class TagListCommand(Command):
def apply(self, ui):
tags = ui.dbman.get_all_tags()
- buf = buffer.TagListBuffer(ui, tags, self.filtfun)
+ buf = buffers.TagListBuffer(ui, tags, self.filtfun)
ui.buffers.append(buf)
buf.rebuild()
ui.buffer_focus(buf)
@@ -404,7 +394,7 @@ class ComposeCommand(Command):
return
self.mail['Subject'] = encode_header('subject', subject)
- ui.apply_command(EnvelopeEditCommand(mail=self.mail))
+ ui.apply_command(commands.envelope.EnvelopeEditCommand(mail=self.mail))
@registerCommand(MODE, 'move', {})
@@ -426,6 +416,6 @@ class EnvelopeOpenCommand(Command):
Command.__init__(self, **kwargs)
def apply(self, ui):
- ui.buffer_open(buffer.EnvelopeBuffer(ui, mail=self.mail))
+ ui.buffer_open(buffers.EnvelopeBuffer(ui, mail=self.mail))
diff --git a/alot/commands/search.py b/alot/commands/search.py
index 2c75659a..45c05763 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -1,6 +1,11 @@
from commands import Command, registerCommand
from twisted.internet import defer
+
+from db import DatabaseROError
+import commands
+import buffers
+
MODE = 'search'
@registerCommand(MODE, 'openthread', {}) #todo: make this select
@@ -17,7 +22,7 @@ class OpenThreadCommand(Command):
query = ui.current_buffer.querystring
ui.logger.info('open thread view for %s' % self.thread)
- sb = buffer.ThreadBuffer(ui, self.thread)
+ sb = buffers.ThreadBuffer(ui, self.thread)
ui.buffer_open(sb)
sb.unfold_matching(query)
@@ -43,12 +48,12 @@ class ToggleThreadTagCommand(Command):
return
# flush index
- ui.apply_command(FlushCommand())
+ ui.apply_command(commands.globals.FlushCommand())
# update current buffer
# TODO: what if changes not yet flushed?
cb = ui.current_buffer
- if isinstance(cb, buffer.SearchBuffer):
+ if isinstance(cb, buffers.SearchBuffer):
# refresh selected threadline
threadwidget = cb.get_selected_threadline()
threadwidget.rebuild() # rebuild and redraw the line
@@ -60,7 +65,7 @@ class ToggleThreadTagCommand(Command):
cb.threadlist.remove(threadwidget)
cb.result_count -= self.thread.get_total_messages()
ui.update()
- elif isinstance(cb, buffer.ThreadBuffer):
+ elif isinstance(cb, buffers.ThreadBuffer):
pass
@registerCommand(MODE, 'refine', {})
@@ -132,7 +137,7 @@ class RetagCommand(Command):
return
# flush index
- ui.apply_command(FlushCommand())
+ ui.apply_command(commands.globals.FlushCommand())
# refresh selected threadline
sbuffer = ui.current_buffer
diff --git a/alot/commands/taglist.py b/alot/commands/taglist.py
index 989453cd..48c92b91 100644
--- a/alot/commands/taglist.py
+++ b/alot/commands/taglist.py
@@ -1,35 +1,7 @@
from commands import Command, registerCommand
-from twisted.internet import defer
-import os
-import re
-import code
-import glob
-import logging
-import threading
-import subprocess
-import shlex
-import email
-import tempfile
-from email import Charset
-from email.header import Header
-from email.mime.text import MIMEText
-from email.mime.multipart import MIMEMultipart
-import urwid
-from twisted.internet import defer
+import commands
-import buffer
-import settings
-import widgets
-import completion
-import helper
-from db import DatabaseROError
-from db import DatabaseLockedError
-from completion import ContactsCompleter
-from completion import AccountCompleter
-from message import decode_to_unicode
-from message import decode_header
-from message import encode_header
MODE = 'taglist'
@@ -37,7 +9,7 @@ MODE = 'taglist'
class TaglistSelectCommand(Command):
def apply(self, ui):
tagstring = ui.current_buffer.get_selected_tag()
- cmd = SearchCommand(query='tag:%s' % tagstring)
+ cmd = commands.globals.SearchCommand(query='tag:%s' % tagstring)
ui.apply_command(cmd)
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 8d1133ea..143ff8e9 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -2,33 +2,18 @@ from commands import Command, registerCommand
from twisted.internet import defer
import os
-import re
-import code
-import glob
import logging
-import threading
-import subprocess
-import shlex
-import email
import tempfile
from email import Charset
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
-import urwid
-from twisted.internet import defer
-import buffer
+import commands
import settings
import widgets
import completion
import helper
-from db import DatabaseROError
-from db import DatabaseLockedError
-from completion import ContactsCompleter
-from completion import AccountCompleter
-from message import decode_to_unicode
-from message import decode_header
from message import encode_header
MODE = 'thread'
@@ -129,7 +114,7 @@ class ReplyCommand(Command):
else:
reply['References'] = '<%s>' % self.message.get_message_id()
- ui.apply_command(ComposeCommand(mail=reply))
+ ui.apply_command(commands.globals.ComposeCommand(mail=reply))
def clear_my_address(self, my_addresses, value):
new_value = []
@@ -206,7 +191,7 @@ class ForwardCommand(Command):
account = ui.accountman.get_account_by_address(matched_address)
fromstring = '%s <%s>' % (account.realname, account.address)
reply['From'] = encode_header('From', fromstring)
- ui.apply_command(ComposeCommand(mail=reply))
+ ui.apply_command(commands.globals.ComposeCommand(mail=reply))
@registerCommand(MODE, 'fold', {'visible': False})
@@ -230,7 +215,7 @@ class FoldMessagesCommand(Command):
if self.visible or (self.visible == None and widget.folded):
if 'unread' in msg.get_tags():
msg.remove_tags(['unread'])
- ui.apply_command(FlushCommand())
+ ui.apply_command(commands.globalsFlushCommand())
widget.rebuild()
widget.fold(visible=True)
else:
@@ -386,7 +371,7 @@ class OpenAttachmentCommand(Command):
def afterwards():
os.remove(path)
- ui.apply_command(ExternalCommand(handler, path=path,
+ ui.apply_command(commands.globals.ExternalCommand(handler, path=path,
on_success=afterwards,
in_thread=True))
else: