<commit_before>require 'bugzilla'
require 'base64'

class BugzillaHelper
  # Bugzilla Config
  attr_accessor :username, :password, :product

  attr_accessor :bug

  def initialize(opts)
    opts.each do |k,v|
      send("#{k}=",v)
    end

    xmlrpc = Bugzilla::XMLRPC.new("bugzilla.redhat.com")
    user = Bugzilla::User.new(xmlrpc)

    user.login({'login'=>username, 'password'=><PASSWORD>64.decode64(password), 'remember'=>true})
    @bug = Bugzilla::Bug.new(xmlrpc)
  end

  def bug_status_by_url(url)
    status = 'NOTFOUND'
    if url =~ /https?:\/\/bugzilla\.redhat\.com\/show_bug\.cgi\?id=(\d+)/
      id = $1
      result = []
      tries = 1
      while true
        begin
          result = bug.get_bugs([id], ::Bugzilla::Bug::FIELDS_DETAILS)
          break
        rescue
          if tries == 3
            $stderr.puts "Error getting: #{url}"
            raise
          end
          tries += 1
        end
      end
      if !result.empty?
        status = result.first['status']
      end
    end<commit_msg>Make code a little more precise<commit_after>require 'bugzilla'
require 'base64'

class BugzillaHelper
  # Bugzilla Config
  attr_accessor :username, :password, :product

  attr_accessor :bug

  def initialize(opts)
    opts.each do |k,v|
      send("#{k}=",v)
    end

    xmlrpc = Bugzilla::XMLRPC.new("bugzilla.redhat.com")
    user = Bugzilla::User.new(xmlrpc)

    user.login({'login'=>username, 'password'=><PASSWORD>64.decode64(password), 'remember'=>true})
    @bug = Bugzilla::Bug.new(xmlrpc)
  end

  def bug_status_by_url(url)
    status = 'NOTFOUND'
    if url =~ /https?:\/\/bugzilla\.redhat\.com\/show_bug\.cgi\?id=(\d+)/
      id = $1
      tries = 1
      while true
        begin
          result = bug.get_bugs([id], ::Bugzilla::Bug::FIELDS_DETAILS)
          if !result.empty?
            status = result.first['status']
          end
          break
        rescue
          if tries == 3
            $stderr.puts "Error getting: #{url}"
            raise
          end
          tries += 1
        end
      end
    end
{'fraction_non_alphanumeric': 0.13974854932301742, 'fraction_numerical': 0.009671179883945842, 'mean_word_length': 2.1978361669242656, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '7112478', 'n_tokens_mistral': 739, 'n_tokens_neox': 682, 'n_words': 143}