|
14 | 14 | # You should have received a copy of the GNU General Public License
|
15 | 15 | # along with Headphones. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
17 |
| -from operator import itemgetter |
18 |
| -import unicodedata |
19 |
| -import datetime |
| 17 | +import os |
| 18 | +import re |
20 | 19 | import shutil
|
21 |
| -import time |
22 | 20 | import sys
|
23 | 21 | import tempfile
|
24 |
| -import glob |
25 |
| - |
26 |
| -from beets import logging as beetslogging |
27 |
| -import six |
| 22 | +import time |
| 23 | +import unicodedata |
28 | 24 | from contextlib import contextmanager
|
| 25 | +from datetime import datetime, date |
| 26 | +from fnmatch import fnmatch |
| 27 | +from functools import cmp_to_key |
| 28 | +from glob import glob |
| 29 | +from operator import itemgetter |
29 | 30 |
|
30 |
| -import fnmatch |
31 |
| -import functools |
32 |
| -import re |
33 |
| -import os |
| 31 | +from beets import logging as beetslogging |
34 | 32 | from mediafile import MediaFile, FileTypeError, UnreadableFileError
|
| 33 | +from six import text_type |
35 | 34 | from unidecode import unidecode
|
| 35 | + |
36 | 36 | import headphones
|
37 | 37 |
|
38 | 38 |
|
@@ -74,7 +74,7 @@ def comparer(left, right):
|
74 | 74 | else:
|
75 | 75 | return 0
|
76 | 76 |
|
77 |
| - return sorted(items, key=functools.cmp_to_key(comparer)) |
| 77 | + return sorted(items, key=cmp_to_key(comparer)) |
78 | 78 |
|
79 | 79 |
|
80 | 80 | def checked(variable):
|
@@ -156,21 +156,19 @@ def convert_seconds(s):
|
156 | 156 |
|
157 | 157 |
|
158 | 158 | def today():
|
159 |
| - today = datetime.date.today() |
160 |
| - yyyymmdd = datetime.date.isoformat(today) |
161 |
| - return yyyymmdd |
| 159 | + return date.isoformat(date.today()) |
162 | 160 |
|
163 | 161 |
|
164 | 162 | def now():
|
165 |
| - now = datetime.datetime.now() |
| 163 | + now = datetime.now() |
166 | 164 | return now.strftime("%Y-%m-%d %H:%M:%S")
|
167 | 165 |
|
168 | 166 |
|
169 |
| -def is_valid_date(date): |
170 |
| - if not date: |
| 167 | +def is_valid_date(d): |
| 168 | + if not d: |
171 | 169 | return False
|
172 | 170 | else:
|
173 |
| - return bool(re.match(r'\d{4}-\d{2}-\d{2}', date)) |
| 171 | + return bool(re.match(r'\d{4}-\d{2}-\d{2}', d)) |
174 | 172 |
|
175 | 173 |
|
176 | 174 | def age(d):
|
@@ -508,7 +506,7 @@ def path_match_patterns(path, patterns):
|
508 | 506 | """
|
509 | 507 |
|
510 | 508 | for pattern in patterns:
|
511 |
| - if fnmatch.fnmatch(path, pattern): |
| 509 | + if fnmatch(path, pattern): |
512 | 510 | return True
|
513 | 511 |
|
514 | 512 | # No match
|
@@ -714,7 +712,7 @@ def preserve_torrent_directory(albumpath, forced=False, single=False):
|
714 | 712 | workdir = os.path.join(tempdir, prefix)
|
715 | 713 | workdir = re.sub(r'\[', '[[]', workdir)
|
716 | 714 | workdir = re.sub(r'(?<!\[)\]', '[]]', workdir)
|
717 |
| - if len(glob.glob(workdir + '*/')) >= 3: |
| 715 | + if len(glob(workdir + '*/')) >= 3: |
718 | 716 | logger.error(
|
719 | 717 | "Looks like a temp directory has previously been created "
|
720 | 718 | "for this albumpath, not continuing "
|
@@ -1033,7 +1031,7 @@ def __init__(self):
|
1033 | 1031 | self.messages = []
|
1034 | 1032 |
|
1035 | 1033 | def emit(self, record):
|
1036 |
| - self.messages.append(six.text_type(record.msg)) |
| 1034 | + self.messages.append(text_type(record.msg)) |
1037 | 1035 |
|
1038 | 1036 |
|
1039 | 1037 | @contextmanager
|
|
0 commit comments