-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phonebook - same names are merged, although different numbers #55
Comments
Thanks for reporting! That's because get_all_names() returns a dictionary not assuming that a single phonebook may hold identical names. Since get_all_numbers() works on top of get_all_names() duplicates are also overwritten there. A quick and dirty solution can be to return a list of tuples by inheriting from FritzPhonebook and providing just a get_all_name_numbers()-method:
May be that's a candidate for one of the next releases to add it to FritzPhonebook directly. |
Jup, I tried, and that solved it. Thanks! |
Hi kbr, I plan to include fritzconnection soon into my project ( https://github.com/bufemc/a1-fritzbox ) to use the phonebook and add entries (see my other issue, I already provided a code snippet to do so). I had the idea that there is a solution where you can still use a dictionary: instead of
Otherwise a simple list should do the job (each item would be a dict). I guess most lists are not that big, so the effort should not become an issue ( https://wiki.python.org/moin/TimeComplexity ).
|
I created a PR ( #56 ) with this new "master method" (see above), and tried to be backward compatible, so the old methods
still have the same behavior. Except that (as they use this method) if there are duplicated names in the phonebook, the first entry is returned as "name", 2nd "name_" and 3rd "name__" etc. It's maybe not the best solution but easier to handle than "name", "name (2)", "name (3)". There is a new, but optional parameter (no worries, default to previous behavior): which just removes internal entries like (German) "Wecker", "Sammelruf" and so on. So this PR fixes not only this issue ( 55 ), but also #53 Further thoughts: For now get_all_contacts is the only method returning (/exposing) also the contact.uniqueid (missing in both other methods). Why is this important? If you want to update an entry in the phonebook (in the future), you should use this id as reference only. Example: You rename the contact with (modified by code above) name="Gewinnspiel_" to name="Gewinnspiel Hampelmann-Verlag", then use something (future enhancement) like
which just and only uses the contact.uniqueid to "find" the meant record in the phonebook. |
As said I maintain a phonebook for cold calls. Sometimes, I will just use similar or even equal names, because it's just gambling 1,2,3.. so e.g. I have these items:
Gewinnspiel ['02212928xxx']
Gewinnspiel ['0892213xxx']
But both methods:
contacts = fp.get_all_names(phonebook_id)
contacts = fp.get_all_numbers(phonebook_id)
will just print out the latter one:
Gewinnspiel ['0892213xxx']
Like all the same named before are overwritten by the last one. If I change one of the two items in the Fritzbox, e.g. to Gewinnspiel1.. then it works and I get printed them both.
As I created 4 issues now let me be clear: I am a big fan of this tool set! I just want to document any strange behavior, or give incentives what could be improved.
The text was updated successfully, but these errors were encountered: