Parse a DATA section until : or \n but exclude : in a string part.
        e.g.:
            10 DATA 1,"FOO:BAR",2:PRINT "NO DATA"
766762
def _parse_data(self, line, old_data=""):
        
        log.debug("*** parse DATA: >>>%r<<< old data: >>>%r<<<", line, old_data)
        parts = self.regex_split_data.split(line, maxsplit=1)
        if len(parts) == 1:  # end
            return old_data + parts[0], None

        pre, match, post = parts
        log.debug("\tpre: >>>%r<<<", pre)
        pre = old_data + pre
        log.debug("\tmatch: >>>%r<<<", match)
        log.debug("\tpost: >>>%r<<<", post)
        if match == ":":
            return old_data, match + post
        elif match == '"':
            string_part, rest = self._parse_string(post)
            return self._parse_data(rest, old_data=pre + match + string_part)

        raise RuntimeError("Wrong Reg.Exp.? match is: %r" % match)
1268416
def _string_parser(strip_whitespace):
    """"""
    def _parse_string_value(element_text, _state):
        if element_text is None:
            value = ''
        elif strip_whitespace:
            value = element_text.strip()
        else:
            value = element_text

        return value

    return _parse_string_value
668121
def text_till(self, strings, keep_index=False):
        """"""
        if isinstance(strings, str):
            strings = [strings]

        original_index = self.index

        text = ""
        matched_string = ""

        while self.more:
            test_against = self.characters(len(max(strings, key=len)))
            for string in strings:
                if string.startswith("^"):
                    if test_against[0] in (" ", "\t", "\n", ")", "(") and test_against[1:].startswith(string[1:]):
                        matched_string = string
                        break
                if test_against.startswith(string):
                    matched_string = string
                    break

            if matched_string:
                break

            text += self.pop()

        self += 1

        if keep_index:
            self.index = original_index

        return (text, matched_string)
884462
private static int skipEndOfLine(String text, int offset)
   {
      char c;
      boolean finished = false;

      while (finished == false)
      {
         c = text.charAt(offset);
         switch (c)
         {
            case ' ': // found that OBJDATA could be followed by a space the EOL
            case '\r':
            case '\n':
            {
               ++offset;
               break;
            }

            case '}':
            {
               offset = -1;
               finished = true;
               break;
            }

            default:
            {
               finished = true;
               break;
            }
         }
      }

      return (offset);
   }
97983
def format_data(data):
    
    if data is None:
        return None
    return u":".join([u"{:02x}".format(ord(c)) for c in data])
968759
def get_string_from_data(self, offset, data):
        """"""
        s = self.get_bytes_from_data(offset, data)
        end = s.find(b'\0')
        if end >= 0:
            s = s[:end]
        return s
690105
def _parse_depot_section(f):
    
    depots = []

    for line in f:
        line = strip(line)
        if line == '-1' or line == 'EOF': # End of section
            break
        else:
            depots.append(line)

    if len(depots) != 1:
        raise ParseException('One and only one depot is supported')

    return int(depots[0])
890300
def skip_read_line(fd, no_eof=False):
    
    ls = ''
    while 1:
        try:
            line = fd.readline()

        except EOFError:
            break

        if not line:
            if no_eof:
                raise EOFError

            else:
                break

        ls = line.strip()
        if ls and (ls[0] != '#'):
            break

    return ls
1356379
def newline_before_nonwhitespace(string)
      offset = -2
      while /\S/.match(string[offset]).nil?
        return true if string[offset] == "\n"
        offset -= 1
      end
      false
    end
1291596
def _parse_limit(self, limit):
        
        if limit is None:
            return None

        limit_parsed = {
            "include": [],
            "exclude": []
        }
        elems = limit.split(":")
        for elem in elems:
            if elem.startswith('!'):
                limit_parsed['exclude'].append(elem[1:])
            else:
                limit_parsed['include'].append(elem)

        return limit_parsed
784536
def parse_data_shape(data_shape_str):
    """"""
    ds = data_shape_str.strip().split(',')
    if len(ds) == 1:
        data_shape = (int(ds[0]), int(ds[0]))
    elif len(ds) == 2:
        data_shape = (int(ds[0]), int(ds[1]))
    else:
        raise ValueError("Unexpected data_shape: %s", data_shape_str)
    return data_shape
668920
def parse(data, datafile):
    """"""
    data._last_travel = [0, [0]]  # x and verbs used by section 3

    while True:
        section_number = int(datafile.readline())
        if not section_number:  # no further sections
            break
        store = globals().get('section%d' % section_number)
        while True:
            fields = [ (int(field) if field.lstrip('-').isdigit() else field)
                       for field in datafile.readline().strip().split('\t') ]
            if fields[0] == -1:  # end-of-section marker
                break
            store(data, *fields)

    del data._last_travel  # state used by section 3
    del data._object       # state used by section 5

    data.object_list = sorted(set(data.objects.values()), key=attrgetter('n'))
    #data.room_list = sorted(set(data.rooms.values()), key=attrgetter('n'))
    for obj in data.object_list:
        name = obj.names[0]
        if hasattr(data, name):
            name = name + '2'  # create identifiers like ROD2, PLANT2
        setattr(data, name, obj)

    return data
1237258
def parse_pref_string(arduino_output)
      lines = arduino_output.split("\n").select { |l| l.include? "=" }
      ret = lines.each_with_object({}) do |e, acc|
        parts = e.split("=", 2)
        acc[parts[0]] = parts[1]
        acc
      end
      ret
    end
1109
def read_str(delim=',', *lines):
    """"""

    data = []
    for line in lines:
        com = parse_line(line, delim)
        data.append(com)
    return data
392152
function parseAwsIni(ini) {
  var section,
      out = Object.create(null),
      re = /^\[([^\]]+)\]\s*$|^([a-z_]+)\s*=\s*(.+?)\s*$/,
      lines = ini.split(/\r?\n/)

  lines.forEach(function(line) {
    var match = line.match(re)
    if (!match) return
    if (match[1]) {
      section = match[1]
      if (out[section] == null) out[section] = Object.create(null)
    } else if (section) {
      out[section][match[2]] = match[3]
    }
  })

  return out
}
762305
def preprocess(str)
      str.gsub!(/late/i, '')
      str.gsub!(/early/i, '')
      str.strip!
      str.gsub!(/\s+/, ' ')
      str.gsub!('0s', 'x') if str.match(/^[1-9]+0s$/)
      str.gsub!('-', 'x') if str.match(/^[1-9]+\-+$/)
      str
    end
342506
def read_until(stream, delimiter, max_bytes=16):
    

    buf = bytearray()
    delim_len = len(delimiter)

    while len(buf) < max_bytes:
        c = stream.read(1)

        if not c:
            break

        buf += c
        if buf[-delim_len:] == delimiter:
            return bytes(buf[:-delim_len])