ue_pe_web/scripts/templates/my_script.py
2024-01-07 15:25:19 +01:00

71 lines
2 KiB
Python

######################################################################
# Copyright (c) Boris Baldassari, Adrien Luxey-Bitri
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
######################################################################
import argparse
from pprint import pprint
"""
This module provides a set of example functions.
See also the tests for the module, located in test_my_script.py.
Run tests with `pytest test_my_script`:
$ pytest test_my_script.py -vvvv
======================== test session starts ========================
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0+repack -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/user/project/scripts/templates
collected 1 item
test_my_script.py::test_add_integers_case0 PASSED [100%]
========================= 1 passed in 0.00s =========================
"""
def _parse_args():
"""
Parse arguments from command line.
"""
parser = argparse.ArgumentParser(description="A script that does something.")
parser.add_argument('-wg', '--working_group',
help='Retrieve information for all projects in a working group.')
parser.add_argument('-p', '--project',
help='Retrieve information for a single project ID.')
parser.add_argument('-c', '--conf',
help='Configuration file for opensearch access.')
args = parser.parse_args()
return args
def add_ints(a: int, b: int):
"""
Adds two integers and returns the outcome.
Returns
Parameters:
- `a`: First integer to add.
- `b`: Second integer to add.
"""
print('Printed from add_ints function.')
return a + b
if __name__ == '__main__':
# Parse command-line arguments
args = _parse_args()
pprint(args)