Commit ba246d94 authored by Maxime Perrotin's avatar Maxime Perrotin

Add proper indentation in f-strings

parent 386c29e6
......@@ -19,6 +19,11 @@ import opengeode
# f{LF.join(...)}. Alternatively chr(10).join() would also work.
LF = '\n'
def indent(nb: int, phrase: List[str]):
# offer indenting of multiple line strings when referenced inside f-strings
result = LF.join(phrase)
return (LF+nb*" ").join(result.splitlines())
def asn1_module (module: str) -> str:
return f'''with {module}; use {module};
'''
......@@ -30,26 +35,20 @@ def required_interface (interface: str) -> str:
return f'{interface}_ri'
def event (interface: str, sort: str, param: bool) -> str:
res = f'when {interface}_pi =>'
if param:
res += f'''
{interface}_Param: aliased asn1Scc{sort};
'''
return f'''when {interface}_pi =>
{interface}_Param: aliased asn1Scc{sort};'''
else:
res += f'''
null;
'''
return res
return f'''when {interface}_pi =>
null;'''
def print_event (interface: str, sort: str, param : bool) -> str:
if param:
return f'''when {interface}_pi =>
Put_Line ("{interface}(" & {sort}_Pkg.Image(Event.{interface}_Param) & ")");
'''
Put_Line ("{interface}(" & {sort}_Pkg.Image(Event.{interface}_Param) & ")");'''
else:
return f'''when {interface}_pi =>
Put_Line ("{interface}");
'''
Put_Line ("{interface}");'''
def check_ppty (num: int, model: str) -> str:
return f'''errno := {num};
......@@ -130,25 +129,25 @@ procedure Model_Checker is
case Option is
when start =>
null;
{LF.join(events)}
{indent(12, events)}
end case;
end record;
-- Display scenario (in the future: generate MSC)
procedure Print_Event(Event: Event_ty) is
begin
case Event.Option is
when start =>
Put_Line("START");
{LF.join(print_events)}
end case;
case Event.Option is
when start =>
Put_Line("START");
{indent(9, print_events)}
end case;
end;
-- Check all properties in one go, and if one fails, set errno
function Check_Properties (Errno: out Natural) return Boolean is
Res : Boolean := False;
begin
{LF.join(check_properties)}
{indent(6, check_properties)}
return Res;
end Check_Properties;
......@@ -161,13 +160,13 @@ procedure Model_Checker is
use ES;
-- One function per PI to exhaust the interface parameters
{LF.join(exhaust_procedures)}
{indent(3, exhaust_procedures)}
procedure Exhaustive_Simulator is
begin
backup_ctxt := Process_Ctxt;
backup_hash := State_Hash(Backup_ctxt);
{LF.join(exhausts)}
{indent(6, exhausts)}
end Exhaustive_Simulator;
Event : Event_ty(start);
......
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