Process the transform sub command

@param ns Namespace which contains parsed commandline arguments
@return true if the transform is successful, false if an error occured
541596
@Override
    public boolean process( Namespace ns ) {

        Chainr chainr;
        try {
            chainr = ChainrFactory.fromFile((File) ns.get("spec"));
        } catch ( Exception e ) {
            JoltCliUtilities.printToStandardOut( "Chainr failed to load spec file.", SUPPRESS_OUTPUT );
            e.printStackTrace( System.out );
            return false;
        }

        File file = ns.get( "input" );
        Object input = JoltCliUtilities.readJsonInput( file, SUPPRESS_OUTPUT );

        Object output;
        try {
            output = chainr.transform( input );
        } catch ( Exception e ) {
            JoltCliUtilities.printToStandardOut( "Chainr failed to run spec file.", SUPPRESS_OUTPUT );
            return false;
        }

        Boolean uglyPrint = ns.getBoolean( "u" );
        return JoltCliUtilities.printJsonObject( output, uglyPrint, SUPPRESS_OUTPUT );
    }
380349
@Override
	protected void doTransform(ITransformable.Scale transformable, float comp)
	{
		float fromX = reversed ? this.toX : this.fromX;
		float toX = reversed ? this.fromX : this.toX;
		float fromY = reversed ? this.toY : this.fromY;
		float toY = reversed ? this.fromY : this.toY;
		float fromZ = reversed ? this.toZ : this.fromZ;
		float toZ = reversed ? this.fromZ : this.toZ;

		transformable.scale(fromX + (toX - fromX) * comp, fromY + (toY - fromY) * comp, fromZ + (toZ - fromZ) * comp, offsetX, offsetY,
				offsetZ);
	}
491556
public static void transformSq(final GrayF32 input , final GrayF64 transformed )
	{
		int indexSrc = input.startIndex;
		int indexDst = transformed.startIndex;
		int end = indexSrc + input.width;

		double total = 0;
		for( ; indexSrc < end; indexSrc++ ) {
			float value = input.data[indexSrc];
			transformed.data[indexDst++] = total += value*value;
		}

		for( int y = 1; y < input.height; y++ ) {
			indexSrc = input.startIndex + input.stride*y;
			indexDst = transformed.startIndex + transformed.stride*y;
			int indexPrev = indexDst - transformed.stride;

			end = indexSrc + input.width;

			total = 0;
			for( ; indexSrc < end; indexSrc++ ) {
				float value = input.data[indexSrc];
				total +=  value*value;
				transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
			}
		}
	}
701514
private boolean processTemplateCommand(String cmdLine, int cmdTPosBegin, int cmdTPosEnd)
            throws MiniTemplator.TemplateSyntaxException {
        int p0 = skipBlanks(cmdLine, 0);
        if (p0 >= cmdLine.length()) {
            return false;
        }
        int p = skipNonBlanks(cmdLine, p0);
        String cmd = cmdLine.substring(p0, p);
        String parms = cmdLine.substring(p);
        /* select */
        if (cmd.equalsIgnoreCase("$beginBlock")) {
            processBeginBlockCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$endBlock")) {
            processEndBlockCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$include")) {
            processIncludeCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$if")) {
            processIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$elseIf")) {
            processElseIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$else")) {
            processElseCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$endIf")) {
            processEndIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else {
            if (cmd.startsWith("$") && !cmd.startsWith("${")) {
                throw new MiniTemplator.TemplateSyntaxException(
                        "Unknown command \"" + cmd + "\" in template at offset " + cmdTPosBegin + ".");
            } else {
                return false;
            }
        }
        return true;
    }
1067112
private boolean perform(File outputDir, Map<String,Transformer> suffixRules)
    {
        boolean rc = true;
        // Group sources based on transforms. A source file can only belong to a single transform.
        Map<Transformer,Map<String,Set<URI>>> groupedSources = new HashMap<Transformer,Map<String,Set<URI>>>();
        for (Source src : now.sources().values()) {
            Transformer t = suffixRules.get(src.suffix());
               if (t != null) {
                if (taintedPackages.contains(src.pkg().name()) && !src.isLinkedOnly()) {
                    addFileToTransform(groupedSources, t, src);
                }
            }
        }
        // Go through the transforms and transform them.
        for (Map.Entry<Transformer,Map<String,Set<URI>>> e : groupedSources.entrySet()) {
            Transformer t = e.getKey();
            Map<String,Set<URI>> srcs = e.getValue();
            // These maps need to be synchronized since multiple threads will be writing results into them.
            Map<String,Set<URI>> packageArtifacts = Collections.synchronizedMap(new HashMap<String,Set<URI>>());
            Map<String,Set<String>> packageDependencies = Collections.synchronizedMap(new HashMap<String,Set<String>>());
            Map<String,String> packagePublicApis = Collections.synchronizedMap(new HashMap<String,String>());

            boolean  r = t.transform(srcs,
                                     visibleSrcs,
                                     visibleClasses,
                                     prev.dependents(),
                                     outputDir.toURI(),
                                     packageArtifacts,
                                     packageDependencies,
                                     packagePublicApis,
                                     0,
                                     isIncremental(),
                                     numCores,
                                     out,
                                     err);
            if (!r) rc = false;

            for (String p : srcs.keySet()) {
                recompiledPackages.add(p);
            }
            // The transform is done! Extract all the artifacts and store the info into the Package objects.
            for (Map.Entry<String,Set<URI>> a : packageArtifacts.entrySet()) {
                Module mnow = now.findModuleFromPackageName(a.getKey());
                mnow.addArtifacts(a.getKey(), a.getValue());
            }
            // Extract all the dependencies and store the info into the Package objects.
            for (Map.Entry<String,Set<String>> a : packageDependencies.entrySet()) {
                Set<String> deps = a.getValue();
                Module mnow = now.findModuleFromPackageName(a.getKey());
                mnow.setDependencies(a.getKey(), deps);
            }
            // Extract all the pubapis and store the info into the Package objects.
            for (Map.Entry<String,String> a : packagePublicApis.entrySet()) {
                Module mprev = prev.findModuleFromPackageName(a.getKey());
                List<String> pubapi = Package.pubapiToList(a.getValue());
                Module mnow = now.findModuleFromPackageName(a.getKey());
                mnow.setPubapi(a.getKey(), pubapi);
                if (mprev.hasPubapiChanged(a.getKey(), pubapi)) {
                    // Aha! The pubapi of this package has changed!
                    // It can also be a new compile from scratch.
                    if (mprev.lookupPackage(a.getKey()).existsInJavacState()) {
                        // This is an incremental compile! The pubapi
                        // did change. Trigger recompilation of dependents.
                        packagesWithChangedPublicApis.add(a.getKey());
                        Log.info("The pubapi of "+Util.justPackageName(a.getKey())+" has changed!");
                    }
                }
            }
        }
        return rc;
    }
1231803
def get_ns_commands(self, cmd_name):
        
        namespace, command = _split_ns_command(cmd_name)
        if not namespace:
            # Name space not given, look for the commands
            spaces = self.__find_command_ns(command)
            if not spaces:
                # Unknown command
                raise ValueError("Unknown command {0}".format(command))
            else:
                # Return a sorted list of tuples
                return sorted((namespace, command) for namespace in spaces)

        # Single match
        return [(namespace, command)]
440731
def transform(self, line, _continue_prompt):
        """'"""

        # Capture the original line
        orig_line = line

        # Get tokens from all the currently active namespace
        ns_token_set = set([token for nspace in self.shell.all_ns_refs for token in nspace])

        # Build up token set and info out of the incoming line
        token_list = re.split(' |;|,|(|)|\'|"', line)
        token_list = [item for item in token_list if item != None and item != '']
        num_tokens = len(token_list)
        first_token = token_list[0]
        token_set = set(token_list)       

        # Very conservative logic (but possibly flawed)
        # 1) Lines with any of these symbols ; , ' " ( ) aren't touched
        # 2) Need to have more than one token
        # 3) First token in line must be in the workbench command set
        # 4) If first token is 'help' than all other tokens are quoted
        # 5) Otherwise only tokens that are not in any of the namespace are quoted

        # Fixme: Horse shit temp hack for load_sample
        # 0) If load_sample do special processing
        if first_token == 'load_sample':
            # If the second arg isn't in namespace quote it
            if token_list[1] not in ns_token_set:
                line = line.replace(token_list[1], '"'+token_list[1]+'",')
            return line

        # Fixme: Horse shit temp hack for pivot
        # 0) If pivot do special processing
        if first_token == 'pivot':
            # Quote all other tokens
            for token in token_list:
                if token not in ns_token_set:
                    line = line.replace(token, '"' + token + '",')
            return line

        # 1) Lines with any of these symbols ; , ' " ( ) aren't touched
        skip_symbols = [';', ',', '\'', '"', '(', ')']
        if any([sym in line for sym in skip_symbols]):
            return line

        # 2) Need to have more than one token
        # 3) First token in line must be in the workbench command set
        if num_tokens > 1 and first_token in self.command_set:

            # 4) If first token is 'help' than all other tokens are quoted
            if first_token == 'help':
                token_set.remove('help')
                for token in token_set:
                    line = line.replace(token, '"'+token+'"')

            # 5) Otherwise only tokens that are not in any of the namespace are quoted
            else: # Not help
                for token in token_set:
                    if token not in ns_token_set:
                        line = line.replace(token, '"'+token+'"')

        # Return the processed line
        return line
267519
def process_alias_create_namespace(namespace):
    
    namespace = filter_alias_create_namespace(namespace)
    _validate_alias_name(namespace.alias_name)
    _validate_alias_command(namespace.alias_command)
    _validate_alias_command_level(namespace.alias_name, namespace.alias_command)
    _validate_pos_args_syntax(namespace.alias_name, namespace.alias_command)
543360
@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected void doTransform(ITransformable transformable, float comp)
	{
		if (listTransformations.size() == 0)
			return;

		for (Transformation transformation : listTransformations)
			transformation.transform(transformable, elapsedTimeCurrentLoop);
	}
39167
protected void process(String cmd) {
        int firstSpace = cmd.indexOf(' ');
        if(firstSpace < 0) firstSpace = cmd.length();

        CommandInfo info = commands.get(cmd.substring(0, firstSpace).toUpperCase());

        if(info == null) {
            sendResponse(502, "Unknown command");
            return;
        }

        processCommand(info, firstSpace != cmd.length() ? cmd.substring(firstSpace + 1) : "");
    }
1040919
public boolean containsNamespace(String ns)
    {
        return _namespace.equals(ns) || (_aliasNamespace != null && _aliasNamespace.equals(ns));
    }
372360
@Override
    public void intializeSubCommand( Subparsers subparsers ) {
        Subparser transformParser = subparsers.addParser( "transform" )
                .description( "Jolt CLI Transform Tool. This tool will ingest a JSON spec file and an JSON input (from a file or " +
                        "standard input) and run the transforms specified in the spec file on the input. The program will return an " +
                        "exit code of 0 if the input is transformed successfully or a 1 if an error is encountered" )
                .defaultHelp( true );

        File nullFile = null;
        transformParser.addArgument( "spec" ).help( "File path to Jolt Transform Spec to execute on the input. " +
                "This file should contain valid JSON." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() );
        transformParser.addArgument( "input" ).help( "File path to the input JSON for the Jolt Transform operation. " +
                "This file should contain valid JSON. " +
                "If this argument is not specified then standard input will be used." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() )
                .nargs( "?" ).setDefault( nullFile );   // these last two method calls make input optional

        transformParser.addArgument( "-u" ).help( "Turns off pretty print for the output. Output will be raw json with no formatting." )
                .action( Arguments.storeTrue() );
    }
1150576
protected boolean processLine(final CommandLine line, final Options options)
            throws Exception {
        if (line.hasOption("version")) {
            System.out.println("version " + getVersion());
            return false;
        }
        if (line.hasOption("help")) {
            produceHelp(options);
            return false;
        }
        if (line.hasOption("config")) {
            setConfigFile(line.getOptionValue("config").trim());
        }
        if (line.hasOption("input")) {
            setInput(line.getOptionValue("input").trim());
        }
        if (line.hasOption("inputEncoding")) {
            setInputEncoding(line.getOptionValue("inputEncoding").trim());
        }
        if (line.hasOption("output")) {
            setOutput(line.getOptionValue("output").trim());
        }
        if (line.hasOption("targetNamespacePrefix")) {
            setTargetNamespacePrefix(line.getOptionValue(
                    "targetNamespacePrefix").trim());
        }
        if (line.hasOption("xsltFileName")) {
            setXsltFileName(line.getOptionValue(
                    "xsltFileName").trim());
        }

        return true;
    }
1079289
public boolean process(DMatrixRMaj A , int numSingularValues, DMatrixRMaj nullspace ) {
        decomposition.decompose(A);

        if( A.numRows > A.numCols ) {
            Q.reshape(A.numCols,Math.min(A.numRows,A.numCols));
            decomposition.getQ(Q, true);
        } else {
            Q.reshape(A.numCols, A.numCols);
            decomposition.getQ(Q, false);
        }

        nullspace.reshape(Q.numRows,numSingularValues);
        CommonOps_DDRM.extract(Q,0,Q.numRows,Q.numCols-numSingularValues,Q.numCols,nullspace,0,0);

        return true;
    }
657321
public function hasSub($name, $ns = null)
    {
        foreach ($this->subs as $sub) {
            if (($name === "*" or $sub->name === $name) and ($ns === null or $sub->ns === $ns)) {
                return true;
            }
        }
        return false;
    }
1122437
public CommandResult exec(String commandLine) {
        CommandResult result = new CommandResult(RESULT);

        try {
            Object raw = shellSession.execute(commandLine);

            if(raw != null){
                result.setContent(format(raw));
            }

        } catch (Exception e) { //NOSONAR
            //the result is an error
            result.setType(ERR);
            result.setContent(e.getMessage());
        }

        return result;
    }
374343
private AbstractTransform getTransform(String fileName) {
        File file = new File(fileName);
        
        for (Transform transform : transforms) {
            if (transform.filter.accept(file)) {
                return transform.transform;
            }
        }
        
        return null;
    }