mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2025-04-02 00:22:00 +01:00
[svn r8054] Removed last of the sqlite save hack
Started to add reading of dates Changed character encoding code so it works
This commit is contained in:
parent
e56ad841b2
commit
c2876c0b64
@ -7,26 +7,18 @@ re_include_extension = re.compile(r"^\s*\*include\s+([^\s]*).svx$", re.IGNORECAS
|
|||||||
re_include_no_extension = re.compile(r"^\s*\*include\s+([^\s]*)$", re.IGNORECASE)
|
re_include_no_extension = re.compile(r"^\s*\*include\s+([^\s]*)$", re.IGNORECASE)
|
||||||
re_begin = re.compile(r"^\s*\*begin\s+(.*?)\s*$", re.IGNORECASE)
|
re_begin = re.compile(r"^\s*\*begin\s+(.*?)\s*$", re.IGNORECASE)
|
||||||
re_end = re.compile(r"^\s*\*end\s+(.*?)\s*$", re.IGNORECASE)
|
re_end = re.compile(r"^\s*\*end\s+(.*?)\s*$", re.IGNORECASE)
|
||||||
|
re_date = re.compile(r"^\s*\*date\s+(.*?)\s*$", re.IGNORECASE)
|
||||||
def save(x): #There seems to be an intermitent problem with sqlite and Vista, this should fix it
|
|
||||||
#try:
|
|
||||||
x.save()
|
|
||||||
#except Exception: #sqlite3.OperationalError:
|
|
||||||
# print "Error"
|
|
||||||
# time.sleep(1)
|
|
||||||
# save(x)
|
|
||||||
|
|
||||||
def fileIterator(directory, filename):
|
def fileIterator(directory, filename):
|
||||||
survex_file = os.path.join(directory, filename + ".svx")
|
survex_file = os.path.join(directory, filename + ".svx")
|
||||||
f = open(os.path.join(settings.SURVEX_DATA, survex_file), "rb")
|
f = open(os.path.join(settings.SURVEX_DATA, survex_file), "rb")
|
||||||
char = 0
|
char = 0
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
line = unicode(line, "latin1").decode("utf-8")
|
line = unicode(line, "latin1")
|
||||||
include_extension = re_include_extension.match(line)
|
include_extension = re_include_extension.match(line)
|
||||||
include_no_extension = re_include_no_extension.match(line)
|
include_no_extension = re_include_no_extension.match(line)
|
||||||
def a(include):
|
def a(include):
|
||||||
link = re.split(r"/|\\", include)
|
link = re.split(r"/|\\", include)
|
||||||
print os.path.join(directory, *link[:-1]), link[-1]
|
|
||||||
return fileIterator(os.path.join(directory, *link[:-1]), link[-1])
|
return fileIterator(os.path.join(directory, *link[:-1]), link[-1])
|
||||||
if include_extension:
|
if include_extension:
|
||||||
for sf, c, l in a(include_extension.groups()[0]):
|
for sf, c, l in a(include_extension.groups()[0]):
|
||||||
@ -43,26 +35,29 @@ def make_model(name, parent, iter_lines, sf, c, l):
|
|||||||
m = models.SurvexBlock(name = name, parent = parent, begin_file = sf, begin_char = c, text = l)
|
m = models.SurvexBlock(name = name, parent = parent, begin_file = sf, begin_char = c, text = l)
|
||||||
else:
|
else:
|
||||||
m = models.SurvexBlock(name = name, begin_file = sf, begin_char = c, text = l)
|
m = models.SurvexBlock(name = name, begin_file = sf, begin_char = c, text = l)
|
||||||
save(m)
|
m.save()
|
||||||
for survex_file, count, line in iter_lines:
|
for survex_file, count, line in iter_lines:
|
||||||
begin = re_begin.match(line.split(";")[0])
|
begin = re_begin.match(line.split(";")[0])
|
||||||
end = re_end.match(line.split(";")[0])
|
end = re_end.match(line.split(";")[0])
|
||||||
|
date = re_date.match(line.split(";")[0])
|
||||||
if begin:
|
if begin:
|
||||||
make_model(begin.groups()[0], m, iter_lines, survex_file, count, line)
|
make_model(begin.groups()[0], m, iter_lines, survex_file, count, line)
|
||||||
elif end:
|
elif end:
|
||||||
m.text = m.text + line
|
m.text = m.text + line
|
||||||
m.end_file = survex_file
|
m.end_file = survex_file
|
||||||
m.end_char = count
|
m.end_char = count
|
||||||
print len(m.text)
|
m.save()
|
||||||
save(m)
|
|
||||||
assert (end.groups()[0]).lower() == (name).lower()
|
assert (end.groups()[0]).lower() == (name).lower()
|
||||||
return None
|
return None
|
||||||
|
elif date:
|
||||||
|
print date.groups()[0]
|
||||||
|
m.text = m.text + line
|
||||||
else:
|
else:
|
||||||
m.text = m.text + line
|
m.text = m.text + line
|
||||||
m.text = m.text + line
|
m.text = m.text + line
|
||||||
m.end_file = survex_file
|
m.end_file = survex_file
|
||||||
m.end_char = count
|
m.end_char = count
|
||||||
save(m)
|
m.save()
|
||||||
|
|
||||||
|
|
||||||
filename = "all"
|
filename = "all"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user