habitmove/run.py

36 lines
669 B
Python
Raw Normal View History

#!/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
import sys
2021-12-02 22:08:58 +00:00
def migrate(data: NomieImport):
db = schema.migrate("output.db")
if not db:
raise ConnectionError
2021-12-02 22:08:58 +00:00
if data.trackers is not None:
2021-12-02 22:08:58 +00:00
habitlist = habits.migrate(db, data.trackers)
2021-12-02 22:08:58 +00:00
if data.events is not None:
rep.migrate(db, habitlist, data.events)
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)
if __name__ == "__main__":
main()