Skip to content
Snippets Groups Projects

Various fixes

Merged Samuel Gaist requested to merge various_fixes into master
1 file
+ 12
4
Compare changes
  • Side-by-side
  • Inline
+ 12
4
 
#!/usr/bin/env python
"""
"""
**
**
** Copyright (C) 2018 The Qt Company Ltd.
** Copyright (C) 2018 The Qt Company Ltd.
@@ -33,10 +34,11 @@ import io
@@ -33,10 +34,11 @@ import io
import json
import json
import os
import os
import sys
import sys
 
import six
from jinja2 import Environment, FileSystemLoader, Template
from jinja2 import Environment, FileSystemLoader, Template
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file", nargs="?", help="qt_attribution.json file",
parser.add_argument("-f", "--file", nargs="?", help="qt_attribution.json file generated by qtattributionscanner",
type=argparse.FileType('r'), default=sys.stdin)
type=argparse.FileType('r'), default=sys.stdin)
parser.add_argument("-o", "--out", nargs="?", help="file to write to",
parser.add_argument("-o", "--out", nargs="?", help="file to write to",
type=argparse.FileType('w'), default=sys.stdout)
type=argparse.FileType('w'), default=sys.stdout)
@@ -46,13 +48,17 @@ args = parser.parse_args()
@@ -46,13 +48,17 @@ args = parser.parse_args()
# Set up jinja2
# Set up jinja2
env = Environment(
env = Environment(
loader = FileSystemLoader(os.path.dirname(os.path.realpath(__file__)) + "/templates")
loader = FileSystemLoader(os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates"))
)
)
template = env.get_template(args.template)
template = env.get_template(args.template)
# Read in qt_attribution.json file
# Read in qt_attribution.json file
attributions = json.load(args.file)
attributions = json.load(args.file)
 
if not isinstance(attributions, list):
 
print("Invalid JSON, should contain a list of attributions")
 
sys.exit(1)
 
# Load content of license files directly into the structure
# Load content of license files directly into the structure
for entry in attributions:
for entry in attributions:
if entry['LicenseFile']:
if entry['LicenseFile']:
@@ -62,5 +68,7 @@ for entry in attributions:
@@ -62,5 +68,7 @@ for entry in attributions:
entry['LicenseText'] = content.read()
entry['LicenseText'] = content.read()
# Render
# Render
result = template.render(attributions = attributions)
result = template.render(attributions=attributions)
args.out.write(result.encode('UTF8'))
if six.PY2:
 
result = result.encode('UTF8')
 
args.out.write(result)
Loading