Synthesize all fragments without using the cache
488060
def _loop_no_cache(self, helper_function, num, fragment):
        
        self.log([u"Examining fragment %d (no cache)...", num])
        # synthesize and get the duration of the output file
        voice_code = self._language_to_voice_code(fragment.language)
        self.log(u"Calling helper function")
        succeeded, data = helper_function(
            text=fragment.filtered_text,
            voice_code=voice_code,
            output_file_path=None,
            return_audio_data=True
        )
        # check output
        if not succeeded:
            self.log_crit(u"An unexpected error occurred in helper_function")
            return (False, None)
        self.log([u"Examining fragment %d (no cache)... done", num])
        return (True, data)
1017540
private synchronized static void loadAll() throws DaoManagerException {
		if (setImpl ==null) {
			long implLastModifiedTime=impl.getLastModified();
				
			if (lastModified<implLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);	
			}
		} else {
			long implLastModifiedTime=impl.getLastModified();
			long setImplLastModifiedTime=setImpl.getLastModified();
		
			if (lastModified<implLastModifiedTime || lastModified<setImplLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				Map<String,PropertyDescriptor> dynamicValues=setImpl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
					cache.putAll(dynamicValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);
			}
		}
	}
3227
def save_cache(dpath, fname, cfgstr, data, ext='.cPkl', verbose=None):
    
    fpath = _args2_fpath(dpath, fname, cfgstr, ext)
    util_io.save_data(fpath, data, verbose=verbose)
    return fpath
820359
def complete(fragment)
      self.class.filter(shell.instance_methods).grep Regexp.new(Regexp.quote(fragment))
    end
36575
def get_fragment_generator(self, gp, **kwargs):
        
        collector = FragmentCollector(self.__host, gp)
        return collector.get_fragment_generator(**kwargs)
818952
private static Collection<Set<Fragment>> getConnectedFragmentSets(Set<Fragment> allFragments) {
        // TODO this could be implemented in a more readable way (eg. using a graph + BFS etc.)
        final Map<Integer, Set<Variable>> varSetMap = new HashMap<>();
        final Map<Integer, Set<Fragment>> fragmentSetMap = new HashMap<>();
        final int[] index = {0};
        allFragments.forEach(fragment -> {
            Set<Variable> fragmentVarNameSet = Sets.newHashSet(fragment.vars());
            List<Integer> setsWithVarInCommon = new ArrayList<>();
            varSetMap.forEach((setIndex, varNameSet) -> {
                if (!Collections.disjoint(varNameSet, fragmentVarNameSet)) {
                    setsWithVarInCommon.add(setIndex);
                }
            });

            if (setsWithVarInCommon.isEmpty()) {
                index[0] += 1;
                varSetMap.put(index[0], fragmentVarNameSet);
                fragmentSetMap.put(index[0], Sets.newHashSet(fragment));
            } else {
                Iterator<Integer> iterator = setsWithVarInCommon.iterator();
                Integer firstSet = iterator.next();
                varSetMap.get(firstSet).addAll(fragmentVarNameSet);
                fragmentSetMap.get(firstSet).add(fragment);
                while (iterator.hasNext()) {
                    Integer nextSet = iterator.next();
                    varSetMap.get(firstSet).addAll(varSetMap.remove(nextSet));
                    fragmentSetMap.get(firstSet).addAll(fragmentSetMap.remove(nextSet));
                }
            }
        });
        return fragmentSetMap.values();
    }
1051091
def fragment_nesting(cls, elem1, tag2, namespaces=None):
        """"""
        elems2 = elem1.xpath("child::%s" % tag2, namespaces=namespaces)
        while len(elems2) > 0:
            elem2 = elems2[0]
            parent2 = elem2.getparent()
            index2 = parent2.index(elem2)

            # all of elem2 has a new tag1 element embedded inside of it
            child_elem1 = etree.Element(elem1.tag)
            for k in elem1.attrib:
                child_elem1.set(k, elem1.get(k))
            elem2.text, child_elem1.text = '', elem2.text
            for ch in elem2.getchildren():
                child_elem1.append(ch)
            elem2.insert(0, child_elem1)

            # new_elem1 for all following children of parent2
            new_elem1 = etree.Element(elem1.tag)
            for k in elem1.attrib:
                new_elem1.set(k, elem1.get(k))
            new_elem1.text, elem2.tail = elem2.tail, ''
            for ch in parent2.getchildren()[index2 + 1 :]:
                new_elem1.append(ch)

            # elem2 is placed after parent2
            parent = parent2.getparent()
            parent.insert(parent.index(parent2) + 1, elem2)
            last_child = elem2

            # new_elem1 is placed after elem2
            parent.insert(parent.index(elem2) + 1, new_elem1)
            new_elem1.tail, elem1.tail = elem1.tail, ''

            XML.remove_if_empty(elem1)
            XML.remove_if_empty(new_elem1)

            # repeat until all tag2 elements are unpacked from the new_elem1
            elem1 = new_elem1
            elems2 = elem1.xpath("child::%s" % tag2, namespaces=namespaces)
973765
def _transform_snapshots_for_blockhash(storage: SQLiteStorage, cache: BlockHashCache) -> None:
    """"""

    snapshots = storage.get_snapshots()
    snapshot_records = [
        TransformSnapshotRecord(
            data=snapshot.data,
            identifier=snapshot.identifier,
            storage=storage,
            cache=cache,
        )
        for snapshot in snapshots
    ]

    pool_generator = Pool(len(snapshots)).imap(_do_transform_snapshot, snapshot_records)

    updated_snapshots_data = []
    for result in pool_generator:
        updated_snapshots_data.append(result)

    storage.update_snapshots(updated_snapshots_data)
473178
function compile(fragments, template) {
  var walker = document.createTreeWalker(template, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
  var bindings = [], currentNode, parentNode, previousNode;

  // Reset first node to ensure it isn't a fragment
  walker.nextNode();
  walker.previousNode();

  // find bindings for each node
  do {
    currentNode = walker.currentNode;
    parentNode = currentNode.parentNode;
    bindings.push.apply(bindings, getBindingsForNode(fragments, currentNode, template));

    if (currentNode.parentNode !== parentNode) {
      // currentNode was removed and made a template
      walker.currentNode = previousNode || walker.root;
    } else {
      previousNode = currentNode;
    }
  } while (walker.nextNode());

  return bindings;
}
659765
function (fragment) {
            var self = this;
            if (S.startsWith(fragment, '#')) {
                fragment = fragment.slice(1);
            }
            self.fragment = fragment;
            return self;
        }
1165227
public FragmentBuilder getFragmentBuilder() {
        FragmentBuilder builder = builders.get();

        if (builder == null) {
            if (log.isLoggable(Level.FINEST)) {
                log.finest("Creating new FragmentBuilder");
            }
            builder = new FragmentBuilder();
            builders.set(builder);

            int currentCount = threadCounter.incrementAndGet();
            int builderCount = builder.incrementThreadCount();

            if (log.isLoggable(Level.FINEST)) {
                log.finest("Associate Thread with FragmentBuilder(1): Total Thread Count = " + currentCount
                        + " : Fragment Thread Count = " + builderCount);
                synchronized (threadNames) {
                    threadNames.add(Thread.currentThread().getName());
                }
            }
        }

        return builder;
    }
1147142
function(inDir, outDir, relativePath, newCache) {
    var ext = this._matchingFileExtension(relativePath);
    var moduleName = relativePath.slice(0, relativePath.length - (ext.length + 1));
    var fullInputPath = path.join(inDir, relativePath);
    var fullOutputPath = path.join(outDir, moduleName + '.' + this.targetExtension);

    var entry = this._transpileThroughCache(
      moduleName,
      fs.readFileSync(fullInputPath, 'utf-8'),
      newCache
    );

    mkdirp.sync(path.dirname(fullOutputPath));
    fs.writeFileSync(fullOutputPath, entry.output);
  }
519848
def cached_generator(function):
    """"""
    cache_variable = '_cached_' + function.__name__
    @wraps(function)
    def function_wrapper(obj, *args, **kwargs):
        # values are cached in a list stored in the object
        try:
            for item in getattr(obj, cache_variable):
                yield item
        except AttributeError:
            setattr(obj, cache_variable, [])
            cache = getattr(obj, cache_variable)
            for item in function(obj, *args, **kwargs):
                cache.append(item)
                yield item
    return function_wrapper
540407
function createMemorySource(initialPathname = "/") {
    let index = 0;
    let states = [];
    let stack = [{
        pathname: initialPathname,
        search: ""
    }];

    let target = {
        // location
        addEventListener(name, fn) {},
        removeEventListener(name, fn) {},
        history: {
            // index
            // entries,
            // state
            back(){},
            pushState(state, _, uri) {
                index++;
                stack.push(uri2obj(uri));
                states.push(state);
                sync(target);
            },
            replaceState(state, _, uri) {
                stack[index] = uri2obj(uri);
                states[index] = state;
                sync(target);
            }
        }
    };

    function sync(target) {
        var history = target.history;
        history.index = index;
        history.entries = stack;
        history.state = states[index];
        target.location = stack[index];
    }
    sync(target);
    return target;
}
1115791
def cache_results(&block)
        if template_cache_configured? && Rabl.configuration.cache_all_output && @_object.respond_to?(:cache_key)
          cache_key = [@_object, @options[:root_name], @options[:format]]

          fetch_result_from_cache(cache_key, &block)
        else # skip cache
          yield
        end
      end
1212878
def _get_inline_fragment(ast):
    """"""
    if not ast.selection_set:
        # There is nothing selected here, so no fragment.
        return None

    fragments = [
        ast_node
        for ast_node in ast.selection_set.selections
        if isinstance(ast_node, InlineFragment)
    ]

    if not fragments:
        return None

    if len(fragments) > 1:
        raise GraphQLCompilationError(u'Cannot compile GraphQL with more than one fragment in '
                                      u'a given selection set.')

    return fragments[0]
1357438
def append_fragment_list_to_sync_root(self, sync_root):
        
        if not isinstance(sync_root, Tree):
            self.log_exc(u"sync_root is not a Tree object", None, True, TypeError)

        self.log(u"Appending fragment list to sync root...")
        for fragment in self.smflist:
            sync_root.add_child(Tree(value=fragment))
        self.log(u"Appending fragment list to sync root... done")