mirror of
https://github.com/AdaCore/git-hooks.git
synced 2026-02-12 12:43:11 -08:00
In preparation for the transition to Python 3, convert to using the
print function. The special import
from __future__ import print_function
in Python 2.7 makes "print" become the function and not the statement.
In Python 3, it has no effect. Once the transition is done and we
exclusively use Python 3, we can simply remove the imports.
The testsuite shows no regressions.
34 lines
991 B
Python
34 lines
991 B
Python
"""A module providing some generally useful stuff.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
import sys
|
|
|
|
def abort(exit_code=0):
|
|
"""Abort the execution of the current process. Any cleanup that
|
|
might be needed before aborting is guaranteed to be performed.
|
|
|
|
PARAMETERS
|
|
exit_code: The process exit code sent to the parent process.
|
|
|
|
REMARKS
|
|
This function is meant to be a routine that knows what to do
|
|
depending on whether we're inside the main-loop process, or
|
|
if we're inside a testcase process. As of the time of this writing,
|
|
it is sufficient for either process to just call sys.exit. But
|
|
there might come a day when we might need to do different things
|
|
depending on the process.
|
|
"""
|
|
sys.exit(exit_code)
|
|
|
|
def fatal_error(msg):
|
|
"""Print the given message on standard output and then exit immediately.
|
|
|
|
PARAMETERS
|
|
msg: The error message to print.
|
|
"""
|
|
print("*** Error: " + msg)
|
|
abort(1)
|
|
|
|
|