Commit 0edbf0c2 authored by Aurelien's avatar Aurelien
Browse files

Merge branch '269-add-argparse-to-all-python-tools' into 'latest'

Resolve "Add argparse to all python tools"

Closes #269

See merge request r2devops/hub!169
parents b05f0712 3b61ffd8
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ from urllib.parse import quote, urlencode
import requests
from yaml import full_load, YAMLError
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
import argparse

# Import the config module
from tools.utils.utils import Config
@@ -363,6 +364,17 @@ def add_placeholder():
                template = env.get_template(utils.TEMPLATE_PLACEHOLDER)
                file_handle.write(template.render())

def argparse_setup():
    """Setup argparse

    Return
    ------
    obj
        Python object with arguments parsed
    """
    parser = argparse.ArgumentParser()
    return parser.parse_args()

def main():
    """
    Main function, multiple-purpose:
@@ -372,8 +384,12 @@ def main():
    - Create jobs index
    """

    # Setup argparse
    args = argparse_setup()

    # logging
    logging.basicConfig(level=logging.INFO)
    
    # Iterate over every directories in jobs directory to create their job.md for the documentation
    jobs = listdir(utils.JOBS_DIR)
    for job in jobs:
+15 −2
Original line number Diff line number Diff line
@@ -8,13 +8,12 @@ import sys
from urllib.parse import quote, urlencode
from os import getenv, listdir
import requests
import argparse

# Import the config module
from tools.utils.utils import Config
utils = Config()



def get_labels(project_name, with_counts=False, include_ancestor_groups=True, search=""):
    """Get labels of the project, can also serach for a specific label with search filter

@@ -99,6 +98,17 @@ def delete_label(project_name, label_name):
    logging.info(f"Deleting a label {label_name} for the project {project_name}")
    return (requests.delete(url, headers=headers))

def argparse_setup():
    """Setup argparse

    Return
    ------
    obj
        Python object with arguments parsed
    """
    parser = argparse.ArgumentParser()
    return parser.parse_args()

if __name__ == "__main__":
    """Main function if used as a program
    Looping through all jobs to check if their scoped
@@ -109,6 +119,9 @@ if __name__ == "__main__":
    boolean
        0 if nothing is wrong, 1 otherwise
    """
    # Setup argparse
    args = argparse_setup()

    # Setup logging
    logging.basicConfig(
        encoding="utf-8",