Skip to content

Commit

Permalink
fix black
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Nov 14, 2024
1 parent 4293428 commit fe7be9f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 122 deletions.
22 changes: 0 additions & 22 deletions server/data_updates/00002_20160803-171643_validators.py

This file was deleted.

23 changes: 0 additions & 23 deletions server/data_updates/00003_20160829-094134_validators.py

This file was deleted.

24 changes: 0 additions & 24 deletions server/data_updates/00004_20171026-103118_content_types.py

This file was deleted.

39 changes: 0 additions & 39 deletions server/data_updates/00005_20181114-090110_vocabularies.py

This file was deleted.

4 changes: 2 additions & 2 deletions server/gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
24 changes: 12 additions & 12 deletions server/macros/replace_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"

0 comments on commit fe7be9f

Please sign in to comment.