parse a scene.name message
512210
def scene_name(frames):
        """"""
        # "scene.name" <scene_id> <config>
        reader = MessageReader(frames)
        results = reader.string("command").uint32("scene_id").string("name").assert_end().get()
        if results.command != "scene.name":
            raise MessageParserError("Command is not 'scene.name'")
        return (results.scene_id, results.name)
1270410
def _parse_proplist(data):
    '''
    
    '''
    out = {}
    for line in data.split("\n"):
        line = re.split(r"\s+", line, 1)
        if len(line) == 2:
            out[line[0]] = line[1]

    return out
756463
def scene_color(frames):
        """"""
        # "scene.color" <scene_id> <color>
        reader = MessageReader(frames)
        results = reader.string("command").uint32("scene_id").uint8_3("color").assert_end().get()
        if results.command != "scene.color":
            raise MessageParserError("Command is not 'scene.color'")
        return (results.scene_id, np.array([results.color[0]/255, results.color[1]/255, results.color[2]/255]))
1293926
def get_scene(self):
        """"""
        if self._scene is None:
            parent = getattr(self, "parent", None)
            if parent:
                self._scene = parent.get_scene()
        return self._scene
1337942
def ParseFromString(self, text, message):
    """"""
    if not isinstance(text, str):
      text = text.decode('utf-8')
    return self.ParseLines(text.split('\n'), message)
437600
def parse_event_name(name):
    
    try:
        app, event = name.split('.')
        return '{}.{}'.format(app, EVENTS_MODULE_NAME), event
    except ValueError:
        raise InvalidEventNameError(
            (u'The name "{}" is invalid. '
             u'Make sure you are using the "app.KlassName" format'
             ).format(name))
76779
def _landsat_parse_scene_id(sceneid):
    
    pre_collection = r"(L[COTEM]8\d{6}\d{7}[A-Z]{3}\d{2})"
    collection_1 = r"(L[COTEM]08_L\d{1}[A-Z]{2}_\d{6}_\d{8}_\d{8}_\d{2}_(T1|T2|RT))"
    if not re.match("^{}|{}$".format(pre_collection, collection_1), sceneid):
        raise InvalidLandsatSceneId("Could not match {}".format(sceneid))

    precollection_pattern = (
        r"^L"
        r"(?P<sensor>\w{1})"
        r"(?P<satellite>\w{1})"
        r"(?P<path>[0-9]{3})"
        r"(?P<row>[0-9]{3})"
        r"(?P<acquisitionYear>[0-9]{4})"
        r"(?P<acquisitionJulianDay>[0-9]{3})"
        r"(?P<groundStationIdentifier>\w{3})"
        r"(?P<archiveVersion>[0-9]{2})$"
    )

    collection_pattern = (
        r"^L"
        r"(?P<sensor>\w{1})"
        r"(?P<satellite>\w{2})"
        r"_"
        r"(?P<processingCorrectionLevel>\w{4})"
        r"_"
        r"(?P<path>[0-9]{3})"
        r"(?P<row>[0-9]{3})"
        r"_"
        r"(?P<acquisitionYear>[0-9]{4})"
        r"(?P<acquisitionMonth>[0-9]{2})"
        r"(?P<acquisitionDay>[0-9]{2})"
        r"_"
        r"(?P<processingYear>[0-9]{4})"
        r"(?P<processingMonth>[0-9]{2})"
        r"(?P<processingDay>[0-9]{2})"
        r"_"
        r"(?P<collectionNumber>\w{2})"
        r"_"
        r"(?P<collectionCategory>\w{2})$"
    )

    meta = None
    for pattern in [collection_pattern, precollection_pattern]:
        match = re.match(pattern, sceneid, re.IGNORECASE)
        if match:
            meta = match.groupdict()
            break

    if meta.get("acquisitionJulianDay"):
        date = datetime.datetime(
            int(meta["acquisitionYear"]), 1, 1
        ) + datetime.timedelta(int(meta["acquisitionJulianDay"]) - 1)

        meta["date"] = date.strftime("%Y-%m-%d")
    else:
        meta["date"] = "{}-{}-{}".format(
            meta["acquisitionYear"], meta["acquisitionMonth"], meta["acquisitionDay"]
        )

    collection = meta.get("collectionNumber", "")
    if collection != "":
        collection = "c{}".format(int(collection))

    meta["key"] = os.path.join(
        collection, "L8", meta["path"], meta["row"], sceneid, sceneid
    )

    meta["scene"] = sceneid

    return meta
1214569
def parse_option(self, option, block_name, message):
        

        if option == 'show':
            option = 'start_' + option

        key = option.split('_', 1)[0]
        self.messages[key] = message
168918
def parse_name(name):
    
    inverted, op = False, OP_EQ
    if name is not None:
        for op_ in (OP_NIN, OP_IN, OP_NOT, OP_LIKE):
            if name.endswith(op_):
                op = op_
                name = name[:len(name) - len(op)]
                break
        if name.startswith('!'):
            inverted = True
            name = name[1:]
    return name, inverted, op
983841
function parseName(name) {
  if (name) {
    const arr = name.split('.')
    const len = arr.length

    if (len > 2) {
      return arr.slice(0, -1).join('.')
    }
    else if (len === 2 || len === 1) {
      return arr[0]
    }
  }
  return name
}
645028
def parse_rec(filename):
    
    tree = ET.parse(filename)
    objects = []
    for obj in tree.findall('object'):
        obj_struct = {}
        obj_struct['name'] = obj.find('name').text
        obj_struct['pose'] = obj.find('pose').text
        obj_struct['truncated'] = int(obj.find('truncated').text)
        obj_struct['difficult'] = int(obj.find('difficult').text)
        bbox = obj.find('bndbox')
        obj_struct['bbox'] = [int(bbox.find('xmin').text) - 1,
                              int(bbox.find('ymin').text) - 1,
                              int(bbox.find('xmax').text) - 1,
                              int(bbox.find('ymax').text) - 1]
        objects.append(obj_struct)

    return objects
1127322
def __parse_names():
    ''''''
    filename = get_file('names.tsv.gz')

    with io.open(filename, 'r', encoding='cp1252') as textfile:
        next(textfile)

        for line in textfile:
            tokens = line.strip().split('\t')
            chebi_id = int(tokens[1])

            if chebi_id not in __ALL_NAMES:
                __ALL_NAMES[chebi_id] = []

            # Append Name:
            nme = Name(tokens[4],
                       tokens[2],
                       tokens[3],
                       tokens[5] == 'T',
                       tokens[6])

            __ALL_NAMES[chebi_id].append(nme)
679425
def parse_to_instance(self, title_of_name_and_default):
        """"""
        result = {}
        for title, name_and_default in title_of_name_and_default.items():
            logger.debug((title, name_and_default))
            result[title] = opts = []
            for opt_str, default in name_and_default:
                logger.debug('%s:%r' % (opt_str, default))
                opt, repeat = self.parse_opt_str(opt_str)
                opt.default = default
                opt_ins = Optional(opt, repeat=repeat)
                for name in opt.names:
                    self.name_2_instance[name] = opt_ins
                opts.append(opt_ins)

        return result
1157101
def get_view_name(namespace, view):
    
    name = ""
    if namespace != "":
        name = namespace + "_"
    return sanitize(name + view.name)
911638
def parse_filename(filename):
    

    _patterns = patterns.get_expressions()
    result = {}

    for cmatcher in _patterns:
        match = cmatcher.match(filename)
        if match:
            namedgroups = match.groupdict().keys()

            result['pattern'] = cmatcher.pattern
            result['series_name'] = match.group('seriesname')
            result['season_number'] = _get_season_no(match, namedgroups)
            result['episode_numbers'] = _get_episodes(match, namedgroups)
            break
    else:
        result = None

    return result
135593
def _parse_nicknameinuse(client, command, actor, args):
    
    nick, _, _ = args.rpartition(" ")
    client.dispatch_event("NICKNAMEINUSE", nick)
788178
def publish_scene_name(self, scene_id, name):
        """"""
        self.sequence_number += 1
        self.publisher.send_multipart(msgs.MessageBuilder.scene_name(self.sequence_number, scene_id, name))
        return self.sequence_number