Commit Graph

111 Commits

Author SHA1 Message Date
Laurent Monin
fd25dc987d PICARD-1748: limit number of countries displayed to 10 2020-02-19 20:11:58 +00:00
Laurent Monin
498c8eab1b Add mktmpdir method to PicardTestCase, and use it more widely 2020-02-08 18:04:39 +01:00
Philipp Wolfer
0855862c8c PICARD-321: Support backslash in filenames on non-Windows OS
With this change backslashes can be used in filenames on systems other than Windows. Only if Windows compatibility is activated backslashes will be replaced as before.
2019-12-14 01:03:46 +01:00
Laurent Monin
e529ee7d71 Test display_tag_name() when name contains multiple double dot separators 2019-12-09 12:48:24 +01:00
Philipp Wolfer
26d51865b4 PICARD-456: Do not remove empty standard directories
This protects standard directories like e.g. ~/Desktop being deleted if empty.
2019-09-13 16:25:51 +02:00
Philipp Wolfer
2e0afbae4d PICARD-1488: Display player position 0 as 0:00 instead of ?:?? 2019-08-13 17:42:34 +02:00
Philipp Wolfer
dc0ec84401 isort: Consistently use two blank lines after import 2019-04-04 08:35:23 +02:00
Philipp Wolfer
dd4da2aa47 Updated isort config to put test imports in separate section 2019-04-04 08:32:22 +02: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
Philipp Wolfer
f0619614a3 PICARD-1485: Format track durations with hours
Durations of an hour or more will show the hours as HH:MM:SS
2019-03-08 10:24:12 +01:00
Laurent Monin
6388ef20f5 Use IS_WIN, IS_MACOS, IS_LINUX 2019-03-05 21:53:32 +01:00
Laurent Monin
1ca043dd90 Add tests for mbid_validate() 2019-03-04 19:35:05 +01:00
Philipp Wolfer
f93a44e00b compare_barcodes: Both None and '' are considered "no barcode" 2018-10-25 08:53:53 +02:00
Philipp Wolfer
e94e36eca0 PICARD-1383: Select release with matching barcode on disc ID lookup 2018-10-25 08:53:53 +02:00
Wieland Hoffmann
e624aa121c Make PicardTestCase the parent class of all tests
This brings the faketagger and, more importantly, settings reset to all of them.
2018-10-23 17:32:50 +02:00
Laurent Monin
16a3074be4 PEP8 fixes 2018-09-13 17:54:13 +02:00
Laurent Monin
5329e3592a Clean up and sort imports using isort
Add a config for isort (https://github.com/timothycrosley/isort)
Run isort -rc . and make import style consistent across files
Add a note about `isort` in CONTRIBUTING.md
2018-08-22 08:51:25 +02:00
Sophist
c2c37c8037 Remove unused variables 2017-05-17 15:07:12 +01:00
Shen-Ta Hsieh
d0d9711a37 Update test/data/mb.png size for test_png
Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
2017-05-05 17:54:13 +08:00
Sambhav Kothari
b0fcc9eedf Fix test_script 2017-04-07 16:06:15 +05:30
Frederik “Freso” S. Olesen
82da54a9af Update test for new PNG file size. 2016-02-22 01:09:37 +01:00
Wieland Hoffmann
7bd95c46be Merge branch 'PICARD-663' of https://github.com/phw/picard 2014-12-05 17:55:14 +01:00
Philipp Wolfer
3b49da9109 Split the drive in replace_win32_incompat only on win32.
Also updated the tests, since this is now platform dependent.
2014-12-05 17:28:01 +01:00
Philipp Wolfer
eb3bb01ca7 Do not run the HiddenFileTest unit tests on Windows.
The unit tests only consider the string and whether any path component starts with a ".". On Windows the dotfiles are not used for hidden files so the tests fail. To have proper tests on Windows would require to have an actual folder structure with hidden files and folders.
2014-12-05 17:08:52 +01:00
Philipp Wolfer
8a336f4b92 Fixed renaming paths starting with "[a-z]:" being interpreted as drive names on Windows.
Fixes PICARD-663
2014-12-04 13:30:05 +01:00
Philipp Wolfer
80e852ceae Allow explicit loading of hidden files.
This will allow explicit loading of hidden files, but still will ignore hidden files and folders on deeper levels if the "show_hidden_files" option is disabled.

This fixes PICARD-589 and improves PICARD-528.
2014-10-26 13:08:38 +01:00
Laurent Monin
19d307d9bb PICARD-630: linear_combination_of_weights() raises exception
It happens when the function is called with empty parts list.
Returns 0.0 instead of raising ZeroDivisionError exception
2014-09-26 10:24:56 +02:00
Laurent Monin
c0de7d95c9 PEP8 fixes 2014-05-21 16:04:35 +02:00
Laurent Monin
dc6e150d45 imageinfo: differentiate each failure case
Add exceptions (subclassing IdentificationError):
- NotEnoughData
- UnrecognizedFormat

Add corresponding test code.
2014-05-16 15:47:24 +02:00
Laurent Monin
fe62ec7c1e imageinfo.IdentifyError -> imageinfo.IdentificationError 2014-05-16 15:40:23 +02:00
Laurent Monin
5ab4625fe7 imageinfo: simplify code and exceptions, image_info() -> identify() 2014-05-15 15:40:36 +02:00
Laurent Monin
9a8fd64aec imageinfo: add extension to result 2014-05-15 15:29:22 +02:00
Laurent Monin
b4367486bd Introduce image_info() to extract width, height from image data 2014-05-15 14:35:56 +02:00
Sophist
6344ca2806 Move album_artist_from_path to utils
and add test.
2014-05-12 22:24:31 +01:00
Sophist
adab289bdb Fix and add tests for windows drive 2014-05-11 10:24:35 +01:00
Laurent Monin
4f2da821d3 Add tests for util.linear_combination_of_weights 2014-04-28 16:22:18 +02:00
Laurent Monin
8a5a2d8514 Fix missing _() in some cases.
======================================================================
ERROR: test_display_tag_name (test.test_utils.TagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/musicbrainz/picard/test/test_utils.py", line 89, in test_display_tag_name
self.assertEqual(dtn('tag'), 'tag')
File "/home/travis/build/musicbrainz/picard/picard/util/tags.py", line 106, in display_tag_name
return _(name)
NameError: global name '_' is not defined
2014-04-26 14:32:13 +02:00
Laurent Monin
14c09a8d1e Add a test for util.tags.display_tag_name() 2014-04-22 10:31:19 +02:00
Sophist
323d12892c Improve unicode to ascii ...
for punctuation, normalization (merging similar looking characters into
the most common one), accents, and full conversion to ascii.

Functions and tests moved into separate files.

Although more comprehensive, the code should run faster because it
eliminates several loops (inc. a loop with two unicodedata references).

This is intended to form the basis of future PRs to:
a. Clean up (simplify) the file naming code
b. Provide script function(s) for cleaning individual tags / file name
parts
c. Add support for translation / transliteration plugins (which I think
make more sense than being included in Picard itself).
d. Support for converting Tags to ISO-8859-1 rather than ascii (since
that is what is supported by ID3 at least)
e. Possible additional options for allowing / preventing normalization,
possible reorganisation of options to centralise all encoding settings
onto one page rather than metadata, tags and file naming pages at
present (to be discussed).
2014-04-14 11:57:31 +01:00
Laurent Monin
a2a84ac8e6 Convert release_type_scores option to ListOption
We had a space-separated list of name,value tuples ("Album 0.5 Other 0.4"),
and two helper functions to load and save data in the correct format
(`load_release_type_scores` and `save_release_type_scores`).

Since option is converted to recently-introduced ListOption, data is now saved
as a list of tuples, eventually converted to dict when needed.
It simplifies code, and also prevents an issue if it comes we have a release group type
with a space in its name.

An upgrade hook was added to handle this change on Picard upgrade.
2014-04-10 10:21:30 +02:00
Laurent Monin
a0598bdc6f Ignore hidden files and directories based on show_hidden_files option.
http://tickets.musicbrainz.org/browse/PICARD-528
2013-12-27 11:09:23 +01:00
Ionuț Ciocîrlan
aaab0dae48 moved filenaming stuff to its own module 2013-07-06 11:38:12 +03:00
Ionuț Ciocîrlan
b07e7f3e4d Merge remote-tracking branch 'upstream/master'
Conflicts:
	picard/util/__init__.py
	test/test_utils.py
2013-07-06 10:21:00 +03:00
Laurent Monin
7dd311697f tests: PEP8 fixes 2013-07-03 03:37:24 +02:00
Laurent Monin
60ed243470 Deprecated failUnlessRaises() -> assertRaises()
http://docs.python.org/2/library/unittest.html#deprecated-aliases
2013-07-01 13:33:42 +02:00
Laurent Monin
6062fe404e Deprecated failIfEqual() -> assertNotEqual()
http://docs.python.org/2/library/unittest.html#deprecated-aliases
2013-07-01 13:31:41 +02:00
Laurent Monin
403bafbbaa Deprecated failUnlessEqual() -> assertEqual()
http://docs.python.org/2/library/unittest.html#deprecated-aliases
2013-07-01 13:29:57 +02:00
Ionuț Ciocîrlan
fe8f6c2176 Characters counted in UTF-16 code points where appropriate.
NFD handled under OS X.
Windows bugfix when the relative directory path is short enough.
2013-06-17 21:42:10 +03:00
Ionuț Ciocîrlan
1b695eea63 small fixes and some comments 2013-06-14 21:18:25 +03:00
Ionuț Ciocîrlan
c2874ed671 tests and subsequent fixes 2013-06-11 18:19:15 +03:00