<commit_before>// Copyright (c) 2015 <NAME>

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:args/args.dart';
import 'package:destiny-common/db.dart';

const OPTION_DRIVE_ID = 'drive_id';
const OPTION_DRIVE_SECRET = 'drive_secret';
const OPTION_OUTPUT_FILE = 'output_file';
const FLAG_HELP = 'help';

main(List<String> args) async {
  final parser = new ArgParser()
      ..addOption(OPTION_DRIVE_ID)
      ..addOption(OPTION_DRIVE_SECRET)
      ..addOption(OPTION_OUTPUT_FILE)
      ..addFlag(FLAG_HELP, negatable: false);
  var params = parser.parse(args);
  if (params[FLAG_HELP] ||
      !params.options.contains(OPTION_DRIVE_ID) ||
      !params.options.contains(OPTION_DRIVE_SECRET) ||
      !params.options.contains(OPTION_OUTPUT_FILE)) {
    print(parser.usage);
    return;
  }

  var config = new Config(
      params[OPTION_DRIVE_ID], params[OPTION_DRIVE_SECRET]);
  var loader = new DatabaseLoader(config);
  await loader.initialize();
  Database db = await loader.load();

  var xboxUsers = db.users.where((user) => user.onXbox).toList();
  var data = new JsonEncoder.withIndent('  ').convert(xboxUsers);
  await new File(params[OPTION_OUTPUT_FILE]).writeAsString(data);

  loader.destroy();
}<commit_msg>Added data for PSN roster<commit_after>// Copyright (c) 2015 <NAME>

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:args/args.dart';
import 'package:destiny-common/db.dart';

const OPTION_DRIVE_ID = 'drive_id';
const OPTION_DRIVE_SECRET = 'drive_secret';
const OPTION_OUTPUT_FILE = 'output_file';
const FLAG_HELP = 'help';

// Sorts a user list.
// Currently uses platform ids.
_sortUserList(List<User> users) {
  users.sort((a, b) {
    var comparable = (User user) => user.platformId.toLowerCase();
    return comparable(a).compareTo(comparable(b));
  });
  return users;
}

main(List<String> args) async {
  final parser = new ArgParser()
      ..addOption(OPTION_DRIVE_ID)
      ..addOption(OPTION_DRIVE_SECRET)
      ..addOption(OPTION_OUTPUT_FILE)
      ..addFlag(FLAG_HELP, negatable: false);
  var params = parser.parse(args);
  if (params[FLAG_HELP] ||
      !params.options.contains(OPTION_DRIVE_ID) ||
      !params.options.contains(OPTION_DRIVE_SECRET) ||
      !params.options.contains(OPTION_OUTPUT_FILE)) {
    print(parser.usage);
    return;
  }

  var config = new Config(
      params[OPTION_DRIVE_ID], params[OPTION_DRIVE_SECRET]);
  var loader = new DatabaseLoader(config);
  await loader.initialize();
  Database db = await loader.load();

  var xblUsers = _sortUserList(db.users.where((user) => user.onXbox).toList());
  var psnUsers = _sortUserList(db.users.where((user) => !user.onXbox).toList());
  var model = {
    'xblUsers': xblUsers,
    'psnUsers': psnUsers,
  };
  var data = new JsonEncoder.withIndent('  ').convert(model);
  await new File(params[OPTION_OUTPUT_FILE]).writeAsString(data);

  loader.destroy();
}
{'fraction_non_alphanumeric': 0.14246668944311583, 'fraction_numerical': 0.0027331738981892723, 'mean_word_length': 4.545454545454546, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '7038194', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1027, 'n_words': 193}