mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 21:37:13 +00:00
[svn] Initial troggle checkin
This is a development site using Django 1.0 Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8034 by julian @ 10/26/2008 9:04 PM
This commit is contained in:
31
parsers/survex.py
Normal file
31
parsers/survex.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import settings
|
||||
import expo.models as models
|
||||
import re
|
||||
import os
|
||||
|
||||
def readFile(filename):
|
||||
for line in fileIterator(settings.SURVEX_DATA, filename):
|
||||
print line
|
||||
|
||||
re_include_extension = re.compile(r"^\s*\*include\s+([^\s]*).svx$", re.IGNORECASE)
|
||||
re_include_no_extension = re.compile(r"^\s*\*include\s+([^\s]*)$", re.IGNORECASE)
|
||||
|
||||
def fileIterator(directory, filename):
|
||||
f = open(os.path.join(directory, filename + ".svx"), "rb")
|
||||
for line in f.readlines():
|
||||
include_extension = re_include_extension.match(line)
|
||||
include_no_extension = re_include_no_extension.match(line)
|
||||
def a(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])
|
||||
if include_extension:
|
||||
for b in a(include_extension.groups()[0]):
|
||||
yield b
|
||||
elif include_no_extension:
|
||||
for b in a(include_no_extension.groups()[0]):
|
||||
yield b
|
||||
else:
|
||||
yield line
|
||||
|
||||
readFile("all")
|
||||
Reference in New Issue
Block a user