Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93738200
warning_manager.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 1, 02:31
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Dec 3, 02:31 (2 d)
Engine
blob
Format
Raw Data
Handle
22694846
Attached To
R6746 RationalROMPy
warning_manager.py
View Options
# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import
traceback
as
tb
from
datetime
import
datetime
__all__
=
[
'RROMPyWarning'
]
def
getTimestamp
()
->
str
:
return
"
\x1b
[42m{}
\x1b
[0m"
.
format
(
datetime
.
now
()
.
strftime
(
"%H:%M:%S.
%f
"
))
def
RROMPyWarning
(
msg
:
str
=
""
,
stacklevel
:
int
=
0
):
frameSummary
=
tb
.
extract_stack
()[
-
3
-
stacklevel
]
timestamp
=
getTimestamp
()
if
frameSummary
.
name
==
"<module>"
:
name
=
""
else
:
name
=
", within {}"
.
format
(
frameSummary
.
name
)
print
(
"{}
\x1b
[3m Warning at {}:{}{}:
\x1b
[0m"
.
format
(
timestamp
,
frameSummary
.
filename
,
frameSummary
.
lineno
,
name
))
print
(
">
\x1b
[31m{}
\x1b
[0m"
.
format
(
frameSummary
.
line
))
if
len
(
msg
)
>
0
:
print
(
"
\x1b
[3m {}
\x1b
[0m
\n
"
.
format
(
msg
))
Event Timeline
Log In to Comment