🔊 Log when input are ascending
relate to forga/process/fr/embarquement#6
This commit is contained in:
parent
e959fa780e
commit
1159d4b189
|
@ -13,6 +13,9 @@ The goal is to build durable python script using standard library
|
||||||
This script compute the greater common divisor of 2 integrers
|
This script compute the greater common divisor of 2 integrers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# MESSAGES
|
||||||
|
WRONG_INPUT_ORDER = "Inputs in ascending order"
|
||||||
|
|
||||||
|
|
||||||
def pgcd(input_a, input_b):
|
def pgcd(input_a, input_b):
|
||||||
"""
|
"""
|
||||||
|
@ -50,6 +53,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# ARGUMENTS, PARAMETERS & OPTIONS
|
# ARGUMENTS, PARAMETERS & OPTIONS
|
||||||
import argparse
|
import argparse
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
PARSER = argparse.ArgumentParser(
|
PARSER = argparse.ArgumentParser(
|
||||||
|
@ -61,12 +65,21 @@ if __name__ == "__main__":
|
||||||
PARSER.add_argument(
|
PARSER.add_argument(
|
||||||
"-v", "--verbose", help="A near mathematics answer", action="store_true"
|
"-v", "--verbose", help="A near mathematics answer", action="store_true"
|
||||||
)
|
)
|
||||||
|
|
||||||
ARGS = PARSER.parse_args()
|
ARGS = PARSER.parse_args()
|
||||||
|
|
||||||
# DO THE JOB
|
# CHECKS INPUTS
|
||||||
NEW_PGCD = pgcd(ARGS.INPUT_A, ARGS.INPUT_B)
|
if ARGS.INPUT_A <= ARGS.INPUT_B:
|
||||||
|
logging.critical(WRONG_INPUT_ORDER)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
# DO THE JOB
|
||||||
|
else:
|
||||||
|
NEW_PGCD = pgcd(ARGS.INPUT_A, ARGS.INPUT_B)
|
||||||
|
|
||||||
|
# RESPONSE
|
||||||
if ARGS.verbose:
|
if ARGS.verbose:
|
||||||
print(f"PGCD({ARGS.INPUT_A};{ARGS.INPUT_B}) = {NEW_PGCD}")
|
print(f"PGCD({ARGS.INPUT_A};{ARGS.INPUT_B}) = {NEW_PGCD}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(NEW_PGCD)
|
print(NEW_PGCD)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user