🌐 AI搜索 & 代理 主页
Skip to content

Commit a39c647

Browse files
committed
fix: use raw strings for regex patterns in API dictionary
Converts all string keys in the API dictionary to raw strings to prevent SyntaxError on invalid escape sequences like '\s' in regex patterns. The error was triggered by pytest's AST rewriting during import but not during normal Python imports.
1 parent 92d8efb commit a39c647

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

motifapi/api.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -102,48 +102,48 @@ class MotifApi(object):
102102
STREAM_TYPE_IMAGE = 1
103103
STREAM_TYPE_STATE = 2
104104

105-
API = {'version$': 'GET',
106-
'cameras$': 'GET',
107-
'cameras/configure$': 'PATCH',
108-
'cameras/read/(?P<name>[^\s /]+)$': 'GET',
109-
'camera/(?P<serial>[^\s /]+)$': 'GET',
110-
'camera/(?P<serial>[^\s /]+)/configure$': 'PATCH',
111-
'camera/(?P<serial>[^\s /]+)/read/(?P<name>[^\s /]+)$': 'GET',
112-
'camera/(?P<serial>[^\s /]+)/recording/start$': 'POST',
113-
'camera/(?P<serial>[^\s /]+)/recording/stop$': 'POST',
114-
'camera/(?P<serial>[^\s /]+)/recordings$': 'GET',
115-
'camera/(?P<serial>[^\s /]+)/recordings/copy_all$': 'POST',
116-
'camera/(?P<serial>[^\s /]+)/recordings/export_all$': 'POST',
117-
'camera/(?P<serial>[^\s /]+)/io/(?P<name>[^\s /]+)/set': 'POST',
118-
'camera/(?P<serial>[^\s /]+)/io/log': 'POST',
119-
'camera/(?P<serial>[^\s /]+)/io/read': 'GET',
120-
'recording/start$': 'POST',
121-
'recording/stop$': 'POST',
122-
'recordings$': 'GET',
123-
'recordings/copy_all$': 'POST',
124-
'recordings/export_all$': 'POST',
125-
'schedule$': 'GET',
126-
'schedule/clear$': 'POST',
127-
'schedule/(?P<identifier>[^\s /]+)/clear$': 'DELETE',
128-
'schedule/recording/start$': 'POST',
129-
'schedule/camera/(?P<serial>[^\s /]+)/recording/start$': 'POST',
130-
'schedule/recordings/copy_all': 'POST',
131-
'schedule/camera/(?P<serial>[^\s /]+)/recordings/copy_all$': 'POST',
132-
'schedule/recordings/export_all': 'POST',
133-
'schedule/camera/(?P<serial>[^\s /]+)/recordings/export_all$': 'POST',
134-
'schedule/io/(?P<name>[^\s /]+)/set': 'POST',
135-
'schedule/camera/(?P<serial>[^\s /]+)/io/(?P<name>[^\s /]+)/set': 'POST',
136-
'schedule/cameras/configure/(?P<name>[^\s /]+)': 'POST',
137-
'schedule/camera/(?P<serial>[^\s /]+)/configure/(?P<name>[^\s /]+)': 'POST',
138-
'io/(?P<io_serial>[^\s /]+)/(?P<io_port>[^\s /]+)/set': 'POST',
139-
'io/(?P<name>[^\s /]+)/set': 'POST',
140-
'io/log': 'POST',
141-
'io/read': 'GET',
142-
'multicam/synchronize': 'POST',
143-
'multicam/connect_camera/(?P<serial>[^\s /]+)': 'POST',
144-
'multicam/disconnect_camera/(?P<serial>[^\s /]+)': 'POST',
145-
'multicam/connect_all': 'POST',
146-
'multicam/disconnect_all': 'POST',
105+
API = {r'version$': 'GET',
106+
r'cameras$': 'GET',
107+
r'cameras/configure$': 'PATCH',
108+
r'cameras/read/(?P<name>[^\s /]+)$': 'GET',
109+
r'camera/(?P<serial>[^\s /]+)$': 'GET',
110+
r'camera/(?P<serial>[^\s /]+)/configure$': 'PATCH',
111+
r'camera/(?P<serial>[^\s /]+)/read/(?P<name>[^\s /]+)$': 'GET',
112+
r'camera/(?P<serial>[^\s /]+)/recording/start$': 'POST',
113+
r'camera/(?P<serial>[^\s /]+)/recording/stop$': 'POST',
114+
r'camera/(?P<serial>[^\s /]+)/recordings$': 'GET',
115+
r'camera/(?P<serial>[^\s /]+)/recordings/copy_all$': 'POST',
116+
r'camera/(?P<serial>[^\s /]+)/recordings/export_all$': 'POST',
117+
r'camera/(?P<serial>[^\s /]+)/io/(?P<name>[^\s /]+)/set': 'POST',
118+
r'camera/(?P<serial>[^\s /]+)/io/log': 'POST',
119+
r'camera/(?P<serial>[^\s /]+)/io/read': 'GET',
120+
r'recording/start$': 'POST',
121+
r'recording/stop$': 'POST',
122+
r'recordings$': 'GET',
123+
r'recordings/copy_all$': 'POST',
124+
r'recordings/export_all$': 'POST',
125+
r'schedule$': 'GET',
126+
r'schedule/clear$': 'POST',
127+
r'schedule/(?P<identifier>[^\s /]+)/clear$': 'DELETE',
128+
r'schedule/recording/start$': 'POST',
129+
r'schedule/camera/(?P<serial>[^\s /]+)/recording/start$': 'POST',
130+
r'schedule/recordings/copy_all': 'POST',
131+
r'schedule/camera/(?P<serial>[^\s /]+)/recordings/copy_all$': 'POST',
132+
r'schedule/recordings/export_all': 'POST',
133+
r'schedule/camera/(?P<serial>[^\s /]+)/recordings/export_all$': 'POST',
134+
r'schedule/io/(?P<name>[^\s /]+)/set': 'POST',
135+
r'schedule/camera/(?P<serial>[^\s /]+)/io/(?P<name>[^\s /]+)/set': 'POST',
136+
r'schedule/cameras/configure/(?P<name>[^\s /]+)': 'POST',
137+
r'schedule/camera/(?P<serial>[^\s /]+)/configure/(?P<name>[^\s /]+)': 'POST',
138+
r'io/(?P<io_serial>[^\s /]+)/(?P<io_port>[^\s /]+)/set': 'POST',
139+
r'io/(?P<name>[^\s /]+)/set': 'POST',
140+
r'io/log': 'POST',
141+
r'io/read': 'GET',
142+
r'multicam/synchronize': 'POST',
143+
r'multicam/connect_camera/(?P<serial>[^\s /]+)': 'POST',
144+
r'multicam/disconnect_camera/(?P<serial>[^\s /]+)': 'POST',
145+
r'multicam/connect_all': 'POST',
146+
r'multicam/disconnect_all': 'POST',
147147
}
148148

149149
def __init__(self, host=None, api_key=None, port=None, ca_cert=None, api_version=1):

0 commit comments

Comments
 (0)