|
Last change
on this file was
13719,
checked in by Jun Omae, 10 years ago
|
|
TagsPlugin: small tweaks (refs #2429)
- iterate directly
cursor rather than cursor.fetchall()
- remove redefined
to_datetime in tractags.model
- prevent calling
strip() twice in split_into_tags()
|
|
File size:
922 bytes
|
| Line | |
|---|
| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2006 Alec Thomas <alec@swapoff.org> |
|---|
| 4 | # Copyright (C) 2013 Steffen Hoffmann <hoff.st@web.de> |
|---|
| 5 | # |
|---|
| 6 | # This software is licensed as described in the file COPYING, which |
|---|
| 7 | # you should have received as part of this distribution. |
|---|
| 8 | # |
|---|
| 9 | |
|---|
| 10 | import re |
|---|
| 11 | |
|---|
| 12 | _TAG_SPLIT = re.compile('[,\s]+') |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | def split_into_tags(text): |
|---|
| 16 | """Split plain text into tags.""" |
|---|
| 17 | return set(filter(None, [tag.strip() for tag in _TAG_SPLIT.split(text)])) |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | def get_db_exc(env): |
|---|
| 21 | if hasattr(env, 'db_exc'): |
|---|
| 22 | return env.db_exc |
|---|
| 23 | database = env.config.get('trac', 'database') |
|---|
| 24 | if database.startswith('sqlite:'): |
|---|
| 25 | from trac.db.sqlite_backend import sqlite |
|---|
| 26 | return sqlite |
|---|
| 27 | if database.startswith('postgres:'): |
|---|
| 28 | from trac.db.postgres_backend import psycopg |
|---|
| 29 | return psycopg |
|---|
| 30 | if database.startswith('mysql:'): |
|---|
| 31 | from trac.db.mysql_backend import MySQLdb |
|---|
| 32 | return MySQLdb |
|---|
Note: See
TracBrowser
for help on using the repository browser.