Commit d5a3a690 authored by FulcrandG's avatar FulcrandG
Browse files

License moved from file in job dir to an entry in job.yml

parent b813f6f0
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ from os import listdir
from yaml import full_load
from jinja2 import Environment, FileSystemLoader
import requests
from datetime import datetime

# Job variables
JOBS_DIR = "jobs"
@@ -25,7 +26,6 @@ MKDOCS_DIR = "docs"
MKDOCS_PLACEHOLDER_FILE = "placeholder.md"
JOB_CHANGELOG_DIR = "versions"
JOB_DESCRIPTION_FILE = "README.md"
JOB_LICENSE_FILE = "LICENSE"
JOB_METADATA_FILE = "job.yml"

GITLAB_API_URL = "https://gitlab.com/api/v4/"
@@ -37,7 +37,9 @@ TEMPLATE_DIR = "templates"
TMEPLATE_INDEX = "index.md.j2"
TEMPLATE_DOC = "job_documentation.md.j2"
TEMPLATE_PLACEHOLDER = "placeholder.md.j2"
TEMPLATE_LICENSE_DIR = "licenses"
INDEX_FILE = "index.md"

index = {
    "static_tests": [],
    "build": [],
@@ -64,6 +66,7 @@ def get_changelogs(job_path, job_name):
    }

    changelogs = []

    for version in listdir(job_path + "/" + JOB_CHANGELOG_DIR):
        with open(job_path + "/" + JOB_CHANGELOG_DIR + "/" + version) as changelog_file:
            changelogs.append({
@@ -73,9 +76,14 @@ def get_changelogs(job_path, job_name):
            })
    return (latest, changelogs)

def get_license(job_path):
    with open(job_path + "/" + JOB_LICENSE_FILE) as license_file:
        return license_file.readlines()
def get_license(license_name, copyright_holder):
    env = Environment(loader=FileSystemLoader(BUILDER_DIR + "/" + TEMPLATE_DIR + "/" + TEMPLATE_LICENSE_DIR))
    template = env.get_template(license_name + ".md.j2")
    return template.render(
        year = datetime.now().year,
        copyright_holder = copyright_holder
    )


def get_user(code_owner):
    url = GITLAB_API_URL + "users?username=" + code_owner
@@ -92,6 +100,7 @@ def create_job_doc(job):
    # Getting conf for indexing
    conf = get_conf(job_path)
    code_owner = conf.get("maintainer")
    license_name = conf.get("license")
    index[conf["default_stage"]].append(conf)

    mkdocs_file_path = MKDOCS_DIR + "/" + JOBS_DIR + "/" + conf["default_stage"] + "/" + job + ".md"
@@ -99,7 +108,7 @@ def create_job_doc(job):
    # Get variables for jinja
    description = get_description(job_path)
    latest, changelogs = get_changelogs(job_path, job)
    license_content = get_license(job_path)
    license_content = get_license(license_name, code_owner)
    user = get_user(code_owner)

    # Write final file
+2 −2
Original line number Diff line number Diff line
Copyright 2020 Go2Scale
Copyright {{ year }} {{ copyright_holder }}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+2 −2
Original line number Diff line number Diff line
Copyright 2020 Go2Scale
Copyright {{ year }} {{ copyright_holder }}

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

+2 −1
Original line number Diff line number Diff line
@@ -3,3 +3,4 @@ description: A ready-to-use apidoc job to build a web documentation of your API
default_stage: build
icon: 📒
maintainer: thomasboni
license: MIT
 No newline at end of file

jobs/coala/LICENSE

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
Copyright 2020 Go2Scale

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading