hello!
i have this problem with this code. I mean everything works just fine except i dont know how to change program to return me new value. in my program i had to make 2 functions. preberiKontakte() to get their names & id and izlusciOsebe(vrstica, kontakti) to get set of people on the picture.
and then i have to write down the programm to get dictionary of people that know each other depending on the pictures they were on together.
for example this is what my program does:
{'Ahmed': set(), 'Mustafa': set(), 'Abdulah ibn Husein': set(), 'Abdul': set(), 'Husein': set(), 'Osama': set(), 'Fadil': set(), 'Omar': set(), 'Jibril': set()}
that means that
now i would have to edit my program to get all the pairs of people that ever apeared on the picture together
so instead that i would get what i have above, i should get:
Osama Abdul
Abdul Osama
Osama Abdulah ibn Husein
Abdulah ibn Husein Osama
Osama Ahmed
Osama Mustafa
Ahmed Osama
Ahmed Mustafa
Mustafa Osama
Mustafa Ahmed
Abdulah ibn Husein Husein
Husein Abdulah ibn Husein
Ahmed Mustafa
Ahmed Jibril
and so on..
this shouldnt be too hard but i have already spend too much time on this and i have to move on with studying><
here are also some files if anyone would like to help me><
http://www.mediafire.com/file/8zrwyjdg8fyvad2/podatki-picasa2.zip
def preberiKontakte():
d = {}
for l in file("contacts.xml"):
if not l.startswith(" <contact id="):
continue
id = l[14:30]
ime = l[38:l.find("display")-2]
d[id] = ime
return d
def izlusciOsebe(vrstica, kontakti):
osebe = set()
for obraz in vrstica.strip().split(";"):
kje, id = obraz.split(",")
osebe.add(kontakti[id])
return osebe
kontakti=preberiKontakte()
znanci={}
f=file(".picasa.ini","r")
for i in f:
i.strip
if not i.startswith("faces=rect64"):
continue
osebe= izlusciOsebe(i,kontakti)
for oseba in osebe:
if oseba not in znanci:
znanci[oseba]=set()
znanci[oseba].update(osebe)
for oseba, znani in znanci.items():
znani.remove(oseba)
print znanci