<commit_before># -*- encoding : utf-8 -*-
require 'reg_api2'

include RegApi2

RegApi2.username = 'test'
RegApi2.password = '<PASSWORD>'<commit_msg>Try to load username/password from ~/.regapi2 when exists.<commit_after># -*- encoding : utf-8 -*-
require 'reg_api2'

include RegApi2

# try to load defaults from ~/.regapi2
def try_lo_load_defaults
  filename = "#{ENV['HOME']}/.regapi2"
  username = 'test'
  password = '<PASSWORD>'

  if File.readable?(filename)
    IO.read(filename).split("\n").each do |line|
      username = $1  if line.strip =~ /^\s*username\s*\=(.+)\s*$/;
      password = $1  if line.strip =~ /^\s*password\s*\=(.+)\s*$/;
    end
  end

  RegApi2.username = username
  RegApi2.password = password
  puts "Your default username: \"#{username}\", and You can change it with \"#{filename}\"."
end

try_lo_load_defaults
{'fraction_non_alphanumeric': 0.17857142857142858, 'fraction_numerical': 0.017857142857142856, 'mean_word_length': 3.5706521739130435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5263125', 'n_tokens_mistral': 298, 'n_tokens_neox': 293, 'n_words': 73}