MCPcopy Index your code
hub / github.com/RustPython/RustPython / consts_from_url

Function consts_from_url

scripts/libc_posix.py:159–186  ·  view source on GitHub ↗

Extract all consts from the contents found at the given URL. Parameters ---------- url : str URL to fetch the contents from. pattern : re.Pattern, Optional RE compiled pattern for extracting the consts. exclude : frozenset[str], Optional Items to exc

(
    url: str, *, pattern: re.Pattern = CONSTS_PATTERN, exclude: frozenset[str] = EXCLUDE
)

Source from the content-addressed store, hash-verified

157
158
159def consts_from_url(
160 url: str, *, pattern: re.Pattern = CONSTS_PATTERN, exclude: frozenset[str] = EXCLUDE
161) -> frozenset[str]:
162 """
163 Extract all consts from the contents found at the given URL.
164
165 Parameters
166 ----------
167 url : str
168 URL to fetch the contents from.
169 pattern : re.Pattern, Optional
170 RE compiled pattern for extracting the consts.
171 exclude : frozenset[str], Optional
172 Items to exclude from the returned value.
173
174 Returns
175 -------
176 frozenset[str]
177 All constant names at the URL.
178 """
179 try:
180 with urllib.request.urlopen(url) as f:
181 contents = f.read().decode()
182 except urllib.error.HTTPError as err:
183 err.add_note(url)
184 raise
185
186 return extract_consts(contents, pattern=pattern, exclude=exclude)
187
188
189def main():

Callers 1

mainFunction · 0.85

Calls 5

extract_constsFunction · 0.85
add_noteMethod · 0.80
urlopenMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected