<commit_before>{CompositeDisposable} = require 'atom'
{call} = require './proc'
provider = require './provider'

module.exports =
  config:
    pythonPaths:
      type: 'string'
      default: ''
      title: 'Python Executable Paths'
      description: '
        Paths to python executable, must be semicolon separated.
        First takes precedence.
        $PROJECT_NAME is the current project name
        $PROJECT is the current project full path'
    autocompleteImports:
      type: 'boolean'
      default: true
      title: 'Use autocomplete to show a list of possible imports and
      add the chosen import at completion.'
    reindexOnSave:
      type: 'boolean'
      default: false
      title: 'Run a reindexation of imports on file save'

  activate: (state) ->
    @subscriptions = new CompositeDisposable()
    @subscriptions.add(atom.commands.add 'atom-workspace',
      'python-import-magic:update': => @update()
      'python-import-magic:reindex': => @reindex()
    )
    @subscriptions.add atom.workspace.observeTextEditors((editor) =>
      return unless editor.getFileName().endsWith('.py')
      @subscriptions.add editor.onDidSave =>
        return if @reindexing
        return unless atom.config.get('python-import-magic.reindexOnSave')
        @reindexing = true
        call
          cmd: 'reindex', 'utf-8', =>
            @reindexing = false
          , true
    )
    @reindexing = false
    call
      cmd: 'init', 'utf-8', (out) ->
        console.log 'Import magic', out.message
  deactivate: ->
    @subscriptions.dispose()

  update: ->
    editor = atom.workspace.getActiveTextEditor()

    call
      cmd: 'file_import_magic'
      source: editor.getBuffer().getText()
    , editor.getBuffer().getEncoding(), (out) ->
      editor.getBuffer().setTextViaDiff(out.file)

  reindex: ->
    console.log 'Import magic', 'Reindexing...'
    call cmd: 'reindex', 'utf-8'
  provide: -> provider
<commit_msg>Fix null<commit_after>{CompositeDisposable} = require 'atom'
{call} = require './proc'
provider = require './provider'

module.exports =
  config:
    pythonPaths:
      type: 'string'
      default: ''
      title: 'Python Executable Paths'
      description: '
        Paths to python executable, must be semicolon separated.
        First takes precedence.
        $PROJECT_NAME is the current project name
        $PROJECT is the current project full path'
    autocompleteImports:
      type: 'boolean'
      default: true
      title: 'Use autocomplete to show a list of possible imports and
      add the chosen import at completion.'
    reindexOnSave:
      type: 'boolean'
      default: false
      title: 'Run a reindexation of imports on file save'

  activate: (state) ->
    @subscriptions = new CompositeDisposable()
    @subscriptions.add(atom.commands.add 'atom-workspace',
      'python-import-magic:update': => @update()
      'python-import-magic:reindex': => @reindex()
    )
    @subscriptions.add atom.workspace.observeTextEditors((editor) =>
      return unless editor.getFileName()?.endsWith('.py')
      @subscriptions.add editor.onDidSave =>
        return if @reindexing
        return unless atom.config.get('python-import-magic.reindexOnSave')
        @reindexing = true
        call
          cmd: 'reindex', 'utf-8', =>
            @reindexing = false
          , true
    )
    @reindexing = false
    call
      cmd: 'init', 'utf-8', (out) ->
        console.log 'Import magic', out.message
  deactivate: ->
    @subscriptions.dispose()

  update: ->
    editor = atom.workspace.getActiveTextEditor()

    call
      cmd: 'file_import_magic'
      source: editor.getBuffer().getText()
    , editor.getBuffer().getEncoding(), (out) ->
      editor.getBuffer().setTextViaDiff(out.file)

  reindex: ->
    console.log 'Import magic', 'Reindexing...'
    call cmd: 'reindex', 'utf-8'
  provide: -> provider

{'fraction_non_alphanumeric': 0.12036082474226804, 'fraction_numerical': 0.0015463917525773195, 'mean_word_length': 2.6613207547169813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '4097606', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1124, 'n_words': 297}