Commit Graph

6071 Commits

Author SHA1 Message Date
Philipp Wolfer
a1313bef84 PEP8 fixes 2019-03-28 11:45:42 +01:00
Philipp Wolfer
3b3980adb0 Added tests for technical file info tags 2019-03-28 11:45:42 +01:00
Philipp Wolfer
8fdfcf1ffe Restructure format tests into separate files 2019-03-28 11:10:06 +01:00
Philipp Wolfer
ab1adf15cb Add common tests for Vorbis formats 2019-03-27 15:05:47 +01:00
Philipp Wolfer
8e613f64ce Merge pull request #1151 from phw/PICARD-1468-localize-nsis
PICARD-1468: Localize NSIS installer
2019-03-27 06:17:05 +00:00
Laurent Monin
b80f433385 Merge pull request #1150 from phw/PICARD-1492-fix-vorbis-rating-email-with-invalid-chars
PICARD-1492: Fix saving Vorbis ratings with invalid chars in user e-mail
2019-03-27 01:18:02 +01:00
Laurent Monin
4345958540 Merge pull request #1145 from zas/oauth_cleanup
Oauth cleanup: use properties
2019-03-27 00:04:53 +01:00
Philipp Wolfer
cf9528bd86 PICARD-1492: Added tests and docs for vorbis.sanitize_key 2019-03-26 16:06:08 +01:00
Laurent Monin
aaea31b1e8 Use kw argument for callback returned value 2019-03-26 11:49:33 +01:00
Laurent Monin
d990fc801a Make use of kw argument access_token for callback
This one ends to call back a method defined as:
def _send_request(self, request, access_token=None)

and passed as callback using partial(self._send_request, request)
2019-03-26 11:49:33 +01:00
Laurent Monin
16385ea461 OAuthManager: use @property.deleter instead of setting to None 2019-03-26 11:47:47 +01:00
Laurent Monin
9f93047495 OAuthManager: store config.persist in persist property 2019-03-26 11:47:47 +01:00
Laurent Monin
b2a8ddcd93 OAuthManager: introduce username property 2019-03-26 11:47:47 +01:00
Laurent Monin
cc1b26bc08 OAuthManager: introduce access_token and access_token_expires properties 2019-03-26 11:43:58 +01:00
Laurent Monin
d91bf51204 OAuthManager: introduce refresh_token and refresh_token_scopes properties
- it prevents direct use of config.persist
- setting properties to None executes config.persist.remove()
2019-03-26 11:42:16 +01:00
Laurent Monin
4c49788769 Reduce code redundancy, new properties: host & port 2019-03-26 11:40:51 +01:00
Laurent Monin
277897b9f0 Merge pull request #1148 from zas/versions_count
PICARD-1496: display count of Other versions in menu and refactoring
2019-03-26 10:45:54 +01:00
Philipp Wolfer
2d98026c22 PICARD-1492: Fix saving Vorbis ratings with invalid chars in user e-mail 2019-03-26 09:24:56 +01:00
Philipp Wolfer
3a2cfc3a89 Fix ASFFile._save modifying passed metadata 2019-03-26 07:32:59 +00:00
Philipp Wolfer
601df7b158 Simpified initializing Metadata() in formats tests 2019-03-26 07:32:59 +00:00
Laurent Monin
22a1a104fd Merge pull request #1146 from zas/pylint_cleanup
Pylint errors/warnings cleanup
2019-03-25 21:43:22 +01:00
Laurent Monin
42f6cfb38a Use tuples of integers and heapq instead strings/sort/list/dict for menu ordering
- old code was a bit tricky, concatenating special prefix to name to order
- use a heapq so entries are sorted on insert
- rename few local variables to make them more explicit
- use "constants" ORDER_BEFORE and ORDER_AFTER instead of "0", "?"
- review behavior with countries/formats & preferences, making the code easier to understand
- simplify "grouping": we add a separator after each group
2019-03-25 18:21:26 +01:00
Laurent Monin
f2823f165d Merge pull request #1147 from zas/fix_country_list
Fix country list
2019-03-25 17:57:09 +01:00
Laurent Monin
c80ae1344b Name countries-related tests, classes and variables consistently 2019-03-25 14:40:52 +01:00
Laurent Monin
a458bbe2ff country_list_from_node() -> countries_from_node() 2019-03-25 14:38:51 +01:00
Laurent Monin
a930e688e3 country_list_from_node(): country -> countries
That's a list of countries.
2019-03-25 14:36:56 +01:00
Laurent Monin
f9e1373d9a country_list_from_node(): returns [] instead of implicit None if no release-event in node
Since this code was introduced in f8559fdd7, it was returning None implicitly if no "release-events" were found in node.
This behavior differs from other methods of the same kind like release_dates_and_countries_from_node()

This change shouldn't have any negative impact, since callers always test for emptyness
2019-03-25 14:36:56 +01:00
Laurent Monin
5ae92454f4 Add a test for release without events vs countries 2019-03-25 14:36:56 +01:00
Laurent Monin
8fe3ee23d8 Address PyLint W0105: convert to valid docstrings, they have to be at top 2019-03-25 13:11:38 +01:00
Laurent Monin
95eb1c8904 Fix PyLint W0221: use a property instead of passing a parameter, no use outside this file
picard/webservice/__init__.py:218:4: W0221: Parameters differ from overridden '_init_headers' method (arguments-differ)
picard/webservice/__init__.py:229:4: W0221: Parameters differ from overridden '_init_headers' method (arguments-differ)
picard/webservice/__init__.py:238:4: W0221: Parameters differ from overridden '_init_headers' method (arguments-differ)
picard/webservice/__init__.py:247:4: W0221: Parameters differ from overridden '_init_headers' method (arguments-differ)
2019-03-25 13:11:38 +01:00
Laurent Monin
3d38e39a1f Fix PyLint R1704: rename local a & b to av & bv
picard/similarity.py:55:8: R1704: Redefining argument with the local name 'a' (redefined-argument-from-local)
picard/similarity.py:58:22: R1704: Redefining argument with the local name 'b' (redefined-argument-from-local)
2019-03-25 13:11:38 +01:00
Laurent Monin
6b1b97e41b Fix PyLint W0221: Mapping.get() is using key not name
picard/metadata.py:307:4: W0221: Parameters differ from overridden 'get' method (arguments-differ)

https://hg.python.org/cpython/file/3.5/Lib/_collections_abc.py#l594
2019-03-25 13:11:38 +01:00
Laurent Monin
42b0cdcd17 Fix PyLint W0611: import is unused because code is using picard.api_versions not api_versions
picard/plugin.py:35:0: W0611: Unused api_versions imported from picard (unused-import)
2019-03-25 13:11:38 +01:00
Laurent Monin
7c1f5efcad Fix PyLint R0201 and R0203
picard/formats/mutagenext/tak.py:45:4: R0201: Method could be a function (no-self-use)
picard/formats/mutagenext/tak.py:55:4: R0203: Consider using a decorator instead of calling staticmethod (no-staticmethod-decorator
2019-03-25 13:11:38 +01:00
Laurent Monin
cad2ffdb9b Append number of alternative versions to Other versions menu label
"Other versions" before download or when no alternative versions exist
"Other versions (#)" after download and when more than one alternative versions exist
2019-03-25 09:00:51 +01:00
Laurent Monin
f0adc86f89 Disable PyLint C0123, this is intentional as explained in the comment 2019-03-24 17:48:59 +01:00
Laurent Monin
d7b77141eb Remove unused imports
picard/ui/util.py:20:0: W0611: Unused QtGui imported from PyQt5 (unused-import)
picard/ui/util.py:31:0: W0611: Unused icontheme imported from picard.util (unused-import)
2019-03-24 17:47:07 +01:00
Laurent Monin
2c457b8dcd Fix PyLint E0202
picard/config.py:260:4: E0202: An attribute defined in picard.config line 244 hides this method (method-hidden)
picard/config.py:287:4: E0202: An attribute defined in picard.config line 244 hides this method (method-hidden)
2019-03-24 17:44:18 +01:00
Laurent Monin
30449d56f7 Fix E1003: Bad first argument 'CoverArtProviderCaa' given to super() (bad-super-call) 2019-03-24 14:49:48 +01:00
Laurent Monin
4983631f70 Merge pull request #1142 from zas/coverimage_metadata_cleanup
CoverArtImage/ImageList/Metadata cleanup
2019-03-24 14:33:50 +01:00
Laurent Monin
7fe2fda12e Merge pull request #1144 from zas/cluster_match_cleanup
Clean up various matching iterations, unify a bit
2019-03-24 14:33:26 +01:00
Laurent Monin
195f3ab9bb Drop debug parameter and associate output, make code easier to read 2019-03-24 12:10:12 +01:00
Laurent Monin
6ab7755f74 Use same parameter name as the overridden method, fixing a pylint warning
https://github.com/metabrainz/picard/pull/1142#discussion_r268423763

Replace `image` by `value` according to https://hg.python.org/cpython/file/3.5/Lib/_collections_abc.py#l895
2019-03-24 12:06:20 +01:00
Laurent Monin
1159df51da Remove extra parenthesis 2019-03-24 11:36:10 +01:00
Laurent Monin
3cbcc1cf0e Reduce code redundancy, using a locally-defined method to output messages 2019-03-23 18:45:24 +01:00
Laurent Monin
7e8235ebf8 rg_id -> release_group_id 2019-03-23 17:19:06 +01:00
Laurent Monin
b9bcf47805 Album._match_files(): add a debug parameter
- it will ease testing, using debug=False will not call log.debug()
2019-03-23 17:13:15 +01:00
Laurent Monin
ecf3cbb3bc Move part of File._lookup_finished() to new File._match_to_track()
- separate UI-related code from processing code
- it will ease testing
2019-03-23 17:11:14 +01:00
Laurent Monin
5e4b698c25 Move part of code from Cluster._lookup_finished() to new _match_to_album()
It will ease testing, separating UI-related code from processing code
2019-03-23 16:46:09 +01:00
Laurent Monin
b33e59428f Clean up various matching iterations, unify a bit
- use generators for candidates
- introduce picard.util.find_best_match() and sort_by_similarity() with tests
- partially revert change that removed sorted(), it was actually faster and cleaner
- use namedtuples to get rid of numeric indexes
- when no match, output max similarity, threshold and number of candidates to debug log
- make code easier to understand, using long names and namedtuple attributes, and simpler workflow
- use repr(best_match) for debug, as it provides all the needed info
- set values explicitly using namedtuple kw parameters
- use same prefix for namedtuples names, it eases searching through code

Typical debug output looks like:
```
D: 13:16:41,806 cluster._lookup_finished:223: BestMatch(similarity=0.79, result=SimMatchRelease(similarity=0.79, release={'id': '36b8f767-c4c0-4ba1-becd-f40a452303d5', 'score': 79, 'count': 1, 'title': 'Purple', 'status': 'Official', 'packaging': 'Jewel Case', 'text-representation': {'language': 'eng', 'script': 'Latn'}, 'artist-credit': [{'artist': {'id': '8c32bb01-58a3-453b-8050-8c0620edb0e5', 'name': 'Stone Temple Pilots', 'sort-name': 'Stone Temple Pilots'}}], 'release-group': {'id': '01d45519-54a6-3427-b0dc-222203fa5d57', 'type-id': 'f529b476-6e62-324f-b0aa-1f3e33d313fc', 'title': 'Purple', 'primary-type': 'Album'}, 'date': '1995-08-25', 'country': 'US', 'release-events': [{'date': '1995-08-25', 'area': {'id': '489ce91b-6658-3307-9877-795b68554c98', 'name': 'United States', 'sort-name': 'United States', 'iso-3166-1-codes': ['US']}}], 'track-count': 11, 'media': [{'format': 'CD', 'disc-count': 10, 'track-count': 11}]}), num_results=25) < threshold=0.800000
```
2019-03-23 16:29:44 +01:00