Return |_Marker| or subclass instance appropriate for marker at *offset*
    in *stream* having *marker_code*.
764292
def _MarkerFactory(marker_code, stream, offset):
    
    if marker_code == JPEG_MARKER_CODE.APP0:
        marker_cls = _App0Marker
    elif marker_code == JPEG_MARKER_CODE.APP1:
        marker_cls = _App1Marker
    elif marker_code in JPEG_MARKER_CODE.SOF_MARKER_CODES:
        marker_cls = _SofMarker
    else:
        marker_cls = _Marker
    return marker_cls.from_stream(stream, marker_code, offset)
1147839
def _name_value_to_bson(name, value, check_keys, opts,
                        in_custom_call=False,
                        in_fallback_call=False):
    """"""
    # First see if the type is already cached. KeyError will only ever
    # happen once per subtype.
    try:
        return _ENCODERS[type(value)](name, value, check_keys, opts)
    except KeyError:
        pass

    # Second, fall back to trying _type_marker. This has to be done
    # before the loop below since users could subclass one of our
    # custom types that subclasses a python built-in (e.g. Binary)
    marker = getattr(value, "_type_marker", None)
    if isinstance(marker, int) and marker in _MARKERS:
        func = _MARKERS[marker]
        # Cache this type for faster subsequent lookup.
        _ENCODERS[type(value)] = func
        return func(name, value, check_keys, opts)

    # Third, check if a type encoder is registered for this type.
    # Note that subtypes of registered custom types are not auto-encoded.
    if not in_custom_call and opts.type_registry._encoder_map:
        custom_encoder = opts.type_registry._encoder_map.get(type(value))
        if custom_encoder is not None:
            return _name_value_to_bson(
                name, custom_encoder(value), check_keys, opts,
                in_custom_call=True)

    # Fourth, test each base type. This will only happen once for
    # a subtype of a supported base type. Unlike in the C-extensions, this
    # is done after trying the custom type encoder because checking for each
    # subtype is expensive.
    for base in _BUILT_IN_TYPES:
        if isinstance(value, base):
            func = _ENCODERS[base]
            # Cache this type for faster subsequent lookup.
            _ENCODERS[type(value)] = func
            return func(name, value, check_keys, opts)

    # As a last resort, try using the fallback encoder, if the user has
    # provided one.
    fallback_encoder = opts.type_registry._fallback_encoder
    if not in_fallback_call and fallback_encoder is not None:
        return _name_value_to_bson(
            name, fallback_encoder(value), check_keys, opts,
            in_fallback_call=True)

    raise InvalidDocument(
        "cannot encode object: %r, of type: %r" % (value, type(value)))
645986
def getDataMap(self, intype, pos, name, offset = 0):
        
        if intype == "input":
            vector = self.inputs
        elif intype == "target":
            vector = self.targets
        else:
            raise AttributeError("invalid map type '%s'" % intype)
        return vector[pos][offset:offset+self[name].size]
325396
def get_contained_extras(marker):
    
    if not marker:
        return set()
    marker = Marker(str(marker))
    extras = set()
    _markers_collect_extras(marker._markers, extras)
    return extras
442104
def marker_split(block):
    
    marker = None
    value = []

    for line in block.split('\n'):
        line = line.strip()
        if line.startswith('\\_'):
            continue  # we simply ignore SFM header fields
        match = MARKER_PATTERN.match(line)
        if match:
            if marker:
                yield marker, '\n'.join(value)
            marker = match.group('marker')
            value = [line[match.end():]]
        else:
            value.append(line)
    if marker:
        yield marker, ('\n'.join(value)).strip()
707767
def to_marker(marker):
        
        from sevenbridges.models.marker import Marker
        if not marker:
            raise SbgError('Marker is required!')
        elif isinstance(marker, Marker):
            return marker.id
        elif isinstance(marker, six.string_types):
            return marker
        else:
            raise SbgError('Invalid marker parameter!')
1226932
def tmarker_(self, lat, long, text, pmap,
                 color=None, icon=None, style=None):
        
        try:
            xmap = self._marker(
                lat, long, text, pmap, color, icon, True, style)
            return xmap
        except Exception as e:
            self.err(e, self.tmarker_, "Can not get text marker")
31480
function getMarker(node, markerType, parentNode) {
  var id = referenceToId(svgAttr(node, markerType));

  return domQuery('marker#' + id, parentNode || document);
}
1370341
function(ln, offset) {
  var rest = ln.slice(offset);
  var match;
  var spaces_after_marker;
  var data = {};
  if (rest.match(reHrule)) {
    return null;
  }
  if ((match = rest.match(/^[*+-]( +|$)/))) {
    spaces_after_marker = match[1].length;
    data.type = 'Bullet';
    data.bullet_char = match[0].charAt(0);

  } else if ((match = rest.match(/^(\d+)([.)])( +|$)/))) {
    spaces_after_marker = match[3].length;
    data.type = 'Ordered';
    data.start = parseInt(match[1]);
    data.delimiter = match[2];
  } else {
    return null;
  }
  var blank_item = match[0].length === rest.length;
  if (spaces_after_marker >= 5 ||
      spaces_after_marker < 1 ||
      blank_item) {
        data.padding = match[0].length - spaces_after_marker + 1;
  } else {
        data.padding = match[0].length;
  }
  return data;
}
969774
def from_stream(cls, stream):
        
        marker_parser = _MarkerParser.from_stream(stream)
        markers = []
        for marker in marker_parser.iter_markers():
            markers.append(marker)
            if marker.marker_code == JPEG_MARKER_CODE.SOS:
                break
        return cls(markers)
241389
def _correct_splitlines_in_headers(markers, lines):
    
    updated_markers = ""
    i = 0
    in_header_block = False
    for m in markers:
        # Only set in_header_block flag when we hit an 's' and line is a header
        if m == 's':
            if not in_header_block:
                if bool(re.search(RE_HEADER, lines[i])):
                    in_header_block = True
            else:
                if QUOT_PATTERN.match(lines[i]):
                    m = 'm'
                else:
                    m = 't'

        # If the line is not a header line, set in_header_block false.
        if not bool(re.search(RE_HEADER, lines[i])):
            in_header_block = False

        # Add the marker to the new updated markers string.
        updated_markers += m
        i += 1

    return updated_markers
109146
function Parser_findASCII85DecodeInlineStreamEnd(stream) {
      var TILDE = 0x7E, GT = 0x3E;
      var startPos = stream.pos, ch, length;
      while ((ch = stream.getByte()) !== -1) {
        if (ch === TILDE && stream.peekByte() === GT) {
          stream.skip();
          break;
        }
      }
      length = stream.pos - startPos;
      if (ch === -1) {
        warn('Inline ASCII85Decode image stream: ' +
             'EOD marker not found, searching for /EI/ instead.');
        stream.skip(-length); // Reset the stream position.
        return this.findDefaultInlineStreamEnd(stream);
      }
      this.inlineStreamSkipEI(stream);
      return length;
    }
1260757
def offset(self, offset):
        
        query = self._copy()
        query._offset = offset
        return query
252388
def _parse_reserved_marker(self, fptr):
        
        the_id = '0x{0:x}'.format(self._marker_id)
        segment = Segment(marker_id=the_id, offset=self._offset, length=0)
        return segment
1222794
def marker_for_line(self, line):
        
        block = self.editor.document().findBlockByNumber(line)
        try:
            return block.userData().messages
        except AttributeError:
            return []
917815
def _get_trailing_whitespace(marker, s):
    
    suffix = ''
    start = s.index(marker) + len(marker)
    i = start
    while i < len(s):
        if s[i] in ' \t':
            suffix += s[i]
        elif s[i] in '\r\n':
            suffix += s[i]
            if s[i] == '\r' and i + 1 < len(s) and s[i + 1] == '\n':
                suffix += s[i + 1]
            break
        else:
            break
        i += 1
    return suffix
55684
function marker(spec) {
        var elt = window.document.createElement("div");
        elt.className = spec;
        return elt;
    }