This is a sweep to remove bad inclusive terms like master. Also testing functionality.

This commit is contained in:
gallowj
2021-04-22 16:13:23 -05:00
parent 3fd7649a9f
commit 50abfbb3f5
17 changed files with 313 additions and 230 deletions
@@ -29,7 +29,10 @@ import collections
from collections import abc
# import subprocess
import logging as _logging
import pathlib
try:
import pathlib
except:
import pathlib2 as pathlib
from pathlib import *
import shelve
# import socket
@@ -17,8 +17,14 @@
import logging as _logging
try:
import pathlib
except:
import pathlib2 as pathlib
from pathlib import Path
import pathlib
from box import Box
import os
@@ -62,15 +62,15 @@ _LOGGER.debug('Invoking:: {0}.'.format({_MODULENAME}))
# To Do: move the callback key like 'NewSceneOpened' here (instead of None)
# ^ this would provide ability to loop through and replace key with CB object
_G_callbacks = Box(box_dots=True) # global scope container
_G_masterkey = 'DCCsi_callbacks'
_G_callbacks[_G_masterkey] = True # required master key
_G_CALLBACKS = Box(box_dots=True) # global scope container
_G_PRIMEKEY = 'DCCsi_callbacks'
_G_CALLBACKS[_G_PRIMEKEY] = True # required prime key
# -------------------------------------------------------------------------
def init_callbacks(_callbacks=_G_callbacks):
def init_callbacks(_callbacks=_G_CALLBACKS):
# store as a dict (Box is a fancy dict)
_callbacks[_G_masterkey] = True # required master key
_callbacks[_G_PRIMEKEY] = True # required prime key
# signature dict['callback key'] = ('CallBack'(type), func, callbackObj)
_callbacks['on_new_file'] = ['NewSceneOpened', set_defaults, None]
@@ -96,24 +96,24 @@ def uninstall_callbacks():
"""Bulk uninstalls hte globally defined set of callbacks:
_G_callbacks"""
global _G_callbacks
global _G_CALLBACKS
_LOGGER.debug('uninstall_callbacks() fired')
for key, value in _G_callbacks:
for key, value in _G_CALLBACKS:
if value[2] is not None: # have a cb
value[2].uninstall() # so uninstall it
else:
_LOGGER.warning('No callback in: key {0}, value:{1}'
''.format(key, value))
_G_callbacks = None
_G_CALLBACKS = None
_LOGGER.info('DCCSI CALLBACKS UNINSTALLED ... EXITING')
return _G_callbacks
return _G_CALLBACKS
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
def install_callbacks(_callbacks=_G_callbacks):
def install_callbacks(_callbacks=_G_CALLBACKS):
"""Bulk installs the globally defined set of callbacks:
_G_callbacks"""
@@ -126,15 +126,15 @@ def install_callbacks(_callbacks=_G_callbacks):
_callbacks.pop('box_dots')
# don't pass anything but carefully considered dict
if _G_masterkey in _callbacks:
_masterkey = _callbacks.pop(_G_masterkey)
if _G_PRIMEKEY in _callbacks:
_primekey = _callbacks.pop(_G_PRIMEKEY)
else:
_LOGGER.error('No master key, use a correct dictionary')
_LOGGER.error('No prime key, use a correct dictionary')
#To Do: implement error handling and return codes
return _callbacks[None]
for key, value in _G_callbacks.items():
# we popped the master key should the rest should be safe
for key, value in _G_CALLBACKS.items():
# we popped the prime key should the rest should be safe
if value[0] != 'nodeMessageType':
# set callback up
_cb = azEvCbH.EventCallbackHandler(value[0],
@@ -195,10 +195,10 @@ def update_workspace(foo=None):
# -------------------------------------------------------------------------
# install and init callbacks on an import obj
_G_callbacks = install_callbacks(_G_callbacks)
_G_CALLBACKS = install_callbacks(_G_CALLBACKS)
# ==========================================================================
# Module Tests
#==========================================================================
if __name__ == '__main__':
_G_callbacks = install_callbacks(_G_callbacks)
_G_CALLBACKS = install_callbacks(_G_CALLBACKS)
@@ -262,9 +262,9 @@ def post_startup():
# callbacks, To Do: these should also be moved to the bootstrapping config
# Defered startup after the Ui is running.
_G_callbacks = Box(box_dots=True) # this just ensures a global scope container
_G_CALLBACKS = Box(box_dots=True) # this just ensures a global scope container
if _G_LOAD_CALLBACKS:
from set_callbacks import _G_callbacks
from set_callbacks import _G_CALLBACKS
# ^ need to hold on to this as the install repopulate set
# this ensures the fixPaths callback is loaded
@@ -74,7 +74,9 @@ Now your local maya install is all set up with pip so you can install additional
Now you will want to run the following file to finish setup...
We have a requirements.txt file with the extension packages we use in the DCCsi.
You'll need the repo/branch path of your Lumberyard(O3DE) install.
And you'll need to know where the DCCsi, we will install package dependancies there.
You'll need the repo/branch path of your O3DE (aka Lumberyard) install.
And you'll need to know where the DCCsi is located, we will install package dependancies there.
C:\Program Files\Autodesk\Maya2020\bin>mayapy -m pip install -r C:\Depot\Lumberyard\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Maya\requirements.txt -t C:\Depot\Lumberyard\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages
Note: you may need to update the paths below to match your local o3de engine install!
C:\Program Files\Autodesk\Maya2020\bin>mayapy -m pip install -r C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Maya\requirements.txt -t C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages
@@ -4,12 +4,14 @@
#
# pip-compile --generate-hashes requirements.txt
#
typing==3.7.4.3 \
--hash=sha256:1187fb9c82fd670d10aa07bbb6cfcfe4bdda42d6fab8d5134f04e8c4d0b71cc9 \
--hash=sha256:283d868f5071ab9ad873e5e52268d611e851c870a2ba354193026f2dfb29d8b5
# via
# -r requirements.txt
# dynaconf
cachetools==3.1.1 \
--hash=sha256:428266a1c0d36dc5aca63a2d7c5942e88c2c898d72139fca0e97fdd2380517ae \
--hash=sha256:8ea2d3ce97850f31e4a08b0e2b5e6c34997d7216a9d2c98e0f3978630d4da69a
# via -r requirements.txt
certifi==2020.6.20 \
--hash=sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3 \
--hash=sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41
# via -r requirements.txt
click==7.1.2 \
--hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a \
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc
@@ -20,6 +22,14 @@ dynaconf==3.1.4 \
--hash=sha256:b2f472d83052f809c5925565b8a2ba76a103d5dc1dbb9748b693ed67212781b9 \
--hash=sha256:e6f383b84150b70fc439c8b2757581a38a58d07962aa14517292dcce1a77e160
# via -r requirements.txt
hashids==1.3.1 \
--hash=sha256:6c3dc775e65efc2ce2c157a65acb776d634cb814598f406469abef00ae3f635c \
--hash=sha256:8bddd1acba501bfc9306e7e5a99a1667f4f2cacdc20cbd70bcc5ddfa5147c94c
# via -r requirements.txt
pathlib2==2.3.5 \
--hash=sha256:0ec8205a157c80d7acc301c0b18fbd5d44fe655968f5d947b6ecef5290fc35db \
--hash=sha256:6cd9a47b597b37cc57de1c05e56fb1a1c9cc9fab04fe78c29acd090418529868
# via -r requirements.txt
pathlib==1.0.1 \
--hash=sha256:6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f
# via -r requirements.txt
@@ -27,7 +37,38 @@ python-box==3.4.6 \
--hash=sha256:694a7555e3ff9fbbce734bbaef3aad92b8e4ed0659d3ed04d56b6a0a0eff26a9 \
--hash=sha256:a71d3dc9dbaa34c8597d3517c89a8041bd62fa875f23c0f3dad55e1958e3ce10
# via -r requirements.txt
scandir==1.10.0 \
--hash=sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e \
--hash=sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022 \
--hash=sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f \
--hash=sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f \
--hash=sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae \
--hash=sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173 \
--hash=sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4 \
--hash=sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32 \
--hash=sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188 \
--hash=sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d \
--hash=sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac
# via
# -r requirements.txt
# pathlib2
six==1.15.0 \
--hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259 \
--hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced
# via
# -r requirements.txt
# pathlib2
typing==3.7.4.3 \
--hash=sha256:1187fb9c82fd670d10aa07bbb6cfcfe4bdda42d6fab8d5134f04e8c4d0b71cc9 \
--hash=sha256:283d868f5071ab9ad873e5e52268d611e851c870a2ba354193026f2dfb29d8b5
# via
# -r requirements.txt
# dynaconf
unipath==1.1 \
--hash=sha256:09839adcc72e8a24d4f76d63656f30b5a1f721fc40c9bcd79d8c67bdd8b47dae \
--hash=sha256:e6257e508d8abbfb6ddd8ec357e33589f1f48b1599127f23b017124d90b0fff7
# via -r requirements.txt
wincertstore==0.2 \
--hash=sha256:22d5eebb52df88a8d4014d5cf6d1b6c3a5d469e6c3b2e2854f3a003e48872356 \
--hash=sha256:780bd1557c9185c15d9f4221ea7f905cb20b93f7151ca8ccaed9714dce4b327a
# via -r requirements.txt
@@ -67,7 +67,10 @@ _DCCSI_DEV_MODE = env_bool.env_bool(constants.ENVAR_DCCSI_DEV_MODE, False)
# for py2.7 (Maya) we provide this, so we must assume some bootstrapping
# has occured, see DccScriptingInterface\\config.py (_DCCSI_PYTHON_LIB_PATH)
import pathlib
try:
import pathlib
except:
import pathlib2 as pathlib
from pathlib import Path
if _G_DEBUG:
print('DCCsi debug breadcrumb, pathlib is: {}'.format(pathlib))
@@ -145,7 +145,7 @@ def start_wing_to_maya_menu():
port = object() # init a dummy object
# default name ... name is first arg, or a kwarg
portName, kwargs = setSynthArgKwarg(port, argPosIndex=0, argTag='portName',
portName, kwargs = setSynthArgKwarg(port, arg_pos_index=0, argTag='portName',
inArgs=args, inKwargs=kwargs,
defaultValue="127.0.0.1:6000")
@@ -15,30 +15,118 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""azpy.shared.ui.__init__"""
import os
import logging
import logging.config
from pathlib import Path
import logging as _logging
# global space debug flag
_G_DEBUG = os.getenv('DCCSI_GDEBUG', False)
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# global space debug flag
_DCCSI_DEV_MODE = os.getenv('DCCSI_DEV_MODE', False)
# global space
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
if _PACKAGENAME is '__main__':
_PACKAGENAME = 'azpy.shared.noodely'
import azpy
_LOGGER = azpy.initialize_logger(_PACKAGENAME)
_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PACKAGENAME}))
# -------------------------------------------------------------------------
#
__all__ = ['find_arg',
'helpers',
'node',
'synth',
'synth_arg_kwarg',
'test_foo']
#
# -------------------------------------------------------------------------
# -- Project Globals ------------------------------------------------------
while 1:
# But if we want to change the prject root, we can set a new one here.
def set_G_DEFAULT_PROJECT_DIR(value):
global _G_DEFAULT_PROJECT_DIR
"""Sets and returns the _G_DEFAULT_PROJECT_DIR"""
_G_DEFAULT_PROJECT_DIR = Path(value).resolve()
return Path(_G_DEFAULT_PROJECT_DIR)
def get_G_DEFAULT_PROJECT_DIR():
global _G_DEFAULT_PROJECT_DIR
"""Returns the _G_DEFAULT_PROJECT_DIR"""
return Path(_G_DEFAULT_PROJECT_DIR)
# if we are initializing everythin properly, we can assume the project
# variables are properly set
global _G_DEFAULT_PROJECT_DIR
_G_DEFAULT_PROJECT_DIR = Path(os.getcwd()).resolve()
break
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
while 1:
global _G_PRIME_ROOT_NODE
_G_PRIME_ROOT_NODE = None # <-- needs to be set up!
# But if we want to change the prject root, we can set a new one here.
def set_G_PRIME_ROOT_NODE(node):
"""Sets and returns the _G_PRIME_ROOT_NODE"""
global _G_PRIME_ROOT_NODE
if not isinstance(node, ProjectRootNode):
message = '_G_PRIME_ROOT_NODE: {}\r'.format(type(node))
message += 'A project root node needs to be properly set\r'
raise TypeError(message)
_G_PRIME_ROOT_NODE = node
return _G_PRIME_ROOT_NODE
def get_G_PRIME_ROOT_NODE():
"""Returns the _G_PRIME_ROOT_NODE"""
global _G_PRIME_ROOT_NODE
return _G_PRIME_ROOT_NODE
break
# -------------------------------------------------------------------------
###########################################################################
# tests(), code block for testing module
# -------------------------------------------------------------------------
def tests():
_G_DEFAULT_PROJECT_DIR = set_G_DEFAULT_PROJECT_DIR(os.getcwd())
_LOGGER.info(_G_DEFAULT_PROJECT_DIR)
_LOGGER.info(_G_DEFAULT_PROJECT_DIR.parent)
_LOGGER.info(_G_DEFAULT_PROJECT_DIR.parts)
# NOT implemented yet
# _G_PRIME_ROOT_NODE
return
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
if _DCCSI_DEV_MODE:
_PACKAGENAME = __name__
if _PACKAGENAME is '__main__':
_PACKAGENAME = 'noodely'
_PKG_PARENT_PATH = str('azpy.shared')
_PKG_PATH = str('{0}.{1}'.format(_PKG_PARENT_PATH, _PACKAGENAME))
_LOGGER = logging.getLogger(_PACKAGENAME)
_LOGGER.debug('Invoking __init__.py for {0}.'.format({_PKG_PATH}))
# -------------------------------------------------------------------------
#
__all__ = ['config', 'find_arg', 'master', 'node', 'synth',
'synth_arg_kwarg', 'test_foo']
#
# If in dev mode this will test imports of __all__
from azpy import test_imports
_LOGGER.debug('Testing Imports from {0}'.format(_PACKAGENAME))
test_imports(__all__,
_pkg=_PACKAGENAME,
_logger=_LOGGER)
# -------------------------------------------------------------------------
del _LOGGER
###########################################################################
# --call block-------------------------------------------------------------
if __name__ == "__main__":
_LOGGER.info("# {0} #".format('-' * 72))
_LOGGER.info('~ noodely.prime ... Running script as __main__')
_LOGGER.info("# {0} #".format('-' * 72))
# run simple tests
tests()
del _LOGGER
@@ -23,7 +23,7 @@ __author__ = 'HogJonny'
# -------------------------------------------------------------------------
def find_arg(argPosIndex=None, argTag=None, removeKwarg=None,
def find_arg(arg_pos_index=None, argTag=None, removeKwarg=None,
inArgs=None, inKwargs=None, defaultValue=None):
"""
# finds and returns an arg...
@@ -41,15 +41,15 @@ def find_arg(argPosIndex=None, argTag=None, removeKwarg=None,
#
# foundArg, args, kwargs = find_arg(0, 'name',)
"""
if argPosIndex != None:
if not isinstance(argPosIndex, int):
if arg_pos_index != None:
if not isinstance(arg_pos_index, int):
raise TypeError('argPosIndex: accepts a index integer!\r'
'got: {0}'.format(argPosIndex))
'got: {0}'.format(arg_pos_index))
# positional args ... check the position
if len(inArgs) > 0:
try:
foundArg = inArgs[argPosIndex]
foundArg = inArgs[arg_pos_index]
except:
pass
@@ -88,10 +88,10 @@ if __name__ == "__main__":
super().__init__()
self._name, kwargs = find_arg(argTag='foo', removeKwarg=True,
inArgs=args, inKwargs=kwargs)
self._name, kwargs = find_arg(argPosIndex=0, argTag='name',
self._name, kwargs = find_arg(arg_pos_index=0, argTag='name',
removeKwarg=True,
inArgs=args, inKwargs=kwargs) # <-- first positional OR kwarg
self._parent, kwargs = find_arg(argPosIndex=1, argTag='parent',
self._parent, kwargs = find_arg(arg_pos_index=1, argTag='parent',
removeKwarg=True,
inArgs=args, inKwargs=kwargs) # <-- second positional OR kwarg
@@ -1,90 +0,0 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# master.py
# Allows for project based setup to be used with noodly
# version: 0.1
# author: Gallowj
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
import os
from unipath import Path
_G_DEFAULT_PROJECT_DIR = os.getcwd()
_G_MASTER_ROOT_NODE = None
@property
def _G_DEFAULT_PROJECT_DIR(value):
_G_DEFAULT_PROJECT_DIR = value
return _G_DEFAULT_PROJECT_DIR
def set_PROJECT_DIR(value):
"""Sets and returns _G_DEFAULT_PROJECT_DIR"""
global _G_DEFAULT_PROJECT_DIR
_G_DEFAULT_PROJECT_DIR = Path(value).expand()
return Path(_G_DEFAULT_PROJECT_DIR)
@property
def _G_MASTER_ROOT_NODE(value):
_G_MASTER_ROOT_NODE = value
return _G_MASTER_ROOT_NODE
def set_MASTER_ROOT_NODE(value):
"""Sets and returns _G_MASTER_ROOT_NODE"""
global _G_MASTER_ROOT_NODE
if not isinstance(inNode, ProjectRootNode):
raise TypeError('self._projectRootNode is: {0}\r'
'A _projectRootNode, needs to be properly set\r'
'So that we can acces:\r'
'\tself._projectRootNode._sourceRoot\r'
'\tself._projectRootNode._overrideRoot\r'
'Use self.assignProjectRootNode(<projectRootNode>)\r'
''.format(type(inNode)))
_G_MASTER_ROOT_NODE = inNode
return _G_MASTER_ROOT_NODE
###########################################################################
# tests(), code block for testing module
# -------------------------------------------------------------------------
def tests():
set_PROJECT_DIR(os.getcwd())
print(_G_DEFAULT_PROJECT_DIR)
print(_G_DEFAULT_PROJECT_DIR.parent)
print(_G_DEFAULT_PROJECT_DIR.components())
# NOT implemented yet
# set_PROJECT_DIR
return
###########################################################################
# --call block-------------------------------------------------------------
if __name__ == "__main__":
print ("# ----------------------------------------------------------------------- #")
print ('~ noodly.master ... Running script as __main__')
print ("# ----------------------------------------------------------------------- #\r")
# run simple tests
tests()
#_G_DEFAULT_PROJECT_DIR = Path(os.getcwd())
print(_G_DEFAULT_PROJECT_DIR.components())
@@ -16,7 +16,7 @@ from __future__ import division
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# node.py
# simple base Node Class, for tool creation.
# simple base Node Class, useful in tool creation.
# version: 0.1
# author: Gallowj
# -------------------------------------------------------------------------
@@ -25,16 +25,8 @@ from __future__ import division
Module docstring:
A Simple Node Base Class Module, for creating basic nodes within a hierarchy.
"""
__author__ = 'HogJonny'
_G_DEBUG = True # global state for debugging
_G_SETTINGS = None # global Settings storage
_G_LOG = None # global LOGger storage
_G_MASTER_NODE = None # We intend to init a master node, unless provided
# -------------------------------------------------------------------------
# built-ins
import os
import copy
@@ -48,11 +40,32 @@ import cachetools
from sched import scheduler
# local imports
from LyPy.si_shared.noodly.helpers import display_cached_value
from LyPy.si_shared.noodly.find_arg import find_arg
from LyPy.si_shared.noodly.synth import synthesize
from azpy.shared.noodely.helpers import display_cached_value
from azpy.shared.noodely.find_arg import find_arg
from azpy.shared.noodely.synth import synthesize
import azpy
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# global space
# To Do: update to dynaconf dynamic env and settings?
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_MODULENAME = 'azpy.shared.noodely.node'
_log_level = int(20)
if _G_DEBUG:
_log_level = int(10)
_LOGGER = azpy.initialize_logger(_MODULENAME,
log_to_file=False,
default_log_level=_log_level)
_LOGGER.debug('Starting:: {}.'.format({_MODULENAME}))
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# quick test code (remove later)
from hashids import Hashids
@@ -79,8 +92,6 @@ if os.path.supports_unicode_filenames:
###########################################################################
# HELPER method functions
# -------------------------------------------------------------------------
def return_node_from_hashid(hashid):
if not isinstance(hashid, str):
raise TypeError("{0},{1}: Accepts hashids as str types!\r"
@@ -95,6 +106,7 @@ def return_node_from_hashid(hashid):
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
class Node(object):
"""Class constructor: makes a node."""
@@ -131,7 +143,7 @@ class Node(object):
# -- secret keyword -----------------------------------------------
self._temp_node = False
temp_node, kwargs = find_arg(argPosIndex=None, argTag='temp_node',
temp_node, kwargs = find_arg(arg_pos_index=None, argTag='temp_node',
removeKwarg=True, inArgs=args,
inKwargs=kwargs) # <-- kwarg only
self._temp_node = temp_node
@@ -141,7 +153,7 @@ class Node(object):
# -- store message header -----------------------------------------
# setup the .message_header <-- kwarg only
message_header, kwargs = find_arg(argPosIndex=None, argTag='message_header',
message_header, kwargs = find_arg(arg_pos_index=None, argTag='message_header',
removeKwarg=True, inArgs=args, inKwargs=kwargs,
defaultValue=('{0}(), Message'
.format(self._node_type)))
@@ -165,7 +177,7 @@ class Node(object):
# -- store the node name ------------------------------------------
self._node_name = node_name
if (self._node_class_index == 0 and self._node_name == None):
self._node_name = 'MASTER'
self._node_name = 'PRIME'
elif (self._node_class_index > 0 and self._node_name == None):
# set a default node_name if none, based on the unihashid
if not self._name_is_uni_hashid:
@@ -325,7 +337,7 @@ class Node(object):
@property
def cls_node_dict(self):
return Node._cls_node_dict
# ----------------------------------------------------------------------
# ---------------------------------------------------------------------
# --method-set---------------------------------------------------------
def cls_node_count_up(self):
@@ -584,10 +596,10 @@ def tests():
print(default_node.hierarchy())
# retreive a node from it's known hashid
master_node = return_node_from_hashid('kxYLm0XQeXJ7jWaP')
print(master_node.uni_hashid) # verify hasid
prime_node = return_node_from_hashid('kxYLm0XQeXJ7jWaP')
print(prime_node.uni_hashid) # verify hasid
# should return the same node as default_node
print(master_node.node_name) # should be 'MASTER'
print(prime_node.node_name) # should be 'PRIME'
return
# -------------------------------------------------------------------------
@@ -27,12 +27,6 @@ A simple path objecy based Node Class, for creating path hierarchies.
"""
__author__ = 'HogJonny'
_G_DEBUG = True # global state for debugging
_G_SETTINGS = None # global Settings storage
_G_LOG = None # global LOGger storage
_G_MASTER_NODE = None # We intend to init a master node
# -------------------------------------------------------------------------
# built-ins
import os
@@ -44,10 +38,31 @@ import logging
from unipath import Path, AbstractPath
# local ly imports
from LyPy.si_shared.noodly.helpers import istext
from LyPy.si_shared.noodly.find_arg import find_arg
from LyPy.si_shared.noodly.synth import synthesize
from LyPy.si_shared.noodly.node import Node
from azpy.shared.noodely.helpers import istext
from azpy.shared.noodely.find_arg import find_arg
from azpy.shared.noodely.synth import synthesize
from azpy.shared.noodely.node import Node
import azpy
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# -------------------------------------------------------------------------
# global space
# To Do: update to dynaconf dynamic env and settings?
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_MODULENAME = 'azpy.shared.noodely.pathnode'
_log_level = int(20)
if _G_DEBUG:
_log_level = int(10)
_LOGGER = azpy.initialize_logger(_MODULENAME,
log_to_file=False,
default_log_level=_log_level)
_LOGGER.debug('Starting:: {}.'.format({_MODULENAME}))
# -------------------------------------------------------------------------
@@ -63,20 +78,12 @@ if os.path.supports_unicode_filenames:
# -------------------------------------------------------------------------
# set up logger
_G_LOGGER = logging.getLogger(__name__)
# -------------------------------------------------------------------------
class PathNode(Node):
"""doc string"""
# share the debug state
_DEBUG = _G_DEBUG
# logger
_LOGGER = _G_LOGGER
# class header
_message_header = 'noodly, PathNode(): Message'
@@ -117,7 +124,7 @@ class PathNode(Node):
# -- secret keyword -----------------------------------------------
self._temp_node = False
temp_node, kwargs = find_arg(argPosIndex=None, argTag='temp_node',
temp_node, kwargs = find_arg(arg_pos_index=None, argTag='temp_node',
removeKwarg=True, inArgs=args,
inKwargs=kwargs) # <-- kwarg only
@@ -126,11 +133,11 @@ class PathNode(Node):
self.k_wargs_dict['temp_node'] = self._temp_node
# -- Node class args/kwargs ---------------------------------------
node_name, kwargs = find_arg(argPosIndex=2, argTag='node_name',
node_name, kwargs = find_arg(arg_pos_index=2, argTag='node_name',
removeKwarg=True, inArgs=args,
inKwargs=kwargs) # <-- third arg, kwarg
parent_node, kwargs = find_arg(argPosIndex=3, argTag='parent_node',
parent_node, kwargs = find_arg(arg_pos_index=3, argTag='parent_node',
removeKwarg=True, inArgs=args,
inKwargs=kwargs) # <-- fourth arg, kwarg
@@ -344,12 +351,12 @@ class PathNode(Node):
# -------------------------------------------------------------------------
def tests():
from node import Node
default_node = Node() # result: Node(node_name='MASTER')
default_node = Node() # result: Node(node_name='PRIME')
print(default_node)
first_child = PathNode(path=None, node_name='first_child', parent_node=default_node)
print(first_child)
# result: PathNode(temp_node=True, parent_node=Node(node_name='MASTER')).siblingNodeFromHashid('WNPZoKBVpXV16QLz')
# result: PathNode(temp_node=True, parent_node=Node(node_name='PRIME')).siblingNodeFromHashid('WNPZoKBVpXV16QLz')
# first_child.nodeType
# first_child.parent_node
# first_child.node_name
@@ -20,7 +20,10 @@ import os
# from io import StringIO # for handling unicode strings
# azpy
from azpy import initialize_logger
import azpy
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# 3rd Party
from unipath import Path
@@ -28,22 +31,22 @@ import PySide2.QtCore as QtCore
import PySide2.QtWidgets as QtWidgets
import PySide2.QtGui as QtGui
# -------------------------------------------------------------------------
# global space debug flag
_G_DEBUG = os.getenv('DCCSI_GDEBUG', False)
# global space debug flag
_DCCSI_DEV_MODE = os.getenv('DCCSI_DEV_MODE', False)
# global space
# To Do: update to dynaconf dynamic env and settings?
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_MODULE_PATH = Path(__file__)
_ORG_TAG = 'Amazon_Lumberyard'
_APP_TAG = 'DCCsi'
_TOOL_TAG = 'azpy.shared.ui.custom_treemodel'
_TYPE_TAG = 'test'
_MODULENAME = 'azpy.shared.ui.custom_treemodel'
_MODULENAME = __name__
if _MODULENAME is '__main__':
_MODULENAME = _TOOL_TAG
_log_level = int(20)
if _G_DEBUG:
_log_level = int(10)
_LOGGER = azpy.initialize_logger(_MODULENAME,
log_to_file=False,
default_log_level=_log_level)
_LOGGER.debug('Starting:: {}.'.format({_MODULENAME}))
_UI_FILE = Path(_MODULE_PATH.parent, 'resources', 'example.ui')
# -------------------------------------------------------------------------
@@ -75,15 +78,15 @@ class CustomFileTreeModel(QtCore.QAbstractItemModel):
# TODO: need to make sure we are getting path objects
# build the root node
self._root_node = self.buildRootNode('root', None, self._rootFilePath)
self._root_node = self.build_rootnode('root', None, self._root_filepath)
# master selection
self._masterSelection = masterSelection
# prime selection
self._prime_selection = prime_selection
# build the master selection node
self._masterNode = self.buildMasterNode('master', None, self._masterSelection, self._rootNode.path())
# build the prime selection node
self._primenode = self.build_primenode('prime', None, self._prime_selection, self._rootnode.path())
# want to store off a couple lists in the model, for retreival later
self._nodeList = None
self._depNodesList = None
self._nodelist = None
self._dep_nodelist = None
@@ -25,6 +25,7 @@ from pathlib import Path
# -------------------------------------------------------------------------
_BOOT_CHECK = False # set true to test breakpoint in this module directly
import azpy
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
@@ -26,7 +26,6 @@ import re
# our framework for dcc tools need to run in apps like Maya that may still be
# on py27 so we need to import and use after some boostrapping
# -------------------------------------------------------------------+------
#os.environ['PYTHONINSPECT'] = 'True'
_MODULE_PATH = os.path.abspath(__file__)
@@ -78,7 +77,10 @@ _DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSIG_PATH)
# Now we should be able to just carry on with pth lib and dynaconf
from dynaconf import Dynaconf
from pathlib import Path
try:
import pathlib
except:
import pathlib2 as pathlib
_DCCSIG_PATH = Path(_DCCSIG_PATH).resolve()
_DCCSI_PYTHON_LIB_PATH = Path(_DCCSI_PYTHON_LIB_PATH).resolve()
@@ -4,34 +4,39 @@
#
# pip-compile --generate-hashes requirements.txt
#
typing==3.7.4.3 \
--hash=sha256:1187fb9c82fd670d10aa07bbb6cfcfe4bdda42d6fab8d5134f04e8c4d0b71cc9 \
--hash=sha256:283d868f5071ab9ad873e5e52268d611e851c870a2ba354193026f2dfb29d8b5
# via
# -r requirements.txt
# dynaconf
cachetools==4.2.1 \
--hash=sha256:1d9d5f567be80f7c07d765e21b814326d78c61eb0c3a637dffc0e5d1796cb2e2 \
--hash=sha256:f469e29e7aa4cff64d8de4aad95ce76de8ea1125a16c68e0d93f65c3c3dc92e9
# via -r requirements.txt
certifi==2020.12.5 \
--hash=sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c \
--hash=sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830
# via -r requirements.txt
click==7.1.2 \
--hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a \
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc
# via
# -r requirements.txt
# pip-tools
dynaconf==3.1.4 \
--hash=sha256:b2f472d83052f809c5925565b8a2ba76a103d5dc1dbb9748b693ed67212781b9 \
--hash=sha256:e6f383b84150b70fc439c8b2757581a38a58d07962aa14517292dcce1a77e160
# via -r requirements.txt
hashids==1.3.1 \
--hash=sha256:6c3dc775e65efc2ce2c157a65acb776d634cb814598f406469abef00ae3f635c \
--hash=sha256:8bddd1acba501bfc9306e7e5a99a1667f4f2cacdc20cbd70bcc5ddfa5147c94c
# via -r requirements.txt
pathlib==1.0.1 \
--hash=sha256:6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f
# via -r requirements.txt
python-box==3.4.6 \
--hash=sha256:694a7555e3ff9fbbce734bbaef3aad92b8e4ed0659d3ed04d56b6a0a0eff26a9 \
--hash=sha256:a71d3dc9dbaa34c8597d3517c89a8041bd62fa875f23c0f3dad55e1958e3ce10
python-box==5.3.0 \
--hash=sha256:4ed4ef5d34de505a65c01e3f1911de8cdb29484fcae0c035141dce535c6c194a \
--hash=sha256:f2a531f9f5bbef078c175fad6abb31e9b59d40d121ea79993197e6bb221c6be6
# via -r requirements.txt
unipath==1.1 \
--hash=sha256:09839adcc72e8a24d4f76d63656f30b5a1f721fc40c9bcd79d8c67bdd8b47dae \
--hash=sha256:e6257e508d8abbfb6ddd8ec357e33589f1f48b1599127f23b017124d90b0fff7
# via -r requirements.txt
# WARNING: The following packages were not pinned, but pip requires them to be
# pinned when the requirements file includes hashes. Consider using the --allow-unsafe flag.
# pip
wincertstore==0.2 \
--hash=sha256:22d5eebb52df88a8d4014d5cf6d1b6c3a5d469e6c3b2e2854f3a003e48872356 \
--hash=sha256:780bd1557c9185c15d9f4221ea7f905cb20b93f7151ca8ccaed9714dce4b327a
# via -r requirements.txt