Exemplo n.º 1
0
    def processSnippets(self, snippets: 'COMP', thenRun: Callable,
                        runArgs: list):
        self.log('Processing snippets')
        snippetsRoot = snippets.op('snippets')
        snippetTable = snippets.op('navigator/snippetTable')  # type: DAT
        opTable = RaytkContext().opTable()
        knownOpTypes = [c.val for c in opTable.col('opType')[1:]]

        self.log(f'Found {snippetTable.numRows - 1} snippets')

        def processSnippetsStage(row: int):
            if row >= snippetTable.numRows:
                queueCall(thenRun, *runArgs)
            else:
                snippetOpType = snippetTable[row, 'opType'].val
                snippet = snippetsRoot.op(snippetTable[row, 'relPath'])
                self.log(f'Processing snippet {snippet}')
                self.context.focusInNetworkPane(snippet)
                if snippetOpType not in knownOpTypes:
                    self.log(
                        f'Removing snippet for missing type {snippetOpType}')
                    self.context.safeDestroyOp(snippet)
                    queueCall(processSnippetsStage, row + 1)
                else:
                    queueCall(self.processSnippet, snippet,
                              processSnippetsStage, [row + 1])

        queueCall(processSnippetsStage, 1)
Exemplo n.º 2
0
def setToolkitVersion(version: Version):
    context = RaytkContext()
    toolkit = context.toolkit()
    if toolkit.par['Raytkversion'] is None:
        page = toolkit.appendCustomPage('RayTK')
        page.appendStr('Raytkversion', label='RayTK Version')
    par = toolkit.par.Raytkversion
    par.val = str(version)
    par.readOnly = True
Exemplo n.º 3
0
    def OnOperatorsShortcutRightClick(self, button: 'COMP'):
        def goToItem(name, path):
            return popMenu.Item(
                name,
                callback=lambda: self.NavigateTo(op(path)),
            )

        categories = RaytkContext().allCategories()
        categories.sort(key=lambda c: c.name)
        popMenu.fromButton(button, h='Right', v='Top').Show(
            [goToItem(o.name, o.path) for o in categories])
Exemplo n.º 4
0
 def _loadToolkitTox(self, toxPath: str):
     toolkit = RaytkContext().toolkit()
     if toolkit:
         toolkit.par.externaltox = toxPath
         toolkit.par.reinitnet.pulse()
     else:
         toolkit = root.loadTox(toxPath)
         toolkit.name = 'raytk'
     # Do this early since it switches off things like automatically writing to the opList.txt file.
     # See https://github.com/t3kt/raytk/issues/95
     toolkit.par.Devel = False
     self.log('Finished loading toolkit')
Exemplo n.º 5
0
def buildOpInfoTable(dat: 'DAT'):
    dat.clear()
    dat.appendRow([
        'path',
        'kind',
        'status',
        'hasHelp',
        'hasInputs',
        'hasSubRops',
        'Coordtype',
        'Returntype',
        'Contexttype',
    ] + _opDefParamNames + [
        'hasThumb',
        'paramPages',
    ])
    opThumbs = op('opThumbs')
    context = RaytkContext()
    for rop in context.allMasterOperators():
        info = ROPInfo(rop)
        if not info:
            continue
        helpDat = info.helpDAT
        if not helpDat:
            hasHelp = False
        elif '## Parameters' in helpDat.text or len(helpDat.text.split()) > 6:
            hasHelp = True
        else:
            hasHelp = False
        dat.appendRow([
            rop.path,
            info.ropKind or '',
            info.statusLabel or 'stable',
            hasHelp,
            info.hasROPInputs,
            bool(info.subROPs),
        ])
        typeSpec = info.typeSpec
        if typeSpec:
            types = typeSpec.op('supportedTypes')
            dat[rop.path, 'Coordtype'] = types['coordType', 'spec']
            dat[rop.path, 'Contexttype'] = types['contextType', 'spec']
            dat[rop.path, 'Returntype'] = types['returnType', 'spec']
        for pn in _opDefParamNames:
            dat[rop.path, pn] = _formatPar(info.opDefPar[pn])
        dat[rop.path, 'hasThumb'] = bool(opThumbs[rop.path, 'thumb'])
        dat[rop.path,
            'paramPages'] = ' '.join([page.name for page in rop.customPages])
Exemplo n.º 6
0
 def getOutputToxPath(self, baseName: str):
     version = RaytkContext().toolkitVersion()
     if self.context.experimental:
         suffix = '-exp'
     else:
         suffix = ''
     return f'build/{baseName}-{version}{suffix}.tox'
Exemplo n.º 7
0
 def finalizeRootPars(self, comp: 'COMP'):
     super().finalizeRootPars(comp)
     version = RaytkContext().toolkitVersion()
     comp.par.Raytkversion = version
     comp.par.Raytkversion.default = version
     comp.par.Experimentalbuild = self.context.experimental
     comp.par.Experimentalbuild.default = self.context.experimental
Exemplo n.º 8
0
def buildOpParamsTable(dat: 'DAT'):
    dat.clear()
    dat.appendRow(['path', 'kind'])
    for rop in RaytkContext().allMasterOperators():
        info = ROPInfo(rop)
        if not info:
            continue
        dat.appendRow([
            info.path,
            info.ropKind or '',
        ])
        for tuplet in info.rop.customTuplets:
            par = tuplet[0]
            if par.name in (
                    'Inspect', 'Help', 'Updateop') or par.name.startswith(
                        'Createref') or par.name.startswith('Creatersel'):
                continue
            cell = dat[info.path, par.tupletName]
            if cell is None:
                dat.appendCol([par.tupletName])
                cell = dat[info.path, par.tupletName]
            if par.isMenu:
                opts = ','.join(par.menuNames)
                cell.val = f'Menu: {opts}'
            else:
                cell.val = par.style
Exemplo n.º 9
0
 def removeAllOpHelp(self,
                     thenRun: 'Optional[Callable]' = None,
                     runArgs: list = None):
     operators = RaytkContext().allMasterOperators()
     for comp in operators:
         self.context.removeOpHelp(comp)
     queueCall(thenRun, *(runArgs or []))
Exemplo n.º 10
0
def buildOpTestTable(dat: 'DAT', testTable: 'DAT'):
    dat.clear()
    dat.appendRow([
        'path',
        'testCount',
        'test1',
    ])
    testsByOpType = {}  # type: Dict[str, List[str]]
    for i in range(1, testTable.numRows):
        opType = str(testTable[i, 'opType'])
        name = str(testTable[i, 'filePath']).rsplit('/',
                                                    maxsplit=1)[1].replace(
                                                        '.tox', '')
        if not opType:
            continue
        elif opType not in testsByOpType:
            testsByOpType[opType] = [name]
        else:
            testsByOpType[opType].append(name)
    for rop in RaytkContext().allMasterOperators():
        opType = ROPInfo(rop).opType
        tests = testsByOpType.get(opType) or []
        tests.sort()
        dat.appendRow([
            rop.path,
            len(tests),
        ] + tests)
    for cell in dat.row(0)[2:]:
        cell.val = 'test' + str(cell.col - 1)
Exemplo n.º 11
0
 def runBuild(self, thenRun: Callable):
     super().runBuild(thenRun)
     version = RaytkContext().toolkitVersion()
     self.log('Starting build')
     self.log(f'Version: {version}' +
              (' (experimental)' if self.context.experimental else ''))
     queueCall(self.runBuild_stage, 0)
Exemplo n.º 12
0
def buildToolkitIndexJson():
    toolkitIndex = {
        'categories': {
            CategoryInfo(cat).categoryName: _buildCategoryIndexObj(cat)
            for cat in RaytkContext().allCategories()
        }
    }
    return json.dumps(toolkitIndex, indent='  ')
Exemplo n.º 13
0
 def processOperators(self,
                      comp: 'COMP',
                      thenRun: 'Optional[Callable]' = None,
                      runArgs: list = None):
     self.log(f'Processing operators {comp}')
     self.context.moveNetworkPane(comp)
     self.context.detachTox(comp)
     categories = RaytkContext().allCategories()
     # categories.sort(key=lambda c: c.name)
     if self.docProcessor:
         self.docProcessor.writeCategoryListPage(categories)
     queueCall(self.processOperatorCategories_stage, categories, thenRun,
               runArgs)
Exemplo n.º 14
0
def buildOpCurrentExpandedParamsTable(dat: 'DAT'):
    dat.clear()
    dat.appendRow(['path', 'expandedParams'])
    for rop in RaytkContext().allMasterOperators():
        info = ROPInfo(rop)
        if not info or not info.isROP:
            continue
        expanded = ' '.join([
            cell.val
            for cell in info.opDef.op('paramSpecTable').col('localName')[1:]
        ])
        dat.appendRow([
            info.path,
            expanded,
        ])
Exemplo n.º 15
0
 def processSnippetStage(stage: int):
     if stage == 0:
         self.log('Enabling snippet cooking')
         snippet.allowCooking = True
     elif stage == 1:
         rops = RaytkContext().ropChildrenOf(snippet)
         self.log(f'Updating {len(rops)} ROPs')
         for rop in rops:
             self.processRop(rop)
     elif stage == 2:
         self.log('Disabling snippet cooking')
         snippet.allowCooking = False
     else:
         queueCall(theRun, *(runArgs or []))
         return
     queueCall(processSnippetStage, stage + 1)
Exemplo n.º 16
0
def buildOpInputsTable(dat: 'DAT'):
    dat.clear()
    parNames = [
        'Source',
        'Label',
        'Localalias',
        'Variables',
        'Variableinputs',
        'Help',
    ]
    dat.appendRow([
        'path',
        'index',
        'handler',
        'name',
        'label',
        'required',
        'multi',
        'coordTypes',
        'contextTypes',
        'returnTypes',
        'hasExprs',
    ] + parNames)
    for rop in RaytkContext().allMasterOperators():
        info = ROPInfo(rop)
        if not info:
            continue
        for i, handler in enumerate(info.inputHandlers):
            inInfo = InputInfo(handler)
            dat.appendRow([
                rop.path,
                i + 1,
                handler.name,
                inInfo.name or '',
                inInfo.label or '',
                _formatPar(inInfo.handlerPar.Required),
                bool(inInfo.multiHandler),
                ' '.join(inInfo.supportedCoordTypes),
                ' '.join(inInfo.supportedContextTypes),
                ' '.join(inInfo.supportedReturnTypes),
                any([p.mode != ParMode.CONSTANT for p in handler.customPars]),
            ] + [
                _formatPar(inInfo.handlerPar[parName]) for parName in parNames
            ])
Exemplo n.º 17
0
 def updateLibraryImage(self,
                        toolkit: 'COMP',
                        thenRun: 'Optional[Callable]' = None,
                        runArgs: list = None):
     self.log('Updating library image')
     image = RaytkContext().libraryImage()
     if image:
         # self.context.moveNetworkPane(image)
         self.context.detachTox(image)
         self.context.lockBuildLockOps(image)
         image.par.Showshortcut = True
         toolkit.par.opviewer.val = image
         toolkit.par.opviewer.readOnly = True
         toolkit.viewer = True
     else:
         toolkit.par.opviewer.val = ''
         toolkit.viewer = False
     if thenRun:
         queueCall(thenRun, *(runArgs or []))
Exemplo n.º 18
0
def buildOpVariablesTable(dat: 'DAT'):
    dat.clear()
    dat.appendRow(['path'])
    for rop in RaytkContext().allMasterOperators():
        info = ROPInfo(rop)
        if not info.isROP:
            continue
        varTable = info.opDefPar.Variabletable.eval()
        if varTable and isinstance(varTable, evaluateDAT):
            varTable = varTable.inputs[0]
        if not varTable:
            continue
        dat.appendRow([info.path])
        for i in range(1, varTable.numRows):
            name = varTable[i, 'name'] or varTable[i, 0]
            dataType = varTable[i, 'dataType'] or varTable[i, 2]
            cell = dat[info.path, name]
            if cell is None:
                dat.appendCol([name])
                cell = dat[info.path, name]
            cell.val = dataType
Exemplo n.º 19
0
 def OpenToolkitNetwork():
     navigateTo(RaytkContext().toolkit(),
                name='raytkBuildNetwork',
                popup=True,
                goInto=True)
Exemplo n.º 20
0
 def GetToolkitVersion():
     return RaytkContext().toolkitVersion()
Exemplo n.º 21
0
 def runBuild_stage(self, stage: int):
     toolkit = RaytkContext().toolkit()
     if stage == 0:
         self.log('Disabling snippets')
         snippets = getattr(op, 'raytkSnippets', None)
         if snippets:
             snippets.allowCooking = False
         # self.log('NOT ************   Reloading toolkit')
         # WARNING: SKIPPING RELOAD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         self.log('Reloading toolkit')
         self.reloadToolkit(toolkit)
         self.context.openNetworkPane()
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 1:
         self.logStageStart('Detach fileSync ops')
         self.context.detachAllFileSyncDatsIn(toolkit, reloadFirst=True)
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 2:
         if self.docProcessor:
             self.logStageStart('Clear old docs')
             self.docProcessor.clearPreviousDocs()
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 3:
         self.logStageStart('Process thumbnails')
         self.context.runBuildScript(toolkit.op('libraryThumbs/BUILD'),
                                     thenRun=self.runBuild_stage,
                                     runArgs=[stage + 1])
     elif stage == 4:
         self.logStageStart('Update library info')
         self.updateLibraryInfo(toolkit,
                                thenRun=self.runBuild_stage,
                                runArgs=[stage + 1])
     elif stage == 5:
         self.logStageStart('Update library image')
         self.updateLibraryImage(toolkit,
                                 thenRun=self.runBuild_stage,
                                 runArgs=[stage + 1])
     elif stage == 6:
         self.logStageStart('Preprocessing components')
         self.preProcessComponents(toolkit.op('components'),
                                   thenRun=self.runBuild_stage,
                                   runArgs=[stage + 1])
     elif stage == 7:
         self.logStageStart('Process operators')
         self.processOperators(toolkit.op('operators'),
                               thenRun=self.runBuild_stage,
                               runArgs=[stage + 1])
     elif stage == 8:
         self.logStageStart('Process nested operators')
         self.processNestedOperators(toolkit.op('operators'),
                                     thenRun=self.runBuild_stage,
                                     runArgs=[stage + 1])
     elif stage == 9:
         self.logStageStart('Lock library info')
         self.lockLibraryInfo(toolkit,
                              thenRun=self.runBuild_stage,
                              runArgs=[stage + 1])
     elif stage == 10:
         self.logStageStart('Remove op help')
         self.removeAllOpHelp(thenRun=self.runBuild_stage,
                              runArgs=[stage + 1])
     elif stage == 11:
         self.logStageStart('Process tools')
         self.processTools(toolkit.op('tools'),
                           thenRun=self.runBuild_stage,
                           runArgs=[stage + 1])
     elif stage == 12:
         self.logStageStart('Lock buildLock ops')
         self.context.lockBuildLockOps(toolkit)
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 13:
         self.logStageStart('Process components')
         self.processComponents(toolkit.op('components'),
                                thenRun=self.runBuild_stage,
                                runArgs=[stage + 1])
     elif stage == 14:
         self.logStageStart('Remove buildExclude ops')
         self.removeBuildExcludeOpsIn(
             toolkit, thenRun=lambda: self.runBuild_stage(stage + 1))
     elif stage == 15:
         self.logStageStart('Remove redundant python mods')
         self.context.removeRedundantPythonModules(
             toolkit, toolkit.ops('tools', 'libraryInfo'))
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 16:
         self.logStageStart('Finalize toolkit pars')
         self.finalizeRootPars(toolkit)
         queueCall(self.runBuild_stage, stage + 1)
     elif stage == 17:
         self.logStageStart('Finish build')
         self.context.focusInNetworkPane(toolkit)
         toxFile = self.getOutputToxPath('RayTK')
         self.log(f'Exporting TOX to {toxFile}')
         toolkit.save(toxFile)
         self.log('Build completed!')
         self.log(f'Exported tox file: {toxFile}')
         queueCall(self.afterBuild)
Exemplo n.º 22
0
 def IncrementMinor():
     context = RaytkContext()
     version = context.toolkitVersion()
     setToolkitVersion(Version(version.major, version.minor + 1))
Exemplo n.º 23
0
 def ReloadToolkit(self):
     self.logTable.clear()
     self.log('Reloading toolkit')
     toolkit = RaytkContext().toolkit()
     queueCall(self.reloadToolkit, toolkit)
Exemplo n.º 24
0
 def organizeCurrentCategory(self):
     categories = RaytkContext().currentCategories()
     for cat in categories:
         self.organizeCategory(cat)
Exemplo n.º 25
0
 def IncrementMajor():
     version = RaytkContext().toolkitVersion()
     setToolkitVersion(Version(version.major + 1, 0))
Exemplo n.º 26
0
 def __init__(self, ownerComp: 'COMP'):
     self.ownerComp = ownerComp
     self.context = RaytkContext()
Exemplo n.º 27
0
 def ShowLibraryParams():
     RaytkContext().toolkit().openParameters()
Exemplo n.º 28
0
 def getCurrentROPs(self, primaryOnly=False):
     return RaytkContext().currentROPs(
         primaryOnly=primaryOnly,
         exclude=lambda c: c is self.ownerComp or c.path.startswith(
             self.ownerComp.path + '/'))
Exemplo n.º 29
0
 def forEachSelected(action):
     editor = RaytkContext().activeEditor()
     if not editor:
         return
     for o in editor.owner.selectedChildren:
         action(o)
Exemplo n.º 30
0
 def toolkitVersion(self):
     return RaytkContext().toolkitVersion()