Merge pull request #435 from aws-lumberyard-dev/cherrypick_fix_ATOM-15310
Cherrypick fix ATOM-15310, remove non-inclusive terms like 'master' from code
This commit is contained in:
+4
-1
@@ -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
|
||||
|
||||
+7
-1
@@ -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
|
||||
|
||||
|
||||
+17
-17
@@ -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)
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+47
-6
@@ -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
|
||||
|
||||
@@ -36,11 +36,10 @@ _TYPE_TAG = 'module'
|
||||
|
||||
_PACKAGENAME = _TOOL_TAG
|
||||
|
||||
__all__ = ['initialize_logger',
|
||||
'config_utils', 'render',
|
||||
__all__ = ['config_utils', 'render',
|
||||
'constants', 'return_stub', 'synthetic_env',
|
||||
'env_base', 'env_bool', 'test', 'dev',
|
||||
'lumberyard', 'marmoset'] #'blender', 'maya', 'substance', 'houdini']
|
||||
'lumberyard', 'marmoset'] # 'blender', 'maya', 'substance', 'houdini']
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -68,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))
|
||||
|
||||
@@ -80,9 +80,9 @@ def return_stub_dir(stub_file='dccsi_stub'):
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
def get_stub_check_path(in_path=os.getcwd(), check_stub='engineroot.txt'):
|
||||
def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'):
|
||||
'''
|
||||
Returns the branch root directory of the dev\\'engineroot.txt'
|
||||
Returns the branch root directory of the dev\\'engine.json'
|
||||
(... or you can pass it another known stub)
|
||||
|
||||
so we can safely build relative filepaths within that branch.
|
||||
@@ -158,7 +158,6 @@ def bootstrap_dccsi_py_libs(dccsi_dirpath=return_stub_dir()):
|
||||
"""Builds and adds local site dir libs based on py version"""
|
||||
|
||||
from azpy.constants import STR_DCCSI_PYTHON_LIB_PATH # a path string constructor
|
||||
#_DCCSI_PYTHON_LIB_PATH = "E:\\P4\\jromnoa_spectra_atom_2\\dev\\Tools\\Python\\3.7.5\\windows\\Lib\\site-packages"
|
||||
_DCCSI_PYTHON_LIB_PATH = STR_DCCSI_PYTHON_LIB_PATH.format(dccsi_dirpath,
|
||||
sys.version_info[0],
|
||||
sys.version_info[1])
|
||||
@@ -193,9 +192,9 @@ if __name__ == '__main__':
|
||||
_config = get_dccsi_config()
|
||||
_LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(_config))
|
||||
|
||||
_LOGGER.info('LY_DEV: {}'.format(get_stub_check_path('engineroot.txt')))
|
||||
_LOGGER.info('LY_DEV: {}'.format(get_stub_check_path('engine.json')))
|
||||
|
||||
_LOGGER.info('LY_PROJECT: {}'.format(get_current_project(get_stub_check_path('engineroot.txt'))))
|
||||
_LOGGER.info('LY_PROJECT: {}'.format(get_current_project(get_stub_check_path('bootstrap.cfg'))))
|
||||
|
||||
_LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(bootstrap_dccsi_py_libs(return_stub_dir('dccsi_stub'))))
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ TAG_DIR_LY_BUILD = str('build')
|
||||
TAG_QT_PLUGIN_PATH = str('QT_PLUGIN_PATH')
|
||||
|
||||
# filesystem markers, stub file names.
|
||||
STUB_LY_DEV = str('engineroot.txt')
|
||||
STUB_LY_DEV = str('engine.json')
|
||||
STUB_LY_ROOT_PROJECT = str('ly_project_stub')
|
||||
STUB_LY_ROOT_DCCSI = str('dccsi_stub')
|
||||
STUB_LY_DCCSI_AZPY = str('dccsi_azpy_stub')
|
||||
|
||||
+6
-6
@@ -36,7 +36,7 @@ _LOGGER.info('local_host: {}'.format(_LOCAL_HOST))
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
def start_wing_to_maya(local_host=_LOCAL_HOST,
|
||||
comman_port=6000,
|
||||
command_port=6000,
|
||||
logger=_LOGGER,
|
||||
*args, **kwargs):
|
||||
"""
|
||||
@@ -58,7 +58,7 @@ def start_wing_to_maya(local_host=_LOCAL_HOST,
|
||||
except NameError:
|
||||
port = None
|
||||
|
||||
port_name = str('{0}:{1}'.format(local_host, comman_port))
|
||||
port_name = str('{0}:{1}'.format(local_host, command_port))
|
||||
|
||||
# should only be getting the port passed in
|
||||
_LOGGER.info('Attempting to open port:: {0}'.format(port_name))
|
||||
@@ -145,10 +145,10 @@ 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',
|
||||
inArgs=args, inKwargs=kwargs,
|
||||
defaultValue="127.0.0.1:6000")
|
||||
portName, kwargs = set_synth_arg_kwarg(port, arg_pos_index=0, arg_tag='portName',
|
||||
in_args=args, in_kwargs=kwargs,
|
||||
default_value="127.0.0.1:6000")
|
||||
|
||||
port = start_wing_to_maya(local_host=_LOCAL_HOST, comman_port=6000)
|
||||
port = start_wing_to_maya(local_host=_LOCAL_HOST, command_port=6000)
|
||||
return
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
+109
-21
@@ -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
|
||||
+26
-24
@@ -23,8 +23,8 @@ __author__ = 'HogJonny'
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
def find_arg(argPosIndex=None, argTag=None, removeKwarg=None,
|
||||
inArgs=None, inKwargs=None, defaultValue=None):
|
||||
def find_arg(arg_pos_index=None, arg_tag=None, remove_kwarg=None,
|
||||
in_args=None, in_kwargs=None, default_value=None):
|
||||
"""
|
||||
# finds and returns an arg...
|
||||
# if a positional index is given argPosIndex=0, it checks args first
|
||||
@@ -41,31 +41,33 @@ def find_arg(argPosIndex=None, argTag=None, removeKwarg=None,
|
||||
#
|
||||
# foundArg, args, kwargs = find_arg(0, 'name',)
|
||||
"""
|
||||
if argPosIndex != None:
|
||||
if not isinstance(argPosIndex, int):
|
||||
|
||||
found_arg = None
|
||||
|
||||
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:
|
||||
if len(in_args) > 0:
|
||||
try:
|
||||
foundArg = inArgs[argPosIndex]
|
||||
found_arg = in_args[arg_pos_index]
|
||||
except:
|
||||
pass
|
||||
|
||||
# check kwargs ... a set kwarg will ALWAYS take precident over
|
||||
# positional arg!!!
|
||||
try:
|
||||
foundArg
|
||||
except:
|
||||
foundArg = inKwargs.get(argTag, defaultValue) # defaults to None
|
||||
if in_kwargs:
|
||||
found_arg = in_kwargs.get(arg_tag, default_value) # defaults to None
|
||||
|
||||
if removeKwarg:
|
||||
if argTag in inKwargs:
|
||||
del inKwargs[argTag]
|
||||
if remove_kwarg:
|
||||
if in_kwargs:
|
||||
if arg_tag in in_kwargs:
|
||||
del in_kwargs[arg_tag]
|
||||
|
||||
# if we didn't find the arg/kwarg, the defualt return will be None
|
||||
return foundArg, inKwargs
|
||||
return found_arg, in_kwargs
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -86,14 +88,14 @@ if __name__ == "__main__":
|
||||
class TestNode(Foo):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__()
|
||||
self._name, kwargs = find_arg(argTag='foo', removeKwarg=True,
|
||||
inArgs=args, inKwargs=kwargs)
|
||||
self._name, kwargs = find_arg(argPosIndex=0, argTag='name',
|
||||
removeKwarg=True,
|
||||
inArgs=args, inKwargs=kwargs) # <-- first positional OR kwarg
|
||||
self._parent, kwargs = find_arg(argPosIndex=1, argTag='parent',
|
||||
removeKwarg=True,
|
||||
inArgs=args, inKwargs=kwargs) # <-- second positional OR kwarg
|
||||
self._name, kwargs = find_arg(arg_tag='foo', remove_kwarg=True,
|
||||
in_args=args, in_kwargs=kwargs)
|
||||
self._name, kwargs = find_arg(arg_pos_index=0, arg_tag='name',
|
||||
remove_kwarg=True,
|
||||
in_args=args, in_kwargs=kwargs) # <-- first positional OR kwarg
|
||||
self._parent, kwargs = find_arg(arg_pos_index=1, arg_tag='parent',
|
||||
remove_kwarg=True,
|
||||
in_args=args, in_kwargs=kwargs) # <-- second positional OR kwarg
|
||||
|
||||
self._kwargsDict = {}
|
||||
|
||||
@@ -117,7 +119,7 @@ if __name__ == "__main__":
|
||||
|
||||
testNode2 = TestNode(name='fooey', parent=testNode)
|
||||
|
||||
testNode3 = TestNode('kablooey', testNode2, goober='dufus')
|
||||
testNode3 = TestNode('kablooey', testNode2, gomer='pile')
|
||||
|
||||
print ('testNode2, name: {0}, parent: {1}'.format(testNode2._name, testNode2._parent))
|
||||
print (testNode3)
|
||||
|
||||
-90
@@ -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())
|
||||
+37
-25
@@ -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,9 +143,9 @@ class Node(object):
|
||||
|
||||
# -- secret keyword -----------------------------------------------
|
||||
self._temp_node = False
|
||||
temp_node, kwargs = find_arg(argPosIndex=None, argTag='temp_node',
|
||||
removeKwarg=True, inArgs=args,
|
||||
inKwargs=kwargs) # <-- kwarg only
|
||||
temp_node, kwargs = find_arg(arg_pos_index=None, arg_tag='temp_node',
|
||||
remove_kwarg=True, in_args=args,
|
||||
in_kwargs=kwargs) # <-- kwarg only
|
||||
self._temp_node = temp_node
|
||||
if self._temp_node:
|
||||
self._kwargs_dict['temp_node'] = self._temp_node
|
||||
@@ -141,9 +153,9 @@ class Node(object):
|
||||
|
||||
# -- store message header -----------------------------------------
|
||||
# setup the .message_header <-- kwarg only
|
||||
message_header, kwargs = find_arg(argPosIndex=None, argTag='message_header',
|
||||
removeKwarg=True, inArgs=args, inKwargs=kwargs,
|
||||
defaultValue=('{0}(), Message'
|
||||
message_header, kwargs = find_arg(arg_pos_index=None, arg_tag='message_header',
|
||||
remove_kwarg=True, in_args=args, in_kwargs=kwargs,
|
||||
default_value=('{0}(), Message'
|
||||
.format(self._node_type)))
|
||||
self._message_header = message_header
|
||||
# -----------------------------------------------------------------
|
||||
@@ -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
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
+36
-29
@@ -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,22 +124,22 @@ class PathNode(Node):
|
||||
|
||||
# -- secret keyword -----------------------------------------------
|
||||
self._temp_node = False
|
||||
temp_node, kwargs = find_arg(argPosIndex=None, argTag='temp_node',
|
||||
removeKwarg=True, inArgs=args,
|
||||
inKwargs=kwargs) # <-- kwarg only
|
||||
temp_node, kwargs = find_arg(arg_pos_index=None, arg_tag='temp_node',
|
||||
remove_kwarg=True, in_args=args,
|
||||
in_kwargs=kwargs) # <-- kwarg only
|
||||
|
||||
self._temp_node = temp_node
|
||||
if self._temp_node:
|
||||
self.k_wargs_dict['temp_node'] = self._temp_node
|
||||
|
||||
# -- Node class args/kwargs ---------------------------------------
|
||||
node_name, kwargs = find_arg(argPosIndex=2, argTag='node_name',
|
||||
removeKwarg=True, inArgs=args,
|
||||
inKwargs=kwargs) # <-- third arg, kwarg
|
||||
node_name, kwargs = find_arg(arg_pos_index=2, arg_tag='node_name',
|
||||
remove_kwarg=True, in_args=args,
|
||||
in_kwargs=kwargs) # <-- third arg, kwarg
|
||||
|
||||
parent_node, kwargs = find_arg(argPosIndex=3, argTag='parent_node',
|
||||
removeKwarg=True, inArgs=args,
|
||||
inKwargs=kwargs) # <-- fourth arg, kwarg
|
||||
parent_node, kwargs = find_arg(arg_pos_index=3, arg_tag='parent_node',
|
||||
remove_kwarg=True, in_args=args,
|
||||
in_kwargs=kwargs) # <-- fourth arg, kwarg
|
||||
|
||||
self._root_path = root_path
|
||||
|
||||
@@ -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
|
||||
|
||||
+40
-40
@@ -22,9 +22,9 @@ from synth import synthesize
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
def setSynthArgKwarg(inst, argPosIndex=None, argTag=None, defaultValue=None,
|
||||
inArgs=None, inKwargs=None, removeKwarg=True,
|
||||
setAnyway=True):
|
||||
def set_synth_arg_kwarg(inst, arg_pos_index=None, arg_tag=None, default_value=None,
|
||||
in_args=None, in_kwargs=None, remove_kwarg=True,
|
||||
set_anyway=True):
|
||||
"""
|
||||
Uses find_arg and sets a property on a object.
|
||||
|
||||
@@ -34,44 +34,44 @@ def setSynthArgKwarg(inst, argPosIndex=None, argTag=None, defaultValue=None,
|
||||
If the arg/property doesn't exist we synthesize it
|
||||
"""
|
||||
|
||||
foundArg = None
|
||||
argValueDict = {}
|
||||
found_arg = None
|
||||
arg_value_dict = {}
|
||||
|
||||
# find the argument, or set to default value
|
||||
foundArg, inKwargs = find_arg(argPosIndex, argTag, removeKwarg,
|
||||
inArgs, inKwargs,
|
||||
defaultValue)
|
||||
found_arg, in_kwargs = find_arg(arg_pos_index, arg_tag, remove_kwarg,
|
||||
in_args, in_kwargs,
|
||||
default_value)
|
||||
|
||||
if foundArg:
|
||||
argTag = foundArg
|
||||
if found_arg:
|
||||
arg_tag = found_arg
|
||||
|
||||
# single arg first
|
||||
# make sure the object doesn't arealdy have this property
|
||||
try:
|
||||
hasattr(inst, argTag) # check if property exists
|
||||
if setAnyway:
|
||||
hasattr(inst, arg_tag) # check if property exists
|
||||
if set_anyway:
|
||||
try:
|
||||
setattr(inst, argTag, defaultValue) # try to set
|
||||
setattr(inst, arg_tag, default_value) # try to set
|
||||
except Exception as e:
|
||||
raise e
|
||||
except:
|
||||
pass
|
||||
|
||||
# make it a synthetic property
|
||||
if argTag:
|
||||
if arg_tag:
|
||||
try:
|
||||
argValue = synthesize(inst, argTag, defaultValue)
|
||||
argValueDict[argTag] = argValue
|
||||
arg_value = synthesize(inst, arg_tag, default_value)
|
||||
arg_value_dict[arg_tag] = arg_value
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
# multiple and/or remaining kwards next
|
||||
if inKwargs:
|
||||
if len(inKwargs) > 0:
|
||||
for k, v in inKwargs.items():
|
||||
if in_kwargs:
|
||||
if len(in_kwargs) > 0:
|
||||
for k, v in in_kwargs.items():
|
||||
try:
|
||||
hasattr(inst, k) # check if property exists
|
||||
if setAnyway:
|
||||
if set_anyway:
|
||||
try:
|
||||
setattr(inst, k, v) # try to set
|
||||
except Exception as e:
|
||||
@@ -81,12 +81,12 @@ def setSynthArgKwarg(inst, argPosIndex=None, argTag=None, defaultValue=None,
|
||||
|
||||
if k:
|
||||
try:
|
||||
argValue = synthesize(inst, k, v)
|
||||
argValueDict[k] = argValue
|
||||
arg_value = synthesize(inst, k, v)
|
||||
arg_value_dict[k] = arg_value
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
return argValueDict
|
||||
return arg_value_dict
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -98,28 +98,28 @@ if __name__ == '__main__':
|
||||
from test_foo import Foo
|
||||
|
||||
# define a arg/property tag we know doesn't exist
|
||||
synthArgTag = 'syntheticArg'
|
||||
synth_arg_tag = 'synthetic_arg'
|
||||
|
||||
# create a test object
|
||||
print('~ creating the test foo object...')
|
||||
myFoo = Foo()
|
||||
my_foo = Foo()
|
||||
|
||||
print('~ Starting - single synthetic arg test...')
|
||||
# find and set existing, or create and set
|
||||
argValueDict = setSynthArgKwarg(myFoo,
|
||||
argTag=synthArgTag,
|
||||
defaultValue='kablooey')
|
||||
arg_value_dict = set_synth_arg_kwarg(my_foo,
|
||||
arg_tag=synth_arg_tag,
|
||||
default_value='kablooey')
|
||||
|
||||
# what was returned
|
||||
print('~ single value returned...')
|
||||
for k, v in argValueDict.items():
|
||||
for k, v in arg_value_dict.items():
|
||||
print("Arg '{0}':'{1}'".format(k, v))
|
||||
|
||||
# attempt to access the new synthetic property directly
|
||||
print('~ direct property access test...')
|
||||
try:
|
||||
myFoo.syntheticArg
|
||||
print('myFoo.{0}: {1}'.format(synthArgTag, myFoo.syntheticArg))
|
||||
my_foo.synthetic_arg
|
||||
print('myFoo.{0}: {1}'.format(synth_arg_tag, my_foo.synthetic_arg))
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
@@ -128,31 +128,31 @@ if __name__ == '__main__':
|
||||
newKwargs = {'fooey': 'chop suey', 'success': True}
|
||||
|
||||
# find and set existing, or create and set
|
||||
argValueDict = setSynthArgKwarg(myFoo,
|
||||
inKwargs=newKwargs,
|
||||
defaultValue='kablooey')
|
||||
arg_value_dict = set_synth_arg_kwarg(my_foo,
|
||||
in_kwargs=newKwargs,
|
||||
default_value='kablooey')
|
||||
|
||||
# what was returned
|
||||
print('~ multiple values returned...')
|
||||
for k, v in argValueDict.items():
|
||||
for k, v in arg_value_dict.items():
|
||||
print("Arg '{0}':'{1}'".format(k, v))
|
||||
|
||||
print('~ multiple direct property access test...')
|
||||
try:
|
||||
myFoo.fooey
|
||||
print('myFoo.{0}: {1}'.format('fooey', myFoo.fooey))
|
||||
my_foo.fooey
|
||||
print('myFoo.{0}: {1}'.format('fooey', my_foo.fooey))
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
try:
|
||||
myFoo.success
|
||||
print('myFoo.{0}: {1}'.format('success', myFoo.success))
|
||||
my_foo.success
|
||||
print('myFoo.{0}: {1}'.format('success', my_foo.success))
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
print('~ Starting - known failure test...')
|
||||
try:
|
||||
myFoo.knownBad
|
||||
my_foo.knownBad
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print('Test failed as expected!!!')
|
||||
|
||||
+2
-2
@@ -25,13 +25,13 @@ class Foo(object):
|
||||
This is a Class, it creates a Foo object... which does nothing really
|
||||
"""
|
||||
|
||||
__propertyTag = 'fooProperty'
|
||||
__property_tag = 'fooProperty'
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
def __init__(self, name='Foo', value='defaultValue', *args, **kwargs):
|
||||
'''Class __init__'''
|
||||
synthesize(self, 'name', name)
|
||||
synthesize(self, Foo.__propertyTag, value)
|
||||
synthesize(self, Foo.__property_tag, value)
|
||||
|
||||
synthesize(self, 'test', 'testValue')
|
||||
|
||||
|
||||
+23
-20
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class HelpMenu():
|
||||
INPUTS:
|
||||
main_window = the class instance of the QMainWindow
|
||||
tool_label = the menu label for the tool's help item
|
||||
tool_help_page = the http:// path to the specific bpTool help page
|
||||
tool_help_page = the http:// path to the tool specific help page
|
||||
|
||||
Here's an example
|
||||
# self.help_menu = azpy.shared.ui.help_menu.setup(self, 'Help...', 'https://some.site.com/azpy')
|
||||
|
||||
@@ -667,7 +667,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
import azpy.test.entry_test
|
||||
print('SUCCESS: import azpy.test.entry_test')
|
||||
azpy.test.entry_test.main(verbose=True, connectDebugger=True)
|
||||
azpy.test.entry_test.main(verbose=True, connect_debugger=True)
|
||||
except ImportError as e:
|
||||
print('ERROR: {0}'.format(e))
|
||||
raise e
|
||||
|
||||
@@ -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
|
||||
@@ -48,13 +49,13 @@ _LOGGER.debug('Starting:: {}.'.format({_MODULENAME}))
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
def main(verbose=_G_DEBUG, connectDebugger=True):
|
||||
def main(verbose=_G_DEBUG, connect_debugger=True):
|
||||
_LOGGER.info('{}'.format('-' * 74))
|
||||
_LOGGER.info('entry_test.main()')
|
||||
_LOGGER.info('Root test import successful:')
|
||||
_LOGGER.info('~ {}'.format(__file__))
|
||||
|
||||
if connectDebugger:
|
||||
if connect_debugger:
|
||||
status = connect_wing()
|
||||
_LOGGER.info(status)
|
||||
# -------------------------------------------------------------------------
|
||||
@@ -137,4 +138,4 @@ def connect_wing():
|
||||
# -------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
_G_DEBUG = True
|
||||
main(verbose=_G_DEBUG, connectDebugger=_G_DEBUG)
|
||||
main(verbose=_G_DEBUG, connect_debugger=_G_DEBUG)
|
||||
|
||||
@@ -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,6 +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
|
||||
try:
|
||||
import pathlib
|
||||
except:
|
||||
import pathlib2 as pathlib
|
||||
from pathlib import Path
|
||||
|
||||
_DCCSIG_PATH = Path(_DCCSIG_PATH).resolve()
|
||||
@@ -218,7 +221,7 @@ os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE)
|
||||
|
||||
# search up to get \dev
|
||||
_LY_DEV = azpy.config_utils.get_stub_check_path(in_path=_DCCSIG_PATH,
|
||||
check_stub='engineroot.txt')
|
||||
check_stub='engine.json')
|
||||
os.environ["DYNACONF_LY_DEV"] = str(_LY_DEV.resolve())
|
||||
_LY_PROJECT = azpy.config_utils.get_current_project(_LY_DEV)
|
||||
os.environ["DYNACONF_LY_PROJECT"] = _LY_PROJECT
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user