mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-09-30 01:07:24 +13:00
a78f3e229d
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
33 lines
779 B
Python
33 lines
779 B
Python
#!/usr/bin/env python
|
|
# --!-- coding: utf8 --!--
|
|
|
|
import os
|
|
|
|
from manuskript.io.textFile import TextFile
|
|
|
|
LEGACY_MSK_VERSION = 0
|
|
CURRENT_MSK_VERSION = 1
|
|
|
|
|
|
class Version:
|
|
|
|
def __init__(self, path):
|
|
self.file = TextFile(os.path.join(path, "MANUSKRIPT"))
|
|
self.legacy_file = TextFile(os.path.join(path, "VERSION"))
|
|
|
|
self.value = LEGACY_MSK_VERSION
|
|
|
|
def loadLegacy(self):
|
|
try:
|
|
return int(self.legacy_file.load())
|
|
except FileNotFoundError or ValueError:
|
|
return LEGACY_MSK_VERSION
|
|
|
|
def load(self):
|
|
try:
|
|
self.value = int(self.file.load())
|
|
except FileNotFoundError or ValueError:
|
|
self.value = self.loadLegacy()
|
|
|
|
def save(self):
|
|
self.file.save(str(self.value))
|