mirror of https://gitlab.com/pamhyr/pamhyr2
pamhyr: End switch print to logging.
parent
a8bd871f94
commit
504ef7ec48
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
@ -32,6 +34,7 @@ from View.BoundaryCondition.Edit.translate import *
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class ExtendedTimeEdit(AWidget):
|
class ExtendedTimeEdit(AWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
@ -108,7 +111,7 @@ class ExTimeDelegate(QItemDelegate):
|
||||||
self.editor = ExtendedDateTimeEdit(parent=parent)
|
self.editor = ExtendedDateTimeEdit(parent=parent)
|
||||||
value = index.data(Qt.DisplayRole)
|
value = index.data(Qt.DisplayRole)
|
||||||
self.editor.set_time(value)
|
self.editor.set_time(value)
|
||||||
print(value)
|
logger.debug(str(value))
|
||||||
return self.editor
|
return self.editor
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
|
|
@ -116,7 +119,7 @@ class ExTimeDelegate(QItemDelegate):
|
||||||
if self._mode == "time":
|
if self._mode == "time":
|
||||||
model.setData(index, int(time.total_seconds()))
|
model.setData(index, int(time.total_seconds()))
|
||||||
else:
|
else:
|
||||||
print(time.timestamp())
|
logger.debug(str(time.timestamp()))
|
||||||
model.setData(index, int(time.timestamp()))
|
model.setData(index, int(time.timestamp()))
|
||||||
editor.close()
|
editor.close()
|
||||||
editor.deleteLater()
|
editor.deleteLater()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -43,6 +45,7 @@ from View.BoundaryCondition.Edit.Window import EditBoundaryConditionWindow
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Boundary conditions", study=None, parent=None):
|
def __init__(self, title="Boundary conditions", study=None, parent=None):
|
||||||
|
|
@ -184,10 +187,10 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._table[tab].move_down(row)
|
self._table[tab].move_down(row)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
tab = self.current_tab()
|
tab = self.current_tab()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import timer
|
from tools import timer
|
||||||
from View.Plot.APlot import APlot
|
from View.Plot.APlot import APlot
|
||||||
|
|
||||||
|
|
@ -9,6 +11,8 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class PlotAC(APlot):
|
class PlotAC(APlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None, plot_xy=None):
|
def __init__(self, canvas=None, data=None, toolbar=None, plot_xy=None):
|
||||||
super(PlotAC, self).__init__(
|
super(PlotAC, self).__init__(
|
||||||
|
|
@ -284,7 +288,7 @@ class PlotAC(APlot):
|
||||||
self.color_incomplete_gl[lincomplete.index(txt)]
|
self.color_incomplete_gl[lincomplete.index(txt)]
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{e}")
|
logger.warning(f"{e}")
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import timer
|
from tools import timer
|
||||||
from View.Plot.APlot import APlot
|
from View.Plot.APlot import APlot
|
||||||
|
|
||||||
|
|
@ -9,6 +11,8 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class PlotKPC(APlot):
|
class PlotKPC(APlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
def __init__(self, canvas=None, data=None, toolbar=None,
|
||||||
display_current=True):
|
display_current=True):
|
||||||
|
|
@ -214,7 +218,7 @@ class PlotKPC(APlot):
|
||||||
kp, z_complete[i]
|
kp, z_complete[i]
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to update graphic 2: {e}")
|
logger.warning(f"Failed to update graphic KPC: {e}")
|
||||||
|
|
||||||
self.canvas.axes.autoscale_view(True, True, True)
|
self.canvas.axes.autoscale_view(True, True, True)
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
from View.Plot.APlot import APlot
|
from View.Plot.APlot import APlot
|
||||||
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
|
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
|
||||||
|
|
@ -10,6 +12,8 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class Plot(APlot):
|
class Plot(APlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None, table=None):
|
def __init__(self, canvas=None, data=None, toolbar=None, table=None):
|
||||||
super(Plot, self).__init__(
|
super(Plot, self).__init__(
|
||||||
|
|
@ -123,5 +127,5 @@ class Plot(APlot):
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def update(self, ind=None):
|
def update(self, ind=None):
|
||||||
print("TODO: implemente update")
|
logger.info("TODO: implemente update")
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
||||||
msg_box.setStandardButtons(QtWidgets.QMessageBox.Ok)
|
msg_box.setStandardButtons(QtWidgets.QMessageBox.Ok)
|
||||||
|
|
||||||
return_value = msg_box.exec()
|
return_value = msg_box.exec()
|
||||||
if return_value == QtWidgets.QMessageBox.Ok:
|
# if return_value == QtWidgets.QMessageBox.Ok:
|
||||||
print('OK clicked')
|
# print('OK clicked')
|
||||||
|
|
||||||
def edit_profile(self):
|
def edit_profile(self):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -39,6 +41,7 @@ from View.InitialConditions.DialogDischarge import DischargeDialog
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Initial condition",
|
def __init__(self, title="Initial condition",
|
||||||
|
|
@ -197,11 +200,11 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
@ -31,6 +32,7 @@ from View.LateralContribution.Edit.translate import *
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class ExtendedTimeEdit(AWidget):
|
class ExtendedTimeEdit(AWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
@ -107,7 +109,7 @@ class ExTimeDelegate(QItemDelegate):
|
||||||
self.editor = ExtendedDateTimeEdit(parent=parent)
|
self.editor = ExtendedDateTimeEdit(parent=parent)
|
||||||
value = index.data(Qt.DisplayRole)
|
value = index.data(Qt.DisplayRole)
|
||||||
self.editor.set_time(value)
|
self.editor.set_time(value)
|
||||||
print(value)
|
logger.debug(str(value))
|
||||||
return self.editor
|
return self.editor
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
|
|
@ -115,7 +117,7 @@ class ExTimeDelegate(QItemDelegate):
|
||||||
if self._mode == "time":
|
if self._mode == "time":
|
||||||
model.setData(index, int(time.total_seconds()))
|
model.setData(index, int(time.total_seconds()))
|
||||||
else:
|
else:
|
||||||
print(time.timestamp())
|
logger.debug(str(time.timestamp()))
|
||||||
model.setData(index, int(time.timestamp()))
|
model.setData(index, int(time.timestamp()))
|
||||||
editor.close()
|
editor.close()
|
||||||
editor.deleteLater()
|
editor.deleteLater()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -43,6 +45,7 @@ from View.LateralContribution.Edit.Window import EditLateralContributionWindow
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Lateral contribution", study=None, parent=None):
|
def __init__(self, title="Lateral contribution", study=None, parent=None):
|
||||||
|
|
@ -226,11 +229,11 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._set_current_reach()
|
self._set_current_reach()
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
self._set_current_reach()
|
self._set_current_reach()
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
self._set_current_reach()
|
self._set_current_reach()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
@ -6,6 +8,7 @@ from PyQt5.QtCore import QItemSelectionModel, Qt
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from shapely.geometry.polygon import Polygon as ShapelyPolygon
|
from shapely.geometry.polygon import Polygon as ShapelyPolygon
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class OnpickEvent(object):
|
class OnpickEvent(object):
|
||||||
def __init__(self, ax, x, y, x_carto, y_carto, tableview=None):
|
def __init__(self, ax, x, y, x_carto, y_carto, tableview=None):
|
||||||
|
|
@ -105,14 +108,13 @@ class OnpickEvent(object):
|
||||||
[pl[0].set_data([], [])
|
[pl[0].set_data([], [])
|
||||||
for pl in self.pt if len(self.pt) > 1]
|
for pl in self.pt if len(self.pt) > 1]
|
||||||
except:
|
except:
|
||||||
print("Probleme de mise à jour ... update_select_point_point()")
|
logger.info("update_select_point_point: Update issue")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.update_select_point_point_bis(self.x[row],
|
self.update_select_point_point_bis(self.x[row],
|
||||||
self.y[row])
|
self.y[row])
|
||||||
except:
|
except:
|
||||||
print("index introuvable pour la mise à jour de l'affichage de la sélection du point."
|
logger.info("update_select_point_point_bis: Update issue, possible index missing")
|
||||||
"Editer les cases en 'nan'.")
|
|
||||||
|
|
||||||
self.ax.figure.canvas.draw_idle()
|
self.ax.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
from matplotlib.backends import qt_compat
|
from matplotlib.backends import qt_compat
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
@ -10,6 +11,7 @@ from PyQt5.QtCore import pyqtSignal, QSize
|
||||||
|
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
file_path = os.path.abspath(os.path.dirname(__file__))
|
file_path = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -123,7 +125,7 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
|
||||||
)
|
)
|
||||||
|
|
||||||
def cursor1(self):
|
def cursor1(self):
|
||||||
print("TODO")
|
logger.info("TODO: cursor1")
|
||||||
|
|
||||||
def isometric_view(self):
|
def isometric_view(self):
|
||||||
self.my_canvas.axes.axis("equal")
|
self.my_canvas.axes.axis("equal")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -39,6 +41,8 @@ from View.Stricklers.Window import StricklersWindow
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SectionsWindow(ASubMainWindow, ListedSubWindow):
|
class SectionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Sections", study=None, parent=None):
|
def __init__(self, title="Sections", study=None, parent=None):
|
||||||
self._study = study
|
self._study = study
|
||||||
|
|
@ -214,10 +218,10 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._table.move_down(row)
|
self._table.move_down(row)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._table.undo()
|
self._table.undo()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -31,6 +33,7 @@ from Solver.Solvers import solver_long_name, solver_type_list
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Solver parameters", study=None, parent=None):
|
def __init__(self, title="Solver parameters", study=None, parent=None):
|
||||||
|
|
@ -120,7 +123,7 @@ class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._set_current_reach()
|
self._set_current_reach()
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow
|
||||||
|
|
@ -29,6 +31,7 @@ from View.Stricklers.Table import TableModel
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Stricklers", study=None, config=None, parent=None):
|
def __init__(self, title="Stricklers", study=None, config=None, parent=None):
|
||||||
|
|
@ -115,10 +118,10 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self._table['study'].sort(False)
|
self._table['study'].sort(False)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
print("TODO")
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
print("TODO")
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._table['study'].undo()
|
self._table['study'].undo()
|
||||||
|
|
|
||||||
12
src/tools.py
12
src/tools.py
|
|
@ -53,7 +53,7 @@ def display_timers():
|
||||||
for t in range(fmax + 26):
|
for t in range(fmax + 26):
|
||||||
head += "-"
|
head += "-"
|
||||||
head += "+"
|
head += "+"
|
||||||
print(head)
|
logger.debug(head)
|
||||||
|
|
||||||
lst = sorted(
|
lst = sorted(
|
||||||
map(
|
map(
|
||||||
|
|
@ -67,13 +67,13 @@ def display_timers():
|
||||||
for func, time, calls in lst:
|
for func, time, calls in lst:
|
||||||
name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" +
|
name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" +
|
||||||
f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{fmax - len(func.__module__)}}{Style.RESET_ALL}")
|
f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{fmax - len(func.__module__)}}{Style.RESET_ALL}")
|
||||||
print(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |")
|
logger.debug(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |")
|
||||||
|
|
||||||
tail = " +--"
|
tail = " +--"
|
||||||
for t in range(fmax + 32):
|
for t in range(fmax + 32):
|
||||||
tail += "-"
|
tail += "-"
|
||||||
tail += "+"
|
tail += "+"
|
||||||
print(tail)
|
logger.debug(tail)
|
||||||
|
|
||||||
def timer(func):
|
def timer(func):
|
||||||
"""Function wrapper to register function runtime"""
|
"""Function wrapper to register function runtime"""
|
||||||
|
|
@ -85,7 +85,7 @@ def timer(func):
|
||||||
try:
|
try:
|
||||||
value = func(*args, **kwargs)
|
value = func(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[{Fore.RED}ERROR{Style.RESET_ALL}]" +
|
logger.debug(f"[{Fore.RED}ERROR{Style.RESET_ALL}]" +
|
||||||
f"[{func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}]: " +
|
f"[{func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}]: " +
|
||||||
f"{Fore.RED}{e}{Style.RESET_ALL}")
|
f"{Fore.RED}{e}{Style.RESET_ALL}")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
@ -113,13 +113,13 @@ def trace(func):
|
||||||
t = time.ctime()
|
t = time.ctime()
|
||||||
head = f"[{Fore.BLUE}TRACE{Style.RESET_ALL}]"
|
head = f"[{Fore.BLUE}TRACE{Style.RESET_ALL}]"
|
||||||
c = f"{head}[{t}] Call {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}({args}, {kwargs})"
|
c = f"{head}[{t}] Call {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}({args}, {kwargs})"
|
||||||
print(c)
|
logger.debug(c)
|
||||||
|
|
||||||
value = func(*args, **kwargs)
|
value = func(*args, **kwargs)
|
||||||
|
|
||||||
t = time.ctime()
|
t = time.ctime()
|
||||||
r = f"{head}[{t}] Return {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}: {value}"
|
r = f"{head}[{t}] Return {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}: {value}"
|
||||||
print(r)
|
logger.debug(r)
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue