<commit_before>(in-package :cldm)

(defparameter *verbose-mode* nil "When true, verbose messages are displayed on the standard output")

(defparameter *debug-mode* nil "When true, debugging messages are displayed on the standard output")

(defparameter *libraries-directory*
  (pathname "~/.cldm/cache/libraries/"))

(defparameter *standard-cldm-repo*
  `(make-instance 'cldm:cached-http-cld-repository
                  :name "cldm-repo"
                  :url "http://mmontone.github.io/cldm-repo/cld"
		  :cache-directory (pathname "~/.cldm/cache/cld-repositories/cldm-repo/")))

(defparameter *cld-repositories* (list *standard-cldm-repo*))

(defparameter *address-cache-operation* :symlink "What to do when caching a local file system directory. Can be either :symlink or :copy (copy the directory recursively). Default is :symlink")

(defparameter *solving-mode* :strict "One of :strict, :lenient. If :strict, errors are signaled if a cld cannot be found, or a dependency version is not specified. If :lenient, signal warnings and try to solve dependencies loading latest versions and the like.")

(defparameter *clean-asdf-environment* nil "If T, load libraries in a clean ASDF environment")

(defparameter *minisat+-binary* "/usr/bin/minisat+"
  "minisat+ binary for PBO solving")

(defparameter *local-libraries-directory* (merge-pathnames (pathname "lib/")
							   (osicat:current-directory)))

;; Configuration files

(defparameter *global-config-file* #p"/etc/cldm/config")
(defparameter *user-config-file* #p"~/.cldm/config")
(defparameter *local-config-file* (merge-pathnames (pathname ".cldm")
						   (osicat:current-directory)))

(defun call-with-libraries-directory (pathname function)
  (let ((*libraries-directory* pathname))
    (funcall function)))

(defmacro with-libraries-directory (pathname &body body)
  `(call-with-libraries-directory
    ,pathname
    (lambda ()
      ,@body)))

(defun call-with-cld-repositories (repositories function)
  (let ((*cld-repositories* repositories))
    (funcall function)))

(defmacro with-cld-repositories (repositories &body body)
  `(call-with-cld-repositories
    (list ,@repositories)
    (lambda ()
      ,@body)))

(defun list-cld-repositories ()
  (let ((*package* (find-package :cldm)))
    (mapcar #'eval *cld-repositories*)))

(defun read-config-file (pathname)
  (when (probe-file pathname)
    (read-from-string (file-to-string pathname) nil)))

(defun read-config (scope)
  (let ((config-file (ecase scope
		       (:local *local-config-file*)<commit_msg>Check a config file is not a directory before trying to load<commit_after>(in-package :cldm)

(defparameter *verbose-mode* nil "When true, verbose messages are displayed on the standard output")

(defparameter *debug-mode* nil "When true, debugging messages are displayed on the standard output")

(defparameter *libraries-directory*
  (pathname "~/.cldm/cache/libraries/"))

(defparameter *standard-cldm-repo*
  `(make-instance 'cldm:cached-http-cld-repository
                  :name "cldm-repo"
                  :url "http://mmontone.github.io/cldm-repo/cld"
		  :cache-directory (pathname "~/.cldm/cache/cld-repositories/cldm-repo/")))

(defparameter *cld-repositories* (list *standard-cldm-repo*))

(defparameter *address-cache-operation* :symlink "What to do when caching a local file system directory. Can be either :symlink or :copy (copy the directory recursively). Default is :symlink")

(defparameter *solving-mode* :strict "One of :strict, :lenient. If :strict, errors are signaled if a cld cannot be found, or a dependency version is not specified. If :lenient, signal warnings and try to solve dependencies loading latest versions and the like.")

(defparameter *clean-asdf-environment* nil "If T, load libraries in a clean ASDF environment")

(defparameter *minisat+-binary* "/usr/bin/minisat+"
  "minisat+ binary for PBO solving")

(defparameter *local-libraries-directory* (merge-pathnames (pathname "lib/")
							   (osicat:current-directory)))

;; Configuration files

(defparameter *global-config-file* #p"/etc/cldm/config")
(defparameter *user-config-file* #p"~/.cldm/config")
(defparameter *local-config-file* (merge-pathnames (pathname ".cldm")
						   (osicat:current-directory)))

(defun call-with-libraries-directory (pathname function)
  (let ((*libraries-directory* pathname))
    (funcall function)))

(defmacro with-libraries-directory (pathname &body body)
  `(call-with-libraries-directory
    ,pathname
    (lambda ()
      ,@body)))

(defun call-with-cld-repositories (repositories function)
  (let ((*cld-repositories* repositories))
    (funcall function)))

(defmacro with-cld-repositories (repositories &body body)
  `(call-with-cld-repositories
    (list ,@repositories)
    (lambda ()
      ,@body)))

(defun list-cld-repositories ()
  (let ((*package* (find-package :cldm)))
    (mapcar #'eval *cld-repositories*)))

(defun read-config-file (pathname)
  (when (and (probe-file pathname)
	     (not (cl-fad:directory-pathname-p pathname)))
    (read-from-string (file-to-string pathname) nil)))

(defun read-config (scope)
  (let ((config-file (ecase scope
		       (:local *local-config-file*)
{'fraction_non_alphanumeric': 0.13926499032882012, 'fraction_numerical': 0.0, 'mean_word_length': 4.314491264131552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3987205', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1656, 'n_words': 452}