MCPcopy
hub / github.com/psycopg/psycopg / parse

Method parse

tests/utils.py:81–101  ·  view source on GitHub ↗
(cls, spec: str, *, postgres_rule: bool = False)

Source from the content-addressed store, hash-verified

79
80 @classmethod
81 def parse(cls, spec: str, *, postgres_rule: bool = False) -> VersionCheck:
82 # Parse a spec like "> 9.6", "skip < 21.2.0"
83 m = re.match(
84 r"""(?ix)
85 ^\s* (skip|only)?
86 \s* (==|!=|>=|<=|>|<)?
87 \s* (?:(\d+)(?:\.(\d+)(?:\.(\d+))?)?)?
88 \s* $
89 """,
90 spec,
91 )
92 if m is None:
93 pytest.fail(f"bad wanted version spec: {spec}")
94
95 skip = (m.group(1) or "only").lower() == "skip"
96 op = m.group(2)
97 version_tuple = tuple(int(n) for n in m.groups()[2:] if n)
98
99 return cls(
100 skip=skip, op=op, version_tuple=version_tuple, postgres_rule=postgres_rule
101 )
102
103 def get_skip_message(self, version: int | None) -> str | None:
104 got_tuple = self._parse_int_version(version)

Callers 11

convertFunction · 0.45
_visit_type_stringMethod · 0.45
check_crdb_versionFunction · 0.45
check_versionFunction · 0.45
test_connect_async_badFunction · 0.45
test_infoFunction · 0.45
test_used_passwordFunction · 0.45
test_change_passwordFunction · 0.45
test_conninfo_parseFunction · 0.45
test_conninfo_parse_96Function · 0.45
test_conninfo_parse_badFunction · 0.45

Calls 2

lowerMethod · 0.80
failMethod · 0.45

Tested by 7

test_connect_async_badFunction · 0.36
test_infoFunction · 0.36
test_used_passwordFunction · 0.36
test_change_passwordFunction · 0.36
test_conninfo_parseFunction · 0.36
test_conninfo_parse_96Function · 0.36
test_conninfo_parse_badFunction · 0.36