Exemple #1
0
def extract_db_entry(key, data):
    # DB entries are feed.ContentStorageProto messages. First extract
    # the content_data contained within.
    text_proto = protoc_util.decode_proto(data, 'feed.ContentStorageProto',
                                          ROOT_DIR, CONTENT_STORAGE_PROTO)
    m = re.search(r"content_data: \"((?:\\\"|[^\"])*)\"", text_proto)
    raw_data = prototext().CUnescape(m.group(1))

    # Next, convert raw_data into a textproto. The DB key informs which message
    # is stored.
    result = protoc_util.decode_proto(raw_data, proto_message_from_db_key(key),
                                      ROOT_DIR, CONTENT_STORAGE_PROTO)
    return result
Exemple #2
0
def binary_to_text():
    with open(FLAGS.source_file, mode='rb') as file:
        value_text_proto = file.read()

    encoded = protoc_util.decode_proto(value_text_proto, FLAGS.message,
                                       FLAGS.chromium_path,
                                       COMPONENT_FEED_PROTO_PATH)

    with open(FLAGS.output_file, mode='w') as file:
        file.write(encoded)
Exemple #3
0
def binary_to_text():
  encoded = protoc_util.decode_proto(read_input(), FLAGS.message,
                                     FLAGS.chromium_path,
                                     COMPONENT_FEED_PROTO_PATH)

  if FLAGS.output_file:
    with open(FLAGS.output_file, mode='w') as file:
      file.write(encoded)
  else:
    print(encoded)
Exemple #4
0
def extract_db_entry(key, data):
    return protoc_util.decode_proto(data, 'feedstore.Record', ROOT_DIR,
                                    STORAGE_PROTO)