<commit_before># Kontrol is a class for communicating with the Kontrol Kite.
# In our application, there is only one instance of this and it can be
# reachable from KD.getSingleton("kontrol").
class Kontrol extends KDObject

  constructor: (options={})->
    super options

    kite =
      name     : "kontrol"
      url      : "#{KD.config.newkontrol.url}"

    authentication =
      type     : "sessionID"
      key      : KD.remote.getSessionToken()

    @kite = new NewKite kite, authentication
    @kite.connect()

  # getKites Calls the callback function with the list of NewKite instances.
  # The returned kites are not connected. You must connect with
  # NewKite.connect().
  #
  # Query parameters are below from general to specific:
  #
  #   username    string
  #   environment string
  #   name        string
  #   version     string
  #   region      string
  #   hostname    string
  #   id          string
  #
  getKites: (query={}, callback = noop)->
    @_sanitizeQuery query

    @kite.tell "getKites", [query], (err, kites)=>
      return callback err, null  if err

      callback null, (@_createKite k for k in kites)

  # watchKites watches for Kites that matches the query. The onEvent functions
  # is called for current kites and every new kite event.
  watchKites: (query={}, callback)->
    return warn "callback is not defined "  unless callback

    @_sanitizeQuery query

    onEvent = (options)=>
      e = options.withArgs[0]
      kite =
        kite   : e.kite
        token  :
          key  : e.token?.key
          ttl  : e.token?.ttl

      callback null, {action: e.action, kite: @_createKite kite}

    @kite.tell "getKites", [query, onEvent], (err, kites)=>
      return callback err, null  if err

      for kite in kites
        callback null, {action: @KiteAction.Register, kite: @_createKite kite}

  # Returns a new NewKite instance from Kite data structure coming from
  # getKites() and watchKites() methods.
  _createKite: (k)->
    new NewKite k.kite, {type: "token", key: k.token.key}<commit_msg>kite: update for new token format<commit_after># Kontrol is a class for communicating with the Kontrol Kite.
# In our application, there is only one instance of this and it can be
# reachable from KD.getSingleton("kontrol").
class Kontrol extends KDObject

  constructor: (options={})->
    super options

    kite =
      name     : "kontrol"
      url      : "#{KD.config.newkontrol.url}"

    authentication =
      type     : "sessionID"
      key      : KD.remote.getSessionToken()

    @kite = new NewKite kite, authentication
    @kite.connect()

  # getKites Calls the callback function with the list of NewKite instances.
  # The returned kites are not connected. You must connect with
  # NewKite.connect().
  #
  # Query parameters are below from general to specific:
  #
  #   username    string
  #   environment string
  #   name        string
  #   version     string
  #   region      string
  #   hostname    string
  #   id          string
  #
  getKites: (query={}, callback = noop)->
    @_sanitizeQuery query

    @kite.tell "getKites", [query], (err, kites)=>
      return callback err, null  if err

      callback null, (@_createKite k for k in kites)

  # watchKites watches for Kites that matches the query. The onEvent functions
  # is called for current kites and every new kite event.
  watchKites: (query={}, callback)->
    return warn "callback is not defined "  unless callback

    @_sanitizeQuery query

    onEvent = (options)=>
      e = options.withArgs[0]
      callback null, {action: e.action, kite: @_createKite e}

    @kite.tell "getKites", [query, onEvent], (err, kites)=>
      return callback err, null  if err

      for kite in kites
        callback null, {action: @KiteAction.Register, kite: @_createKite kite}

  # Returns a new NewKite instance from Kite data structure coming from
  # getKites() and watchKites() methods.
  _createKite: (k)->
    new NewKite k.kite, {type: "token", key: k.token}
{'fraction_non_alphanumeric': 0.09345327336331834, 'fraction_numerical': 0.0004997501249375312, 'mean_word_length': 2.6691109074243813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4016560', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1221, 'n_words': 438}