156 """ |
156 """ |
157 if re.match(r'\d+\.\d+\.\d+\.\d+', host): |
157 if re.match(r'\d+\.\d+\.\d+\.\d+', host): |
158 yield host |
158 yield host |
159 return |
159 return |
160 parts = host.split('.') |
160 parts = host.split('.') |
161 l = min(len(parts), 5) |
161 partsLen = min(len(parts), 5) |
162 if l > 4: |
162 if partsLen > 4: |
163 yield host |
163 yield host |
164 for i in range(l - 1): |
164 for i in range(partsLen - 1): |
165 yield '.'.join(parts[i - l:]) |
165 yield '.'.join(parts[i - partsLen:]) |
166 |
166 |
167 def pathPermutations(path): |
167 def pathPermutations(path): |
168 """ |
168 """ |
169 Method to generate the permutations of the path. |
169 Method to generate the permutations of the path. |
170 |
170 |
174 @rtype generator of str |
174 @rtype generator of str |
175 """ |
175 """ |
176 yield path |
176 yield path |
177 query = None |
177 query = None |
178 if '?' in path: |
178 if '?' in path: |
179 path, query = path.split('?', 1) |
179 path, query = path.split('?', 1) |
180 if query is not None: |
180 if query is not None: |
181 yield path |
181 yield path |
182 pathParts = path.split('/')[0:-1] |
182 pathParts = path.split('/')[0:-1] |
183 curPath = '' |
183 curPath = '' |
184 for i in range(min(4, len(pathParts))): |
184 for i in range(min(4, len(pathParts))): |