Convert runs of qQ's in the stack into single graphobjs
555757
def _normalize_stack(graphobjs):
    """"""
    for operands, operator in graphobjs:
        operator = str(operator)
        if re.match(r'Q*q+$', operator):  # Zero or more Q, one or more q
            for char in operator:  # Split into individual
                yield ([], char)  # Yield individual
        else:
            yield (operands, operator)
742114
function createDependencyGraph(tasks) {
    var graph = {
      tasks: {},
      roots: [],
      leaves: [],
      resources: [],
      depth: 0,
      end : 0
    };

    for(var i = 0, len = tasks.length; i < len; i++) {
      var t = tasks[i];
      graph.tasks[t.id] = {
        id: t.id,
        duration: t.duration,
        priority: t.priority,
        schedule: t.schedule,
        minSchedule: t.minSchedule,
        dependsOn: t.dependsOn,
        resources: t.resources
      };
    }

    setResources(graph);
    setRequiredBy(graph.tasks);
    setRootsAndLeaves(graph);

    setDepth(graph, graph.leaves, 0);
    graph.depth += 1; // increment depth so it is 1 based

    forwardPass(graph, {}, graph.roots, 0);
    setEnd(graph, graph.leaves);
    backwardPass(graph, {}, graph.leaves, graph.end);

    return graph;
  }
646940
function pageToJqtree(page) {
          var info = {
            label: page.title,
            slug: page.slug,
            // Available both ways for compatibility with jqtree and
            // mongodb expectations
            _id: page._id,
            id: page._id,
            // For icons
            type: page.type,
            // Also nice for icons and browser-side decisions about what's draggable where
            trash: page.trash,
            publish: (page.path === 'home/trash') || apos.permissions.can(req, 'publish-page', page),
            edit: apos.permissions.can(req, 'edit-page', page)
          };
          if (page.children && page.children.length) {
            info.children = [];
            // Sort trash after non-trash
            _.each(page.children, function(child) {
              if (!child.trash) {
                info.children.push(pageToJqtree(child));
              }
            });
            _.each(page.children, function(child) {
              if (child.trash) {
                info.children.push(pageToJqtree(child));
              }
            });
          }
          return info;
        }
1274594
function specs() {
    var routes = {};

    // Reducing the app's recursive stack
    function reduceStack(path, items, item) {
      var nextPath;

      if (item.handle && item.handle.stack) {
        nextPath = join(path, (item.path || helpers.unescapeRegex(item.regexp) || ''));
        return items.concat(item.handle.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      if (item.route) {
        nextPath = join(path, (item.route.path || ''));
        return items.concat(item.route.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      return items.concat({
        handle: item.handle,
        path: path
      });
    }

    // Filtering the actions coming from dolman
    app._router.stack
      .reduce(reduceStack.bind(null, ''), [])
      .map(function(item) {
        return {
          route: routesMap.get(item.handle),
          path: item.path
        };
      })
      .filter(function(item) {
        return item.route && item.route.name;
      })
      .forEach(function(item) {
        var route = item.route,
            method = [].concat(route.method || route.methods)[0];

        var routeData = {
          path: item.path,
          name: route.name,
          method: !method || method === 'ALL' ? 'GET' : method
        };

        ['description'].forEach(function(k) {
          if (route[k])
            routeData[k] = route[k];
        });

        routes[route.name] = routeData;
      });

    return {
      formats: ['json'],
      methods: routes
    };
  }
406002
function runGlob(args, opts, cb) {
  var dotIdx = args.indexOf('.');
  if (dotIdx !== -1) {
    args.splice(dotIdx, 1);
  }
  glob(args, opts, function(err, globbed) {
    if (Array.isArray(globbed) && dotIdx !== -1) globbed.push('.');
    cb(err, globbed);
  });
}
54614
function (nodes, batchOps, done) {
      self.db.batch(batchOps, function (err) {
        if (err) {
          nodes.forEach(rejectNode)
          return done(err)
        }
        done(null, nodes)
      })
    }
388086
function loadGraphSONSync(graph, filename) {
        var FileInputStream = Tinkerpop.autoImport('FileInputStream');
        var stream = new FileInputStream(filename);
        var builder = Tinkerpop.GraphSONReader.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var reader = builder.create();
        reader.readGraph(stream, graph);
        return graph;
    }
781344
function JSONStream(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var total = runner.total;

  runner.once(EVENT_RUN_BEGIN, function() {
    writeEvent(['start', {total: total}]);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    writeEvent(['pass', clean(test)]);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    test = clean(test);
    test.err = err.message;
    test.stack = err.stack || null;
    writeEvent(['fail', test]);
  });

  runner.once(EVENT_RUN_END, function() {
    writeEvent(['end', self.stats]);
  });
}
313550
def execute_fields_serially(
        self,
        parent_type: GraphQLObjectType,
        source_value: Any,
        path: Optional[ResponsePath],
        fields: Dict[str, List[FieldNode]],
    ) -> AwaitableOrValue[Dict[str, Any]]:
        
        results: Dict[str, Any] = {}
        for response_name, field_nodes in fields.items():
            field_path = add_path(path, response_name)
            result = self.resolve_field(
                parent_type, source_value, field_nodes, field_path
            )
            if result is INVALID:
                continue
            if isawaitable(results):
                # noinspection PyShadowingNames
                async def await_and_set_result(results, response_name, result):
                    awaited_results = await results
                    awaited_results[response_name] = (
                        await result if isawaitable(result) else result
                    )
                    return awaited_results

                # noinspection PyTypeChecker
                results = await_and_set_result(
                    cast(Awaitable, results), response_name, result
                )
            elif isawaitable(result):
                # noinspection PyShadowingNames
                async def set_result(results, response_name, result):
                    results[response_name] = await result
                    return results

                # noinspection PyTypeChecker
                results = set_result(results, response_name, result)
            else:
                results[response_name] = result
        if isawaitable(results):
            # noinspection PyShadowingNames
            async def get_results():
                return await cast(Awaitable, results)

            return get_results()
        return results
1364832
def run_steps(node: Node, pipeline: RenderingPipeline, **args):
    """"""
    for step in pipeline.steps:
        result = step(node, pipeline=pipeline, **args)
        if isinstance(result, dict):
            args = {**args, **result}
174853
function (stack, req, res, next) {

  if (typeof stack === 'function') {
    stack = [stack];
  }

  var walkStack = function (i, err) {

    if (err) {
      return next(err);
    }

    if (i >= stack.length) {
      return next();
    }

    stack[i](req, res, walkStack.bind(null, i + 1));

  };

  walkStack(0);

}
1124399
def run(plugins):
    '''
    
    '''
    all_plugins = list_plugins()

    if isinstance(plugins, six.string_types):
        plugins = plugins.split(',')

    data = {}
    for plugin in plugins:
        if plugin not in all_plugins:
            continue
        data[plugin] = {}
        muninout = __salt__['cmd.run'](
                'munin-run {0}'.format(plugin),
                python_shell=False)
        for line in muninout.split('\n'):
            if 'value' in line:  # This skips multigraph lines, etc
                key, val = line.split(' ')
                key = key.split('.')[0]
                try:
                    # We only want numbers
                    if '.' in val:
                        val = float(val)
                    else:
                        val = int(val)
                    data[plugin][key] = val
                except ValueError:
                    pass
    return data
1128558
def map(self, fn, *seq):
        " "
        "block until done."
        results = Queue()
        args = zip(*seq)
        for seq in args:
            j = SimpleJob(results, fn, seq)
            self.put(j)

        # Aggregate results
        r = []
        for i in range(len(list(args))):
            r.append(results.get())

        return r
1258233
function(type, url, opts) {
        opts = opts || {};

        var id = "q" + (qidx++), q,
            thresh = opts.purgethreshold || Y.Get.PURGE_THRESH;

        if (qidx % thresh === 0) {
            _autoPurge();
        }

        queues[id] = Y.merge(opts, {
            tId: id,
            type: type,
            url: url,
            finished: false,
            nodes: []
        });

        q           = queues[id];
        q.win       = q.win || Y.config.win;
        q.context   = q.context || q;
        q.autopurge = ("autopurge" in q) ? q.autopurge : 
                      (type === "script") ? true : false;

        q.attributes = q.attributes || {};
        q.attributes.charset = opts.charset || q.attributes.charset || 'utf-8';

        _next(id);

        return {
            tId: id
        };
    }
170527
function compileGraphQLTag(
  t: $FlowFixMe,
  path: Object,
  state: BabelState,
  ast: DocumentNode,
): void {
  if (ast.definitions.length !== 1) {
    throw new Error(
      'BabelPluginRelay: Expected exactly one definition per graphql tag.',
    );
  }
  const definition = ast.definitions[0];
  if (
    definition.kind !== 'FragmentDefinition' &&
    definition.kind !== 'OperationDefinition'
  ) {
    throw new Error(
      'BabelPluginRelay: Expected a fragment, mutation, query, or ' +
        'subscription, got `' +
        definition.kind +
        '`.',
    );
  }
  return replaceMemoized(t, path, createAST(t, state, path, definition));
}
536050
function (graph, opts, params) {
    var self = this;
    var newNodes = graph.allNodes.filter(function(node) {
      return node.props[self.db.options.id] == null
          && !(node.model.uniqueness && node.model.uniqueness.returnOld);
    });

    if (!newNodes.length) return '';

    var statements = newNodes.map(function(node) {
      var label = node.model.type;
      return '(' + node.name + ':' + label + ')';
    });

    return 'CREATE ' + statements.join(',');
  }
227565
function renderBatch(batch) {
  // Localize batch info
  var description = batch.nodeName,
      value = batch.value,
      childNodes = batch.childNodes,
      fns;

  // If there are no children, we are on a leaf
  if (!childNodes) {
    // If the value is an array, run all of them in series
    if (Array.isArray(value)) {
      fns = value;
      // TODO: Conditionally require a callback
      it(description, function handleMultipleIts (done) {
        // Iterate the functions in order
        var that = this;
        async.forEachSeries(fns, function (fn, cb) {
          // Clear the timeout
          that.runnable().resetTimeout();

          // If the function is async, pass it a callback
          if (fn.length) {
            fn.call(that, cb);
          } else{
          // Otherwise, run it and call the callback
            fn.call(that);
            cb(null);
          }
        }, done);
      });
    } else {
    // Otherwise, describe and execute `it`
      it(description, value);
    }
  } else {
  // Otherwise, we are on a parent node
    // Describe this context
    describe(description, function execRecursiveRender () {
      // If there is a value, act on it
      if (value) {
        // If the value is not an object, upcast them to an object
        var valObj = value;
        if (typeof value !== 'object' || Array.isArray(value)) {
          valObj = {before: value};
        }

        // Run all the hooks that exist
        // DEV: In all cases, `mocha` will handle the async and sync timings =3
        if (valObj.before) { addHooks(before, valObj.before); }
        if (valObj.beforeEach) { addHooks(beforeEach, valObj.beforeEach); }
        if (valObj.afterEach) { addHooks(afterEach, valObj.afterEach); }
        if (valObj.after) { addHooks(after, valObj.after); }
      }

      // Execute each of the children
      childNodes.forEach(renderBatch, this);
    });
  }
}