# -*- coding: utf-8 -*-
#
-# Copyright (C) 2008-2022 EDF R&D
+# Copyright (C) 2008-2023 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
"""
Store and retrieve the data for C: internal class
"""
+ __slots__ = ("__part", "__styles", "__content")
+ #
def __init__(self, part="default"):
self.__part = str(part)
self.__styles = []
self.__content = []
-
+ #
def append(self, content, style="p", position=-1):
if position == -1:
self.__styles.append(style)
self.__styles.insert(position, style)
self.__content.insert(position, content)
return 0
-
+ #
def get_styles(self):
return self.__styles
-
+ #
def get_content(self):
return self.__content
"""
Store and retrieve the data for C: internal class
"""
+ __slots__ = ("__document")
+ #
def __init__(self, part='default'):
self.__document = {}
self.__document[part] = _ReportPartM__(part)
-
+ #
def append(self, content, style="p", position=-1, part='default'):
if part not in self.__document:
self.__document[part] = _ReportPartM__(part)
self.__document[part].append(content, style, position)
return 0
-
+ #
def get_styles(self):
op = list(self.__document.keys()) ; op.sort()
return [self.__document[k].get_styles() for k in op]
-
+ #
def get_content(self):
op = list(self.__document.keys()) ; op.sort()
return [self.__document[k].get_content() for k in op]
-
+ #
def clear(self):
self.__init__()
"""
Get user commands, update M and V: user intertace to create the report
"""
+ __slots__ = ()
+ #
m = _ReportM__()
-
+ #
def append(self, content="", style="p", position=-1, part="default"):
return self.m.append(content, style, position, part)
-
+ #
def retrieve(self):
st = self.m.get_styles()
ct = self.m.get_content()
return st, ct
-
+ #
def clear(self):
self.m.clear()
"""
Interact with user and C: template for reports
"""
-
+ __slots__ = ("c")
+ #
default_filename="report.txt"
-
+ #
def __init__(self, c):
self.c = c
-
+ #
def save(self, filename=None):
if filename is None:
filename = self.default_filename
fid.write(h)
fid.close()
return filename, _filename
-
+ #
def retrieve(self):
return self.c.retrieve()
-
+ #
def __str__(self):
return self.get()
-
+ #
def close(self):
del self.c
return 0
# ==============================================================================
-# Classes d'interface utilisateur : ReportStorage, ReportViewIn*
+# Classes d'interface utilisateur : ReportViewIn*, ReportStorage
# Tags de structure : (title, h1, h2, h3, p, uli, oli, <b></b>, <i></i>)
-ReportStorage = __ReportC__
-
class ReportViewInHtml(__ReportV__):
"""
Report in HTML
"""
-
+ __slots__ = ()
+ #
default_filename="report.html"
tags = {
"oli":"li",
"uli":"li",
}
-
+ #
def get(self):
st, ct = self.retrieve()
inuLi, inoLi = False, False
"""
Report in RST
"""
-
+ __slots__ = ()
+ #
default_filename="report.rst"
tags = {
"p":["\n\n",""],
"</b>":"**",
"</i>":"*",
}
-
+ #
def get(self):
st, ct = self.retrieve()
inuLi, inoLi = False, False
"""
Report in plain TXT
"""
-
+ #
default_filename="report.txt"
tags = {
"p":["\n",""],
"</b>":"",
"</i>":"",
}
-
+ #
def get(self):
st, ct = self.retrieve()
inuLi, inoLi = False, False
pg += "\n"
return pg
+# Interface utilisateur de stockage des informations
+ReportStorage = __ReportC__
+
# ==============================================================================
if __name__ == "__main__":
print('\n AUTODIAGNOSTIC\n')