summaryrefslogtreecommitdiff
path: root/alot/db
Commit message (Collapse)AuthorAge
* Replace unused arguments with _Dylan Baker2016-12-21
| | | | | | | | | | 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).
* Don't use dict.keys when not necessaryDylan Baker2016-12-21
| | | | | | | | | | | 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())``.
* Use dict's iter methodsDylan Baker2016-12-21
| | | | | | | | 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.
* db/thread: Set some protected variables in the constructor.Dylan Baker2016-12-21
|
* db/thread: Avoid intermediate data structureDylan Baker2016-12-21
| | | | | | 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.
* db/thread: don't create multiple lists to sortDylan Baker2016-12-21
| | | | | | | | | | | | | | | 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.
* Replace map() and filter() with comprehensionsDylan Baker2016-12-21
| | | | | | | | 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.
* Use raw strings with backslashesDylan Baker2016-12-21
| | | | This just adds the `r` prefix to a few strings.
* tests: Add tests for alot.db.thread.Thread.get_authorDylan Baker2016-12-21
|
* db/thread: define Thread._authors in constructorDylan Baker2016-12-21
| | | | This is needed by unittest that mock Thread.refresh.
* Drop little used helperDylan Baker2016-12-19
| | | | | | | | 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 filesLucas Hoffmann2016-12-18
|
* use open() as context managerDylan Baker2016-12-14
| | | | | | | | | | 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.
* Don't pass None as second argument of dict.get()Dylan Baker2016-12-13
| | | | This is the default value.
* Replace list comprehension with set comprehensionDylan Baker2016-12-13
| | | | | | | Instead of using set([l for l in list]) use {l for l in list} (which shouldn't be confused with a dict comprehension which requires the ':' in the first value}. This avoids creating a list before reducing it to a set. This feature is new in 2.7 and 3.3.
* Replace mutable keyword argumentsDylan Baker2016-12-13
| | | | | | | | | | | | | | | | | | | | | | | There are a number of cases of mutable keyword arguments (list and dict in this case). Mutable keyword arguments are rather dangerous, since any mutation of the default value is persistent, which will inevitably lead to bugs. For example, imagine this code: def func(def=[]): def.append('foo') return def >>> func() ['foo'] >>> func() ['foo', 'foo'] This is almost certainly not what was intended. This code generally uses the idiom of setting the default value to None, and then assigning with or `value = value or []` which will replace value with the empty list (or dict) when value is falsey, like None or another empty list.
* Further minor style fixesLucas Hoffmann2016-12-09
|
* Clean up importsLucas Hoffmann2016-12-09
| | | | | | - use relative imports if possible - group imports into standard library, third party, and alot modules - sort imports alphabetically
* Use logging's native string interpolationLucas Hoffmann2016-12-09
|
* Remove braces after `del` and `return`Lucas Hoffmann2016-12-09
| | | | | `del` and `return` are keywords and not functions so the braces are not needed.
* New option `thread_authors_order_by` to control author orderTommy Lindgren2016-12-06
| | | | | | | | | | | | | Default value 'first_message' lists authors in the order they joined the conversation. Value 'latest_message' order authors by their latest message, which makes it easier to see which authors who wrote the most recent messages. Note that authors with duplicate emails were previously filtered. We now keep all authors where name + email is unique. This is behavior is desired for some email notification services. For example, Jira will set the From header to "Joe User <jira@company.com>" meaning you will only see one author if you only keep unique email addresses.
* Merge pull request #752 from jkoelker/pipeto_field_keyPatrick Totzke2016-12-06
|\ | | | | Allow specifing the mailcap field key for `pipeto`
| * Allow specifing the mailcap field key for `pipeto`Jason Kölker2015-02-11
| | | | | | | | | | When decoding the message, use the mailcap field specified for command lookup.
* | Merge pull request #901 from xunam/fix-backslash-tPatrick Totzke2016-12-06
|\ \ | | | | | | Removed incorrect backslash-t substitution in envelope.
| * | Removed incorrect backslash-t substitution in envelope.Emmanuel Beffara2016-10-20
| | |
* | | Merge branch '0.3.8-feature-untrusted-signatures-858'Patrick Totzke2016-12-06
|\ \ \ | |/ / |/| |
| * | Define local var in all code paths.Lucas Hoffmann2016-03-30
| | |
| * | Indicate untrusted PGP signatures in thread view.Lucas Hoffmann2016-03-24
| | |
* | | fix #891Patrick Totzke2016-10-19
|/ /
* | pep8 fixesPatrick Totzke2015-12-16
| |
* | Allow configuring what does alot consider to be the thread subject.Anton Khirnov2015-12-16
| |
* | remove deprecated methodPatrick Totzke2015-11-24
|/ | | | see also issue #794
* fix regex for unquoting in decode_headerTomas Tomecek2015-01-08
| | | | issue #539
* use magic on application/octetstream' attachmentsPatrick Totzke2014-11-22
| | | | | | | | Some versions of AppleMail apparently send out attachements with incorrect mimetypes "application/octetstream" (instead of "application/octet-stream"). This patch makes alot use libmagic on the attachments content to determine the actual content type.
* just formating (pep8 etc.)Patrick Totzke2014-08-02
|
* Move email_as_string function from crypto to helper moduleYann Rouillard2014-08-02
| | | | | | | | | The email_as_string function, and the related RFC3156_canonicalize function, are now used by the ForwardCommand and are not specific anymore to the crypto routine. So we move them to the global helper module. fix an import removal mistake while moving email_as_string function: StringIO was not only used by email_as_string
* ensure that Envelope.body is unicode stringPatrick Totzke2014-03-21
|
* add mailto-helperPatrick Totzke2013-12-01
|
* db.utils: Use unicode for GPG error messagesSimon Chopin2013-08-13
| | | | | This patch makes the use of unicode more consistent, and enforces the UTF8 charset for the added payload in case of failure.
* Use Unicode strings when dealing with GPGSimon Chopin2013-07-24
| | | | | This delays the encoding of special chars, if any, to the actual display which is supposed to know into what it should be encoded.
* pep8&pyflakes fixesPatrick Totzke2013-07-07
| | | | mostly automatically fixed
* adjust error messagePatrick Totzke2013-07-07
|
* move check to add_message directlyPatrick Totzke2013-07-07
|
* raise exception when adding msg no non-indexable pathPatrick Totzke2013-07-07
| | | | i.e., one not below that of notmuch's root path
* add helper to check if path is below anotherPatrick Totzke2013-07-07
| | | | this is used in the Database manager
* Fix the default failobj of get_paramsJustus Winter2013-06-20
| | | | | | | | | Formerly None was used as failobj, but None is not iterable and that is all that get_params does. Use list() instead which is iterable. Closes #626. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Tune the parsing of RFC 3156 style mailsJustus Winter2013-06-16
| | | | | | | | | Formerly any SMIME signed mail triggered a malformed OpenPGP message warning. Be more selective wrt what to interpret as OpenPGP data by looking at the protocol parameter first. Includes minor stylistic changes. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Fix detection of OpenPGP encrypted dataJustus Winter2013-06-16
| | | | | | | Fix detection of OpenPGP encrypted data and also check the 'protocol' parameter. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Move the parameter extraction to its own functionJustus Winter2013-06-16
| | | | | | | Move the parameter extraction to its own function and generalize it so it can be reused. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Normalize Content-Type parametersJustus Winter2013-06-16
| | | | | | | RFC 2045 specifies that parameter names are case-insensitive, so normalize them by converting them to their lower case version. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>