~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to protobuf/files/examples/list_people.py

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/python
2
 
 
3
 
# See README.txt for information and build instructions.
4
 
 
5
 
import addressbook_pb2
6
 
import sys
7
 
 
8
 
# Iterates though all people in the AddressBook and prints info about them.
9
 
def ListPeople(address_book):
10
 
  for person in address_book.person:
11
 
    print "Person ID:", person.id
12
 
    print "  Name:", person.name
13
 
    if person.HasField('email'):
14
 
      print "  E-mail address:", person.email
15
 
 
16
 
    for phone_number in person.phone:
17
 
      if phone_number.type == addressbook_pb2.Person.MOBILE:
18
 
        print "  Mobile phone #:",
19
 
      elif phone_number.type == addressbook_pb2.Person.HOME:
20
 
        print "  Home phone #:",
21
 
      elif phone_number.type == addressbook_pb2.Person.WORK:
22
 
        print "  Work phone #:",
23
 
      print phone_number.number
24
 
 
25
 
# Main procedure:  Reads the entire address book from a file and prints all
26
 
#   the information inside.
27
 
if len(sys.argv) != 2:
28
 
  print "Usage:", sys.argv[0], "ADDRESS_BOOK_FILE"
29
 
  sys.exit(-1)
30
 
 
31
 
address_book = addressbook_pb2.AddressBook()
32
 
 
33
 
# Read the existing address book.
34
 
f = open(sys.argv[1], "rb")
35
 
address_book.ParseFromString(f.read())
36
 
f.close()
37
 
 
38
 
ListPeople(address_book)