<commit_before>local Loader = require "cosy.loader"
local I18n   = require "cosy.i18n"
local Logger = require "cosy.logger"
local Layer  = require "layeredata"
local layers = require "cosy.configuration.layers"

local i18n   = I18n.load "cosy.configuration"

layers.default.locale    = "en"
layers.default.__label__ = "configuration"

local Configuration = {}

function Configuration.load (t)
  if type (t) ~= "table" then
    t = { t }
  end
  for _, name in ipairs (t) do
    require (name .. ".conf")
  end
end

local Metatable = {}

function Metatable.__index (_, key)
  return layers.whole [key]
end

function Metatable.__newindex (_, key, value)
  layers.whole [key] = value
end

setmetatable (Configuration, Metatable)

local files = {
  etc  = "/etc/cosy.conf",
  home = os.getenv "HOME" .. "/.cosy/cosy.conf",
  pwd  = os.getenv "PWD"  .. "/cos<PASSWORD>",
}

if not _G.js then
  package.searchers [#package.searchers+1] = function (name)
    local result, err = io.open (name, "r")
    if not result then
      return nil, err
    end
    result, err = loadfile (name)<commit_msg>Compute /etc/cosy.conf path using prefix.<commit_after>local Loader = require "cosy.loader"
local I18n   = require "cosy.i18n"
local Logger = require "cosy.logger"
local Layer  = require "layeredata"
local layers = require "cosy.configuration.layers"
local Lfs    = require "lfs"

local i18n   = I18n.load "cosy.configuration"

layers.default.locale    = "en"
layers.default.__label__ = "configuration"

local Configuration = {}

function Configuration.load (t)
  if type (t) ~= "table" then
    t = { t }
  end
  for _, name in ipairs (t) do
    require (name .. ".conf")
  end
end

local Metatable = {}

function Metatable.__index (_, key)
  return layers.whole [key]
end

function Metatable.__newindex (_, key, value)
  layers.whole [key] = value
end

setmetatable (Configuration, Metatable)

-- Compute prefix:
local main = package.searchpath ("cosy.configuration", package.path)
if main:sub (1, 1) == "." then
  main = Lfs.currentdir () .. "/" .. main
end
local prefix = main:gsub ("/share/lua/5.1/cosy/configuration/.*", "/etc")

local files = {
  etc  = prefix .. "/cosy.conf",
  home = os.getenv "HOME" .. "/.cosy/cosy.conf",
  pwd  = os.getenv "PWD"  .. "/cosy.conf",
}

if not _G.js then
  package.searchers [#package.searchers+1] = function (name)
    local result, err = io.open (name, "r")
    if not result then
      return nil, err
    end
    result, err = loadfile (name)
{'fraction_non_alphanumeric': 0.13876563130294473, 'fraction_numerical': 0.008874546187979023, 'mean_word_length': 3.3205574912891986, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1859617', 'n_tokens_mistral': 875, 'n_tokens_neox': 861, 'n_words': 249}