Read a plist data from a string. Return the root object.
496806
def readPlistFromString(data):
    ''''''
    try:
        plistData = buffer(data)
    except TypeError, err:
        raise NSPropertyListSerializationException(err)
    dataObject, dummy_plistFormat, error = (
        NSPropertyListSerialization.
        propertyListFromData_mutabilityOption_format_errorDescription_(
            plistData, NSPropertyListMutableContainers, None, None))
    if dataObject is None:
        if error:
            error = error.encode('ascii', 'ignore')
        else:
            error = "Unknown error"
        raise NSPropertyListSerializationException(error)
    else:
        return dataObject
585639
def from_string(dir_string):
    '''

    '''
    dir_string = dir_string.upper()
    if dir_string == UP:
        return UP
    elif dir_string == DOWN:
        return DOWN
    elif dir_string == LEFT:
        return LEFT
    elif dir_string == RIGHT:
        return RIGHT
    else:
        raise InvalidDirectionError(dir_string)
326375
def read_from(value):
    """"""
    path = normalized_path(value)
    if not os.path.exists(path):
        raise argparse.ArgumentTypeError("%s is not a valid path." % path)
    LOG.debug("%s exists.", path)
    with open(path, 'r') as reader:
        read = reader.read()
    return read
523719
def read_string(self, len):
        """"""
        format = '!' + str(len) + 's'
        length = struct.calcsize(format)
        info = struct.unpack(format,
                self.data[self.offset:self.offset + length])
        self.offset += length
        return info[0]
600675
def from_data(cls, data):
        
        obj = cls()
        with contextlib.closing(BytesIO(data)) as file_handle:
            obj.load_file(file_handle)
        return obj
1300240
def readPlist(pathOrFile):
    """"""
    didOpen = False
    result = None
    if isinstance(pathOrFile, (bytes, unicode)):
        pathOrFile = open(pathOrFile, 'rb')
        didOpen = True
    try:
        reader = PlistReader(pathOrFile)
        result = reader.parse()
    except NotBinaryPlistException as e:
        try:
            pathOrFile.seek(0)
            result = None
            if hasattr(plistlib, 'loads'):
                contents = None
                if isinstance(pathOrFile, (bytes, unicode)):
                    with open(pathOrFile, 'rb') as f:
                        contents = f.read()
                else:
                    contents = pathOrFile.read()
                result = plistlib.loads(contents)
            else:
                result = plistlib.readPlist(pathOrFile)
            result = wrapDataObject(result, for_binary=True)
        except Exception as e:
            raise InvalidPlistException(e)
    finally:
        if didOpen:
            pathOrFile.close()
    return result
278643
def _parse(self, text, i):
        """"""

        m = self.start_dict_re.match(text, i)
        if m:
            parsed = m.group(0)
            i += len(parsed)
            return self._parse_dict(text, i)

        m = self.start_list_re.match(text, i)
        if m:
            parsed = m.group(0)
            i += len(parsed)
            return self._parse_list(text, i)

        m = self.value_re.match(text, i)
        if m:
            parsed = m.group(0)
            i += len(parsed)
            if hasattr(self.current_type, "read"):
                reader = self.current_type()
                # Give the escaped value to `read` to be symetrical with
                # `plistValue` which handles the escaping itself.
                value = reader.read(m.group(1))
                return value, i

            value = self._trim_value(m.group(1))

            if self.current_type in (None, dict, OrderedDict):
                self.current_type = self._guess_current_type(parsed, value)

            if self.current_type == bool:
                value = bool(int(value))  # bool(u'0') returns True
                return value, i

            value = self.current_type(value)

            return value, i

        m = self.hex_re.match(text, i)
        if m:
            from glyphsLib.types import BinaryData

            parsed, value = m.group(0), m.group(1)
            decoded = BinaryData.fromHex(value)
            i += len(parsed)
            return decoded, i
        else:
            self._fail("Unexpected content", text, i)
11947
def parse_plist(entry):
    """"""
    if is_leaf(entry):
        url = entry[KEY_URLSTRING]
        title = entry[KEY_URIDICTIONARY].get('title', url)
        yield (url, title)
    elif has_children(entry):
        for child in entry[KEY_CHILDREN]:
            for item in parse_plist(child):
                yield item
1240575
def from_string(cls, string):
        
        items = shlex.split(string, **cls.split_args)
        return cls(items)
1342736
def from_string(cls, string):
        """"""
        if string is None:
            string = ''

        if not isinstance(string, six.string_types):
            raise TypeError('string has to be a string type, got: {}'.format(type(string)))

        dictionary = {}
        tokens = [token.strip() for token in shlex.split(string)]

        def list_tuples(some_iterable):
            items, nexts = itertools.tee(some_iterable, 2)
            nexts = itertools.chain(itertools.islice(nexts, 1, None), [None])
            return list(zip(items, nexts))

        for token_current, token_next in list_tuples(tokens):

            # If current token starts with a dash, it is a value so we skip it
            if not token_current.startswith('-'):
                continue

            # If the next token is None or starts with a dash, the current token must be a flag, so the value is True
            if not token_next or token_next.startswith('-'):
                dictionary[token_current.lstrip('-')] = True

            # Otherwise the current token is an option with the next token being its value
            else:
                dictionary[token_current.lstrip('-')] = token_next

        return cls.from_dictionary(dictionary)
781451
def parse_contents(password_string)
      unpacked = password_string[/password: 0x([a-f0-9]+)/i, 1]

      password = if unpacked
        [unpacked].pack("H*")
      else
        password_string[/password: "(.+)"/m, 1]
      end

      password ||= ""

      parsed = Plist.parse_xml(password.force_encoding("".encoding))
      if parsed and parsed["NOTE"]
        parsed["NOTE"]
      else
        password
      end
    end
1109
def read_str(delim=',', *lines):
    """"""

    data = []
    for line in lines:
        com = parse_line(line, delim)
        data.append(com)
    return data
899919
def read_file_to_string(path):
  """"""
  bytes_string = tf.gfile.Open(path, 'r').read()
  return dlutils.python_portable_string(bytes_string)
1220231
def parse(cls, string):
		'''
			
		'''
		obj, i = cls.match(string, 0)
		if i != len(string):
			raise Exception("Could not parse '" + string + "' beyond index " + str(i))
		return obj
404518
def loads(astring):
        """"""
        try:
            return pickle.loads(lzma.decompress(astring))
        except lzma.LZMAError as e:
            raise SerializerError(
                'Cannot decompress object ("{}")'.format(str(e))
            )
        except pickle.UnpicklingError as e:
            raise SerializerError(
                'Cannot restore object ("{}")'.format(str(e))
            )
582139
def parse_root(raw):
    ""
    if sys.version < '3':
        fp = StringIO(raw)
    else:
        fp = BytesIO(raw.encode('UTF-8'))
    for event, element in etree.iterparse(fp, events=('start',)):
        return (element.tag, element.attrib)
130202
def readString(self):
        
        resultStr = ""
        while self.data[self.offset] != "\x00":
            resultStr += self.data[self.offset]
            self.offset += 1
        return resultStr