Compare commits

...

7 Commits

Author SHA1 Message Date
vicky 6f4cc857d0 added todo 2022-05-21 20:01:23 +02:00
vicky 8adc925b0a more stuff for testing 2022-05-21 19:29:07 +02:00
vicky a8bcb13480 added todo 2022-05-21 19:28:46 +02:00
vicky 7db2c40be8 implemented alias replacement 2022-05-21 19:27:36 +02:00
vicky b4ff63c2cc added todo and corrected typo 2022-05-21 19:27:35 +02:00
vicky 1091c6a484 added a todo 2022-05-21 19:14:52 +02:00
vicky 8b991b7efd added a line for testing 2022-05-21 19:14:26 +02:00
7 changed files with 33 additions and 16 deletions

View File

@ -1,10 +1,11 @@
shortcuts:
copyright: Copyright (c) 2020 by Idle-Corp, all rights reserved.
website_url: https://idle-corp.com
website_name: Idle-Corp
cc_license: CC-BY-SA-4.0
replace: Test with {} and {}
copyright: 'Copyright (c) 2020 by Idle-Corp, all rights reserved.'
website_url: 'https://idle-corp.com'
website_name: 'Idle-Corp'
cc_license: 'CC-BY-SA-4.0'
replace: 'Test with {} and {}'
alias: 'test alias replacement with format {test}'
images:
logo: ressources/images/logo.png
favicon: ressources/images/favicon.png
logo: 'resources/images/logo.png'
favicon: 'resources/images/favicon.png'

View File

@ -1 +1,2 @@
@{image1.png}{style="border:2px"}{{card red}}{{second class insert}}[i=2, 12, 'string', q=13, o='joli', 17][d="okboomer"]{target="_blank"}
@[replace][1, 'chaussette', test='chauss', 2, 32]
@{image.png}{style="border:2px"}{{card red}}{{second class insert}}[i=2, 12, 'string', q=13, o='joli', 17][d="okboomer"]{target="_blank"}

View File

@ -108,6 +108,7 @@ class BaseContainerWithOptionals(BaseContainer):
# Define containers all the Enhanced text elements, divs, headers, list and any element that can be a container
# TODO: List all elements and their specialties (custom span id, header level, etc.)
class TextContainer(BaseContainer):
pass

View File

@ -46,7 +46,7 @@ def log_message(message, level="ERROR"):
:return: None
"""
level = level.lower()
logging.__getattribute__(level)(' ' + message)
logging.__getattribute__(level)(' ' + message) # TODO: Error handling on type error
logging.__getattribute__(level)(traceback.format_exc())
logging.__getattribute__(level)(__GLk())
if level in ["critical"]:

View File

@ -12,7 +12,7 @@ markup element and pass it over to ExportManager.
ExportRequest = namedtuple("ExportRequest", ["type", "subtype", "optionals", "others"], defaults=[None, None, "", {}])
"""
Class containing all necessary information to proceed with the
Named tuple containing all necessary information to proceed with the
final output.
"""
ExportResponse = namedtuple("ExportResponse", ["start", "end"])
@ -88,7 +88,7 @@ class ExportManager:
level='CRITICAL'
)
# future: allow for template selection
if export_request.optionals != '':
if export_request.optionals != '': # TODO: Use format_optionals?
optionals = " " + export_request.optionals
else:
optionals = ''

View File

@ -227,15 +227,29 @@ class PreParser:
self.replacements_done = True
return self.file_with_all_replacements
def get_alias_from_config(self, shortcut, optional):
def get_alias_from_config(self, shortcut, optionals):
"""
Fetches shortcut paths from aliases.yaml
:return: the html to insert as a string
:param shortcut: id of the shortcut to fetch
:param optional: optional parameters along with alias
:param optionals: optional parameters along with alias
"""
# return self.__env.config["aliases"][shortcut]
return f'<h1>{shortcut}</h1>' # TODO : replace with actual alias
try:
output = self.__env.config.loaded_conf['aliases']['shortcuts'][shortcut]
except KeyError:
error_mngr.log_exception(
KeyError(
f'Shortcut "{shortcut}" could not be found in {"; ".join(self.__env.config.config_folders)}.'
), level='CRITICAL'
)
_, _, var_list, var_dict = export.split_optionals(optionals)
try:
output = output.format(*var_list, **var_dict) # noqa
except KeyError:
error_mngr.log_message(
'Could not find appropriate replacement values in options provided', level='WARNING'
)
return output
def get_image_from_config(self, shortcut, optionals):
"""

View File

@ -275,7 +275,7 @@ rgx_import_file = regex.compile(r'::( ?\< ?(?P<file_name>[\w\-._/]+) ?\>[ \s]*)+
# Base elements
quotes = pp.Word(r""""'""")
value = (pps(quotes) + pp.Word(pp.alphanums + r'\._') + pps(pp.match_previous_literal(quotes)) ^
pp.common.fnumber)("value")
pp.common.fnumber)("value") # TODO: not every number is a float
assignation = pp.Group(
pp.common.identifier('var_name') + pps('=') + value('var_value')
)("assignation")