mirror of https://gitlab.com/bashrc2/epicyon
POST variables should be camel case
parent
3e97e9e6a4
commit
1d0da992e9
|
@ -222,15 +222,15 @@ def switch_words(base_dir: str, nickname: str, domain: str, content: str,
|
|||
return content
|
||||
|
||||
if not rules:
|
||||
switch_wordsFilename = \
|
||||
switch_words_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/replacewords.txt'
|
||||
if not os.path.isfile(switch_wordsFilename):
|
||||
if not os.path.isfile(switch_words_filename):
|
||||
return content
|
||||
try:
|
||||
with open(switch_wordsFilename, 'r') as fp:
|
||||
with open(switch_words_filename, 'r') as fp:
|
||||
rules = fp.readlines()
|
||||
except OSError:
|
||||
print('EX: unable to read switches ' + switch_wordsFilename)
|
||||
print('EX: unable to read switches ' + switch_words_filename)
|
||||
|
||||
for line in rules:
|
||||
replaceStr = line.replace('\n', '').replace('\r', '')
|
||||
|
|
|
@ -6273,10 +6273,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
switchFilename = \
|
||||
acct_dir(base_dir, nickname, domain) + \
|
||||
'/replacewords.txt'
|
||||
if fields.get('switch_words'):
|
||||
if fields.get('switchwords'):
|
||||
try:
|
||||
with open(switchFilename, 'w+') as switchfile:
|
||||
switchfile.write(fields['switch_words'])
|
||||
switchfile.write(fields['switchwords'])
|
||||
except OSError:
|
||||
print('EX: unable to write switches ' +
|
||||
switchFilename)
|
||||
|
|
36
tests.py
36
tests.py
|
@ -4460,6 +4460,39 @@ def _diagram_groups(includeGroups: [],
|
|||
'-Gsep=+100 -Tx11 epicyon_modules.dot')
|
||||
|
||||
|
||||
def _test_post_variable_names():
|
||||
print('testPostVariableNames')
|
||||
|
||||
for subdir, dirs, files in os.walk('.'):
|
||||
for source_file in files:
|
||||
if not source_file.endswith('.py'):
|
||||
continue
|
||||
if source_file.startswith('.#'):
|
||||
continue
|
||||
if source_file.startswith('flycheck_'):
|
||||
continue
|
||||
source_str = ''
|
||||
with open(source_file, 'r') as file_source:
|
||||
source_str = file_source.read()
|
||||
if not source_str:
|
||||
continue
|
||||
if ' name="' not in source_str:
|
||||
continue
|
||||
names_list = source_str.split(' name="')
|
||||
for index in range(1, len(names_list)):
|
||||
if '"' not in names_list[index]:
|
||||
continue
|
||||
name_var = names_list[index].split('"')[0]
|
||||
if not name_var:
|
||||
continue
|
||||
if ' ' in name_var:
|
||||
continue
|
||||
if '_' in name_var:
|
||||
print(name_var + ' is not camel case POST variable in ' +
|
||||
source_file)
|
||||
return False
|
||||
|
||||
|
||||
def _test_functions():
|
||||
print('testFunctions')
|
||||
function = {}
|
||||
|
@ -4474,6 +4507,8 @@ def _test_functions():
|
|||
continue
|
||||
if sourceFile.startswith('.#'):
|
||||
continue
|
||||
if sourceFile.startswith('flycheck_'):
|
||||
continue
|
||||
modName = sourceFile.replace('.py', '')
|
||||
modules[modName] = {
|
||||
'functions': []
|
||||
|
@ -6103,6 +6138,7 @@ def run_all_tests():
|
|||
update_default_themes_list(os.getcwd())
|
||||
_translate_ontology(base_dir)
|
||||
_test_get_price_from_string()
|
||||
_test_post_variable_names()
|
||||
_test_functions()
|
||||
_test_get_actor_from_in_reply_to()
|
||||
_test_valid_emoji_content()
|
||||
|
|
|
@ -1731,7 +1731,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
|
|||
' <br><b><label class="labels">' + \
|
||||
translate['Word Replacements'] + '</label></b>\n' + \
|
||||
' <br><label class="labels">A -> B</label>\n' + \
|
||||
' <textarea id="message" name="switch_words" ' + \
|
||||
' <textarea id="message" name="switchwords" ' + \
|
||||
'style="height:200px" spellcheck="false">' + \
|
||||
switchStr + '</textarea>\n' + \
|
||||
' <br><b><label class="labels">' + \
|
||||
|
|
Loading…
Reference in New Issue