<commit_before>#!/usr/bin/env ruby

#
# Android Cluster Toolkit
# 
# reconfig.rb - generate devices.rb based on 'adb devices' and 'devices-orig.rb'
#
# (c) 2012-2014 <NAME> (jduck)
#

bfn = __FILE__
while File.symlink?(bfn)
  bfn = File.expand_path(File.readlink(bfn), File.dirname(bfn))
end
$:.unshift(File.join(File.dirname(bfn), 'lib'))

require 'madb'


# load persistent devices
$devices = []
require 'devices-orig'
$stderr.puts "[*] Loaded #{$devices.length} device#{plural($devices.length)} from 'devices-orig.rb'"

# get a list of devices via 'adb devices'
adb_devices = adb_scan()
$stderr.puts "[*] Found #{adb_devices.length} device#{plural(adb_devices.length)} via 'adb devices'"


# print missing devices and store found ones
missing = $devices.dup
new = []
adb_devices.each { |ser|
  $devices.each { |dev|
    if dev[:serial] == ser
      new << dev
      missing.delete dev
      break
    end
  }
}


$stderr.puts "[*] Found #{new.length} device#{plural(new.length)}!"

$stderr.puts "[*] Missing #{missing.length} device#{plural(missing.length)}:"
missing.each { |dev|
  $stderr.puts "    #{dev[:name]} (#{dev[:serial]})"
}


# produce a new devices.rb with the currently connected devices only
devices = File.join(File.dirname(bfn), 'lib', 'devices.rb')

File.open(devices, "wb") { |f|
  f.puts "$devices = ["
  new.each { |dev|
    name = "'#{dev[:name]}',"
    serial = "'#{dev[:serial]}',"
    usb = "'#{dev[:usb]}',"
    codename = ""
    codename = ":codename => '#{dev[:codename]}'," if dev[:codename]

    f.puts "  { :name => %-16s :serial => %-24s :usb => %-10s %s }," % [name, serial, usb, codename]
  }
  f.puts "]"
}
<commit_msg>Slight change to output<commit_after>#!/usr/bin/env ruby

#
# Android Cluster Toolkit
# 
# reconfig.rb - generate devices.rb based on 'adb devices' and 'devices-orig.rb'
#
# (c) 2012-2014 <NAME> (jduck)
#

bfn = __FILE__
while File.symlink?(bfn)
  bfn = File.expand_path(File.readlink(bfn), File.dirname(bfn))
end
$:.unshift(File.join(File.dirname(bfn), 'lib'))

require 'madb'


# load persistent devices
$devices = []
require 'devices-orig'
$stderr.puts "[*] Loaded #{$devices.length} device#{plural($devices.length)} from 'devices-orig.rb'"

# get a list of devices via 'adb devices'
adb_devices = adb_scan()
$stderr.puts "[*] Found #{adb_devices.length} device#{plural(adb_devices.length)} via 'adb devices'"


# print missing devices and store found ones
missing = $devices.dup
new = []
adb_devices.each { |ser|
  $devices.each { |dev|
    if dev[:serial] == ser
      new << dev
      missing.delete dev
      break
    end
  }
}


$stderr.puts "[*] Matched #{new.length} device#{plural(new.length)}!"

$stderr.puts "[*] Missing #{missing.length} device#{plural(missing.length)}:"
missing.each { |dev|
  $stderr.puts "    #{dev[:name]} (#{dev[:serial]})"
}


# produce a new devices.rb with the currently connected devices only
devices = File.join(File.dirname(bfn), 'lib', 'devices.rb')

File.open(devices, "wb") { |f|
  f.puts "$devices = ["
  new.each { |dev|
    name = "'#{dev[:name]}',"
    serial = "'#{dev[:serial]}',"
    usb = "'#{dev[:usb]}',"
    codename = ""
    codename = ":codename => '#{dev[:codename]}'," if dev[:codename]

    f.puts "  { :name => %-16s :serial => %-24s :usb => %-10s %s }," % [name, serial, usb, codename]
  }
  f.puts "]"
}

{'fraction_non_alphanumeric': 0.1984365604329525, 'fraction_numerical': 0.00841852074564041, 'mean_word_length': 3.9954954954954953, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, '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': '2912115', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1249, 'n_words': 285}