MCPcopy Index your code
hub / github.com/pmxt-dev/pmxt / match

Method match

sdks/python/pmxt/models.py:141–189  ·  view source on GitHub ↗

Find a single market by case-insensitive substring match. Args: query: Substring to search for. search_in: Fields to search in (default: ["title"]). Returns: The matching UnifiedMarket. Raises: ValueError: If zero or multiple

(
        self,
        query: str,
        search_in: Optional[List[Literal["title", "description", "category", "tags", "outcomes"]]] = None,
    )

Source from the content-addressed store, hash-verified

139 """A list of UnifiedMarket objects with a convenience match() method."""
140
141 def match(
142 self,
143 query: str,
144 search_in: Optional[List[Literal["title", "description", "category", "tags", "outcomes"]]] = None,
145 ) -> "UnifiedMarket":
146 """Find a single market by case-insensitive substring match.
147
148 Args:
149 query: Substring to search for.
150 search_in: Fields to search in (default: ["title"]).
151
152 Returns:
153 The matching UnifiedMarket.
154
155 Raises:
156 ValueError: If zero or multiple markets match.
157 """
158 if search_in is None:
159 search_in = ["title"]
160 lower_query = query.lower()
161 matches = []
162 for m in self:
163 for field in search_in:
164 if field == "title" and m.title and lower_query in m.title.lower():
165 matches.append(m)
166 break
167 if field == "description" and m.description and lower_query in m.description.lower():
168 matches.append(m)
169 break
170 if field == "category" and m.category and lower_query in m.category.lower():
171 matches.append(m)
172 break
173 if field == "tags" and m.tags and any(lower_query in t.lower() for t in m.tags):
174 matches.append(m)
175 break
176 if field == "outcomes" and m.outcomes and any(lower_query in o.label.lower() for o in m.outcomes):
177 matches.append(m)
178 break
179 if len(matches) == 0:
180 raise ValueError(f"No markets matching '{query}'")
181 if len(matches) > 1:
182 titles_str = "\n ".join(
183 f"{i+1}. {m.title[:70]}{'...' if len(m.title) > 70 else ''}"
184 for i, m in enumerate(matches)
185 )
186 raise ValueError(
187 f"Multiple markets matching '{query}' ({len(matches)} matches):\n {titles_str}\n\nPlease refine your search."
188 )
189 return matches[0]
190
191
192@dataclass

Callers 15

mainFunction · 0.95
index.test.jsFile · 0.45
collectPythonAllFunction · 0.45
extractTsInterfaceFieldsFunction · 0.45
extractPyDataclassFieldsFunction · 0.45
mapNotFoundErrorMethod · 0.45
ensureDateMethod · 0.45
extractAnchorErrorMethod · 0.45
ensureDateFunction · 0.45
mapNotFoundErrorMethod · 0.45
composeSeriesTitleMethod · 0.45

Calls

no outgoing calls