def _parse_hstore(hstore_str):
 result = {}
 pos = 0
 pair_match = HSTORE_PAIR_RE.match(hstore_str)
 while (pair_match is not None):
  key = pair_match.group('key').replace('\\"', '"').replace('\\\\', '\\')
  if pair_match.group('value_null'):
   value = None
  else:
   value = pair_match.group('value').replace('\\"', '"').replace('\\\\', '\\')
  result[key] = value
  pos += pair_match.end()
  delim_match = HSTORE_DELIMITER_RE.match(hstore_str[pos:])
  if (delim_match is not None):
   pos += delim_match.end()
  pair_match = HSTORE_PAIR_RE.match(hstore_str[pos:])
 if (pos != len(hstore_str)):
  raise ValueError(_parse_error(hstore_str, pos))
 return result

def _parse_hstore ( hstore_str ) : result = { } pos = 0 pair_match = HSTORE_PAIR_RE . match ( hstore_str ) while ( pair_match is not None ) : key = pair_match . group ( 'key' ) . replace ( '\\"' , '"' ) . replace ( '\\\\' , '\\' ) if pair_match . group ( 'value_null' ) : value = None else : value = pair_match . group ( 'value' ) . replace ( '\\"' , '"' ) . replace ( '\\\\' , '\\' ) result [ key ] = value pos += pair_match . end ( ) delim_match = HSTORE_DELIMITER_RE . match ( hstore_str [ pos : ] ) if ( delim_match is not None ) : pos += delim_match . end ( ) pair_match = HSTORE_PAIR_RE . match ( hstore_str [ pos : ] ) if ( pos != len ( hstore_str ) ) : raise ValueError ( _parse_error ( hstore_str , pos ) ) return result
parse an hstore from its literal string representation .