fix bug
This commit is contained in:
parent
7d12c4defa
commit
ce8c934436
15
main.py
15
main.py
@ -10,7 +10,7 @@ import sys
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
|
|
||||||
__title__ = "KeyJ's iPod shuffle Database Builder"
|
__title__ = "iPod shuffle Database Builder" # by Sylvain
|
||||||
__version__ = "1.0-rc1"
|
__version__ = "1.0-rc1"
|
||||||
KNOWN_PROPS = frozenset(
|
KNOWN_PROPS = frozenset(
|
||||||
("filename", "size", "ignore", "type", "shuffle", "reuse", "bookmark")
|
("filename", "size", "ignore", "type", "shuffle", "reuse", "bookmark")
|
||||||
@ -240,6 +240,17 @@ class ShuffleRebuild:
|
|||||||
ka, kb = cls._key_repr(a), cls._key_repr(b)
|
ka, kb = cls._key_repr(a), cls._key_repr(b)
|
||||||
return (ka > kb) - (ka < kb)
|
return (ka > kb) - (ka < kb)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _cmp_file_entry(cls, a, b) -> int:
|
||||||
|
c = (a[0] > b[0]) - (a[0] < b[0])
|
||||||
|
if c:
|
||||||
|
return c
|
||||||
|
c = cls._cmp_sort_key(a[1], b[1])
|
||||||
|
if c:
|
||||||
|
return c
|
||||||
|
pa, pb = a[2], b[2]
|
||||||
|
return (pa > pb) - (pa < pb)
|
||||||
|
|
||||||
def _file_entry(self, path: str, name: str, prefix: str = ""):
|
def _file_entry(self, path: str, name: str, prefix: str = ""):
|
||||||
if not name or name[0] == ".":
|
if not name or name[0] == ".":
|
||||||
return None
|
return None
|
||||||
@ -302,7 +313,7 @@ class ShuffleRebuild:
|
|||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
files.sort(key=cmp_to_key(self._cmp_sort_key))
|
files.sort(key=cmp_to_key(self._cmp_file_entry))
|
||||||
nfiles = sum(1 for x in files if x[0])
|
nfiles = sum(1 for x in files if x[0])
|
||||||
if nfiles:
|
if nfiles:
|
||||||
self.domains.append([])
|
self.domains.append([])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user