<commit_before>Package = require 'package'
fs = require 'fs'
_ = require 'underscore'

module.exports =
class AtomPackage extends Package
  metadata: null
  keymapsDirPath: null
  autoloadStylesheets: true

  constructor: ->
    super
    @keymapsDirPath = fs.join(@path, 'keymaps')

  load: ->
    try
      @loadMetadata()
      @loadKeymaps()
      @loadStylesheets() if @autoloadStylesheets
      if activationEvents = @getActivationEvents()
        @subscribeToActivationEvents(activationEvents)
      else
        @activatePackageMain()
    catch e
      console.warn "Failed to load package named '#{@name}'", e.stack
    this

  subscribeToActivationEvents: (activationEvents) ->
    if _.isArray(activationEvents)
      activateHandler = =>
        @activatePackageMain()
        for event in activationEvents
          rootView.off event, activateHandler
      for event in activationEvents
        rootView.command event, activateHandler
    else
      activateHandler = =>
        @activatePackageMain()
        for event, selector of activationEvents
          rootView.off event, selector, activateHandler
      for event, selector of activationEvents
        rootView.command event, selector, activateHandler

  activatePackageMain: ->
    if packageMain = @getPackageMain()<commit_msg>:lipstick:<commit_after>Package = require 'package'
fs = require 'fs'
_ = require 'underscore'

module.exports =
class AtomPackage extends Package
  metadata: null
  keymapsDirPath: null
  autoloadStylesheets: true

  constructor: ->
    super
    @keymapsDirPath = fs.join(@path, 'keymaps')

  load: ->
    try
      @loadMetadata()
      @loadKeymaps()
      @loadStylesheets() if @autoloadStylesheets
      if activationEvents = @getActivationEvents()
        @subscribeToActivationEvents(activationEvents)
      else
        @activatePackageMain()
    catch e
      console.warn "Failed to load package named '#{@name}'", e.stack
    this

  subscribeToActivationEvents: (activationEvents) ->
    if _.isArray(activationEvents)
      activateHandler = =>
        @activatePackageMain()
        rootView.off(event, activateHandler) for event in activationEvents
      rootView.command(event, activateHandler) for event in activationEvents
    else
      activateHandler = =>
        @activatePackageMain()
        rootView.off(event, selector, activateHandler) for event, selector of activationEvents
      rootView.command(event, selector, activateHandler) for event, selector of activationEvents

  activatePackageMain: ->
    if packageMain = @getPackageMain()
{'fraction_non_alphanumeric': 0.08336579664978574, 'fraction_numerical': 0.0, 'mean_word_length': 3.330522765598651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1976826', 'n_tokens_mistral': 698, 'n_tokens_neox': 680, 'n_words': 181}