<commit_before>require "fileutils"

class Xraylib < Formula
  homepage "https://github.com/tschoonj/xraylib"
  url "http://lvserver.ugent.be/xraylib/xraylib-3.1.0.tar.gz"
  mirror "https://xraylib.s3.amazonaws.com/xraylib-3.1.0.tar.gz"
  sha1 "38a8ea77984234d24eeff50d94a662baa6cf6907"

  bottle do
    root_url "https://downloads.sf.net/project/machomebrew/Bottles/science"
    sha1 "3d5cc1069008cca66f12b38b086368a570209633" => :yosemite
    sha1 "41bec42fb26f343e4edf648bcdcfc6fd9ce89e32" => :mavericks
    sha1 "ea821b25add248b3738cd4da30586a9bc403b5b9" => :mountain_lion
  end

  depends_on :python => :recommended
  depends_on :python3 => :optional
  depends_on :fortran => :optional
  depends_on "lua" => :optional
  depends_on :java  => :optional
  option "with-perl", "Build with perl support"
  option "with-ruby", "Build with ruby support"
  option "without-check", "Disable build-time checking (not recommended)"

  if build.with?("python") ||
     build.with?("python3") ||
     build.with?("perl") ||
     build.with?("ruby") ||
     build.with?("java") ||
     build.with?("lua")
    depends_on "swig" => :build
  end

  def install
    args = %W[
      --disable-dependency-tracking
      --disable-silent-rules
      --prefix=#{prefix}
      --disable-idl
      --disable-python-numpy
      --disable-php
    ]

    args << ((build.with? :fortran) ? "--enable-fortran" : "--disable-fortran")
    args << ((build.with? "perl") ? "--enable-perl" : "--disable-perl")
    args << ((build.with? "lua") ? "--enable-lua" : "--disable-lua")
    args << ((build.with? "ruby") ? "--enable-ruby" : "--disable-ruby")
    args << ((build.with? "java") ? "--enable-java" : "--disable-java")

    if !(build.with?("python") && build.with?("python3"))
      # regular build: either no or one type of python bindings required
      args << ((build.with?("python") || build.with?("python3")) ? "--enable-python" : "--disable-python")
      args << "PYTHON=python3" if build.with? :python3

      system "./configure", *args
      system "make"
      system "make", "check" if build.with? "check"
      system "make", "install"
    else
      # build for both python2 and python3 bindings
      # since the configure script allows for only one python binding,
      # some tricks are required here...
      args_nopython = args.dup
      args_python2 = args.dup
      args_python3 = args.dup
      args_nopython << "--disable-python"
      args_python2 << "--enable-python"
      args_python3 << "--enable-python" << "PYTHON=python3"
<commit_msg>xraylib: remove require fileutils<commit_after>class Xraylib < Formula
  homepage "https://github.com/tschoonj/xraylib"
  url "http://lvserver.ugent.be/xraylib/xraylib-3.1.0.tar.gz"
  mirror "https://xraylib.s3.amazonaws.com/xraylib-3.1.0.tar.gz"
  sha1 "38a8ea77984234d24eeff50d94a662baa6cf6907"

  bottle do
    root_url "https://downloads.sf.net/project/machomebrew/Bottles/science"
    sha1 "3d5cc1069008cca66f12b38b086368a570209633" => :yosemite
    sha1 "41bec42fb26f343e4edf648bcdcfc6fd9ce89e32" => :mavericks
    sha1 "ea821b25add248b3738cd4da30586a9bc403b5b9" => :mountain_lion
  end

  option "with-perl", "Build with perl support"
  option "with-ruby", "Build with ruby support"
  option "without-check", "Disable build-time checking (not recommended)"

  depends_on :python => :recommended
  depends_on :python3 => :optional
  depends_on :fortran => :optional
  depends_on "lua" => :optional
  depends_on :java  => :optional

  depends_on "swig" => :build

  def install
    args = %W[
      --disable-dependency-tracking
      --disable-silent-rules
      --prefix=#{prefix}
      --disable-idl
      --disable-python-numpy
      --disable-php
    ]

    args << ((build.with? "fortran") ? "--enable-fortran" : "--disable-fortran")
    args << ((build.with? "perl") ? "--enable-perl" : "--disable-perl")
    args << ((build.with? "lua") ? "--enable-lua" : "--disable-lua")
    args << ((build.with? "ruby") ? "--enable-ruby" : "--disable-ruby")
    args << ((build.with? "java") ? "--enable-java" : "--disable-java")

    if build.without?("python") && build.with?("python3")
      # regular build: either no or one type of python bindings required
      args << ((build.with?("python") || build.with?("python3")) ? "--enable-python" : "--disable-python")
      args << "PYTHON=python3" if build.with? "python3"

      system "./configure", *args
      system "make"
      system "make", "check" if build.with? "check"
      system "make", "install"
    else
      # build for both python2 and python3 bindings
      # since the configure script allows for only one python binding,
      # some tricks are required here...
      args_nopython = args.dup
      args_python2 = args.dup
      args_python3 = args.dup
      args_nopython << "--disable-python"
      args_python2 << "--enable-python"
      args_python3 << "--enable-python" << "PYTHON=python3"

{'fraction_non_alphanumeric': 0.161204966415632, 'fraction_numerical': 0.04946061469570527, 'mean_word_length': 3.1573604060913705, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3649743', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1707, 'n_words': 355}