|
|
@@ -10,7 +10,7 @@
|
|
|
# Pytho vobject: http://eventable.github.io/vobject/
|
|
|
|
|
|
# Version
|
|
|
-version=0.6
|
|
|
+version=0.7
|
|
|
|
|
|
# ChangeLog
|
|
|
# 2021-08-03 - 0.1 - multiple E-Mails with different types are working correctly
|
|
|
@@ -20,6 +20,7 @@ version=0.6
|
|
|
# - Address export fixing
|
|
|
# 2021-09-18 - 0.5 - bugfixing wrong table column mapping
|
|
|
# 2021-09-21 - 0.6 - changing table mapping, adding fix for phonenumber categories
|
|
|
+# 2021-10-14 - 0.7 - output to one file
|
|
|
|
|
|
import sqlite3
|
|
|
import vobject
|
|
|
@@ -44,7 +45,8 @@ def setDefault(var, default):
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Restore SailfishOS 3 Contacts', epilog='This script was written to restore SailfishOS 3 contacts as VCF files. To see additional information, visit: https://wiki.siningsoft.de/doku.php?id=sailfishos:projects:sailfish_contacts_rescue' )
|
|
|
parser.add_argument('--db','-d', required=True, help="Sqlite3 Database file usually /home/{nemo,defaultuser}/.local/share/system/Contacts/qtcontacts-sqlite/contacts.db")
|
|
|
-parser.add_argument('--output','-o',required=True, help="Output directory for vcf files")
|
|
|
+parser.add_argument('--output','-o',required=True, help="Output directory for vcf files.'")
|
|
|
+parser.add_argument('--outsinglefile','-f',required=False,help="If specefied, a file with that name is created under specified path, contianing all VCard entrie. E.G. your address book")
|
|
|
parser.add_argument('--avatars','-a',required=False, help='Avatar directory. If present otherwise we skip this block of avatars, means, no avatars at all')
|
|
|
parser.add_argument('--debug',action="store_true",help="debugging output to identify problems")
|
|
|
parser.add_argument('--version', action='version', version='%(prog)s ' + str(version))
|
|
|
@@ -52,10 +54,20 @@ args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
-SQLconn = sqlite3.connect(args.db)
|
|
|
-SQLconn.row_factory = sqlite3.Row #das macht den Unterschied und liefert die Werte
|
|
|
|
|
|
try:
|
|
|
+ SQLconn = sqlite3.connect(args.db)
|
|
|
+ SQLconn.row_factory = sqlite3.Row #das macht den Unterschied und liefert die Werte
|
|
|
+
|
|
|
+ # only this, when fullfile is specified:
|
|
|
+ if args.outsinglefile is not None:
|
|
|
+ outfile=args.outsinglefile.replace(" ","_").replace("(","").replace(")","").replace(",","")
|
|
|
+ ofile = open(outfile,'w')
|
|
|
+ osf=True
|
|
|
+ else:
|
|
|
+ osf=False
|
|
|
+
|
|
|
+
|
|
|
SQLContCur = SQLconn.cursor()
|
|
|
SQLContCur.execute('SELECT * FROM Contacts')
|
|
|
rows = SQLContCur.fetchall()
|
|
|
@@ -67,9 +79,13 @@ try:
|
|
|
contactID=setDefault(row['contactId'],"NA")
|
|
|
familyN=setDefault(row['lastName'],"NA")
|
|
|
givenN=setDefault(row['firstName'],"NA")
|
|
|
+ FullLabel=setDefault(row['displayLabel'],"NA")
|
|
|
|
|
|
- if familyN != None and givenN != None:
|
|
|
+ if (familyN == "NA" and givenN == "NA") and FullLabel != "NA":
|
|
|
+ fullN = FullLabel
|
|
|
+ else:
|
|
|
fullN = givenN + " " + familyN
|
|
|
+
|
|
|
|
|
|
#fullN=setDefault(row['displayLabel'],"NA")
|
|
|
cardfile=args.output + "/" + fullN.replace(" ","_").replace("(","").replace(")","").replace(".","").replace(",","") + ".vcf"
|
|
|
@@ -85,7 +101,7 @@ try:
|
|
|
|
|
|
|
|
|
print("exporting " + fullN + " to file " + cardfile)
|
|
|
- DEBUG(args.debug,"Contact " + str(fullN) + " family-name=" + str(familyN) + " given-name=" + str(givenN))
|
|
|
+ DEBUG(args.debug,"Contact " + str(fullN) + " family-name=" + str(familyN) + " given-name=" + str(givenN) + " displayLabel=" + str(FullLabel))
|
|
|
|
|
|
# abfrage der Adressdaten
|
|
|
SQLADRCur = SQLconn.cursor()
|
|
|
@@ -273,6 +289,13 @@ try:
|
|
|
f.write(vcf.serialize())
|
|
|
f.close()
|
|
|
|
|
|
+ if osf:
|
|
|
+ ofile.write(vcf.serialize())
|
|
|
+
|
|
|
+ # finally we close the general file
|
|
|
+ if osf:
|
|
|
+ ofile.close()
|
|
|
+
|
|
|
# hier brauchen wir einige eception handles -> wie bekommen wir die einzelnen exceptions heruas ?
|
|
|
#except:
|
|
|
#print("Error in executing SQL")
|