Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

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