- Preparation work for using six or future module for Py2/3 compat. The
code will be written in Python 3 with Python 2 fallbacks.
- Added some Py3 imports with Py2 fallbacks to make it easier to remove
Py2 code in future.
- Replace xrange with range (sort out import as top of files in future).
- Workaround Py2to3 basestring issue with inline if in instances. This means
every usage of basestring is more considered.
- Replace iteritems and itervalues for items and values. There might be a
performance penalty on Py2 so might need to revisit this change.
- Python 3 renames `unicode` type to `str` and introduces `bytes` type.
- Python 2.7 has `bytes` but is only an alias for `str` so restricted
to comparisons but helps keep compatibility.
- To test for unicode string on Py2 and Py3 uses the "''.__class__" type.
- Remove usage of utf8encode and just encode, problems with bytes being passed
in code will be picked up faster.
- Where possible refactor out isinstance for try..except duck-typing.
* Added `from __future__ import unicode_literals` to every file so
now all strings in code are forced to be unicode strings unless
marked as byte string `b'str'` or encoded to byte string `'str'.encode('utf-8')`.
This is a large change but we have been working towards the goal of unicode
strings passed in the code so decoding external input and encoding
output as byte strings (where applicable).
Note that in Python 2 the `str` type still refers to byte strings.
* Replaced the use of `str` for `basestring` in isinstance comparison as
this was the original intention but breaks code when encoutering unicode strings.
* Marked byte strings in gtkui as the conversion to utf8 is not always handled, mostly
related to gobject signal names.
- libtorrent 1.1 changes default piece priorty to 4 so changes to
the UIs are required. Some refactoring and improvements were made as well:
- A new 'Low' priority introduced that is values 1-3.
- 'Normal' priority is now value 4.
- Removed 'Highest' with the addition of 'Low' and 'High' is now values 5-7.
- Renamed 'Do not download' to 'Ignore' so it is more succinct.
- Moved file priority constant to ui.common.
* A rather disruptive change but for a few reasons such as easier to read,
easier type, keep consistent and javascript code uses single quotes.
* There are a few exceptions for the automated process:
* Any double quotes in comments
* Triple double quotes for docstrings
* Strings containing single quotes are left e.g. "they're"
* To deal with merge conflicts from feature branches it is best to follow
these steps for each commit:
* Create a patch: `git format-patch -1 <sha1>`
* Edit the patch and replace double quotes with single except those in
comments or strings containing an unescaped apostrophe.
* Check the patch `git apply --check <patchfile>` and fix any remaining
issues if it outputs an error.
* Apply the patch `git am < <patchfile>`
This commit is a rewrite of larger parts of the console code. The
motivation behind the rewrite is to cleanup the code and reduce code
duplication to make it easier to understand and modify, and allow any
form of code reuse. Most changes are to the interactive console, but
also to how the different modes (BaseMode subclasses) are used and set
up.
* Address [#2097] - Improve match_torrent search match:
Instead of matching e.g. torrent name with name.startswith(pattern)
now check for asterix at beginning and end of pattern and search
with startswith, endswith or __contains__ according to the pattern.
Various smaller fixes:
* Add errback handler to connection failed
* Fix cmd line console mixing str and unicode input
* Fix handling delete backwards with ALT+Backspace
* Fix handling resizing of message popups
* Fix docs generation warnings
* Lets not stop the reactor on exception in basemode..
* Markup for translation arg help strings
* Main functionality improvements:
- Add support for indentation in formatting code in popup messages (like help)
- Add filter sidebar
- Add ComboBox and UI language selection
- Add columnsview to allow rearranging the torrentlist columns
and changing column widths.
- Removed Columns pane in preferences as columnsview.py is sufficient
- Remove torrent info panel (short cut 'i') as the torrent detail view
is sufficient
* Cleanups and code restructuring
- Made BaseModes subclass of Component
- Rewrite of most of basic window/panel to allow easier code reuse
- Implemented better handling of multple popups by stacking popups. This
makes it easier to return to previous popup when opening multiple popups.
* Refactured console code:
- modes/ for the different modes
- Renamed Legacy mode to CmdLine
- Renamed alltorrent.py to torrentlist.py and split the code into
- torrentlist/columnsview.py
- torrentlist/torrentsview.py
- torrentlist/search_mode.py (minor mode)
- torrentlist/queue_mode.py (minor mode)
- cmdline/ for cmd line commands
- utils/ for utility files
- widgets/ for reusable GUI widgets
- fields.py: Base widgets like TextInput, SelectInput, ComboInput
- popup.py: Popup windows
- inputpane.py: The BaseInputPane used to manage multiple base widgets in a panel
- window.py: The BaseWindow used by all panels needing a curses screen
- sidebar.py: The Sidebar panel
- statusbars.py: The statusbars
- Moved option parsing code from main.py to parser.py