|
Last change
on this file was
15559,
checked in by Ryan J Ollos, 7 years ago
|
|
0.9dev: Adapt to Trac 1.0 database API
All tests are passing with SQLite, PostgreSQL and MySQL.
Fixes #12137.
|
|
File size:
1014 bytes
|
| Line | |
|---|
| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2006 Alec Thomas <alec@swapoff.org> |
|---|
| 4 | # Copyright (C) 2013,2014 Steffen Hoffmann <hoff.st@web.de> |
|---|
| 5 | # Copyright (C) 2014 Ryan J Ollos <ryan.j.ollos@gmail.com> |
|---|
| 6 | # |
|---|
| 7 | # This software is licensed as described in the file COPYING, which |
|---|
| 8 | # you should have received as part of this distribution. |
|---|
| 9 | # |
|---|
| 10 | |
|---|
| 11 | import re |
|---|
| 12 | from functools import partial |
|---|
| 13 | |
|---|
| 14 | from trac.test import Mock, MockPerm |
|---|
| 15 | from trac.web.api import _RequestArgs |
|---|
| 16 | |
|---|
| 17 | _TAG_SPLIT = re.compile('[,\s]+') |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | # DEVEL: This needs monitoring for possibly varying endpoint requirements. |
|---|
| 21 | MockReq = partial(Mock, args=_RequestArgs(), authname='anonymous', |
|---|
| 22 | perm=MockPerm(), session=dict()) |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | def query_realms(query, all_realms): |
|---|
| 26 | realms = [] |
|---|
| 27 | for realm in all_realms: |
|---|
| 28 | if re.search('(^|\W)realm:%s(\W|$)' % realm, query): |
|---|
| 29 | realms.append(realm) |
|---|
| 30 | return realms |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | def split_into_tags(text): |
|---|
| 34 | """Split plain text into tags.""" |
|---|
| 35 | return set(filter(None, [tag.strip() for tag in _TAG_SPLIT.split(text)])) |
|---|
Note: See
TracBrowser
for help on using the repository browser.