Доработка взаимодействия с API, новая процедура установки, определение установленных версий игры и начальная реализация БД
This commit is contained in:
parent
983d0f9e21
commit
5beb835d1e
4 changed files with 217 additions and 51 deletions
53
mcgetdb.py
Normal file
53
mcgetdb.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import sqlite3
|
||||
import os
|
||||
|
||||
DB_VERSION = 1
|
||||
|
||||
class McGetDB:
|
||||
|
||||
def __init_db(self):
|
||||
with self.db as db:
|
||||
db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS mods (
|
||||
slug TEXT PRIMARY KEY NOT NULL,
|
||||
install_path TEXT NOT NULL,
|
||||
version TEXT NOT NULL
|
||||
);''')
|
||||
db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS properties (
|
||||
db_version TEXT PRIMARY KEY NOT NULL,
|
||||
version TEXT NOT NULL,
|
||||
modloader TEXT,
|
||||
dir_hierarchy TEXT
|
||||
);''')
|
||||
|
||||
def __init__(self, mc_path):
|
||||
self.db_path = os.path.join(mc_path, "mcget.db")
|
||||
self.db = sqlite3.connect(self.db_path)
|
||||
self.__init_db()
|
||||
|
||||
def get_properties(self):
|
||||
properties = None
|
||||
with self.db as db:
|
||||
properties = db.execute('''
|
||||
SELECT * FROM properties;
|
||||
''').fetchone()
|
||||
return properties
|
||||
|
||||
def set_properties(self, mc_ver, modloader = "NULL", dir_hierarhy = "default"):
|
||||
with self.db as db:
|
||||
db.execute('''
|
||||
DELETE FROM properties;
|
||||
''')
|
||||
db.execute('''
|
||||
INSERT INTO properties VALUES (?, ?, ?, ?)
|
||||
''', (DB_VERSION, mc_ver, modloader, dir_hierarhy))
|
||||
|
||||
def add_mod(self):
|
||||
pass
|
||||
|
||||
def remove_mod(self):
|
||||
pass
|
||||
|
||||
def update_mod(self):
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue