forked from gbaptista/sublime-3-shell-exec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSublimeSdf.py
46 lines (34 loc) · 1.78 KB
/
SublimeSdf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sys, sublime_plugin, sublime, os, json #, re, ,
from imp import reload
reload_mods = [mod for mod in sys.modules if mod[0:17] == "NetSuite SDF.lib." and sys.modules[mod] is not None]
for mod in reload_mods:
reload( sys.modules[ mod ] )
from .lib.Commands import *
from .lib.Settings import *
# For anyone examining my code, please forgive how unforgivably bad this is.
# I've never written in Python before, so this was also a crash course in Python
# If anyone wants to help contribute to make it better, be my guest
class SdfExecOpen(sublime_plugin.TextCommand):
temp_password = ""
def run(self, edit, **args):
self.args = args
def run_programm( user_password ):
Settings.password[ Settings.active_account ] = SdfExecOpen.temp_password
Commands.run(self, edit, **args)
def get_password( user_password ):
if( len(user_password) != len(SdfExecOpen.temp_password) ):
if len(user_password) < len(SdfExecOpen.temp_password):
SdfExecOpen.temp_password = SdfExecOpen.temp_password[:len(user_password)]
else:
chg = user_password[len( SdfExecOpen.temp_password ):]
SdfExecOpen.temp_password = SdfExecOpen.temp_password + chg
stars = "*" * len(user_password)
sublime.active_window().show_input_panel("NetSuite Password", stars, run_programm, get_password, None)
if Settings.get_sdf_file():
if Settings.active_account not in Settings.password and ("password" not in Settings.account_info[ Settings.active_account ] or Settings.account_info[ Settings.active_account ][ "password" ] != ""):
sublime.active_window().show_input_panel("NetSuite Password", "", None, get_password, None)
else:
Commands.run(self, edit, **args)
class SdfExecViewInsertCommand(sublime_plugin.TextCommand):
def run(self, edit, pos, text):
self.view.insert(edit, pos, text)