From a80218ecf033d0a48d87dc54302cbde295e65aff Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Thu, 11 May 2023 17:51:17 +0200
Subject: [PATCH] WIP: Rename caosdb -> linkahead

---
 .../bloxberg/bloxberg.py                      | 10 ++--
 src/linkaheadadvancedtools/cfoods/h5.py       |  2 +-
 src/linkaheadadvancedtools/crawler.py         | 14 +++---
 src/linkaheadadvancedtools/export_related.py  |  2 +-
 src/linkaheadadvancedtools/loadFiles.py       | 46 +++++++++----------
 .../models/data_model.py                      |  6 +--
 src/linkaheadadvancedtools/models/parser.py   | 10 ++--
 src/linkaheadadvancedtools/scifolder/utils.py |  2 +-
 .../serverside/examples/example_script.py     |  4 +-
 .../serverside/generic_analysis.py            |  2 +-
 .../serverside/helper.py                      | 20 ++++----
 11 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/linkaheadadvancedtools/bloxberg/bloxberg.py b/src/linkaheadadvancedtools/bloxberg/bloxberg.py
index a774a8b9..43b4cb17 100644
--- a/src/linkaheadadvancedtools/bloxberg/bloxberg.py
+++ b/src/linkaheadadvancedtools/bloxberg/bloxberg.py
@@ -75,12 +75,12 @@ A dict with the following keys:
 
 Parameters
 ----------
-entity : caosdb.Entity
+entity : linkahead.Entity
 The entity to be certified
 
 Returns
 -------
-out : caosdb.Record
+out : linkahead.Record
 A BloxbergCertificate Record with all the necessary Properties.
 """
         # Calculate hash
@@ -126,7 +126,7 @@ This method does nothing if the verification passes, else it raises an exception
 
 Parameters
 ----------
-certificate : caosdb.Record
+certificate : linkahead.Record
 The BloxbergCertificate Record which shall be verified.
 
         """
@@ -138,7 +138,7 @@ The BloxbergCertificate Record which shall be verified.
 
 Parameters
 ----------
-certificate : caosdb.Record
+certificate : linkahead.Record
 The BloxbergCertificate Record for which the JSON is generated.
 
 filename : str
@@ -162,7 +162,7 @@ def certify_entity(entity, json_filename=None):
 
 Parameters
 ----------
-entity : caosdb.Entity
+entity : linkahead.Entity
   The Entity to be certified.
 
 json_filename : str
diff --git a/src/linkaheadadvancedtools/cfoods/h5.py b/src/linkaheadadvancedtools/cfoods/h5.py
index 2615040f..be0cd1c0 100644
--- a/src/linkaheadadvancedtools/cfoods/h5.py
+++ b/src/linkaheadadvancedtools/cfoods/h5.py
@@ -172,7 +172,7 @@ class H5CFood(AbstractFileCFood):
         self.to_be_inserted = db.Container()
         self.insert_missing_structure(self.structure)
 
-        # TODO this is a workaround due to the fact that the caosdb library
+        # TODO this is a workaround due to the fact that the LinkAhead library
         # changes the objects in the Container if it is inserted. The graph
         # structure is flattened. I.e. references to other entity objects are
         # replaced with their IDs. However this code depends on this graph.
diff --git a/src/linkaheadadvancedtools/crawler.py b/src/linkaheadadvancedtools/crawler.py
index dc4e52e6..4a522153 100644
--- a/src/linkaheadadvancedtools/crawler.py
+++ b/src/linkaheadadvancedtools/crawler.py
@@ -526,16 +526,16 @@ ____________________\n""".format(i+1, len(pending_changes)) + str(el[3]))
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <title>Crawler</title>
-  <link rel="stylesheet" href="{url}/webinterface/css/webcaosdb.css"/>
+  <link rel="stylesheet" href="{url}/webinterface/css/weblinkahead.css"/>
   <link rel="stylesheet" href="{url}/webinterface/css/bootstrap.css">
   <script src="{url}/webinterface/js/jquery.js"></script>
   <script src="{url}/webinterface/js/utif.js"></script>
   <script src="{url}/webinterface/js/loglevel.js"></script>
   <script src="{url}/webinterface/js/bootstrap.js"></script>
   <script src="{url}/webinterface/js/ext_table_preview.js"></script>
-  <script src="{url}/webinterface/js/webcaosdb.js"></script>
+  <script src="{url}/webinterface/js/weblinkahead.js"></script>
   <script src="{url}/webinterface/js/plotly.js"></script>
-  <script src="{url}/webinterface/js/caosdb.js"></script>
+  <script src="{url}/webinterface/js/linkahead.js"></script>
   <script src="{url}/webinterface/js/state-machine.js"></script>
   <script src="{url}/webinterface/js/showdown.js"></script>
   <script src="{url}/webinterface/js/preview.js"></script>
@@ -608,7 +608,7 @@ ____________________\n""".format(i+1, len(pending_changes)) + str(el[3]))
         filename: path to the html site that allow the authorization
         """
 
-        caosdb_config = db.configuration.get_config()
+        linkahead_config = db.configuration.get_config()
         text = """Dear Curator,
 there where changes that need your authorization. Please check the following
 carefully and if the changes are ok, click on the following link:
@@ -616,12 +616,12 @@ carefully and if the changes are ok, click on the following link:
 {url}/Shared/{filename}
 
 {changes}
-        """.format(url=caosdb_config["Connection"]["url"],
+        """.format(url=linkahead_config["Connection"]["url"],
                    filename=filename,
                    changes="\n".join(changes))
         try:
-            fro = caosdb_config["advancedtools"]["crawler.from_mail"]
-            to = caosdb_config["advancedtools"]["crawler.to_mail"]
+            fro = linkahead_config["advancedtools"]["crawler.from_mail"]
+            to = linkahead_config["advancedtools"]["crawler.to_mail"]
         except KeyError:
             logger.error("Server Configuration is missing a setting for "
                          "sending mails. The administrator should check "
diff --git a/src/linkaheadadvancedtools/export_related.py b/src/linkaheadadvancedtools/export_related.py
index 62a777ae..ad8aa192 100755
--- a/src/linkaheadadvancedtools/export_related.py
+++ b/src/linkaheadadvancedtools/export_related.py
@@ -128,7 +128,7 @@ def export(cont, directory="."):
     xml = etree.tounicode(cont.to_xml(
         local_serialization=True), pretty_print=True)
 
-    with open(os.path.join(directory, "caosdb_data.xml"), "w") as fi:
+    with open(os.path.join(directory, "linkahead_data.xml"), "w") as fi:
         fi.write(xml)
 
 
diff --git a/src/linkaheadadvancedtools/loadFiles.py b/src/linkaheadadvancedtools/loadFiles.py
index d57ac33c..ec8f1800 100755
--- a/src/linkaheadadvancedtools/loadFiles.py
+++ b/src/linkaheadadvancedtools/loadFiles.py
@@ -50,15 +50,15 @@ def convert_size(size):
     return '%s %s' % (s, size_name[i])
 
 
-def combine_ignore_files(caosdbignore, localignore, dirname=None):
-    """appends the contents of localignore to caosdbignore and saves the result
+def combine_ignore_files(linkaheadignore, localignore, dirname=None):
+    """appends the contents of localignore to linkaheadignore and saves the result
     and returns the name
 
     """
 
     tmp = NamedTemporaryFile(delete=False, mode="w",
-                             dir=dirname, prefix=".caosdbignore")
-    with open(caosdbignore, "r") as base:
+                             dir=dirname, prefix=".linkaheadignore")
+    with open(linkaheadignore, "r") as base:
         tmp.write(base.read())
     with open(localignore, "r") as local:
         tmp.write(local.read())
@@ -66,15 +66,15 @@ def combine_ignore_files(caosdbignore, localignore, dirname=None):
     return tmp.name
 
 
-def compile_file_list(caosdbignore, localpath):
+def compile_file_list(linkaheadignore, localpath):
     """creates a list of files that contain all files under localpath except
-    those excluded by caosdbignore
+    those excluded by linkaheadignore
 
     """
 
     from gitignore_parser import parse_gitignore
-    matches = parse_gitignore(caosdbignore)
-    current_ignore = caosdbignore
+    matches = parse_gitignore(linkaheadignore)
+    current_ignore = linkaheadignore
     non_ignored_files = []
     ignore_files = []
     for root, dirs, files in os.walk(localpath):
@@ -88,14 +88,14 @@ def compile_file_list(caosdbignore, localpath):
             current_ignore = ignore_files[-1][1]
             matches = parse_gitignore(current_ignore)
         else:
-            current_ignore = caosdbignore
+            current_ignore = linkaheadignore
             matches = parse_gitignore(current_ignore)
 
         # create a new local ignore file
-        if ".caosdbignore" in files:
+        if ".linkaheadignore" in files:
             current_ignore = combine_ignore_files(current_ignore,
                                                   os.path.join(
-                                                      root, ".caosdbignore"),
+                                                      root, ".linkaheadignore"),
                                                   # due to the logic of gitignore_parser the file
                                                   # has to be written to this folder
                                                   dirname=root)
@@ -128,12 +128,12 @@ def create_re_for_file_list(files, localroot, remoteroot):
     return "^("+regexp[1:]+")$"
 
 
-def loadpath(path, include, exclude, prefix, dryrun, forceAllowSymlinks, caosdbignore=None,
+def loadpath(path, include, exclude, prefix, dryrun, forceAllowSymlinks, linkaheadignore=None,
              localpath=None):
 
-    if caosdbignore:
+    if linkaheadignore:
         # create list of files and create regular expression for small chunks
-        filelist = compile_file_list(caosdbignore, localpath)
+        filelist = compile_file_list(linkaheadignore, localpath)
         fulllist = filelist
 
         index = 0
@@ -146,7 +146,7 @@ def loadpath(path, include, exclude, prefix, dryrun, forceAllowSymlinks, caosdbi
     else:
         includes = [include]
 
-    # if no caosdbignore file is used, this iterates over a single include
+    # if no linkaheadignore file is used, this iterates over a single include
     for include in includes:
         if dryrun:
             logger.info("Performin a dryrun!")
@@ -194,14 +194,14 @@ def main(argv=None):
     parser.add_argument("-p", "--prefix", dest="prefix",
                         help="store files with this prefix into the server's"
                         " file system.")
-    parser.add_argument("-c", "--caosdbignore", help="""
-Path to a caosdbignore file that defines which files shall be included and which do not.
+    parser.add_argument("-c", "--linkaheadignore", help="""
+Path to a linkaheadignore file that defines which files shall be included and which do not.
 The syntax is the same as in a gitignore file. You must also provide the localpath option
 since the check is done locally.
 """
                         )
     parser.add_argument("-l", "--localpath", help="Path to the root directory on this machine. "
-                        "This is needed if a caosdbignore file is used since the check is done "
+                        "This is needed if a linkaheadignore file is used since the check is done "
                         "locally")
     parser.add_argument("-i", "--include", dest="include",
                         help="""
@@ -236,12 +236,12 @@ exclude is given preference over include.
                         "directory tree.", action="store_true")
     args = parser.parse_args()
 
-    if args.caosdbignore and (args.exclude or args.include):
+    if args.linkaheadignore and (args.exclude or args.include):
         raise ValueError(
-            "Do not use a caosdbignore file and in- or exclude simultaneously!")
+            "Do not use a linkaheadignore file and in- or exclude simultaneously!")
 
-    if args.caosdbignore and not args.localpath:
-        raise ValueError("To use caosdbignore you must supply a local path!")
+    if args.linkaheadignore and not args.localpath:
+        raise ValueError("To use linkaheadignore you must supply a local path!")
 
     if args.localpath and (args.exclude or args.include):
         raise ValueError(
@@ -262,7 +262,7 @@ exclude is given preference over include.
         prefix=args.prefix,
         dryrun=args.dryrun,
         forceAllowSymlinks=args.forceAllowSymlinks,
-        caosdbignore=args.caosdbignore,
+        linkaheadignore=args.linkaheadignore,
         localpath=args.localpath,
     )
 
diff --git a/src/linkaheadadvancedtools/models/data_model.py b/src/linkaheadadvancedtools/models/data_model.py
index c9e344c6..d207ff73 100644
--- a/src/linkaheadadvancedtools/models/data_model.py
+++ b/src/linkaheadadvancedtools/models/data_model.py
@@ -33,7 +33,7 @@ import linkahead as db
 from linkahead.apiutils import compare_entities, describe_diff
 
 
-CAOSDB_INTERNAL_PROPERTIES = [
+LINKAHEAD_INTERNAL_PROPERTIES = [
     "description",
     "name",
     "unit",
@@ -45,7 +45,7 @@ class DataModel(dict):
 
     When constructing a data model the LinkAhead representation can easily be
     created using the classes RecordType and Propery, storing them in a
-    Container and inserting it in CaoSDB. However, this has one drawback: You
+    Container and inserting it in Linkahead. However, this has one drawback: You
     cannot simply change someting and update the container. The container will
     insist on having valid ids for all contained Entities.
 
@@ -136,7 +136,7 @@ class DataModel(dict):
             any_change = False
 
             for ent in existing_entities:
-                if ent.name in CAOSDB_INTERNAL_PROPERTIES:
+                if ent.name in LINKAHEAD_INTERNAL_PROPERTIES:
                     # Workaround for the usage of internal properties like name
                     # in via the extern keyword:
                     ref = db.Property(name=ent.name).retrieve()
diff --git a/src/linkaheadadvancedtools/models/parser.py b/src/linkaheadadvancedtools/models/parser.py
index 981455c5..803fc7fa 100644
--- a/src/linkaheadadvancedtools/models/parser.py
+++ b/src/linkaheadadvancedtools/models/parser.py
@@ -47,11 +47,11 @@ from warnings import warn
 import jsonschema
 import linkahead as db
 
-from .data_model import CAOSDB_INTERNAL_PROPERTIES, DataModel
+from .data_model import LINKAHEAD_INTERNAL_PROPERTIES, DataModel
 
 # Keywords which are allowed in data model descriptions.
 KEYWORDS = ["parent",  # deprecated, use inherit_from_* instead:
-                       # https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/36
+                       # https://gitlab.com/linkahead/linkahead-advanced-user-tools/-/issues/36
             "importance",
             "datatype",  # for example TEXT, INTEGER or REFERENCE
             "unit",
@@ -254,7 +254,7 @@ class Parser(object):
             ymlmodel["extern"] = []
 
         for name in ymlmodel["extern"]:
-            if name in CAOSDB_INTERNAL_PROPERTIES:
+            if name in LINKAHEAD_INTERNAL_PROPERTIES:
                 self.model[name] = db.Property(name=name).retrieve()
                 continue
             for role in ("Property", "RecordType", "Record", "File"):
@@ -547,7 +547,7 @@ class Parser(object):
         iterate over properties and check whether it is a base datatype of a
         name that was defined in the model (or extern part)
 
-        the string representations are replaced with caosdb objects
+        the string representations are replaced with LinkAhead objects
 
         """
 
@@ -771,7 +771,7 @@ class JsonSchemaParser(Parser):
         if "type" in elt and elt["type"] == "integer":
             raise NotImplementedError(
                 "Integer-enums are not allowd until "
-                "https://gitlab.indiscale.com/caosdb/src/caosdb-server/-/issues/224 "
+                "https://gitlab.indiscale.com/caosdb/src/LinkAhead-server/-/issues/224 "
                 "has been fixed."
             )
         rt = db.RecordType(name=name)
diff --git a/src/linkaheadadvancedtools/scifolder/utils.py b/src/linkaheadadvancedtools/scifolder/utils.py
index 34cbcf36..c25d2643 100644
--- a/src/linkaheadadvancedtools/scifolder/utils.py
+++ b/src/linkaheadadvancedtools/scifolder/utils.py
@@ -174,7 +174,7 @@ def get_xls_header(filepath):
     """
     This function reads an xlsx file and creates a dictionary analogue to the
     one created by the yaml headers in README.md files read with the get_header
-    function of caosdb-advancedtools.
+    function of linkahead-advancedtools.
     As xlsx files lack the hierarchical structure, the information that can be
     provided is less complex. See the possibility to use the xlsx files as a
     less powerfull version for people who are not comfortable with the
diff --git a/src/linkaheadadvancedtools/serverside/examples/example_script.py b/src/linkaheadadvancedtools/serverside/examples/example_script.py
index fe401cb3..ff1e5559 100755
--- a/src/linkaheadadvancedtools/serverside/examples/example_script.py
+++ b/src/linkaheadadvancedtools/serverside/examples/example_script.py
@@ -72,14 +72,14 @@ def send_mail(changes: [db.Entity], receipient: str):
     receipient: The person who shall receive the mail.
     """
 
-    caosdb_config = db.configuration.get_config()
+    linkahead_config = db.configuration.get_config()
     text = """Dear Curator,
 The following changes where done automatically.
 
 {changes}
     """.format(changes="\n".join(changes))
     try:
-        fro = caosdb_config["advancedtools"]["automated_updates.from_mail"]
+        fro = linkahead_config["advancedtools"]["automated_updates.from_mail"]
     except KeyError:
         logger.error("Server Configuration is missing a setting for "
                      "sending mails. The administrator should check "
diff --git a/src/linkaheadadvancedtools/serverside/generic_analysis.py b/src/linkaheadadvancedtools/serverside/generic_analysis.py
index a0ff479d..fc1df3c6 100644
--- a/src/linkaheadadvancedtools/serverside/generic_analysis.py
+++ b/src/linkaheadadvancedtools/serverside/generic_analysis.py
@@ -18,7 +18,7 @@
 # along with this program. If not, see <https://www.gnu.org/licenses/>.
 #
 #
-# See: https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools/-/issues/55
+# See: https://gitlab.indiscale.com/caosdb/src/linkahead-advanced-user-tools/-/issues/55
 
 # This source file is work in progress and currently untested.
 
diff --git a/src/linkaheadadvancedtools/serverside/helper.py b/src/linkaheadadvancedtools/serverside/helper.py
index 0a6f32a0..246f308f 100644
--- a/src/linkaheadadvancedtools/serverside/helper.py
+++ b/src/linkaheadadvancedtools/serverside/helper.py
@@ -165,7 +165,7 @@ def recordtype_is_child_of(rt, parent):
     Parameters
     ----------
 
-    rt : caosdb.Entity
+    rt : linkahead.Entity
         The child RecordType.
     parent : str or int
         The parent's name or id.
@@ -193,7 +193,7 @@ def init_data_model(entities):
     Parameters
     ----------
 
-    entities : iterable of caosdb.Entity
+    entities : iterable of linkahead.Entity
         The data model entities which are to be checked for existence.
 
     Raises
@@ -338,7 +338,7 @@ def send_mail(from_addr, to, subject, body, cc=None, bcc=None,
               send_mail_bin=None):
     """ Send an email via the configured send_mail client.
 
-    The relevant options in the pycaosdb.ini are:
+    The relevant options in the pylinkahead.ini are:
 
         [Misc]
         sendmail = ...
@@ -364,8 +364,8 @@ def send_mail(from_addr, to, subject, body, cc=None, bcc=None,
     ------
     subprocess.CalledProcessError
         If the sendmail client returned with a non-zero code.
-    caosdb.ConfigurationException
-        If the caosdb configuration has no `Misc.sendmail` configured while the
+    linkahead.ConfigurationException
+        If the linkahead configuration has no `Misc.sendmail` configured while the
         `send_mail_bin` parameter is None.
     """
 
@@ -388,14 +388,14 @@ def send_mail(from_addr, to, subject, body, cc=None, bcc=None,
     if send_mail_bin is not None:
         sendmail = send_mail_bin
     else:
-        caosdb_config = db.configuration.get_config()
+        linkahead_config = db.configuration.get_config()
 
-        if "Misc" not in caosdb_config or "sendmail" not in caosdb_config["Misc"]:
+        if "Misc" not in linkahead_config or "sendmail" not in linkahead_config["Misc"]:
             err_msg = ("No sendmail executable configured. "
                        "Please configure `Misc.sendmail` "
-                       "in your pycaosdb.ini.")
+                       "in your pylinkahead.ini.")
             raise db.ConfigurationError(err_msg)
-        sendmail = caosdb_config["Misc"]["sendmail"]
+        sendmail = linkahead_config["Misc"]["sendmail"]
 
     # construct sendmail command
     # options explained (from `man sendmail`):
@@ -437,7 +437,7 @@ def get_file_via_download(ent, logger=logging.getLogger(__name__)):
     try:
         # TODO remove the following treatment of size=0 when the
         # following issue is resolved:
-        # https://gitlab.com/caosdb/caosdb-server/-/issues/107
+        # https://gitlab.com/linkahead/linkahead-server/-/issues/107
 
         if ent.size > 0:
             val_file = ent.download()
-- 
GitLab