mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
python: Mark regexes as raw strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
84db245e3f
commit
96fbe060a6
@@ -245,19 +245,19 @@ def normalize_fixture_data(
|
||||
]
|
||||
# We'll replace cus_D7OT2jf5YAtZQ2 with something like cus_NORMALIZED0001
|
||||
pattern_translations = {
|
||||
f"{prefix}_[A-Za-z0-9]{{{length}}}": f"{prefix}_NORMALIZED%0{length - 10}d"
|
||||
rf"{prefix}_[A-Za-z0-9]{{{length}}}": f"{prefix}_NORMALIZED%0{length - 10}d"
|
||||
for prefix, length in id_lengths
|
||||
}
|
||||
# We'll replace "invoice_prefix": "A35BC4Q" with something like "invoice_prefix": "NORMA01"
|
||||
pattern_translations.update(
|
||||
{
|
||||
'"invoice_prefix": "([A-Za-z0-9]{7,8})"': "NORMA%02d",
|
||||
'"fingerprint": "([A-Za-z0-9]{16})"': "NORMALIZED%06d",
|
||||
'"number": "([A-Za-z0-9]{7,8}-[A-Za-z0-9]{4})"': "NORMALI-%04d",
|
||||
'"address": "([A-Za-z0-9]{9}-test_[A-Za-z0-9]{12})"': "000000000-test_NORMALIZED%02d",
|
||||
r'"invoice_prefix": "([A-Za-z0-9]{7,8})"': "NORMA%02d",
|
||||
r'"fingerprint": "([A-Za-z0-9]{16})"': "NORMALIZED%06d",
|
||||
r'"number": "([A-Za-z0-9]{7,8}-[A-Za-z0-9]{4})"': "NORMALI-%04d",
|
||||
r'"address": "([A-Za-z0-9]{9}-test_[A-Za-z0-9]{12})"': "000000000-test_NORMALIZED%02d",
|
||||
# Don't use (..) notation, since the matched strings may be small integers that will also match
|
||||
# elsewhere in the file
|
||||
'"realm_id": "[0-9]+"': '"realm_id": "%d"',
|
||||
r'"realm_id": "[0-9]+"': '"realm_id": "%d"',
|
||||
r'"account_name": "[\w\s]+"': '"account_name": "NORMALIZED-%d"',
|
||||
}
|
||||
)
|
||||
@@ -265,7 +265,7 @@ def normalize_fixture_data(
|
||||
# why we're doing something a bit more complicated
|
||||
for i, timestamp_field in enumerate(tested_timestamp_fields):
|
||||
# Don't use (..) notation, since the matched timestamp can easily appear in other fields
|
||||
pattern_translations[f'"{timestamp_field}": 1[5-9][0-9]{{8}}(?![0-9-])'] = (
|
||||
pattern_translations[rf'"{timestamp_field}": 1[5-9][0-9]{{8}}(?![0-9-])'] = (
|
||||
f'"{timestamp_field}": 1{i + 1:02}%07d'
|
||||
)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ def get_user_activity_summary(records: Collection[UserActivity]) -> UserActivity
|
||||
else:
|
||||
heard_from = max(visit, heard_from)
|
||||
|
||||
if ("send_message" in query) or re.search("/api/.*/external/.*", query):
|
||||
if ("send_message" in query) or re.search(r"/api/.*/external/.*", query):
|
||||
messages += record.count
|
||||
if last_sent is None:
|
||||
last_sent = visit
|
||||
|
||||
Reference in New Issue
Block a user