From fe7be9f0531d680a290fcd9beb847104064ad214 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Thu, 14 Nov 2024 13:15:05 +0100 Subject: [PATCH] fix black --- .../00002_20160803-171643_validators.py | 22 ----------- .../00003_20160829-094134_validators.py | 23 ----------- .../00004_20171026-103118_content_types.py | 24 ------------ .../00005_20181114-090110_vocabularies.py | 39 ------------------- server/gunicorn_config.py | 4 +- server/macros/replace_words.py | 24 ++++++------ 6 files changed, 14 insertions(+), 122 deletions(-) delete mode 100644 server/data_updates/00002_20160803-171643_validators.py delete mode 100644 server/data_updates/00003_20160829-094134_validators.py delete mode 100644 server/data_updates/00004_20171026-103118_content_types.py delete mode 100644 server/data_updates/00005_20181114-090110_vocabularies.py diff --git a/server/data_updates/00002_20160803-171643_validators.py b/server/data_updates/00002_20160803-171643_validators.py deleted file mode 100644 index c349fc3f9..000000000 --- a/server/data_updates/00002_20160803-171643_validators.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8; -*- -# This file is part of Superdesk. -# For the full copyright and license information, please see the -# AUTHORS and LICENSE files distributed with this source code, or -# at https://www.sourcefabric.org/superdesk/license -# -# Author : mugur -# Creation: 2016-08-03 17:16 - -from superdesk.commands.data_updates import BaseDataUpdate -from apps.prepopulate.app_initialize import AppInitializeWithDataCommand - - -class DataUpdate(BaseDataUpdate): - - resource = "validators" - - def forwards(self, mongodb_collection, mongodb_database): - AppInitializeWithDataCommand().run(entity_name="validators") - - def backwards(self, mongodb_collection, mongodb_database): - pass diff --git a/server/data_updates/00003_20160829-094134_validators.py b/server/data_updates/00003_20160829-094134_validators.py deleted file mode 100644 index cc81c3794..000000000 --- a/server/data_updates/00003_20160829-094134_validators.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8; -*- -# This file is part of Superdesk. -# For the full copyright and license information, please see the -# AUTHORS and LICENSE files distributed with this source code, or -# at https://www.sourcefabric.org/superdesk/license -# -# Author : petr -# Creation: 2016-08-29 09:41 - -from superdesk.commands.data_updates import BaseDataUpdate - - -class DataUpdate(BaseDataUpdate): - - resource = "validators" - - def forwards(self, mongodb_collection, mongodb_database): - mongodb_collection.update_many( - {"_id": {"$in": ["publish_embedded_picture", "correct_embedded_picture"]}}, {"$set": {"embedded": True}} - ) - - def backwards(self, mongodb_collection, mongodb_database): - pass diff --git a/server/data_updates/00004_20171026-103118_content_types.py b/server/data_updates/00004_20171026-103118_content_types.py deleted file mode 100644 index c244d6a9c..000000000 --- a/server/data_updates/00004_20171026-103118_content_types.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8; -*- -# This file is part of Superdesk. -# For the full copyright and license information, please see the -# AUTHORS and LICENSE files distributed with this source code, or -# at https://www.sourcefabric.org/superdesk/license -# -# Author : mugur -# Creation: 2017-10-26 10:31 - -from superdesk.commands.data_updates import BaseDataUpdate -from superdesk import get_resource_service - - -class DataUpdate(BaseDataUpdate): - - resource = "content_types" - - def forwards(self, mongodb_collection, mongodb_database): - content_types_service = get_resource_service("content_types") - for content_type in content_types_service.get(req=None, lookup=None): - content_types_service.patch(content_type["_id"], {}) - - def backwards(self, mongodb_collection, mongodb_database): - pass diff --git a/server/data_updates/00005_20181114-090110_vocabularies.py b/server/data_updates/00005_20181114-090110_vocabularies.py deleted file mode 100644 index 620a9c933..000000000 --- a/server/data_updates/00005_20181114-090110_vocabularies.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8; -*- -# This file is part of Superdesk. -# For the full copyright and license information, please see the -# AUTHORS and LICENSE files distributed with this source code, or -# at https://www.sourcefabric.org/superdesk/license -# -# Creation: 2018-11-14 10:31 - -from superdesk.commands.data_updates import BaseDataUpdate -from superdesk import get_resource_service - - -class DataUpdate(BaseDataUpdate): - - resource = "vocabularies" - - def forwards(self, mongodb_collection, mongodb_database): - vocabularies_service = get_resource_service("vocabularies") - for vocabulary in vocabularies_service.get(req=None, lookup=None): - if vocabulary.get("selection_type"): - continue - if vocabulary.get("single_value", False): - value = "single selection" - else: - value = "multi selection" - mongodb_collection.update( - {"_id": vocabulary["_id"]}, {"$set": {"selection_type": value}, "$unset": {"single_value": 1}} - ) - - def backwards(self, mongodb_collection, mongodb_database): - vocabularies_service = get_resource_service("vocabularies") - for vocabulary in vocabularies_service.get(req=None, lookup=None): - if vocabulary.get("selection_type") == "single selection": - value = True - else: - value = False - mongodb_collection.update( - {"_id": vocabulary["_id"]}, {"$set": {"single_value": value}, "$unset": {"selection_type": 1}} - ) diff --git a/server/gunicorn_config.py b/server/gunicorn_config.py index 07dff6bbf..2b527aad7 100644 --- a/server/gunicorn_config.py +++ b/server/gunicorn_config.py @@ -7,5 +7,5 @@ accesslog = "-" access_log_format = "%(m)s %(U)s status=%(s)s time=%(T)ss size=%(B)sb" -reload = 'SUPERDESK_RELOAD' in os.environ -timeout = int(os.environ.get('WEB_TIMEOUT', 30)) +reload = "SUPERDESK_RELOAD" in os.environ +timeout = int(os.environ.get("WEB_TIMEOUT", 30)) diff --git a/server/macros/replace_words.py b/server/macros/replace_words.py index 2df24ecfe..28246be2f 100644 --- a/server/macros/replace_words.py +++ b/server/macros/replace_words.py @@ -40,7 +40,7 @@ def repl(new, old): return new.title() # it is more complex so try to match it else: - result = '' + result = "" all_upper = True for i, c in enumerate(old): if i >= len(new): @@ -52,20 +52,20 @@ def repl(new, old): all_upper = False # append any remaining characters from new if all_upper: - result += new[i + 1:].upper() + result += new[i + 1 :].upper() else: - result += new[i + 1:].lower() + result += new[i + 1 :].lower() return result def do_find_replace(input_string, words_list): found_list = {} for word in words_list: - pattern = r'{}'.format(re.escape(word.get('existing', ''))) + pattern = r"{}".format(re.escape(word.get("existing", ""))) while re.search(pattern, input_string, flags=re.IGNORECASE): # get the original string from the input original = re.search(pattern, input_string, flags=re.IGNORECASE).group(0) - replacement = repl(word.get('replacement', ''), original) + replacement = repl(word.get("replacement", ""), original) if found_list.get(original): break diff[original] = replacement @@ -74,10 +74,10 @@ def do_find_replace(input_string, words_list): return input_string - vocab = get_resource_service('vocabularies').find_one(req=None, _id='replace_words') + vocab = get_resource_service("vocabularies").find_one(req=None, _id="replace_words") if vocab: - replace_words_list = vocab.get('items') or [] + replace_words_list = vocab.get("items") or [] if not replace_words_list: return item @@ -91,10 +91,10 @@ def do_find_replace(input_string, words_list): return item -name = 'Replace_Words' -label = 'Replace words in the article' +name = "Replace_Words" +label = "Replace words in the article" order = 1 -shortcut = 'a' +shortcut = "a" callback = find_and_replace -access_type = 'frontend' -action_type = 'direct' +access_type = "frontend" +action_type = "direct"