Changeset 1357
- Timestamp:
- 10/09/06 04:53:17 (2 years ago)
- Files:
-
- regexincludemacro/RegexInclude.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
regexincludemacro/RegexInclude.py
r1342 r1357 1 1 """ 2 $Id$3 2 4 3 I've added my own comments here. The original text is attached below my comments. 4 Also, please forgive any stupid errors i might have made. My i started on python 1 week ago. 5 5 6 6 use_vars: … … 74 74 regex = None 75 75 argstring = '' 76 match_seperator = ' ' 77 dotall = '' 76 78 db = env.get_db_cnx() 77 79 cursor = db.cursor() … … 95 97 if regex != '': 96 98 regex = regex.split('\',\'') 99 97 100 98 101 #Get URL … … 118 121 argstring.index(',no_dotall,') 119 122 except: 120 re.DOTALL 123 re.DOTALL #Aparantly this doesnt always work.. 124 dotall = '(?s)' # So we use this regex equivilant 125 #buf.write('DOTALL') 121 126 122 127 #Should we only include pages for authenticated users? … … 127 132 except: 128 133 1 #Sorry.. Dont know python at all, and this was the only way i could solve that except: requires at least 1 line 134 #Should we only include pages for authenticated users? 129 135 136 if re.search(',match_seperator(?:=[^,]+)?,',argstring): 137 match_seperator = re.search(',match_seperator(?:=([^,]+))?,',argstring).group(1) 138 139 #Or allow the match seperator to be in quotes 140 if re.search(',match_seperator="[^"]+?"?,',argstring): 141 match_seperator = re.search(',match_seperator="([^"]+?)"?,',argstring).group(1) 142 143 144 130 145 #Should we replace $USER with logged-in username, in URL? 131 146 if re.search(',use_vars(?:=\w+)?,',argstring): … … 163 178 #Do the regex replacements 164 179 for ex in regex: 165 ex = ex.strip("'") 166 ex = ex.split('\'/\'') 167 txt = re.sub(ex[0],ex[1],txt) 180 #Detect replace or search 181 ex = ex.strip("'") 182 183 try: 184 ex.index("'/'") #Check If this is a replacement 185 ex = ex.split('\'/\'') 186 txt = re.sub(dotall+ex[0],ex[1],txt) 187 except: #If this is a search 188 tmp = '' 189 for m in re.finditer(dotall+ex, txt): 190 tmp = "".join([tmp,match_seperator,m.group(1)]) 191 txt = tmp[1:] 192 168 193 169 194 if formatter == 'wiki':
