- image.types_as_string() was called from get_image_type() without translate=False
- dependency wasn't satisfied, so impossible to test as is
- make tests depending on languages isn't a good idea anyway
- use new CoverArtImage.normalized_types() instead
- simplify code
- add tests for ImageList.append() and ImageList.__eq__()
- basically it returns config.setting[key] when key isn't in the internal dict
- it protects config.setting from any write, since __setitem__ only write to self._dict
- del settings['xxx'] will remove 'xxx' from internal dict, but still allow access to config.setting
- it can be used for tests
- minimal implementation based on MutableMapping
- add tests for it
m['tag'] = 0 wasn't doing the same thing as m.add('tag', 0), because the test in __setitem__()
was different: if value vs if value or value == 0
So modify it to make behavior much more consistent.
m['tag'] = 0 or m.add('tag', 0) actually set tag to ['0']
m.add('tag', '') does nothing
m['tag'] = '' explicitly delete the tag (removing it from store, adding it to deleted tags)
m = Metadata(tag='') doesn't create an entry 'tag' (at all)
m = Metadata(tag=0) creates a tag, with internal value ['0']
This way, one can rewrite:
self.metadata = Metadata()
self.metadata['album'] = name
self.metadata['albumartist'] = artist
self.metadata['totaltracks'] = 0
to:
self.metadata = Metadata(album=name, albumartist=artist, totaltracks=0)
Without this patch, totaltracks wasn't set at all.
```python
m = Metadata(tag1='a', tag2='b')
del m['tag1']
```
```
m store: {'tag2': ['b']}
m deleted: {'tag1'}
```
```python
m2 = Metadata(tag1='c', tag2='d')
del m2['tag2']
```
```
m2 store: {'tag2': ['b']}
m2 deleted: {'tag1'}
```
```python
m.update(m2)
```
```
m store: {'tag1': ['c']}
m deleted: {'tag1', 'tag2'} <---- this was incorrect, and untested case
```
This patch fixes it, and results to:
```
m store: {'tag1': ['c']}
m deleted: {'tag2'}
```
- access times are likely to differ, a race condition is possible
- stat() has be done after the change to be able to compare
- comments added
- force sync after modifying test file
- make code easier to understand
See https://github.com/metabrainz/picard/pull/1132#issuecomment-474113665
https://docs.python.org/3/library/os.html#os.utime
Since Python 3.3, ns parameter is available
"The best way to preserve exact times is to use the st_atime_ns and st_mtime_ns
fields from the os.stat() result object with the ns parameter to utime."
Make time preservation testable.
All our current tags support either no or only one type.
Fixes issues where files where shown as modified when loading again and comparing against cover art with more than one type.
The search server outputs these property names with hyphens, not
underscores.
MBS does output them using underscores for artist lookups, but (1)
Picard doesn't appear to perform any artist lookups, and (2) MBS will be
fixing that to use hyphens as well.