Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change licence to MIT licence so we use the same licence as InChI 1.07. #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 2017-03-21 V1.00
First official release of RInChI.

**Contributors**

Biochemfusion Holding ApS

www.biochemfusion.com

Files contributed:

```
src/lib/inchi_api_intf.cpp and .h
src/lib/inchi_generator.cpp and .h
src/lib/rinchi_utils.cpp and .h
src/lib/unit_test.cpp and .h
src/parsers/generic_line_reader.h
src/parsers/mdl_molfile.cpp and .h
src/parsers/mdl_molfile_reader.cpp and .h
```

; EOF

21 changes: 21 additions & 0 deletions LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (C) 2024 IUPAC and InChI Trust

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.
65 changes: 26 additions & 39 deletions scripts/rewrite_license_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

import sys
import os
import datetime
import re

processed_file_count = 0

def process_source_file(a_filename):
global BSD_LICENSE_TXT
global RINCHI_LICENSE_TXT
global BSD_LICENSE_TXT_PYTHON
global RINCHI_LICENSE_TXT_PYTHON

source_txt = open(a_filename).readlines()
start_line = 0
while start_line < len(source_txt) and source_txt[start_line].find(BSD_LICENSE_MARKER_BEGIN) < 0 and source_txt[start_line].find(RINCHI_LICENSE_MARKER_BEGIN) < 0:
while start_line < len(source_txt) and source_txt[start_line].find(LICENSE_MARKER_BEGIN) < 0:
start_line = start_line + 1

if start_line < len(source_txt):
Expand All @@ -26,16 +26,17 @@ def process_source_file(a_filename):
if stop_line >= len(source_txt):
raise Exception, "File '" + a_filename + "' has a license-begin marker but no end marker."

if source_txt[start_line].find(BSD_LICENSE_MARKER_BEGIN) >= 0:
if a_filename.endswith('.py'):
new_txt = source_txt[0:start_line + 1] + BSD_LICENSE_TXT_PYTHON + source_txt[stop_line:]
else:
new_txt = source_txt[0:start_line + 1] + BSD_LICENSE_TXT + source_txt[stop_line:]
# print(a_filename)
license_path = re.sub("/[a-zA-Z0-9_-]*?/", "/../", a_filename)
license_path = re.sub("/[a-zA-Z0-9_-]*?/", "/../", license_path)
license_path = license_path[0:license_path.rfind("/")] + "/LICENCE.txt"
# Convert first parent folder reference to current folder reference.
license_path = license_path[1:]

if a_filename.endswith('.py'):
new_txt = source_txt[0:start_line + 1] + [s.replace("%LICENSE_PATH%", license_path) for s in RINCHI_LICENSE_TXT_PYTHON] + source_txt[stop_line:]
else:
if a_filename.endswith('.py'):
new_txt = source_txt[0:start_line + 1] + RINCHI_LICENSE_TXT_PYTHON + source_txt[stop_line:]
else:
new_txt = source_txt[0:start_line + 1] + RINCHI_LICENSE_TXT + source_txt[stop_line:]
new_txt = source_txt[0:start_line + 1] + [s.replace("%LICENSE_PATH%", license_path) for s in RINCHI_LICENSE_TXT] + source_txt[stop_line:]

open(a_filename, "w").write("".join(new_txt))
else:
Expand All @@ -58,36 +59,22 @@ def process_dir(a_dir):

BASE_DIR = "../src/"

BSD_LICENSE_TXT = [""]
RINCHI_LICENSE_TXT = [""]

if len(sys.argv) < 2:
raise Exception, "You must pass either a revision date or the command 'CLEAR'."
if sys.argv[1].upper() != "CLEAR":
BSD_LICENSE_TXT = open("../src/LICENCES/bsd_license.txt").readlines()
RINCHI_LICENSE_TXT = open("../src/LICENCES/rinchi_license.txt").readlines()
todays_date = sys.argv[1]
else:
todays_date = ""

# Replace keywords/variables in LICENSE_TXT texts with values.
rinchi_consts = open("../src/rinchi/rinchi_consts.cpp").readlines()
rinchi_version = [x for x in rinchi_consts if x.find("RINCHI_VERSION =") > 0]
if len(rinchi_version) != 1:
raise Exception, "Can't determine RINCHI_VERSION."
rinchi_version = rinchi_version[0]
rinchi_version = rinchi_version[rinchi_version.find("="):]
rinchi_version = rinchi_version.replace('"', '').replace("=", "").replace("\r", "").replace("\n", "").replace(";", "").replace(" ", "")

BSD_LICENSE_TXT = [s.replace("%RINCHI_VERSION%", rinchi_version).replace("%TODAY%", todays_date) for s in BSD_LICENSE_TXT]
RINCHI_LICENSE_TXT = [s.replace("%RINCHI_VERSION%", rinchi_version).replace("%TODAY%", todays_date) for s in RINCHI_LICENSE_TXT]
RINCHI_LICENSE_TXT = open("./sourcefile_license_header.txt").readlines()
current_year = str(datetime.datetime.now().year)

RINCHI_LICENSE_TXT = [s.replace("%CURRENT_YEAR%", current_year) for s in RINCHI_LICENSE_TXT]

# Special version for Python code, since Python doesn't have multi-line comments.
BSD_LICENSE_TXT_PYTHON = ["#" + s for s in BSD_LICENSE_TXT]
RINCHI_LICENSE_TXT_PYTHON = ["#" + s for s in RINCHI_LICENSE_TXT]
RINCHI_LICENSE_TXT_PYTHON = ["# " + s for s in RINCHI_LICENSE_TXT]
# Normal C/C++ version.
RINCHI_LICENSE_TXT = ["// " + s for s in RINCHI_LICENSE_TXT]
print("".join(RINCHI_LICENSE_TXT))

if len(sys.argv) >= 2 and sys.argv[1].upper() == "CLEAR":
RINCHI_LICENSE_TXT = [""]
RINCHI_LICENSE_TXT_PYTHON = [""]

BSD_LICENSE_MARKER_BEGIN = "#pragma region BSD-license"
RINCHI_LICENSE_MARKER_BEGIN = "#pragma region InChI-Trust Licence"
LICENSE_MARKER_BEGIN = "#pragma region RInChI-license"
LICENSE_MARKER_END = "#pragma endregion"

process_dir(BASE_DIR)
Expand Down
4 changes: 4 additions & 0 deletions scripts/sourcefile_license_header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Copyright (C) 2017 - %CURRENT_YEAR% InChI Project. All Rights Reserved.
This file is part of the RInChI source code.
The contents are covered by the terms of the MIT license
included in the file %LICENSE_PATH%.
Loading
Loading