wangzhibo
2026-09-11 659c470eba542383987aad227b7f918100f131fa
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
"""Lightweight stubs so App Runtime tests run without the full server venv."""
 
import os
import sys
from types import ModuleType
 
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if ROOT not in sys.path:
    sys.path.insert(0, ROOT)
 
 
class _SilentLogger:
    def bind(self, **kwargs):
        return self
 
    def info(self, *args, **kwargs):
        return None
 
    def warning(self, *args, **kwargs):
        return None
 
    def error(self, *args, **kwargs):
        return None
 
    def debug(self, *args, **kwargs):
        return None
 
 
_LOG = _SilentLogger()
 
 
def _install(name, module):
    sys.modules.setdefault(name, module)
 
 
if "config.logger" not in sys.modules:
    logger_mod = ModuleType("config.logger")
    logger_mod.setup_logging = lambda *args, **kwargs: _LOG
    logger_mod.build_module_string = lambda *args, **kwargs: "0" * 14
    logger_mod.create_connection_logger = lambda *args, **kwargs: _LOG
    logger_mod.logger = _LOG
    _install("config.logger", logger_mod)
 
if "config.config_loader" not in sys.modules:
    loader_mod = ModuleType("config.config_loader")
    loader_mod.get_project_dir = lambda: ROOT.replace("\\", "/") + "/"
    _install("config.config_loader", loader_mod)
 
 
def _remove_punctuation_and_length(text):
    full_width = "!"#$%&'()*+,-。/:;<=>?@[\]^_`{|}~"
    half_width = r'!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'
    result = "".join(
        ch
        for ch in (text or "")
        if ch not in full_width and ch not in half_width and ch not in (" ", " ")
    )
    if result == "Yeah":
        return 0, ""
    return len(result), result
 
 
if "core.utils.util" not in sys.modules:
    util_mod = ModuleType("core.utils.util")
    util_mod.remove_punctuation_and_length = _remove_punctuation_and_length
    _install("core.utils.util", util_mod)