From d60ab6abbbee47f9113ed88498e89f558be3d01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Thu, 25 Jan 2018 12:08:37 +0100 Subject: [PATCH] moved templates to separated directories --- licor/templates.py | 17 +++++++++++------ licor/templates/{ => a}/AGPLv2.copyright.meta | 0 licor/templates/{ => a}/AGPLv2.copyright.tx | 0 licor/templates/{ => a}/AGPLv2.meta | 0 .../{ => a}/AGPLv2.single-file.copyright.meta | 0 .../{ => a}/AGPLv2.single-file.copyright.tx | 0 licor/templates/{ => a}/AGPLv2.single-file.meta | 0 licor/templates/{ => a}/AGPLv2.single-file.tx | 0 licor/templates/{ => a}/AGPLv2.tx | 0 licor/templates/{ => a}/AGPLv3.copyright.meta | 0 licor/templates/{ => a}/AGPLv3.copyright.tx | 0 licor/templates/{ => a}/AGPLv3.meta | 0 .../{ => a}/AGPLv3.single-file.copyright.meta | 0 .../{ => a}/AGPLv3.single-file.copyright.tx | 0 licor/templates/{ => a}/AGPLv3.single-file.meta | 0 licor/templates/{ => a}/AGPLv3.single-file.tx | 0 licor/templates/{ => a}/AGPLv3.tx | 0 licor/templates/{ => g}/GPLv2.copyright.meta | 0 licor/templates/{ => g}/GPLv2.copyright.tx | 0 licor/templates/{ => g}/GPLv2.meta | 0 .../{ => g}/GPLv2.single-file.copyright.meta | 0 .../{ => g}/GPLv2.single-file.copyright.tx | 0 licor/templates/{ => g}/GPLv2.single-file.meta | 0 licor/templates/{ => g}/GPLv2.single-file.tx | 0 licor/templates/{ => g}/GPLv2.tx | 0 licor/templates/{ => g}/GPLv3.copyright.meta | 0 licor/templates/{ => g}/GPLv3.copyright.tx | 0 licor/templates/{ => g}/GPLv3.meta | 0 .../{ => g}/GPLv3.single-file.copyright.meta | 0 .../{ => g}/GPLv3.single-file.copyright.tx | 0 licor/templates/{ => g}/GPLv3.single-file.meta | 0 licor/templates/{ => g}/GPLv3.single-file.tx | 0 licor/templates/{ => g}/GPLv3.tx | 0 licor/templates/{ => l}/LGPLv2.copyright.meta | 0 licor/templates/{ => l}/LGPLv2.copyright.tx | 0 licor/templates/{ => l}/LGPLv2.meta | 0 .../{ => l}/LGPLv2.single-file.copyright.meta | 0 .../{ => l}/LGPLv2.single-file.copyright.tx | 0 licor/templates/{ => l}/LGPLv2.single-file.meta | 0 licor/templates/{ => l}/LGPLv2.single-file.tx | 0 licor/templates/{ => l}/LGPLv2.tx | 0 licor/templates/{ => l}/LGPLv3.copyright.meta | 0 licor/templates/{ => l}/LGPLv3.copyright.tx | 0 licor/templates/{ => l}/LGPLv3.meta | 0 .../{ => l}/LGPLv3.single-file.copyright.meta | 0 .../{ => l}/LGPLv3.single-file.copyright.tx | 0 licor/templates/{ => l}/LGPLv3.single-file.meta | 0 licor/templates/{ => l}/LGPLv3.single-file.tx | 0 licor/templates/{ => l}/LGPLv3.tx | 0 49 files changed, 11 insertions(+), 6 deletions(-) rename licor/templates/{ => a}/AGPLv2.copyright.meta (100%) rename licor/templates/{ => a}/AGPLv2.copyright.tx (100%) rename licor/templates/{ => a}/AGPLv2.meta (100%) rename licor/templates/{ => a}/AGPLv2.single-file.copyright.meta (100%) rename licor/templates/{ => a}/AGPLv2.single-file.copyright.tx (100%) rename licor/templates/{ => a}/AGPLv2.single-file.meta (100%) rename licor/templates/{ => a}/AGPLv2.single-file.tx (100%) rename licor/templates/{ => a}/AGPLv2.tx (100%) rename licor/templates/{ => a}/AGPLv3.copyright.meta (100%) rename licor/templates/{ => a}/AGPLv3.copyright.tx (100%) rename licor/templates/{ => a}/AGPLv3.meta (100%) rename licor/templates/{ => a}/AGPLv3.single-file.copyright.meta (100%) rename licor/templates/{ => a}/AGPLv3.single-file.copyright.tx (100%) rename licor/templates/{ => a}/AGPLv3.single-file.meta (100%) rename licor/templates/{ => a}/AGPLv3.single-file.tx (100%) rename licor/templates/{ => a}/AGPLv3.tx (100%) rename licor/templates/{ => g}/GPLv2.copyright.meta (100%) rename licor/templates/{ => g}/GPLv2.copyright.tx (100%) rename licor/templates/{ => g}/GPLv2.meta (100%) rename licor/templates/{ => g}/GPLv2.single-file.copyright.meta (100%) rename licor/templates/{ => g}/GPLv2.single-file.copyright.tx (100%) rename licor/templates/{ => g}/GPLv2.single-file.meta (100%) rename licor/templates/{ => g}/GPLv2.single-file.tx (100%) rename licor/templates/{ => g}/GPLv2.tx (100%) rename licor/templates/{ => g}/GPLv3.copyright.meta (100%) rename licor/templates/{ => g}/GPLv3.copyright.tx (100%) rename licor/templates/{ => g}/GPLv3.meta (100%) rename licor/templates/{ => g}/GPLv3.single-file.copyright.meta (100%) rename licor/templates/{ => g}/GPLv3.single-file.copyright.tx (100%) rename licor/templates/{ => g}/GPLv3.single-file.meta (100%) rename licor/templates/{ => g}/GPLv3.single-file.tx (100%) rename licor/templates/{ => g}/GPLv3.tx (100%) rename licor/templates/{ => l}/LGPLv2.copyright.meta (100%) rename licor/templates/{ => l}/LGPLv2.copyright.tx (100%) rename licor/templates/{ => l}/LGPLv2.meta (100%) rename licor/templates/{ => l}/LGPLv2.single-file.copyright.meta (100%) rename licor/templates/{ => l}/LGPLv2.single-file.copyright.tx (100%) rename licor/templates/{ => l}/LGPLv2.single-file.meta (100%) rename licor/templates/{ => l}/LGPLv2.single-file.tx (100%) rename licor/templates/{ => l}/LGPLv2.tx (100%) rename licor/templates/{ => l}/LGPLv3.copyright.meta (100%) rename licor/templates/{ => l}/LGPLv3.copyright.tx (100%) rename licor/templates/{ => l}/LGPLv3.meta (100%) rename licor/templates/{ => l}/LGPLv3.single-file.copyright.meta (100%) rename licor/templates/{ => l}/LGPLv3.single-file.copyright.tx (100%) rename licor/templates/{ => l}/LGPLv3.single-file.meta (100%) rename licor/templates/{ => l}/LGPLv3.single-file.tx (100%) rename licor/templates/{ => l}/LGPLv3.tx (100%) diff --git a/licor/templates.py b/licor/templates.py index d18e2ab..6d4622f 100644 --- a/licor/templates.py +++ b/licor/templates.py @@ -25,11 +25,16 @@ from string import Template class TemplateException(Exception): pass -def get_resource_string(name): +def get_resource_string(name, is_global = True): """ Return the resource string with the given name UTF-8 encoded. """ - return pkg_resources.resource_string(__name__,"templates/" + name).decode("UTF-8") + if(is_global): + return pkg_resources.resource_string(__name__,"templates/" + name).decode("UTF-8") + else: + start = name[0].lower() + path = "templates/" + start + "/" + name + return pkg_resources.resource_string(__name__, path).decode("UTF-8") def get_template(name, modifiers = []): @@ -49,7 +54,7 @@ def get_template(name, modifiers = []): get_template("AGPL", modifiers = ["single-file"]) """ - templates_avail = json.loads(get_resource_string("licenses_avail.json")) + templates_avail = get_templates_available() if( not name in templates_avail): raise TemplateException("Unknown license: {}".format(name)) @@ -68,11 +73,11 @@ def get_template(name, modifiers = []): meta_name = ".".join((name, "meta")) data_name = ".".join((name, "tx")) try: - meta = json.loads(get_resource_string(meta_name)) + meta = json.loads(get_resource_string(meta_name, False)) except: continue - data = get_resource_string(data_name) + data = get_resource_string(data_name, False) meta.update({"text": data}) return meta @@ -112,7 +117,7 @@ def get_template_meta(name, modifiers = []): else: meta_name = ".".join((name, "meta")) try: - meta = json.loads(get_resource_string(meta_name)) + meta = json.loads(get_resource_string(meta_name, True)) except: continue diff --git a/licor/templates/AGPLv2.copyright.meta b/licor/templates/a/AGPLv2.copyright.meta similarity index 100% rename from licor/templates/AGPLv2.copyright.meta rename to licor/templates/a/AGPLv2.copyright.meta diff --git a/licor/templates/AGPLv2.copyright.tx b/licor/templates/a/AGPLv2.copyright.tx similarity index 100% rename from licor/templates/AGPLv2.copyright.tx rename to licor/templates/a/AGPLv2.copyright.tx diff --git a/licor/templates/AGPLv2.meta b/licor/templates/a/AGPLv2.meta similarity index 100% rename from licor/templates/AGPLv2.meta rename to licor/templates/a/AGPLv2.meta diff --git a/licor/templates/AGPLv2.single-file.copyright.meta b/licor/templates/a/AGPLv2.single-file.copyright.meta similarity index 100% rename from licor/templates/AGPLv2.single-file.copyright.meta rename to licor/templates/a/AGPLv2.single-file.copyright.meta diff --git a/licor/templates/AGPLv2.single-file.copyright.tx b/licor/templates/a/AGPLv2.single-file.copyright.tx similarity index 100% rename from licor/templates/AGPLv2.single-file.copyright.tx rename to licor/templates/a/AGPLv2.single-file.copyright.tx diff --git a/licor/templates/AGPLv2.single-file.meta b/licor/templates/a/AGPLv2.single-file.meta similarity index 100% rename from licor/templates/AGPLv2.single-file.meta rename to licor/templates/a/AGPLv2.single-file.meta diff --git a/licor/templates/AGPLv2.single-file.tx b/licor/templates/a/AGPLv2.single-file.tx similarity index 100% rename from licor/templates/AGPLv2.single-file.tx rename to licor/templates/a/AGPLv2.single-file.tx diff --git a/licor/templates/AGPLv2.tx b/licor/templates/a/AGPLv2.tx similarity index 100% rename from licor/templates/AGPLv2.tx rename to licor/templates/a/AGPLv2.tx diff --git a/licor/templates/AGPLv3.copyright.meta b/licor/templates/a/AGPLv3.copyright.meta similarity index 100% rename from licor/templates/AGPLv3.copyright.meta rename to licor/templates/a/AGPLv3.copyright.meta diff --git a/licor/templates/AGPLv3.copyright.tx b/licor/templates/a/AGPLv3.copyright.tx similarity index 100% rename from licor/templates/AGPLv3.copyright.tx rename to licor/templates/a/AGPLv3.copyright.tx diff --git a/licor/templates/AGPLv3.meta b/licor/templates/a/AGPLv3.meta similarity index 100% rename from licor/templates/AGPLv3.meta rename to licor/templates/a/AGPLv3.meta diff --git a/licor/templates/AGPLv3.single-file.copyright.meta b/licor/templates/a/AGPLv3.single-file.copyright.meta similarity index 100% rename from licor/templates/AGPLv3.single-file.copyright.meta rename to licor/templates/a/AGPLv3.single-file.copyright.meta diff --git a/licor/templates/AGPLv3.single-file.copyright.tx b/licor/templates/a/AGPLv3.single-file.copyright.tx similarity index 100% rename from licor/templates/AGPLv3.single-file.copyright.tx rename to licor/templates/a/AGPLv3.single-file.copyright.tx diff --git a/licor/templates/AGPLv3.single-file.meta b/licor/templates/a/AGPLv3.single-file.meta similarity index 100% rename from licor/templates/AGPLv3.single-file.meta rename to licor/templates/a/AGPLv3.single-file.meta diff --git a/licor/templates/AGPLv3.single-file.tx b/licor/templates/a/AGPLv3.single-file.tx similarity index 100% rename from licor/templates/AGPLv3.single-file.tx rename to licor/templates/a/AGPLv3.single-file.tx diff --git a/licor/templates/AGPLv3.tx b/licor/templates/a/AGPLv3.tx similarity index 100% rename from licor/templates/AGPLv3.tx rename to licor/templates/a/AGPLv3.tx diff --git a/licor/templates/GPLv2.copyright.meta b/licor/templates/g/GPLv2.copyright.meta similarity index 100% rename from licor/templates/GPLv2.copyright.meta rename to licor/templates/g/GPLv2.copyright.meta diff --git a/licor/templates/GPLv2.copyright.tx b/licor/templates/g/GPLv2.copyright.tx similarity index 100% rename from licor/templates/GPLv2.copyright.tx rename to licor/templates/g/GPLv2.copyright.tx diff --git a/licor/templates/GPLv2.meta b/licor/templates/g/GPLv2.meta similarity index 100% rename from licor/templates/GPLv2.meta rename to licor/templates/g/GPLv2.meta diff --git a/licor/templates/GPLv2.single-file.copyright.meta b/licor/templates/g/GPLv2.single-file.copyright.meta similarity index 100% rename from licor/templates/GPLv2.single-file.copyright.meta rename to licor/templates/g/GPLv2.single-file.copyright.meta diff --git a/licor/templates/GPLv2.single-file.copyright.tx b/licor/templates/g/GPLv2.single-file.copyright.tx similarity index 100% rename from licor/templates/GPLv2.single-file.copyright.tx rename to licor/templates/g/GPLv2.single-file.copyright.tx diff --git a/licor/templates/GPLv2.single-file.meta b/licor/templates/g/GPLv2.single-file.meta similarity index 100% rename from licor/templates/GPLv2.single-file.meta rename to licor/templates/g/GPLv2.single-file.meta diff --git a/licor/templates/GPLv2.single-file.tx b/licor/templates/g/GPLv2.single-file.tx similarity index 100% rename from licor/templates/GPLv2.single-file.tx rename to licor/templates/g/GPLv2.single-file.tx diff --git a/licor/templates/GPLv2.tx b/licor/templates/g/GPLv2.tx similarity index 100% rename from licor/templates/GPLv2.tx rename to licor/templates/g/GPLv2.tx diff --git a/licor/templates/GPLv3.copyright.meta b/licor/templates/g/GPLv3.copyright.meta similarity index 100% rename from licor/templates/GPLv3.copyright.meta rename to licor/templates/g/GPLv3.copyright.meta diff --git a/licor/templates/GPLv3.copyright.tx b/licor/templates/g/GPLv3.copyright.tx similarity index 100% rename from licor/templates/GPLv3.copyright.tx rename to licor/templates/g/GPLv3.copyright.tx diff --git a/licor/templates/GPLv3.meta b/licor/templates/g/GPLv3.meta similarity index 100% rename from licor/templates/GPLv3.meta rename to licor/templates/g/GPLv3.meta diff --git a/licor/templates/GPLv3.single-file.copyright.meta b/licor/templates/g/GPLv3.single-file.copyright.meta similarity index 100% rename from licor/templates/GPLv3.single-file.copyright.meta rename to licor/templates/g/GPLv3.single-file.copyright.meta diff --git a/licor/templates/GPLv3.single-file.copyright.tx b/licor/templates/g/GPLv3.single-file.copyright.tx similarity index 100% rename from licor/templates/GPLv3.single-file.copyright.tx rename to licor/templates/g/GPLv3.single-file.copyright.tx diff --git a/licor/templates/GPLv3.single-file.meta b/licor/templates/g/GPLv3.single-file.meta similarity index 100% rename from licor/templates/GPLv3.single-file.meta rename to licor/templates/g/GPLv3.single-file.meta diff --git a/licor/templates/GPLv3.single-file.tx b/licor/templates/g/GPLv3.single-file.tx similarity index 100% rename from licor/templates/GPLv3.single-file.tx rename to licor/templates/g/GPLv3.single-file.tx diff --git a/licor/templates/GPLv3.tx b/licor/templates/g/GPLv3.tx similarity index 100% rename from licor/templates/GPLv3.tx rename to licor/templates/g/GPLv3.tx diff --git a/licor/templates/LGPLv2.copyright.meta b/licor/templates/l/LGPLv2.copyright.meta similarity index 100% rename from licor/templates/LGPLv2.copyright.meta rename to licor/templates/l/LGPLv2.copyright.meta diff --git a/licor/templates/LGPLv2.copyright.tx b/licor/templates/l/LGPLv2.copyright.tx similarity index 100% rename from licor/templates/LGPLv2.copyright.tx rename to licor/templates/l/LGPLv2.copyright.tx diff --git a/licor/templates/LGPLv2.meta b/licor/templates/l/LGPLv2.meta similarity index 100% rename from licor/templates/LGPLv2.meta rename to licor/templates/l/LGPLv2.meta diff --git a/licor/templates/LGPLv2.single-file.copyright.meta b/licor/templates/l/LGPLv2.single-file.copyright.meta similarity index 100% rename from licor/templates/LGPLv2.single-file.copyright.meta rename to licor/templates/l/LGPLv2.single-file.copyright.meta diff --git a/licor/templates/LGPLv2.single-file.copyright.tx b/licor/templates/l/LGPLv2.single-file.copyright.tx similarity index 100% rename from licor/templates/LGPLv2.single-file.copyright.tx rename to licor/templates/l/LGPLv2.single-file.copyright.tx diff --git a/licor/templates/LGPLv2.single-file.meta b/licor/templates/l/LGPLv2.single-file.meta similarity index 100% rename from licor/templates/LGPLv2.single-file.meta rename to licor/templates/l/LGPLv2.single-file.meta diff --git a/licor/templates/LGPLv2.single-file.tx b/licor/templates/l/LGPLv2.single-file.tx similarity index 100% rename from licor/templates/LGPLv2.single-file.tx rename to licor/templates/l/LGPLv2.single-file.tx diff --git a/licor/templates/LGPLv2.tx b/licor/templates/l/LGPLv2.tx similarity index 100% rename from licor/templates/LGPLv2.tx rename to licor/templates/l/LGPLv2.tx diff --git a/licor/templates/LGPLv3.copyright.meta b/licor/templates/l/LGPLv3.copyright.meta similarity index 100% rename from licor/templates/LGPLv3.copyright.meta rename to licor/templates/l/LGPLv3.copyright.meta diff --git a/licor/templates/LGPLv3.copyright.tx b/licor/templates/l/LGPLv3.copyright.tx similarity index 100% rename from licor/templates/LGPLv3.copyright.tx rename to licor/templates/l/LGPLv3.copyright.tx diff --git a/licor/templates/LGPLv3.meta b/licor/templates/l/LGPLv3.meta similarity index 100% rename from licor/templates/LGPLv3.meta rename to licor/templates/l/LGPLv3.meta diff --git a/licor/templates/LGPLv3.single-file.copyright.meta b/licor/templates/l/LGPLv3.single-file.copyright.meta similarity index 100% rename from licor/templates/LGPLv3.single-file.copyright.meta rename to licor/templates/l/LGPLv3.single-file.copyright.meta diff --git a/licor/templates/LGPLv3.single-file.copyright.tx b/licor/templates/l/LGPLv3.single-file.copyright.tx similarity index 100% rename from licor/templates/LGPLv3.single-file.copyright.tx rename to licor/templates/l/LGPLv3.single-file.copyright.tx diff --git a/licor/templates/LGPLv3.single-file.meta b/licor/templates/l/LGPLv3.single-file.meta similarity index 100% rename from licor/templates/LGPLv3.single-file.meta rename to licor/templates/l/LGPLv3.single-file.meta diff --git a/licor/templates/LGPLv3.single-file.tx b/licor/templates/l/LGPLv3.single-file.tx similarity index 100% rename from licor/templates/LGPLv3.single-file.tx rename to licor/templates/l/LGPLv3.single-file.tx diff --git a/licor/templates/LGPLv3.tx b/licor/templates/l/LGPLv3.tx similarity index 100% rename from licor/templates/LGPLv3.tx rename to licor/templates/l/LGPLv3.tx