| Commit message (Collapse) | Author | Age |
|
|
|
|
|
| |
This reverts commit 581ed2987bd456d2894637a30bb5a14a4caa5f9b.
Fixes #942
|
| |
|
|
|
|
| |
This is just whitespace changes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This replaces the deprecated __cmp__ function with the more modern
__lt__, __eq__, and __ne__, and then uses functools.total_ordering to
implemented the remaining pieces of the rich comparison protocol
automatically. It also make use of the NotImplemented singleton, which
python uses to signal to rich comparators that this class doesn't no how
to compare to the other class, which results in the complementary method
from the other class being used, and if both return NotImplemented than
a TypeError is generated.
There are two reasons to make this change. First, python 3 only supports
rich comparisons, and second rich comparisons are much faster than using
cmp (and the __cmp__ protocol) because cmp is called at least 3 times
per element, while a rich comparitor is called one per element.
functools.total_ordering is in the standard library from 2.7 and 3.3,
and will implement the rich comparison protocol provided that __eq__ and
at least one of __lt__, __le__, __ge__, or __gt__ are implemented. It
does not (oddly enough) implement __ne__, so I've implemented that
manually.
|
| |
|
|
|
|
|
|
|
| |
There are times to call dunder methods explicitly (double underscore
methods, like __contains__), but that's usually only required when
dealing with inheritance. In this case using the standard 'k in d'
syntax is clearer.
|
|
|
|
|
| |
This dict key is deleted, and then promptly replaced. The deletion is
useless, the replacement does the same thing.
|
|
|
|
|
| |
Using file_ instead of FILE still avoids shadowing the builtin, but also
doesn't stand out so much.
|
|
|
|
| |
They are the same, except xrange returns an iterator instead of a list.
|
|
|
|
|
|
|
|
|
| |
This removes the use of range (originally I simply replaced it with
xrange, but the realized that the use of range was itself strange), and
replaces it with generators and iterators to create the dictionary. This
has the advantage of only creating one concrete instance (the choices
dict), and being slightly easier to read and understand, as well as not
needing to call len() repeatedly.
|
|
|
|
|
| |
Simply cast every string to lower() when matching MIME media type and
subtype. Matching is always case-insensitive as per RFC2045, 5.1.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Completer class is abastract, and it's complete method is also
abstract. Using ABCMeta achieve two thing, first it will cause an error
if a developer doesn't overwrite the method in a subclass. And second
that it tells the static analysis tools to ignore the unused arguments
in the signature, since this is the definition of a signature, not an
actual function.
By the same logic addressbook.AddressBook, and account.Account have been
extended to use ABCMeta as their metaclass and have had their abstract
methods decorated with the abstract method attribute.
|
|
|
|
|
|
|
|
|
|
| |
This patch replaces a large number (but not all) unused arguments with
the standard ``_`` placeholder. This has the advantage of signaling that
these values are unused.
There are a number of places that I've chosen not to apply this, largely
in methods that have publicly define signatures that they inherit
(usually from urwid).
|
|
|
|
|
|
|
|
|
|
|
| |
It's pretty easy to get caught up using dict.keys (or iterkeys) when
one doesn't need to. This patch corrects two cases where it's not
needed, the first is the case of inclusion. ``x in mydict.keys()`` is
equivalent to ``x in mydict``, but without the need to generate a list
and walk it. The second case is when calling set() on a dict,
``set(mydict)`` will create a set object of the dict's keys, without the
need to create one in memory and is significantly faster than
``set(mydict.keys())`` or even ``set(mydict.iterkeys())``.
|
|
|
|
|
|
| |
This patch changes an assertion to avoid building a list in memory by
using dict.keys() and then concatenating it (building a second list in
memory). This is both faster and uses less memory.
|
|
|
|
|
|
|
| |
The use of a list comprehension here saves one line of code, but doesn't
make the code clearer, a simple loop is more obvious. This also replaces
``if not v or v == ''`` with simply ``if not v``, since they're
equivalent.
|
|
|
|
|
|
|
|
| |
This patch replaces a number of uses of dict.items, dict.values, and
dict.keys with their iterative siblings. The advantage of using the
iterator version is that they don't copy the keys, values, or items, but
simply return references. This reduces memory usage and may speed up the
these operations a bit.
|
| |
|
| |
|
|
|
|
|
|
| |
This patch removes the need to create an intermediate dictionary while
calculating the authors of a thread, it does so by working directly with
the _authors list.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently this function takes a list, splits into two lists based on
whether or not a function returns None, sorts the list that isn't None,
and then appends the list of None to the end. This creates 4 new
concrete lists on each method call, requires the use of 3 filter +
lambda pairs, and calls list.sort(). Pretty complicated and inefficient.
This patch replaces that with a single sorted() function call with a kay
function that replaces None with a value that is guaranteed to sort less
than what Message.get_date() will return, but will not cause a
comparison to None (which is an error in Python 3.x). This is all based
on iterators and avoids the need for filter or list concatenation. This
should result in only one new list being created.
|
| |
|
|
|
|
|
|
|
|
| |
This had the advantage of being more readable to people without a
functional programming background, and it avoids the need to use lambdas
which are both slow and have many corners in python. In a few cases it
also allows us to use a generator expression instead of a materialized
list, which save some memory.
|
|
|
|
|
|
|
|
|
| |
In alot/helper.py this is a fairly obvious change. In alot/buffers.py
I've taken the liberty of replacing a somewhat odd use of multiplication
that relies on the bool class (True and False) implementing an __int__
method. These are used to add the 's' to the end of 'message' if there
are more than one message (thus messages), this is much clearer (and
more correct) when implemented as a ternary instead.
|
|
|
|
| |
This just adds the `r` prefix to a few strings.
|
|
|
|
|
| |
several of these don't take a self argument. In one case self is needed,
in the others decorating them as static methods fixes the behavior.
|
| |
|
|
|
|
| |
This is needed by unittest that mock Thread.refresh.
|
|
|
|
|
|
|
|
| |
The safely_get helper is just a wrapper around try/except, and is used
twice in the whole code base, in the same function. It really doesn't
even end up saving code because to get around line wrapping a lambda is
assigned (which is not the greatest style wise), it ends up saving one
line of code when it's called, and the function itself is 16 lines long.
|
| |
|
|\
| |
| | |
Use with blocks to write to temp files
|
| | |
|
| | |
|
| | |
|
|/ |
|
|
|
|
|
|
|
|
|
| |
Configobj's string interpolation feature does not work as expected in
account sections of alot configuration files.
The reason is that interpolation is done in ConfigObj.__getitem__
which alot does not use directly for account sections.
This patch causes all values to be read via ConfigObj.__getitem__
explicitly.
|
|\
| |
| | |
Save command line history across sessions
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
The option allows to limit the size of recent command line entries that are
store on disk.
|
| |
| |
| |
| |
| |
| | |
Initialize the command history with lines from
${XDG_CACHE_HOME:-~/.cache}/alot at startup. Write the current history to the
file again during shutdown.
|
| |
| |
| |
| |
| |
| |
| |
| | |
While open().read() is nice for its terseness it has the problem that it
causes an fd to leak until the gc collects it. For short lived scripts
this isn't a big deal, but for a program like alot that run for long
periods of time it's better to be correct and ensure that the fd is
closed.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This uses open() as a context manager instead of calling close()
explicitly. This has the advantage of closing even in the event of an
exception, being easier to visually inspect for correctness, and being
the more modern idiom.
This does leave one case of file.close(), where FILE is opened in an if
tree.
|
|\ \
| |/
|/| |
Small fixes found with pylint
|
| | |
|
| |
| |
| |
| | |
This will also make the string interpolation lazy evaluated.
|
| |
| |
| |
| | |
The lower case version is available since 2.5.
|
| | |
|