Inner function of reverse_format, returns the resolved value for each
    field in pattern.
352703
def _get_parts_of_format_string(resolved_string, literal_texts, format_specs):
    
    _text = resolved_string
    bits = []

    if literal_texts[-1] != '' and _text.endswith(literal_texts[-1]):
        _text = _text[:-len(literal_texts[-1])]
        literal_texts = literal_texts[:-1]
        format_specs = format_specs[:-1]

    for i, literal_text in enumerate(literal_texts):
        if literal_text != '':
            if literal_text not in _text:
                raise ValueError(("Resolved string must match pattern. "
                                  "'{}' not found.".format(literal_text)))
            bit, _text = _text.split(literal_text, 1)
            if bit:
                bits.append(bit)
        elif i == 0:
            continue
        else:
            try:
                format_spec = _validate_format_spec(format_specs[i-1])
                bits.append(_text[0:format_spec])
                _text = _text[format_spec:]
            except:
                if i == len(format_specs) - 1:
                    format_spec = _validate_format_spec(format_specs[i])
                    bits.append(_text[:-format_spec])
                    bits.append(_text[-format_spec:])
                    _text = []
                else:
                    _validate_format_spec(format_specs[i-1])
    if _text:
        bits.append(_text)
    if len(bits) > len([fs for fs in format_specs if fs is not None]):
        bits = bits[1:]
    return bits
840170
def pattern_for(basename)
        extname = File.extname(basename)
        aliases = @reverse_aliases[extname]

        if aliases
          basename = File.basename(basename, extname)
          aliases  = [extname] + aliases
          aliases_pattern = aliases.map { |e| Regexp.escape(e) }.join("|")
          basename_re = Regexp.escape(basename) + "(?:#{aliases_pattern})"
        else
          basename_re = Regexp.escape(basename)
        end

        extension_pattern = extensions.map { |e| Regexp.escape(e) }.join("|")
        /^#{basename_re}(?:#{extension_pattern})*$/
      end
28668
def process_fields(self, fields):
		""""""
		
		result = []
		strip = ''.join(self.PREFIX_MAP)
		
		for field in fields:
			direction = self.PREFIX_MAP['']
			
			if field[0] in self.PREFIX_MAP:
				direction = self.PREFIX_MAP[field[0]]
				field = field.lstrip(strip)
			
			result.append((field, direction))
		
		return result
1054898
def convert_field_value(type_, value):
    """"""
    if value == ".":
        return None
    elif type_ in ("Character", "String"):
        if "%" in value:
            for k, v in record.UNESCAPE_MAPPING:
                value = value.replace(k, v)
        return value
    else:
        try:
            return _CONVERTERS[type_](value)
        except ValueError:
            warnings.warn(
                ("{} cannot be converted to {}, keeping as " "string.").format(value, type_),
                CannotConvertValue,
            )
            return value
1293501
def _strip_trailing_zeros(value):
        
        return list(
           reversed(
              list(itertools.dropwhile(lambda x: x == 0, reversed(value)))
           )
        )
163518
String getPattern() {
        final StringBuilder result = new StringBuilder();

        if (myPrefix != null) {
            result.append(myPrefix);
        }
        if (mySuffixes != null) {
            result.append("*");
            for (final Literal sub : mySuffixes) {
                result.append(sub);
                result.append("*");
            }
        }
        if (myPostfix != null) {
            result.append(myPostfix);
        }
        return result.toString();
    }
345876
def find_multiline_pattern(self, regexp, cursor, findflag):
        """"""
        pattern = to_text_string(regexp.pattern())
        text = to_text_string(self.toPlainText())
        try:
            regobj = re.compile(pattern)
        except sre_constants.error:
            return
        if findflag & QTextDocument.FindBackward:
            # Find backward
            offset = min([cursor.selectionEnd(), cursor.selectionStart()])
            text = text[:offset]
            matches = [_m for _m in regobj.finditer(text, 0, offset)]
            if matches:
                match = matches[-1]
            else:
                return
        else:
            # Find forward
            offset = max([cursor.selectionEnd(), cursor.selectionStart()])
            match = regobj.search(text, offset)
        if match:
            pos1, pos2 = match.span()
            fcursor = self.textCursor()
            fcursor.setPosition(pos1)
            fcursor.setPosition(pos2, QTextCursor.KeepAnchor)
            return fcursor
778773
function getRootFromPattern(pattern, callback) {
  isDirectory(pattern, function (error, data) {
    if (!data) {
      if (glob.hasMagic(pattern)) {
        callback(null, pattern.substring(0, pattern.indexOf("*")));
      } else {
        callback(null, path.dirname(pattern));
      }
    } else {
      callback(null, pattern);
    }
  });
}
658157
def find_reverse(str)
      index = items.reverse.index {|i| i.index < current_row && i.name.start_with?(str)} || items.reverse.index {|i| i.name.start_with? str}
      move_cursor items.size - index - 1 if index
    end
360586
def recoverString(self, strIndex, withIndex=False):
        '''
        
        '''
        retNums = []
        indices = []
        
        #figure out the first hop backwards
        currIndex = strIndex
        prevChar = self.getCharAtIndex(currIndex)
        currIndex = self.getOccurrenceOfCharAtIndex(prevChar, currIndex)
        
        #while we haven't looped back to the start
        while currIndex != strIndex:
            #update the string
            retNums.append(prevChar)
            if withIndex:
                indices.append(currIndex)
        
            #figure out where to go from here
            prevChar = self.getCharAtIndex(currIndex)
            currIndex = self.getOccurrenceOfCharAtIndex(prevChar, currIndex)
        
        for i in xrange(0, self.vcLen):
            if strIndex < self.endIndex[i]:
                retNums.append(i)
                break
                
        if withIndex:
            indices.append(strIndex)
        
        #reverse the numbers, convert to characters, and join them in to a single sequence
        ret = ''.join(self.numToChar[retNums[::-1]])
        
        #return what we found
        if withIndex:
            return (ret, indices[::-1])
        else:
            return ret
30076
private Object resolveReferenceValueOfField(FieldData field) {
        Object value = null;
        // Regardless of its path, the field references another resource.
        // fetch the field value (the path(s) to the referenced resource(s)) and resolve these resources.
        if (field.metaData.isCollectionType()) {
            String[] referencedResourcePaths = resolvePropertyTypedValue(field, String[].class);
            if (referencedResourcePaths != null) {
                value = createCollectionOfReferences(field, referencedResourcePaths);
            }
        } else {
            String referencedResourcePath = resolvePropertyTypedValue(field, String.class);
            if (referencedResourcePath != null) {
                if (field.metaData.isAppendPathPresentOnReference()) {
                    referencedResourcePath += field.metaData.getAppendPathOnReference();
                }
                value = resolveResource(referencedResourcePath, field.metaData.getType());
            }
        }
        return value;
    }
1332412
public function getRegexp()
    {
        $regexps = array();
        /** @var PrefixBasedResolverInterface $resolver */
        foreach ($this->resolvers as $resolver) {
            $regexp = preg_replace('/^\^/', '', substr($resolver->getRegexp(), 1, -1));
            if ($regexp !== '') {
                $regexps[] = $regexp;
            }
        }
        return '/^(' . implode('|', $regexps) . ')/';
    }
1222850
def get_sorted_fields(self):
        
        inf = float("inf")
        order = self.get_field_order()

        def field_cmp(field1, field2):
            _n1 = field1.getName()
            _n2 = field2.getName()
            _i1 = _n1 in order and order.index(_n1) + 1 or inf
            _i2 = _n2 in order and order.index(_n2) + 1 or inf
            return cmp(_i1, _i2)

        return sorted(self.get_fields(), cmp=field_cmp)
434245
function resolvePrefixedValues(snippetObj, isImportant, syntax) {
		var prefixes = [];
		var lookup = {};

		var parts = cssEditTree.findParts(snippetObj.value);
		parts.reverse();
		parts.forEach(function(p) {
			var partValue = p.substring(snippetObj.value);
			(findVendorPrefixes(partValue) || []).forEach(function(prefix) {
				if (!lookup[prefix]) {
					lookup[prefix] = snippetObj.value;
					prefixes.push(prefix);
				}

				lookup[prefix] = utils.replaceSubstring(lookup[prefix], '-' + prefix + '-' + partValue, p);
			});
		});

		return prefixes.map(function(prefix) {
			return transformSnippet(snippetObj.name + ':' + lookup[prefix], isImportant, syntax);
		});
	}
112601
def parse_fields(cls, formatter):
        ""
        if formatter is None: return []
        try:
            parse = list(string.Formatter().parse(formatter))
            return  set(f for f in list(zip(*parse))[1] if f is not None)
        except:
            raise SyntaxError("Could not parse formatter %r" % formatter)
1262353
def reverse_each
      return enum_for(__method__) unless block_given?
      each.to_a.reverse.each { |v| yield v }
    end
1221483
def _reversedict(d):
    
    return dict(list(zip(list(d.values()), list(d.keys()))))