Minor refactor
This commit is contained in:
parent
e2c26d5b46
commit
d9336fda6e
@ -21,6 +21,7 @@ import yanlib
|
|||||||
import os
|
import os
|
||||||
import contextlib
|
import contextlib
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
from functools import reduce
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from mastodon import Mastodon, MastodonIllegalArgumentError, MastodonAPIError, MastodonVersionError
|
from mastodon import Mastodon, MastodonIllegalArgumentError, MastodonAPIError, MastodonVersionError
|
||||||
|
|
||||||
@ -161,16 +162,18 @@ class YandereBot:
|
|||||||
if not self.settings_behavior["master_list"]:
|
if not self.settings_behavior["master_list"]:
|
||||||
raise MissingMasterList
|
raise MissingMasterList
|
||||||
|
|
||||||
list_pictures = []
|
|
||||||
# Return a list of hashes with profiles
|
|
||||||
try:
|
try:
|
||||||
for f in self.settings_behavior["master_list"]:
|
list_pictures = reduce(lambda x, y: x + y,
|
||||||
add_list = get_list_of_hashes_with_profiles(f, self.settings_post, self.settings_post_default)
|
[get_list_of_hashes_with_profiles(
|
||||||
list_pictures.extend(add_list)
|
f,
|
||||||
|
self.settings_post,
|
||||||
|
self.settings_post_default)
|
||||||
|
for f in self.settings_behavior["master_list"]
|
||||||
|
])
|
||||||
|
return yanlib.get_hash_list_blacklist(list_pictures, list_blacklist, self.settings_behavior["max_size"])
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print(e)
|
print(e)
|
||||||
raise MissingMasterList
|
raise MissingMasterList
|
||||||
return yanlib.get_hash_list_blacklist(list_pictures, list_blacklist, self.settings_behavior["max_size"])
|
|
||||||
|
|
||||||
def load_picture_list(self):
|
def load_picture_list(self):
|
||||||
list_blacklist = self.read_blacklist_files()
|
list_blacklist = self.read_blacklist_files()
|
||||||
@ -381,11 +384,7 @@ def get_profile(hash_obj, profiles, profiles_default):
|
|||||||
# @param profiles_default The default profile to apply
|
# @param profiles_default The default profile to apply
|
||||||
# @param callback_get_profile Callback function -> should return a single profile. Default: get_profile()
|
# @param callback_get_profile Callback function -> should return a single profile. Default: get_profile()
|
||||||
def get_list_of_hashes_with_profiles(f_name, profiles, profile_default):
|
def get_list_of_hashes_with_profiles(f_name, profiles, profile_default):
|
||||||
r = []
|
return [YanBotHash(i, get_profile(i, profiles, profile_default)) for i in yanlib.get_hash_list(f_name)]
|
||||||
for item in yanlib.get_hash_list(f_name):
|
|
||||||
post_setting = get_profile(item, profiles, profile_default)
|
|
||||||
r.append(YanBotHash(item, post_setting))
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
# Custom Exceptions for YandereBot
|
# Custom Exceptions for YandereBot
|
||||||
|
Reference in New Issue
Block a user