<commit_before>module Common

  def array_attrs(array_spec,_attrs,distribute)
    dims=0
    array_spec.abstract_boundslist.each_index do |i|
      arrdim=i+1
      _attrs["lb#{arrdim}"]=array_spec.abstract_boundslist[i].alb
      _attrs["ub#{arrdim}"]=array_spec.abstract_boundslist[i].aub
      if distribute and (decompdim=distribute["dim"].index(arrdim))
        _attrs["decomp"]=distribute["decomp"]
        _attrs["dim#{arrdim}"]=decompdim+1
      end
      dims+=1
    end
    _attrs["dims"]||=dims
    _attrs
  end

  def attrchk(node,attr)
    node.respond_to?(attr) && node.send(attr)
  end

  def deepcopy(o)
    Marshal.load(Marshal.dump(o))
  end

  def envext
    ".sms"
  end

  def envfile(m,d=nil)
    d=File.dirname(@srcfile||".")
    File.join(File.expand_path(d),"#{m}#{envext}")
  end

  def sms_ignore
    env[:sms_ignore]
  end

  def sms_serial
    env[:sms_serial]
  end

  def use_localnames(modulename)
    e=(is_a?(Fortran::T))?(use_part.env):(env)
    return [] unless e[:uses]
    e[:uses][modulename].map { |x| x[0] }
  end

  def use_part
    specification_part.e[0]
  end

  def uses?(modname,usename)
    e=(is_a?(Fortran::T))?(use_part.env):(env)
    return false unless e[:uses]
    (e[:uses][modname])?(use_localnames(modname).include?(usename)):(false)
  end

  def write_envfile(modulename,_env)
    modinfo=deepcopy(_env)
    # Do not export symbol keys, which are for internal purposes only
    modinfo.delete_if { |k,v| k.is_a?(Symbol) }
    # Do not export info on private objects
    modinfo.delete_if { |k,v| v["access"]=="private" }
    f=envfile("#{modulename}")
    File.delete(f) if File.exist?(f)
    unless modinfo.empty?
      File.open(f,"w") { |f| f.write(YAML.dump(modinfo)) }
    end
  end

end<commit_msg>envfile now respects provided directory name<commit_after>module Common

  def array_attrs(array_spec,_attrs,distribute)
    dims=0
    array_spec.abstract_boundslist.each_index do |i|
      arrdim=i+1
      _attrs["lb#{arrdim}"]=array_spec.abstract_boundslist[i].alb
      _attrs["ub#{arrdim}"]=array_spec.abstract_boundslist[i].aub
      if distribute and (decompdim=distribute["dim"].index(arrdim))
        _attrs["decomp"]=distribute["decomp"]
        _attrs["dim#{arrdim}"]=decompdim+1
      end
      dims+=1
    end
    _attrs["dims"]||=dims
    _attrs
  end

  def attrchk(node,attr)
    node.respond_to?(attr) && node.send(attr)
  end

  def deepcopy(o)
    Marshal.load(Marshal.dump(o))
  end

  def envext
    ".sms"
  end

  def envfile(m,d)
    File.join(File.expand_path(d),"#{m}#{envext}")
  end

  def sms_ignore
    env[:sms_ignore]
  end

  def sms_serial
    env[:sms_serial]
  end

  def use_localnames(modulename)
    e=(is_a?(Fortran::T))?(use_part.env):(env)
    return [] unless e[:uses]
    e[:uses][modulename].map { |x| x[0] }
  end

  def use_part
    specification_part.e[0]
  end

  def uses?(modname,usename)
    e=(is_a?(Fortran::T))?(use_part.env):(env)
    return false unless e[:uses]
    (e[:uses][modname])?(use_localnames(modname).include?(usename)):(false)
  end

  def write_envfile(modulename,_env)
    modinfo=deepcopy(_env)
    # Do not export symbol keys, which are for internal purposes only
    modinfo.delete_if { |k,v| k.is_a?(Symbol) }
    # Do not export info on private objects
    modinfo.delete_if { |k,v| v["access"]=="private" }
    f=envfile("#{modulename}",".")
    File.delete(f) if File.exist?(f)
    unless modinfo.empty?
      File.open(f,"w") { |f| f.write(YAML.dump(modinfo)) }
    end
  end

end
{'fraction_non_alphanumeric': 0.15535359272933827, 'fraction_numerical': 0.003408122692416927, 'mean_word_length': 3.6587301587301586, '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': '7403380', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1372, 'n_words': 225}