1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
Signed-off-by: Rong Fu <rong.fu.cn@windriver.com>
Last-Update: 2025-04-14
diff --git a/gertty/alembic/versions/50344aecd1c2_add_files_table.py b/gertty/alembic/versions/50344aecd1c2_add_files_table.py
index 2070cf4..87b828a 100644
--- a/gertty/alembic/versions/50344aecd1c2_add_files_table.py
+++ b/gertty/alembic/versions/50344aecd1c2_add_files_table.py
@@ -32,7 +32,7 @@ def upgrade():
sa.PrimaryKeyConstraint('key')
)
- pathre = re.compile('((.*?)\{|^)(.*?) => (.*?)(\}(.*)|$)')
+ pathre = re.compile(r'((.*?)\{|^)(.*?) => (.*?)(\}(.*)|$)')
insert = sa.text('insert into file (key, revision_key, path, old_path, status, inserted, deleted) '
' values (NULL, :revision_key, :path, :old_path, :status, :inserted, :deleted)')
diff --git a/gertty/app.py b/gertty/app.py
index b70f0ef..ef9731d 100644
--- a/gertty/app.py
+++ b/gertty/app.py
@@ -243,7 +243,7 @@ class ProjectCache(object):
del self.projects[project.key]
class App(object):
- simple_change_search = re.compile('^(\d+|I[a-fA-F0-9]{40})$')
+ simple_change_search = re.compile(r'^(\d+|I[a-fA-F0-9]{40})$')
def __init__(self, server=None, palette='default',
keymap='default', debug=False, verbose=False,
diff --git a/gertty/db.py b/gertty/db.py
index 3bb7ddd..ce4afa7 100644
--- a/gertty/db.py
+++ b/gertty/db.py
@@ -24,11 +24,12 @@ import six
import sqlalchemy
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String, Boolean, DateTime, Text, UniqueConstraint
from sqlalchemy.schema import ForeignKey
-from sqlalchemy.orm import mapper, sessionmaker, relationship, scoped_session, joinedload
+from sqlalchemy.orm import registry, sessionmaker, relationship, scoped_session, joinedload
from sqlalchemy.orm.session import Session
from sqlalchemy.sql import exists
from sqlalchemy.sql.expression import and_
+mapper_registry = registry()
metadata = MetaData()
project_table = Table(
'project', metadata,
@@ -612,8 +613,8 @@ class File(object):
return c
-mapper(Account, account_table)
-mapper(Project, project_table, properties=dict(
+mapper_registry.map_imperatively(Account, account_table)
+mapper_registry.map_imperatively(Project, project_table, properties=dict(
branches=relationship(Branch, backref='project',
order_by=branch_table.c.name,
cascade='all, delete-orphan'),
@@ -639,16 +640,16 @@ mapper(Project, project_table, properties=dict(
order_by=change_table.c.number,
),
))
-mapper(Branch, branch_table)
-mapper(Topic, topic_table, properties=dict(
+mapper_registry.map_imperatively(Branch, branch_table)
+mapper_registry.map_imperatively(Topic, topic_table, properties=dict(
projects=relationship(Project,
secondary=project_topic_table,
order_by=project_table.c.name,
viewonly=True),
project_topics=relationship(ProjectTopic),
))
-mapper(ProjectTopic, project_topic_table)
-mapper(Change, change_table, properties=dict(
+mapper_registry.map_imperatively(ProjectTopic, project_topic_table)
+mapper_registry.map_imperatively(Change, change_table, properties=dict(
owner=relationship(Account),
conflicts1=relationship(Change,
secondary=change_conflict_table,
@@ -684,7 +685,7 @@ mapper(Change, change_table, properties=dict(
order_by=(approval_table.c.category,
approval_table.c.value))
))
-mapper(Revision, revision_table, properties=dict(
+mapper_registry.map_imperatively(Revision, revision_table, properties=dict(
messages=relationship(Message, backref='revision',
cascade='all, delete-orphan'),
files=relationship(File, backref='revision',
@@ -692,9 +693,9 @@ mapper(Revision, revision_table, properties=dict(
pending_cherry_picks=relationship(PendingCherryPick, backref='revision',
cascade='all, delete-orphan'),
))
-mapper(Message, message_table, properties=dict(
+mapper_registry.map_imperatively(Message, message_table, properties=dict(
author=relationship(Account)))
-mapper(File, file_table, properties=dict(
+mapper_registry.map_imperatively(File, file_table, properties=dict(
comments=relationship(Comment, backref='file',
order_by=(comment_table.c.line,
comment_table.c.created),
@@ -706,14 +707,14 @@ mapper(File, file_table, properties=dict(
comment_table.c.created)),
))
-mapper(Comment, comment_table, properties=dict(
+mapper_registry.map_imperatively(Comment, comment_table, properties=dict(
author=relationship(Account)))
-mapper(Label, label_table)
-mapper(PermittedLabel, permitted_label_table)
-mapper(Approval, approval_table, properties=dict(
+mapper_registry.map_imperatively(Label, label_table)
+mapper_registry.map_imperatively(PermittedLabel, permitted_label_table)
+mapper_registry.map_imperatively(Approval, approval_table, properties=dict(
reviewer=relationship(Account)))
-mapper(PendingCherryPick, pending_cherry_pick_table)
-mapper(SyncQuery, sync_query_table)
+mapper_registry.map_imperatively(PendingCherryPick, pending_cherry_pick_table)
+mapper_registry.map_imperatively(SyncQuery, sync_query_table)
def match(expr, item):
if item is None:
diff --git a/gertty/gitrepo.py b/gertty/gitrepo.py
index 2f7a19f..66bb499 100644
--- a/gertty/gitrepo.py
+++ b/gertty/gitrepo.py
@@ -332,7 +332,7 @@ class Repo(object):
ret.append(x.split('\t'))
return ret
- trailing_ws_re = re.compile('\s+$')
+ trailing_ws_re = re.compile(r'\s+$')
def _emph_trail_ws(self, style, line):
result = (style, line)
re_result = self.trailing_ws_re.search(line)
@@ -419,7 +419,7 @@ class Repo(object):
#self.log.debug(repr(output_new))
return output_old, output_new
- header_re = re.compile('@@ -(\d+)(,\d+)? \+(\d+)(,\d+)? @@')
+ header_re = re.compile(r'@@ -(\d+)(,\d+)? \+(\d+)(,\d+)? @@')
def diff(self, old, new, context=10000, show_old_commit=False):
"""Create a diff from old to new.
diff --git a/gertty/keymap.py b/gertty/keymap.py
index a77a361..6b3f85e 100644
--- a/gertty/keymap.py
+++ b/gertty/keymap.py
@@ -180,7 +180,7 @@ URWID_COMMANDS = frozenset((
FORMAT_SUBS = (
(re.compile('ctrl '), 'CTRL-'),
(re.compile('meta '), 'META-'),
- (re.compile('f(\d+)'), 'F\\1'),
+ (re.compile(r'f(\d+)'), 'F\\1'),
(re.compile('([a-z][a-z]+)'), lambda x: x.group(1).upper()),
)
|