<commit_before>#
# Sublime Text plugin to support Corona Editor
#
# Copyright (c) 2013 Corona Labs Inc. A mobile development software company. All rights reserved.
#
# MIT License - see https://raw.github.com/coronalabs/CoronaSDK-SublimeText/master/LICENSE

import sublime, sublime_plugin
import os.path
import platform
import json
import datetime

try:
  from . import _corona_utils # P3
except:
  import _corona_utils # P2

"""
# This is run by ST3 after the plugins have loaded (and the ST API is ready for calls)
def plugin_loaded():
  corona_utils.Init()

# This fakes the above functionality on ST2.
# It's important that this is called from a module that isn't imported by any other modules or
# the code gets run multiple times in ST2
if corona_utils.SUBLIME_VERSION < 3000:
  corona_utils.Init()
"""

class AboutCoronaEditorCommand(sublime_plugin.WindowCommand):
  _about_info = None
  _dev_about_info = '{"url": "https://www.coronalabs.com/", "version": "<development>", "description": "Corona Editor is the official Corona SDK plugin for Sublime Text"}'

  def run(self):
    self.load_json("package-manifest.json")
    sublime_info = "[Sublime Text " + sublime.version() +"/"+ sublime.channel() +"/"+ sublime.platform() +"/"+ sublime.arch() +"]"
    canary_file = os.path.join(_corona_utils.PACKAGE_DIR, "about.py") if _corona_utils.SUBLIME_VERSION < 3000 else _corona_utils.PACKAGE_DIR
    install_info = "Installed: " + str(datetime.datetime.fromtimestamp(os.path.getmtime(canary_file)))
    sublime.message_dialog("Corona Editor for Sublime Text\n\nVersion: "+ self._about_info['version'] +"\n\n"+ install_info +"\n\n"+ self._about_info['description'] +"\n\n"+ sublime_info)

  # If we're running ST2, load JSON from file
  # else, load JSON from member of package
  def load_json(self, filename):
    if (_corona_utils.SUBLIME_VERSION < 3000):
      file_path = os.path.join(_corona_utils.PACKAGE_DIR, filename)
      try:
        json_data = open(file_path)
        self._about_info = json.load(json_data)
      except:
        self._about_info = json.loads(self._dev_about_info)
      else:<commit_msg>Use correct Package Control filename for about info<commit_after>#
# Sublime Text plugin to support Corona Editor
#
# Copyright (c) 2013 Corona Labs Inc. A mobile development software company. All rights reserved.
#
# MIT License - see https://raw.github.com/coronalabs/CoronaSDK-SublimeText/master/LICENSE

import sublime, sublime_plugin
import os.path
import platform
import json
import datetime

try:
  from . import _corona_utils # P3
except:
  import _corona_utils # P2

"""
# This is run by ST3 after the plugins have loaded (and the ST API is ready for calls)
def plugin_loaded():
  corona_utils.Init()

# This fakes the above functionality on ST2.
# It's important that this is called from a module that isn't imported by any other modules or
# the code gets run multiple times in ST2
if corona_utils.SUBLIME_VERSION < 3000:
  corona_utils.Init()
"""

class AboutCoronaEditorCommand(sublime_plugin.WindowCommand):
  _about_info = None
  _dev_about_info = '{"url": "https://www.coronalabs.com/", "version": "<development>", "description": "Corona Editor is the official Corona SDK plugin for Sublime Text"}'

  def run(self):
    self.load_json("package-metadata.json")
    sublime_info = "[Sublime Text " + sublime.version() +"/"+ sublime.channel() +"/"+ sublime.platform() +"/"+ sublime.arch() +"]"
    canary_file = os.path.join(_corona_utils.PACKAGE_DIR, "about.py") if _corona_utils.SUBLIME_VERSION < 3000 else _corona_utils.PACKAGE_DIR
    install_info = "Installed: " + str(datetime.datetime.fromtimestamp(os.path.getmtime(canary_file)))
    about_mesg = "Corona Editor for Sublime Text\n\nVersion: "+ self._about_info['version'] +"\n\n"+ install_info +"\n\n"+ self._about_info['description'] +"\n\n"+ sublime_info
    print("about: " + about_mesg.replace("\n\n", " | "))
    sublime.message_dialog(about_mesg)

  # If we're running ST2, load JSON from file
  # else, load JSON from member of package
  def load_json(self, filename):
    if (_corona_utils.SUBLIME_VERSION < 3000):
      file_path = os.path.join(_corona_utils.PACKAGE_DIR, filename)
      try:
        json_data = open(file_path)
        self._about_info = json.load(json_data)
      except:
        self._about_info = json.loads(self._dev_about_info)
      else:
{'fraction_non_alphanumeric': 0.11551684620673848, 'fraction_numerical': 0.010084804033921613, 'mean_word_length': 4.381011097410604, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '3964929', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1412, 'n_words': 390}