I want to switch from my personal baikal caldav/carddav server to a professionally hosted caldav/carddav server.
Why? I used baikal for several years without updating it. Now it was time to update from 0.2.x to 0.9.x, because I switched to a newer PHP version on my server, and the old baikal didn’t work woth the new PHP.
The update itself ran smoothly, but one thing changed: the server address. This is because of a change of directory structure in baikal.
This means that the clients connecting with my server need to change that address. And DAVx5 which I’m using on my android phones can’t do that. You have to make a new local server connection, so a new calendar and contact list. The old calendar and contact list will become redundant.
As the update process took weeks (my personal time is limited), the local copy of my data and the server data were not in sync any more. My idea was to just use the local data and replace the baikal data.
But I learnt: android only has a copy of the last 90 days or so.
As I don’t want to loose my old calendar data, things are getting complex now; the new path is:
- save my local data (there are android apps to do that, I used Calendar Backup by kfsoft.info and MCBackup by GLOBILE)
- export the data from baikal (I used the export function of thunderbird to do so)
- merge the two databases
And now I’m in the process of merging. I was looking for a software to do this, but found myself confronted with untrustful or costly software (or untrustful costly software).
As I’m starting to switch to python, why not do it myself? Parsing calendar .ics files seems not too complex (pure text file, simple structure). Should be possible with some recursive reading of the text file.
My code looked like this:
class CalendarNode:
data: dict()
def __init__(self, f):
line = f.readline()
if (line.startswith("BEGIN")):
self.data["subnode"] = CalendarNode(f)
else:
pass
# read lines from f, every line is a new key in self.data
From other languages it’s good practise to list all member variables in the class definition.
Not in python. I made data a class variable (without knowing it), which means every instance of CalendarNode connects to the same data-object. That’s not what I wanted.
I wanted an instance variable:
class CalendarNode:
def __init__(self, f):
self.data = dict()
line = f.readline()
if (line.startswith("BEGIN")):
self.data["subnode"] = CalendarNode(f)
else:
pass
# read lines from f, every line is a new key in self.data
I learned this from https://www.digitalocean.com/community/tutorials/understanding-class-and-instance-variables-in-python-3.
Schreibe einen Kommentar