summaryrefslogtreecommitdiff
path: root/alot/helper.py
Commit message (Collapse)AuthorAge
* helper: move guess_mimetype into its own fileAnton Khirnov2021-11-24
|
* helper/split_commandline: drop unused function parametersAnton Khirnov2021-11-22
|
* mail/envelope: add missing importAnton Khirnov2021-05-15
| | | | Forgotten during move in fe1450cba.
* helper: move mimewrap() to the only place where it is calledAnton Khirnov2021-01-26
|
* ComposeCommand: read template/signature as textAnton Khirnov2021-01-26
| | | | | | We should not try to guess anything, just use the platform encoding. Remove helper.try_decode(), as it has no more callers.
* addressbook/external: stop using call_cmd()Anton Khirnov2021-01-26
| | | | | | | It does not actually save any code. The new code also uses a shell as is documented. Remove call_cmd(), as it no longer has any callers.
* account: stop using call_cmd_async() to run sendmailAnton Khirnov2021-01-26
| | | | | | | It does not actually save any code. The new code also uses a shell as is documented. Remove call_cmd_async(), as it no longer has any callers.
* Rewrite mailcap handling.Anton Khirnov2021-01-26
| | | | | | | | | | | Add a class that encapsulates the handler and is responsible for managing the temporary file, if one is needed. Use this class for both rendering inline content and displaying attachments externally. External attachments are now wrapped in an asyncio task that is added to a pool of tasks managed by ui.
* helper: get rid of decode_string()Anton Khirnov2021-01-16
| | | | | | | | It just adds unnecessary type confusion. In most places where it is used, the types are always str, so it does nothing. In the few others, the encoding/decoding is better handled explicitly.
* helper: move humanize_size to the only place where it is usedAnton Khirnov2021-01-16
|
* helper: rewrite mailto_to_envelope/parse_mailto to Envelope.from_mailtoAnton Khirnov2021-01-16
|
* helper: drop unused RFC3156_canonicalize()Anton Khirnov2021-01-16
|
* helper: move pretty_datetime to the only place where it is usedAnton Khirnov2021-01-16
| | | | Also, drop now-unnecessary call to decode_string
* helper: move string_sanitize() to the only place where it is usedAnton Khirnov2020-05-05
|
* db/utils: move formataddr to helperAnton Khirnov2020-03-05
| | | | | | | It has no relation to database, so helper seems like a better place for it. As there is nothing left in db/utils, it is removed.
* Remove unicode escape codesLucas Hoffmann2019-11-06
|
* Remove unicode literals syntax from python2Lucas Hoffmann2019-11-06
|
* Fix UnboundLocalErrorLucas Hoffmann2019-08-16
| | | | The local variable proc was not defined in these branches.
* remove unused importsPatrick Totzke2019-08-11
|
* adjust to variable python-magic APIMichael J Gruber2019-06-02
| | | | | | | | Depending on the libmagic/ctypes version, magic_version is a function or a constant. So far, the code expected a constant and fails on the function variant with a TypeError. Test with callable() und use the magic_version attribute accordingly.
* addressbook: add logging statementsMatthieu Coudron2019-02-06
| | | | to help troubleshoot problems
* helper: remove unused GeneratorDylan Baker2018-08-06
|
* helper: replace email_as_* with email builtinsDylan Baker2018-08-02
| | | | | | | | | | | | | | Python 3.3 added a new feature to the email module, policies (https://docs.python.org/3.5/library/email.policy.html). Policy objects allow precise control over how numerous features work when converting to and from str or bytes. With the `email.policy.SMTP` the behavior of email_as_bytes and email_as_string can be achieved using the builtin `.as_string()` and `.as_bytes()` methods, without custom code or the need to test it. Additionally these methods handle corner cases that we don't currently handle, such as multi-part messages with different encodings. Fixes #1257
* remove workaround for python issuePatrick Totzke2018-08-02
| | | | that was solved upstream: https://bugs.python.org/issue14983
* helper: use asyncio.subprocess instead of twistedDylan Baker2018-07-26
|
* Merge pull request #1266 from mjg/message-from-bytesDylan Baker2018-07-17
|\ | | | | Message from bytes
| * Revert "require chardet"Michael J Gruber2018-07-11
| | | | | | | | | | | | | | | | This reverts commit 0b5f8bf143e76be7ac989e8c8ec6e4a7dc08a78a. Chardet takes prohibitively long on large blobs (such as attachments). It will be replaced by functions from the email module in subsequent commits.
* | alot/helper: parse_mailto: unquote is in urllib.parse in Python 3Johannes Löthberg2018-07-16
|/ | | | Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
* Remove old __future__ importsLucas Hoffmann2018-06-19
| | | | They are not needed for python >= 3.0.
* alot/helper: allow call_cmd to take bytes or strings as stdinDylan Baker2018-05-15
| | | | | This might be a little sloppy, but there are legitimate cases where stdin is bytes, and cases where it is a string.
* Raise an exception with a meaningful message.Ben Finney2018-04-23
| | | | | | The `assert` statement is not always executed (it can be optimised away) so is not a suitable run-time check. Also, an exception allows for a better error message.
* helper: add debug for what encoding was guessed.Dylan Baker2018-04-06
|
* require chardetDylan Baker2018-03-06
| | | | | | | magic struggles to decode a number of encodings, particularly it struggles with windows-1252, which Exchange *loves* to silently re-encode mail in, without updated the charset of the payload. Chardet successfully guesses these oddball encodings much more often.
* fix sending encrypted messages in py3kDylan Baker2018-03-01
|
* fix a bunch of utils tests for py3kDylan Baker2018-03-01
| | | | | There are a few that are still broken because of bytes to unicode conversion, and this may not all be correct, but most of the tests pass
* helper: py3k fixesDylan Baker2018-03-01
|
* helper: add a helper to guess the encoding a of a blob and decode itDylan Baker2018-03-01
|
* py3k: only pass str instances to shlexDylan Baker2018-03-01
|
* py3k: don't covert to bytes for shlexDylan Baker2018-03-01
| | | | shlex expectes unicode in python3
* py3k: remove basestring and unicode.Dylan Baker2018-03-01
| | | | This probably isn't completely right, but it's a start.
* py3k: use StringIO from io module instead of cStringIODylan Baker2018-03-01
| | | | | cStringIO doesn't exist in python 3.x, instead one simply uses io.StringIO and python provided a C accelerated version if possible.
* Rename get_env to get_xdg_env and clarify docstring.Julian Mehne2018-01-23
|
* Fix empty XDG_* environment variables.Julian Mehne2018-01-21
| | | | | | | | | | | | Use fallback, if an enviroment variable is unset *or* empty. Bug: - XDG_CONFIG_HOME='' alot Problem: Does not find the configuration file (among others), because os.environ.get('XDG_CONFIG_HOME', '~/.config') returns '', instead of '~/.config'.
* Fix some spelling mistakesLucas Hoffmann2017-09-02
|
* alot/helper: Fix call_cmd_async polluting global environmentDylan Baker2017-08-22
| | | | | | | | | | An assignment `e = os.environ` creates a reference not a copy, which means that modifying one necessarily modifies the other. Using `dict.copy` creates a shallow copy (the keys and values are references, but the dicts are different objects), which means only modifications to mutable objects are shared. In the case of os.environ which only contains immutable objects like strings, bools, and numbers this isn't an issue.
* alot/helper: print ellipsis in codeDylan Baker2017-08-22
| | | | | Since the file is encoded in utf-8 we can actually print the ellipsis. Most people can more readily read that than the raw utf-8 escape.
* Use cStringIO.StringIO to fix #1132Lucas Hoffmann2017-08-21
| | | | | | | | | This undoes a small subset of the changes from fa3dd1b04567c4ea03fa658c3838b569531c79f5 and thus fixes #1132. The io.BytesIO object was not able to handle the unicode header names that where returned by envelope.construct_mail, which in turn did just copy them from the envelope header.
* Use io.BytesIO and io.StringIODylan Baker2017-08-19
| | | | | | | | In python3 StringIO and cStringIO are gone. In their place are io.BytesIO and io.StringIO. They are somewhat different in that they are not separated on implementation, but on the type they emulated. BytesIO works like the bytes class (str in python 2), while StringIO works like the str class (unicode in python2).
* helper: Do not add a newline to the end of a signed sectionDylan Baker2017-07-17
| | | | | | | | | | | | | | | | The spec is very clear here: (2) An appropriate Content-Transfer-Encoding is then applied; see section 3. In particular, line endings in the encoded data MUST use the canonical <CR><LF> sequence where appropriate (note that the canonical line ending may or may not be present on the last line of encoded data and MUST NOT be included in the signature if absent). That very last MUST NOT is what's important here, we shouldn't be adding newlines if they weren't there to begin with. Because we do it causes signed blobs that have newlines to be invalid since we've changed the substance of the signed code.
* Extend docstringLucas Hoffmann2017-06-21
|