's. we don't want \n\n's working here
if test[i:end+1]=='': setpre=1
elif test[end+1-6:end+1]=='': setpre=0
if end-i != 1: # <...>
lst.append( convertarg(test[i:end+1]) )
prevm=test[i:end+1]
else: # <>
lst.append( convertarg( ''+prevm[1:] ) )
#lst.append( ''+prevm[1: prevm.find(' ')] + '>')
prevm=''
last=end+1
i=end+1
elif test[i]=='\n' and setpre==0:
if i')
last=i+2
i+=2
else: #\n
if string.whitespace.find( test[i+1] ) is -1:
lst.append(test[last:i])
lst.append('\n
')
last=i+1
i+=1
else:
i+=1
elif setpre != 0: i+=1
if last!=max:
lst.append(test[last:])
if lst[-1]=='\n\n' or lst[-1]=='\n
':
return lst[:-1]
return lst
def printf(format, *args): sys.stdout.write (format % args)
def append(req,a, oldnew='yes'):
s=append_all(req, a, oldnew)
#do special parenthesis stfs
# try a better way
s = s.replace('(','(').replace(')',')')
return s
def append_all(req,a, oldnew='yes'):
starttime=time.time()
cwd="/apache"+a[:a.rfind('/')]+'/.entries/'
#efiles = os.popen('ls -1 '+ cwd +'/*.entry').read().split('\n')[:-1]
efiles=os.listdir(cwd)
efiles=filter(lambda x: x[-6:]=='.entry', efiles)
if oldnew != 'yes':
efiles.sort()
efiles.reverse()
else:
efiles.sort()
for i in range(len(efiles)):
efiles[i]=cwd+efiles[i]
s=''
### BUILD ent
entries=[]
for e in efiles:
title=e[e.rfind('/')+1 : e.rfind('.')]
filecontents=open(e).read()
#deal with :(X( ::: sloooow! .3 to .7sec! :(
#filecontents=filecontents.replace('(','(').replace(')',')')
#paren=filecontents.count('(')-filecontents.count(')')
#if paren > 0: #more (s than )s
# filecontents+=''*paren
#stuff to put quoted things in a special div
splitcontents=filecontents.split('\"')
if splitcontents[0]=='': #started with quote, replace all odds 1 3
evens=1
else:
evens=1 #started with regular, replace evens 0 2
go=len(splitcontents)
while (evens < go):
if (splitcontents[evens-1] != '' and splitcontents[evens-1][-1]=='\\'):
evens+=1;
continue
#if string.whitespace.find(splitcontents[evens]) is -1:
# evens+=2
# continue
splitcontents[evens]='\"' + splitcontents[evens] + '\"'
evens+=2
send=''
for i in splitcontents:
send+=i
lst=convertent(send)
s+='\n\n
\n'
s+=''
s+=title
s+=' | modified: '
s+=time.ctime(os.path.getmtime(e)).lower()
s+='\n
'
for x in lst: #print this entry
s+=x
#s+=string.join(lst)
s+='\n\n'
s+='\n\n\n'
s+='\n\n\n'
return s
def onefile(req, a):
s=''
file='/apache'+a
lst=convertent(open(file).read())
for x in lst:
s+=x
return s
def test(req,a):
s ="greetz from pytone
"
s+="Passed arguments: " + a
s+="
"+a[:a.rfind('/')]
return s
#if this is running from the cli in python
if __name__=='__main__':
#print append(1,'/html/dreamthoughts/index.html', 'no')
print onefile(1, '/html/entries/mindfluid')