Commit 3a21bd9d authored by Denis Salem's avatar Denis Salem
Browse files

WIP fixing regression triggered in unit tests, fix wrong yaml load call left,...

WIP fixing regression triggered in unit tests, fix wrong yaml load call left, display python version with venc -v
parent 0ac1dc02
......@@ -88,7 +88,10 @@ def to_camel_case(name):
''' Processing blog configuration '''
try:
blog_configuration = yaml.load(open(os.getcwd()+"/blog_configuration.yaml",'r').read())
blog_configuration = yaml.load(
open(os.getcwd()+"/blog_configuration.yaml",'r').read(),
Loader=yaml.FullLoader
)
except FileNotFoundError:
die(messages.no_blog_configuration)
......@@ -156,7 +159,10 @@ yaml.dump(blog_configuration, stream, default_flow_style=False, allow_unicode=Tr
for entry_filename in yield_entries_content():
raw_data = open(os.getcwd()+"/entries/"+entry_filename,'r').read()
try:
metadata = yaml.load(raw_data.split("---\n")[0])
metadata = yaml.load(
raw_data.split("---\n")[0],
Loader=yaml.FullLoader
)
metadata["title"] = metadata.pop("entry_name")
except yaml.scanner.ScannerError:
......
......@@ -79,7 +79,7 @@ def init_theme(argv):
if "config.yaml" in os.listdir(theme_folder) and not os.path.isdir(themes_folder+"/config.yaml"):
import yaml
config = yaml.load(open(theme_folder+"/config.yaml",'r').read())
config = yaml.load(open(theme_folder+"/config.yaml",'r').read(), Loader=yaml.FullLoader)
if "override" in config.keys() and type(config["override"]) == dict:
for param in config["override"].keys():
datastore.blog_configuration[param] = config["override"][param]
......
......@@ -34,7 +34,10 @@ def print_themes():
themes_folder = os.path.expanduser('~')+"/.local/share/VenC/themes/"
for theme in os.listdir(themes_folder):
if "config.yaml" in os.listdir(themes_folder+theme) and not os.path.isdir(themes_folder+theme+"/config.yaml"):
config = yaml.load(open(themes_folder+theme+"/config.yaml",'r').read())
config = yaml.load(
open(themes_folder+theme+"/config.yaml",'r').read(),
Loader=yaml.FullLoader
)
try:
description = getattr(messages, config["info"]["description"])
......
......@@ -23,6 +23,9 @@ from venc2 import venc_version
def print_version(argv):
print("VenC", venc_version)
import platform
print("Python", platform.python_version())
# Will be removed and replaced by argparse
def print_help(argv=None):
......
......@@ -61,11 +61,11 @@ def get_markers_indexes(string, begin=".:", end=":."):
i=0
break
if begin == ".:Escape::":
j = 0
while string[i+10+j] == ' ':
j+=1
strip_begin_append(i+j)
# ~ if begin == ".:Escape::":
# ~ j = 0
# ~ while string[i+10+j] in [' ','\t','\n']:
# ~ j+=1
# ~ strip_begin_append(i+j)
op_append(i)
i+=2
......@@ -75,18 +75,20 @@ def get_markers_indexes(string, begin=".:", end=":."):
if i == -1:
i=0
break
if begin == ".:EndEscape::" and False:
j = -1
while string[i+j] == ' ':
j-=1
strip_end_append(i+j)
# ~ if begin == ".:EndEscape::" and False:
# ~ j = -1
# ~ while string[i+j] == in [' ','\t','\n']:
# ~ j-=1
# ~ strip_end_append(i+j)
cp_append(i)
i+=2
if begin == ".:Escape::":
return (op, cp, strip_begin, strip_end)
# ~ if begin == ".:Escape::":
# ~ a = [ (op[i], strip_begin[i]) for i in range(0,len(op)) ]
# ~ b = [ (cp[i], strip_begin[i]) for i in range(0,len(cp)) ]
# ~ return (a, b)
return (op, cp)
def handle_markup_language_error(message, line=None, string=None):
......@@ -126,8 +128,9 @@ class ProcessedString():
self.open_pattern_pos, self.close_pattern_pos = get_markers_indexes(string)
#Process escape
self.escapes_o, self.escapes_c, self.strip_begin, self.strip_end = get_markers_indexes(string, begin=".:Escape::", end="::EndEscape:.")
self.escapes_o, self.escapes_c = get_markers_indexes(string, begin=".:Escape::", end="::EndEscape:.")
leo, lec = len(self.escapes_o), len(self.escapes_c)
if leo != lec:
raise MalformedPatterns(leo > lec, True, ressource)
......@@ -139,6 +142,7 @@ class ProcessedString():
if self.escapes_o[i] > self.escapes_c[i-1]:
o = self.escapes_o[0]
c = self.escapes_c[i-1]
escapes.append((o,c))
self.escapes_o = self.escapes_o[i:]
self.escapes_c = self.escapes_c[i:]
......@@ -160,11 +164,8 @@ class ProcessedString():
escapes[i] = (o, c-10)
self.open_pattern_pos = [(v-10 if v > o+10 and v <= o+23 else (v-23 if v > o+23 else v)) for v in self.open_pattern_pos]
self.close_pattern_pos = [(v-10 if v > o+10 and v <= o+23 else (v-23 if v > o+23 else v)) for v in self.close_pattern_pos]
if i == 0:
escapes = escapes[:1]+[ (p[0]-23, p[1]-23) for p in escapes[i+1:] ]
else:
escapes = escapes[:i+1]+[ (p[0]-23, p[1]-23) for p in escapes[i+1:] ]
escapes = escapes[:i+1]+[ (p[0]-23 , p[1]-23) for p in escapes[i+1:] ]
if len(escapes):
self.open_pattern_pos = [v for v in self.open_pattern_pos if not index_in_range(v, escapes, process_escapes)]
......@@ -174,12 +175,7 @@ class ProcessedString():
self.len_close_pattern_pos = len(self.close_pattern_pos)
if self.len_open_pattern_pos != self.len_close_pattern_pos:
notify(string, color="RED")
if (self.len_open_pattern_pos > self.len_close_pattern_pos):
die(messages.malformed_patterns_missing_closing_symbols.format(ressource))
else:
die(messages.malformed_patterns_missing_closing_symbols.format(ressource))
raise MalformedPatterns(self.len_open_pattern_pos > self.len_close_pattern_pos, False, ressource)
self.string = string
self.ressource = ressource
......
......@@ -76,7 +76,7 @@ class Thread:
self.processor.set_function(pattern_name, getattr(self, patterns_map.contextual["names"][pattern_name]))
def path_encode(self, path):
if self.path_encoding == '':
if self.path_encoding in ["utf-8",'']:
return unidecode.unidecode(path).replace(' ', '-').replace('\'', '-')
else:
......
......@@ -28,6 +28,7 @@ def run_tests(tests_name, tests):
print(get_formatted_message("\t"+test_name+" Pass", prompt=""))
except AssertionError as e:
if str(e) == test_name:
print(get_formatted_message("\t"+test_name+" Failed", color="RED", prompt=""))
......@@ -42,7 +43,7 @@ def run_tests(tests_name, tests):
except AssertionError:
print(get_formatted_message("\t"+test_name+" "+str(err)+" != "+str(type(venc_defined_exception)), color="RED", prompt=""))
continue
params_okay = True
for arg in args:
try:
......@@ -56,5 +57,4 @@ def run_tests(tests_name, tests):
if params_okay:
print(get_formatted_message("\t"+test_name+" Pass", prompt=""))
print("Done.")
......@@ -37,7 +37,7 @@ path:
ftp: Chemin absolu de votre blog sur l'hôte FTP.
index_file_name: index{page_number}.html
rss_file_name: rss.xml
path_encoding: utf-8
path_encoding: ''
reverse_thread_order: true
server_port: 8888
sort_by: id
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment