Helper method to create an importer transformTask
3921
private boolean createTransformTask(Integer importJobId, Integer taskId, RESTTransform transformTask)
        throws URISyntaxException, HttpException {

        LOG.debug("Creating a new transform task for import job" + importJobId + " and task " + taskId);

        mapper.disable(SerializationFeature.WRAP_ROOT_VALUE);

        Response httpResponse = HttpUtil.post(
            this.addEndPoint(importJobId + "/tasks/" + taskId + "/transforms"),
            this.asJSON(transformTask),
            ContentType.APPLICATION_JSON,
            this.username,
            this.password
        );

        mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);

        if (httpResponse.getStatusCode().equals(HttpStatus.CREATED)) {
            LOG.debug("Successfully created the transform task");
            return true;
        } else {
            LOG.error("Error while creating the transform task");
            return false;
        }
    }
645691
function ConfigurableTaskFactory(recipes, registry, expose) {
	this.recipes = recipes;
	this.registry = registry;
	this.expose = expose;
}
842893
public boolean createGdalWarpTask(Integer importJobId, Integer importTaskId,
                                      List<String> optsGdalWarp) throws URISyntaxException, HttpException {
        RESTGdalWarpTransform transformTask = new RESTGdalWarpTransform();
        if (!optsGdalWarp.isEmpty()) {
            transformTask.setOptions(optsGdalWarp);
        }
        return this.createTransformTask(importJobId, importTaskId, transformTask);
    }
1064718
function(action, channel, imports, sysImports, contentParts, next, invokeOverride) {
    var self = this,
    errStr,
    parsingError = false,
    schemePtr,
    mixedTypes = [ 'mixed', 'array', 'object' ]

    if (this.actions[action].invoke) {

      if (!channel.config) {
        channel.config = {};
      }

      if (!contentParts) {
        contentParts = {
          _files : []
        }
      }

      try {

        // apply channel config defaults into imports, if required
        // fields don't already exist
        var actionSchema = this.getAction(action),
          missingFields = (actionSchema.imports && actionSchema.imports.required && actionSchema.imports.required.length) ? actionSchema.imports.required : [];

        // apply config defaults
        var configDefaults = this.getActionConfigDefaults(action),
          configSchema = this.getActionConfig(action).properties,
          importSchema = this.getActionImports(action).properties;

        _.each(configDefaults, function(value, key) {
          if (!channel.config[key]) {
            channel.config[key] = value;
          }
        });

        // transpose from config to imports (no need to reference channel.config in pods)
        _.each(channel.config, function(value, key) {
          // convert to boolean if not already
          if (configSchema[key] && 'boolean' === configSchema[key].type) {
            channel.config[key] = helper.isTruthy(value) ? true : false;
          }

          if (!imports[key]) {
            imports[key] = channel.config[key];
          }
        });

        // derive import defaults
        var importDefaults = this.getActionImportDefaults(action);
        _.each(importDefaults, function(value, key) {
          if (!imports[key]) {
            imports[key] = value;
          }
        });

        for (var k in imports) {
          // trim empty import
          if (imports.hasOwnProperty(k) && '' === imports[k]) {
            delete imports[k];
            continue;
          }

          if (missingFields.length && missingFields.indexOf(k) > -1  ){
        	   missingFields.splice(missingFields.indexOf(k) ,1);
          }

        var mixed;
		    if(
          importSchema[k] && importSchema[k].type
          || configSchema[k] && configSchema[k].type
          ) {
			  	p_errStr = null;
			  	value = imports[k];

          if (importSchema[k]) {
            schemePtr = importSchema[k];
          } else if (configSchema[k]) {
            schemePtr = configSchema[k];
          }

          type = schemePtr.type.toLowerCase();

          //
          if ('number' === type) {
            pValue = helper.stringToFloat(value);
            if (0 !== pValue && !pValue) {
              p_errStr = k + ': String cannot be converted to Number';
            } else {
              imports[k] = pValue;
            }

          } else if ('integer' === type) {
            pValue = helper.stringToInt(value);
            if (0 !== pValue && !pValue) {
              p_errStr = k + ': String cannot be converted to Integer';
            } else {
              imports[k] = pValue;
            }

          } else if ('boolean' === type) {

            var pValue = helper.stringToBoolean(value);

            if (pValue == null) {
              p_errStr = k + ': String cannot be converted to Boolean';
            } else {
              imports[k] = pValue;
            }

          } else if (-1 !== mixedTypes.indexOf(type) ) {
            if ('object' === type && helper.isObject(value)) {
              imports[k] = value;

            } else if ('array' === type && helper.isArray(value)) {
              imports[k] = value;

            } else {
              pValue = helper.stringToJson(value);

              if (pValue) {
                imports[k] = pValue;

              } else if(!pValue){
                imports[k] = value;

              } else {
                p_errStr = k + ': String cannot be converted to '
                  + (('mixed' === type || 'object' === type) ? 'Object' : 'Array') ;
              }
            }
          }

        	if(p_errStr){
        		parsingError = true;
        		self.log(p_errStr, channel, 'error');
        		next.call(self, p_errStr);
        	}
			  }
      }

      if(missingFields.length){
        errStr = 'Missing Required Field(s):' + missingFields.join();
        self.log(errStr, channel, 'error');
        next.call(self, errStr)
      }

      if (!missingFields.length && !parsingError) {
        var invokeMethod = 'invoke' === this.getTriggerType() ? 'invoke' : 'trigger';

        // @deprecate -- when all trigger actions support 'trigger' method
        if (invokeOverride || !this.actions[action][invokeMethod]) {
          invokeMethod = 'invoke';
        }

        //
        this.actions[action][invokeMethod](imports, channel, sysImports, contentParts, function(err, exports) {
          if (err) {
            self.log(err, channel, 'error');
          }
          next.apply(self, arguments);
        });
      }
     } catch (e) {
       errStr = 'EXCEPT ' + e.toString();
       self.log(errStr, channel, 'error');
 	  	 next.call(self, errStr);
     }
    }
  }
809496
public ImportDescr importStatement(PackageDescrBuilder pkg) throws RecognitionException {
        try {
            String kwd;
            if (helper.validateLT(2, kwd = DroolsSoftKeywords.ACC) ||
                    helper.validateLT(2, kwd = DroolsSoftKeywords.ACCUMULATE)) {
                AccumulateImportDescrBuilder imp = helper.start(pkg,
                        AccumulateImportDescrBuilder.class,
                        null);

                try {
                    // import
                    match(input,
                            DRL6Lexer.ID,
                            DroolsSoftKeywords.IMPORT,
                            null,
                            DroolsEditorType.KEYWORD);
                    if (state.failed)
                        return null;

                    // import accumulate
                    match(input,
                            DRL6Lexer.ID,
                            kwd,
                            null,
                            DroolsEditorType.KEYWORD);
                    if (state.failed)
                        return null;

                    // qualifiedIdentifier
                    String target = qualifiedIdentifier();
                    if (state.failed)
                        return null;
                    
                    // function name
                    Token id = match(input,
                            DRL6Lexer.ID,
                            null,
                            null,
                            DroolsEditorType.IDENTIFIER);
                    if (state.failed)
                        return null;
                    if (state.backtracking == 0) {
                        imp.target(target).functionName(id.getText());
                    }

                    return (imp != null) ? imp.getDescr() : null;
                } finally {
                    helper.end(AccumulateImportDescrBuilder.class,
                            imp);
                }
            } else {
                ImportDescrBuilder imp = helper.start(pkg,
                        ImportDescrBuilder.class,
                        null);

                try {
                    // import
                    match(input,
                            DRL6Lexer.ID,
                            DroolsSoftKeywords.IMPORT,
                            null,
                            DroolsEditorType.KEYWORD);
                    if (state.failed)
                        return null;

                    if (helper.validateIdentifierKey(kwd = DroolsSoftKeywords.FUNCTION) ||
                            helper.validateIdentifierKey(kwd = DroolsSoftKeywords.STATIC)) {
                        // function
                        match(input,
                                DRL6Lexer.ID,
                                kwd,
                                null,
                                DroolsEditorType.KEYWORD);
                        if (state.failed)
                            return null;
                    }

                    // qualifiedIdentifier
                    String target = qualifiedIdentifier();
                    if (state.failed)
                        return null;

                    if (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.STAR) {
                        // .*
                        match(input,
                                DRL6Lexer.DOT,
                                null,
                                null,
                                DroolsEditorType.IDENTIFIER);
                        if (state.failed)
                            return null;
                        match(input,
                                DRL6Lexer.STAR,
                                null,
                                null,
                                DroolsEditorType.IDENTIFIER);
                        if (state.failed)
                            return null;
                        target += ".*";
                    }
                    if (state.backtracking == 0)
                        imp.target(target);
                    return (imp != null) ? imp.getDescr() : null;
                } finally {
                    helper.end(ImportDescrBuilder.class,
                            imp);
                }
            }

        } catch (RecognitionException re) {
            reportError(re);
        }
        return null;
    }
609578
def import_data(self):
        

        tasks_list = self.load_task_list()
        warnings.filterwarnings(
            'ignore', r'Warning: converting a masked element to nan.')
        # FIX
        warnings.filterwarnings('ignore', category=DeprecationWarning)

        # Delete all old (previously constructed) output files
        if self.args.delete_old:
            self.log.warning("Deleting all old entry files.")
            self.delete_old_entry_files()

        # In update mode, load all entry stubs.
        if self.args.load_stubs or self.args.update:
            self.load_stubs()

        if self.args.travis:
            self.log.warning("Running in `travis` mode.")

        prev_priority = 0
        prev_task_name = ''
        # for task, task_obj in tasks_list.items():
        for task_name, task_obj in tasks_list.items():
            if not task_obj.active:
                continue
            self.log.warning("Task: '{}'".format(task_name))

            nice_name = task_obj.nice_name
            mod_name = task_obj.module
            func_name = task_obj.function
            priority = task_obj.priority

            # Make sure things are running in the correct order
            if priority < prev_priority and priority > 0:
                raise RuntimeError("Priority for '{}': '{}', less than prev,"
                                   "'{}': '{}'.\n{}"
                                   .format(task_name, priority, prev_task_name,
                                           prev_priority, task_obj))

            self.log.debug("\t{}, {}, {}, {}".format(nice_name, priority,
                                                     mod_name, func_name))
            mod = importlib.import_module('.' + mod_name, package='astrocats')
            self.current_task = task_obj
            getattr(mod, func_name)(self)

            num_events, num_stubs = self.count()
            self.log.warning("Task finished.  Events: {},  Stubs: {}".format(
                num_events, num_stubs))
            self.journal_entries()
            num_events, num_stubs = self.count()
            self.log.warning("Journal finished.  Events: {}, Stubs: {}".format(
                num_events, num_stubs))

            prev_priority = priority
            prev_task_name = task_name

        process = psutil.Process(os.getpid())
        memory = process.memory_info().rss
        self.log.warning('Memory used (MBs): '
                         '{:,}'.format(memory / 1024. / 1024.))
        return
399476
def refactor_organize_imports(self):
        """"""
        refactor = ImportOrganizer(self.project)
        changes = refactor.organize_imports(self.resource)
        return translate_changes(changes)
955032
function transformer(cst) {
    var concatenate = concatenateFactory();

    visit(cst, 'SentenceNode', any);
    visit(cst, concatenate);

    concatenate.done();
}
70954
def asset_create_task(self, *args, **kwargs):
        
        if not self.cur_asset:
            return
        task = self.create_task(element=self.cur_asset)
        if task:
            taskdata = djitemdata.TaskItemData(task)
            treemodel.TreeItem(taskdata, self.asset_task_model.root)
318540
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {

    if (transformer.currentTemplateRuleIsNull())
    {
      transformer.getMsgMgr().error(this,
        XSLTErrorResources.ER_NO_APPLY_IMPORT_IN_FOR_EACH);  //"xsl:apply-imports not allowed in a xsl:for-each");
    }

    int sourceNode = transformer.getXPathContext().getCurrentNode();
    if (DTM.NULL != sourceNode)
    {
      // supply the current templated (matched, not named)        
      ElemTemplate matchTemplate = transformer.getMatchedTemplate();
      transformer.applyTemplateToNode(this, matchTemplate, sourceNode);
    }
    else  // if(null == sourceNode)
    {
      transformer.getMsgMgr().error(this,
        XSLTErrorResources.ER_NULL_SOURCENODE_APPLYIMPORTS);  //"sourceNode is null in xsl:apply-imports!");
    }
  }
762161
function getComponentsTasks(baseTask) {
	var components = getComponents();
	var tasks = [];

	for (index = 0; index < components.length; ++index) {
	    tasks.push(baseTask + '.' + components[index]);
	}

	return tasks;
}
2964
def call(input)
      context = input[:environment].context_class.new(input)

      engine_options = merge_options({
        filename: input[:filename],
        syntax: self.class.syntax,
        cache_store: build_cache_store(input, @cache_version),
        load_paths: context.environment.paths.map { |p| @importer_class.new(p.to_s) },
        importer: @importer_class.new(Pathname.new(context.filename).to_s),
        sprockets: {
          context: context,
          environment: input[:environment],
          dependencies: context.metadata[:dependencies]
        }
      })

      engine = Autoload::Sass::Engine.new(input[:data], engine_options)

      css, map = Utils.module_include(Autoload::Sass::Script::Functions, @functions) do
        engine.render_with_sourcemap('')
      end

      css = css.sub("\n/*# sourceMappingURL= */\n", '')

      map = SourceMapUtils.format_source_map(JSON.parse(map.to_json(css_uri: '')), input)
      map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map)

      # Track all imported files
      sass_dependencies = Set.new([input[:filename]])
      engine.dependencies.map do |dependency|
        sass_dependencies << dependency.options[:filename]
        context.metadata[:dependencies] << URIUtils.build_file_digest_uri(dependency.options[:filename])
      end

      context.metadata.merge(data: css, sass_dependencies: sass_dependencies, map: map)
    end
841066
def _instantiate_task(api, kwargs):
    """"""
    file_id = kwargs['file_id']
    kwargs['file_id'] = file_id if str(file_id).strip() else None
    kwargs['cid'] = kwargs['file_id'] or None
    kwargs['rate_download'] = kwargs['rateDownload']
    kwargs['percent_done'] = kwargs['percentDone']
    kwargs['add_time'] = get_utcdatetime(kwargs['add_time'])
    kwargs['last_update'] = get_utcdatetime(kwargs['last_update'])
    is_transferred = (kwargs['status'] == 2 and kwargs['move'] == 1)
    if is_transferred:
        kwargs['pid'] = api.downloads_directory.cid
    else:
        kwargs['pid'] = None
    del kwargs['rateDownload']
    del kwargs['percentDone']
    if 'url' in kwargs:
        if not kwargs['url']:
            kwargs['url'] = None
    else:
        kwargs['url'] = None
    task = Task(api, **kwargs)
    if is_transferred:
        task._parent = api.downloads_directory
    return task
912977
function WorkqueueParser(importer) {
    Parser.call(this, importer);

    importer.registerEventHandler('workqueue_execute_start',
        WorkqueueParser.prototype.executeStartEvent.bind(this));
    importer.registerEventHandler('workqueue_execute_end',
        WorkqueueParser.prototype.executeEndEvent.bind(this));
    importer.registerEventHandler('workqueue_queue_work',
        WorkqueueParser.prototype.executeQueueWork.bind(this));
    importer.registerEventHandler('workqueue_activate_work',
        WorkqueueParser.prototype.executeActivateWork.bind(this));
  }
423776
function newTask (call) {
    // get clone of call and reset original
    call = resetCall(call)
    // require ImmutableCoreComponent
    assert.ok(GLOBAL.immutableCoreTask !== undefined, 'ImmutableAI configuration error: immutableCoreTask required')
    // get task - throws error if not found
    var task = GLOBAL.immutableCoreTask.task(call.module)
    // return function wrapper that calls new with session
    return args => {
        // make sure args is object
        if (!defined(args)) {
            args = {}
        }
        // add session to args if not defined
        if (!defined(args.session)) {
            args.session = call.session
        }
        // create new component
        return task.new(args)
    }
}
1144324
private void addFileToTransform(Map<Transformer,Map<String,Set<URI>>> gs, Transformer t, Source s) {
        Map<String,Set<URI>> fs = gs.get(t);
        if (fs == null) {
            fs = new HashMap<String,Set<URI>>();
            gs.put(t, fs);
        }
        Set<URI> ss = fs.get(s.pkg().name());
        if (ss == null) {
            ss = new HashSet<URI>();
            fs.put(s.pkg().name(), ss);
        }
        ss.add(s.file().toURI());
    }
1259761
function transformMemberImports(j, root, importPath, targetPath) {
  // find member imports
  root.find(j.ImportDeclaration, { source: { value: importPath } }).forEach(importDeclaration => {
    const memberImportSpecifiers = importDeclaration.node.specifiers.filter(
      specifier => specifier.type === 'ImportSpecifier',
    );
    if (memberImportSpecifiers.length) {
      j(importDeclaration).replaceWith(() => {
        const importDeclarations = [];
        const assignmentExpressions = [];

        memberImportSpecifiers.forEach(memberSpecifier => {
          const { palette, hue } = colorAccent(memberSpecifier.imported.name);
          const colorModuleName = colorImportPath(palette);
          const modulePath = `${targetPath}/${colorModuleName}`;
          const colorIdentifier = j.identifier(colorModuleName);

          // import color module (if not already imported)
          if (importDeclarations.map(p => p.source.value).indexOf(modulePath) === -1) {
            importDeclarations.push(
              j.importDeclaration(
                [j.importDefaultSpecifier(colorIdentifier)],
                j.literal(modulePath),
              ),
            );
          }

          // conditional assignment expression
          if (hue || colorModuleName === 'common') {
            const property = hue || palette;
            assignmentExpressions.push(
              j.variableDeclaration('const', [
                j.variableDeclarator(
                  j.identifier(memberSpecifier.local.name),
                  j.memberExpression(
                    colorIdentifier,
                    /^[_|a-z]/i.test(property) ? j.identifier(property) : j.literal(property),
                  ),
                ),
              ]),
            );
          }
        });

        return importDeclarations.concat(assignmentExpressions);
      });
    }
  });
}