mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Update vendored beets to 1.6.0
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
This commit is contained in:
parent
5073ec0c6f
commit
56c6773c6b
385 changed files with 25143 additions and 18080 deletions
|
@ -1,7 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
"""Fixes file permissions after the file gets written on import. Put something
|
||||
like the following in your config.yaml to configure:
|
||||
|
||||
|
@ -13,7 +9,6 @@ import os
|
|||
from beets import config, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.util import ancestry
|
||||
import six
|
||||
|
||||
|
||||
def convert_perm(perm):
|
||||
|
@ -21,8 +16,8 @@ def convert_perm(perm):
|
|||
Or, if `perm` is an integer, reinterpret it as an octal number that
|
||||
has been "misinterpreted" as decimal.
|
||||
"""
|
||||
if isinstance(perm, six.integer_types):
|
||||
perm = six.text_type(perm)
|
||||
if isinstance(perm, int):
|
||||
perm = str(perm)
|
||||
return int(perm, 8)
|
||||
|
||||
|
||||
|
@ -40,11 +35,11 @@ def assert_permissions(path, permission, log):
|
|||
"""
|
||||
if not check_permissions(util.syspath(path), permission):
|
||||
log.warning(
|
||||
u'could not set permissions on {}',
|
||||
'could not set permissions on {}',
|
||||
util.displayable_path(path),
|
||||
)
|
||||
log.debug(
|
||||
u'set permissions to {}, but permissions are now {}',
|
||||
'set permissions to {}, but permissions are now {}',
|
||||
permission,
|
||||
os.stat(util.syspath(path)).st_mode & 0o777,
|
||||
)
|
||||
|
@ -60,20 +55,39 @@ def dirs_in_library(library, item):
|
|||
|
||||
class Permissions(BeetsPlugin):
|
||||
def __init__(self):
|
||||
super(Permissions, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
# Adding defaults.
|
||||
self.config.add({
|
||||
u'file': '644',
|
||||
u'dir': '755',
|
||||
'file': '644',
|
||||
'dir': '755',
|
||||
})
|
||||
|
||||
self.register_listener('item_imported', self.fix)
|
||||
self.register_listener('album_imported', self.fix)
|
||||
self.register_listener('art_set', self.fix_art)
|
||||
|
||||
def fix(self, lib, item=None, album=None):
|
||||
"""Fix the permissions for an imported Item or Album.
|
||||
"""
|
||||
files = []
|
||||
dirs = set()
|
||||
if item:
|
||||
files.append(item.path)
|
||||
dirs.update(dirs_in_library(lib.directory, item.path))
|
||||
elif album:
|
||||
for album_item in album.items():
|
||||
files.append(album_item.path)
|
||||
dirs.update(dirs_in_library(lib.directory, album_item.path))
|
||||
self.set_permissions(files=files, dirs=dirs)
|
||||
|
||||
def fix_art(self, album):
|
||||
"""Fix the permission for Album art file.
|
||||
"""
|
||||
if album.artpath:
|
||||
self.set_permissions(files=[album.artpath])
|
||||
|
||||
def set_permissions(self, files=[], dirs=[]):
|
||||
# Get the configured permissions. The user can specify this either a
|
||||
# string (in YAML quotes) or, for convenience, as an integer so the
|
||||
# quotes can be omitted. In the latter case, we need to reinterpret the
|
||||
|
@ -83,21 +97,10 @@ class Permissions(BeetsPlugin):
|
|||
file_perm = convert_perm(file_perm)
|
||||
dir_perm = convert_perm(dir_perm)
|
||||
|
||||
# Create chmod_queue.
|
||||
file_chmod_queue = []
|
||||
if item:
|
||||
file_chmod_queue.append(item.path)
|
||||
elif album:
|
||||
for album_item in album.items():
|
||||
file_chmod_queue.append(album_item.path)
|
||||
|
||||
# A set of directories to change permissions for.
|
||||
dir_chmod_queue = set()
|
||||
|
||||
for path in file_chmod_queue:
|
||||
for path in files:
|
||||
# Changing permissions on the destination file.
|
||||
self._log.debug(
|
||||
u'setting file permissions on {}',
|
||||
'setting file permissions on {}',
|
||||
util.displayable_path(path),
|
||||
)
|
||||
os.chmod(util.syspath(path), file_perm)
|
||||
|
@ -105,16 +108,11 @@ class Permissions(BeetsPlugin):
|
|||
# Checks if the destination path has the permissions configured.
|
||||
assert_permissions(path, file_perm, self._log)
|
||||
|
||||
# Adding directories to the directory chmod queue.
|
||||
dir_chmod_queue.update(
|
||||
dirs_in_library(lib.directory,
|
||||
path))
|
||||
|
||||
# Change permissions for the directories.
|
||||
for path in dir_chmod_queue:
|
||||
# Chaning permissions on the destination directory.
|
||||
for path in dirs:
|
||||
# Changing permissions on the destination directory.
|
||||
self._log.debug(
|
||||
u'setting directory permissions on {}',
|
||||
'setting directory permissions on {}',
|
||||
util.displayable_path(path),
|
||||
)
|
||||
os.chmod(util.syspath(path), dir_perm)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue