Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit 7f95f3f

Browse files
committed
Re-format init SQL & refactor core slightly
1 parent bef7c08 commit 7f95f3f

File tree

4 files changed

+127
-60
lines changed

4 files changed

+127
-60
lines changed

tilde/core/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Functionality exposed as an API
33
# Author: Evgeny Blokhin
44

5-
__version__ = "0.9"
5+
__version__ = "0.9.0"
66

77
import os, sys
88
import re

tilde/core/model.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222
import ujson as json
2323

2424

25-
class NullHandler(logging.Handler): # for Python 2.6
26-
def emit(self, record): pass
27-
2825
logger = logging.getLogger('tilde')
2926
#handler = logging.StreamHandler(sys.stdout)
30-
handler = NullHandler()
27+
handler = logging.NullHandler()
3128
#handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s', datefmt="%d/%m %H:%M"))
3229
logger.setLevel(logging.CRITICAL)
3330
logger.addHandler(handler)

tilde/core/settings.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import tilde.core.model as model
1515

1616

17-
DB_SCHEMA_VERSION = '5.12'
17+
DB_SCHEMA_VERSION = '5.20'
1818
SETTINGS_FILE = 'settings.json'
1919
DEFAULT_SQLITE_DB = 'default.db'
2020
BASE_DIR = os.path.dirname(os.path.realpath(os.path.abspath(__file__)))
@@ -100,12 +100,24 @@ def connect_database(settings, named=None, no_pooling=False, default_actions=Tru
100100
if not os.path.exists(INIT_DATA):
101101
sys.exit(INIT_DATA + ' not found!')
102102

103-
nlines = 0
104103
f = open(INIT_DATA)
105104
statements = filter(None, f.read().splitlines())
106105
f.close()
107-
for stmt in statements:
108-
engine.execute(stmt)
106+
107+
nlines = 0
108+
pocket = []
109+
for n in range(len(statements)):
110+
if statements[n].startswith('--'):
111+
continue
112+
elif not statements[n].endswith(';'):
113+
pocket.append(statements[n])
114+
continue
115+
else:
116+
if pocket:
117+
engine.execute( "".join(pocket) + statements[n] )
118+
pocket = []
119+
else:
120+
engine.execute(statements[n])
109121
nlines += 1
110122

111123
logging.warning("Applied DB model from file %s" % INIT_DATA)

0 commit comments

Comments
 (0)