Coder Social home page Coder Social logo

ab4py's Introduction

AB4Py python module for working with MacOS/OS X Address Book

Needed the Python to Objective-C bridge library PyObjC.

Actual version 8.1 was released on 2021-11-29

Installing or upgrading PyObjC using pip is easy:

$ pip install -U pyobjc

=======

This module was verified with python 3.8. In the December 4, 2021 issue has lost support for python 2.7. If you need to use Python 2.7 you can clone previous issue. The comments in the code have been brought in line with PEP 257. PyCharm with virtual environment was used as IDE. However, it is run in an external terminal in order to comply with macOS contact access security policies.

Special thanks to Vladimir Litovko and Eugene Prusakov for testing, tips and support.

Using function from AddressBook module:

Getting reference on Address Book

book = ABGetSharedAddressBook()
book = AddressBook.ABAddressBook.sharedAddressBook()

Getting reference on Address Book

book = ABGetSharedAddressBook()
book = AddressBook.ABAddressBook.sharedAddressBook()

Getting reference on Login Person

me = ABGetMe(book)

Creating of new person record

new_person = ABPersonCreate()

Get properties of persons record in accordance with key

RefPerson.valueForProperty_(kABMiddleNameProperty)

Create MultiValue record

emails = ABMultiValueCreateMutable()
phones = ABMultiValueCreateMutable()
addresses = ABMultiValueCreateMutable()

Template for address record

adr_tmpl['City'] = "Москва"
adr_tmpl['Country'] = 'Россия'
adr_tmpl['Street'] = "Тупик нечистой силы, 13"
adr_tmpl['ZIP'] = "123123"

Insert element of MultiValue record

ABMultiValueInsert(emails,"[email protected]", ad_label_work, 0, None)
ABMultiValueInsert(phones,"+7(985)999-99-99", ad_label_work, 0, None)
ABMultiValueInsert(new_address,adr_tmpl, ad_label_work, 0, None)

Add MultiValue record to the Personal record

ABRecordSetValue(new_person,kABAddressProperty,new_address)
ABRecordSetValue(new_person,kABEmailProperty,emails)
ABRecordSetValue(new_person,kABPhoneProperty,phones)

Add new_person record to address book

ABAddRecord(book, new_person)

Save address book

ABSave(book)

Function in this module:

SearchPersonByName(Addr_book, Name)
GetFullNamePerson(RefPerson)
GetJobDataPerson(RefPerson)
GetPhonesPerson(RefPerson)
GetEmailsPerson(RefPerson)
GetAddressesPerson(RefPerson)

SetNewPersonRecord(LastName, FirstName='', MiddleName='')
SetJobName(RefPerson, Organization, JobTitle ='', Department='')
FormingPersonalRecord(record_ar, Organization = '')

print_person_date(RefPerson)
rus_phone_numb_norm(ph_numb)

==========

You can use it as separete shell application

Usage : AB4Py.py -[key]
    -m information about login person
    -f 'Name' searching person by name
    -i 'csv.file' 'Organization' - import records to Address book from .csv file
    and setting organsations name for them
    
    Format of csv.file describs in the list header_file

ab4py's People

Contributors

andrewglushchenko avatar andrey4gl avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.