Skip to content

Commit

Permalink
Ready for v1.00
Browse files Browse the repository at this point in the history
  • Loading branch information
instance-id committed Jun 25, 2020
1 parent 8bde06c commit d5814ba
Show file tree
Hide file tree
Showing 28 changed files with 553 additions and 422 deletions.
6 changes: 6 additions & 0 deletions .idea/Searcher.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 42 additions & 15 deletions 456.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from searcher import ptime as ptime
from searcher import language_en as la


from peewee import *
from peewee import SQL
from playhouse.sqlite_ext import SqliteExtDatabase, RowIDField, FTS5Model, SearchField
Expand All @@ -29,18 +28,22 @@
inspect.getsourcefile(lambda: 0)
)


def get_platform():
return getattr(hou.session, "PLATFORM", None)


def get_settings():
return getattr(hou.session, "SETTINGS", None)


def get_dbconnection():
return getattr(hou.session, "DBCONNECTION", None)


scriptpath = os.path.dirname(current_file_path)
dbfile = "searcher.db"
dbpath = os.path.join(
dbpath = os.path.join(
hou.homeHoudiniDirectory(), 'Searcher', dbfile
)

Expand All @@ -51,6 +54,7 @@ def get_dbconnection():
isloading = True
tempkey = ""


# --------------------------------------------------------- DatabaseModels
# SECTION DatabaseModels -------------------------------------------------
# ------------------------------------------------ Settings
Expand All @@ -68,6 +72,7 @@ class Meta:
table_name = 'settings'
database = db


# ------------------------------------------------ HContext
# NOTE HContext -------------------------------------------
class HContext(Model):
Expand All @@ -80,6 +85,7 @@ class Meta:
table_name = 'hcontext'
database = db


# # ------------------------------------------- HContextIndex
# # NOTE HContextIndex --------------------------------------
# class HContextIndex(FTS5Model):
Expand All @@ -105,6 +111,7 @@ class Meta:
table_name = 'hotkeys'
database = db


# -------------------------------------------- HotkeysIndex
# NOTE HotkeysIndex ---------------------------------------
class HotkeysIndex(FTS5Model):
Expand All @@ -119,17 +126,22 @@ class Meta:
# table_name = 'hotkeysindex'
database = db
options = {'prefix': [2, 3], 'tokenize': 'porter'}


# !SECTION DatabaseModels

def create_tables(dbc):
dbc.create_tables([Settings, HContext, Hotkeys, HotkeysIndex])


def worker():
hd.executeInMainThreadWithResult(updatecontext)


def py_unique(data):
return list(set(data))


# ------------------------------------------------- getdata
# NOTE getdata --------------------------------------------
def getdata():
Expand All @@ -143,26 +155,27 @@ def getcontexts(r, context_symbol, root):
for branch in branches:
branch_path = "%s/%s" % (r, branch['label'])
contextdata.append({
'context': branch['symbol'],
'title': branch['label'],
'context': branch['symbol'],
'title': branch['label'],
'description': branch['help']
})
commands = hou.hotkeys.commandsInContext(branch['symbol'])
for command in commands:
keys = hou.hotkeys.assignments(command['symbol'])
ctx = command['symbol'].rsplit('.', 1)
hotkeydata.append({
'hotkey_symbol': command['symbol'],
'label': command['label'],
'hotkey_symbol': command['symbol'],
'label': command['label'],
'description': command['help'],
'assignments': " ".join(keys),
'assignments': " ".join(keys),
'context': ctx[0]
})
getcontexts(branch_path, branch['symbol'], root)

getcontexts("", "", rval)
return contextdata, hotkeydata


# -------------------------------------------- initialsetup
# NOTE initialsetup ---------------------------------------
def initialsetup(cur):
Expand Down Expand Up @@ -190,6 +203,7 @@ def initialsetup(cur):
hou.ui.setStatusMessage(
la.MESSAGES['initialsetup2'], severity=hou.severityType.Message)


# --------------------------------------------------------------- Retrieve
# SECTION Retrieve -------------------------------------------------------
# ------------------------------------------ getchangeindex
Expand All @@ -206,6 +220,7 @@ def getchangeindex(cur):
else:
print(la.DBERRORMSG['getchangeindex'] + str(e))


# ------------------------------------------- getlastusedhk
# NOTE getlastusedhk --------------------------------------
def getlastusedhk(cur):
Expand Down Expand Up @@ -258,6 +273,8 @@ def getlastusedhk(cur):
(la.DBERRORMSG['getlastusedhk1'] + str(e)), severity=hou.severityType.Warning)
else:
print(la.DBERRORMSG['getlastusedhk1'] + str(e))


# !SECTION

# ----------------------------------------------------------------- Update
Expand All @@ -273,13 +290,15 @@ def dbupdate(cur):
updatedataasync()
updatechangeindex(int(currentidx))


# ----------------------------------------- updatedataasync
# NOTE updatedataasync ------------------------------------
def updatedataasync():
thread = threading.Thread(target=worker)
thread.daemon = True
thread.start()


# --------------------------------------- updatechangeindex
# NOTE updatechangeindex ----------------------------------
def updatechangeindex(indexval, new=False):
Expand All @@ -292,12 +311,12 @@ def updatechangeindex(indexval, new=False):
defaultkey = util.HOTKEYLIST[i]

Settings.insert(
indexvalue=indexval,
defaulthotkey=defaultkey,
searchdescription=0,
searchprefix=0,
searchcurrentcontext=0,
lastused="",
indexvalue=indexval,
defaulthotkey=defaultkey,
searchdescription=0,
searchprefix=0,
searchcurrentcontext=0,
lastused="",
id=1).execute()
else:
Settings.update(indexvalue=indexval).where(
Expand All @@ -309,6 +328,7 @@ def updatechangeindex(indexval, new=False):
else:
print(la.DBERRORMSG['updatechangeindex'] + str(e))


# ------------------------------------------- updatecontext
# NOTE updatecontext --------------------------------------
def updatecontext(debug=False):
Expand All @@ -326,6 +346,8 @@ def updatecontext(debug=False):
except(AttributeError, TypeError) as e:
hou.ui.setStatusMessage(
(la.DBERRORMSG['updatecontext'] + str(e)), severity=hou.severityType.Warning)


# endregion

# ------------------------------------------- cleardatabase
Expand All @@ -347,24 +369,29 @@ def cleardatabase():
(la.DBERRORMSG['cleardatabase'] + str(e)), severity=hou.severityType.Warning)
else:
print(la.DBERRORMSG['cleardatabase'] + str(e))


# !SECTION

def deferaction(action, val):
hd.executeDeferred(action, val)


def checklasthk(cur):
getlastusedhk(cur)


def main():
platform = get_platform()
platform = platformselect.get_platform()

if not os.path.exists(settings_data.searcher_path):
os.mkdir(settings_data.searcher_path)
if not os.path.isfile(settings_data.searcher_settings):
if platform == "unix":
os.system(("touch %s" % settings_data.searcher_settings))
else: os.mknod(settings_data.searcher_settings)
else:
os.mknod(settings_data.searcher_settings)
settings_data.createdefaults(platform)

hou.session.SETTINGS = settings_data.loadsettings()
Expand Down
Binary file removed houdini/python27/sqlite3.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion python2.7libs/searcher/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.pythonPath": "e:\\GitHub\\Searcher\\scripts\\python\\searcher\\venv\\Scripts\\python.exe",
"python.pythonPath": "C:\\Python27\\python.exe",
"python.formatting.provider": "autopep8",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion python2.7libs/searcher/HelpButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
hver = 0
if os.environ["HFS"] != "":
ver = os.environ["HFS"]
hver = int(ver[ver.rindex('.')+1:])
# hver = int(ver[ver.rindex('.')+1:])
from hutil.Qt import QtCore
from hutil.Qt import QtWidgets

Expand Down
23 changes: 19 additions & 4 deletions python2.7libs/searcher/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
from searcher import about_ui
from searcher import util
import os
import sys

import hou
hver = 0
if os.environ["HFS"] != "":
ver = os.environ["HFS"]
hver = int(ver[ver.rindex('.')+1:])
# hver = int(ver[ver.rindex('.')+1:])
from hutil.Qt import QtGui
from hutil.Qt import QtCore
from hutil.Qt import QtWidgets
Expand All @@ -27,7 +25,24 @@ def __init__(self, parent=None):
self.ui.setupUi(self)
self.ui.retranslateUi(self)

self.ui.github.mousePressEvent = self.openGithub
self.ui.web.mousePressEvent = self.openWeb

self.installEventFilter(self)

def initmenu(self):
return

def openGithub(self, event):
ghurl = '''https://github.com/instance-id/'''
QtGui.QDesktopServices.openUrl(QtCore.QUrl(ghurl))
self.parentwindow.parentwindow.close()

def openWeb(self, event):
weburl = '''https://instance.id/'''
QtGui.QDesktopServices.openUrl(QtCore.QUrl(weburl))
self.parentwindow.parentwindow.close()

# ------------------------------------------------------------- Events
# SECTION Events -----------------------------------------------------
def eventFilter(self, obj, event):
Expand All @@ -39,4 +54,4 @@ def eventFilter(self, obj, event):
if event.key() == QtCore.Qt.Key_Escape:
self.parentwindow.closeroutine()

return QtCore.QObject.eventFilter(self, obj, event)
return QtCore.QObject.eventFilter(self, obj, event)
3 changes: 3 additions & 0 deletions python2.7libs/searcher/about_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
scriptpath = os.path.dirname(os.path.realpath(__file__))


# noinspection PyAttributeOutsideInit,DuplicatedCode,PyPep8Naming
class Ui_About(object):
def setupUi(self, About):
About.setObjectName("About")
Expand Down Expand Up @@ -34,12 +35,14 @@ def setupUi(self, About):
self.secondrow.setObjectName("secondrow")
self.web = QtWidgets.QLabel(About)
self.web.setObjectName("web")
# self.web.setOpenExternalLinks(True)
self.secondrow.addWidget(self.web)
self.verticalLayout.addLayout(self.secondrow)
self.headerrow = QtWidgets.QHBoxLayout()
self.headerrow.setObjectName("headerrow")
self.github = QtWidgets.QLabel(About)
self.github.setObjectName("github")
# self.github.setOpenExternalLinks(True)
self.headerrow.addWidget(self.github)
self.verticalLayout.addLayout(self.headerrow)
self.horizontalLayout.addLayout(self.verticalLayout)
Expand Down
Loading

0 comments on commit d5814ba

Please sign in to comment.