2021-09-30 15:19:29 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import habitmove.schema as schema
|
|
|
|
import habitmove.habits as habits
|
|
|
|
import habitmove.repetitions as rep
|
|
|
|
import habitmove.nomie as nomie
|
2021-12-02 22:08:58 +00:00
|
|
|
from habitmove.nomiedata import NomieImport
|
2021-09-30 15:19:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2021-12-02 22:08:58 +00:00
|
|
|
def migrate(data: NomieImport):
|
2021-09-30 15:19:29 +00:00
|
|
|
db = schema.migrate("output.db")
|
2021-12-06 18:43:19 +00:00
|
|
|
if not db:
|
|
|
|
raise ConnectionError
|
|
|
|
|
2021-12-02 22:08:58 +00:00
|
|
|
if data.trackers is not None:
|
2021-09-30 15:19:29 +00:00
|
|
|
|
2021-12-02 22:08:58 +00:00
|
|
|
habitlist = habits.migrate(db, data.trackers)
|
2021-09-30 15:19:29 +00:00
|
|
|
|
2021-12-02 22:08:58 +00:00
|
|
|
if data.events is not None:
|
|
|
|
rep.migrate(db, habitlist, data.events)
|
2021-09-30 15:19:29 +00:00
|
|
|
|
|
|
|
db.commit()
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-12-02 17:54:56 +00:00
|
|
|
file = sys.argv[1]
|
2021-12-02 22:08:58 +00:00
|
|
|
data = nomie.get_data(file)
|
|
|
|
migrate(data)
|
2021-09-30 15:19:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|