MCPcopy
hub / github.com/pandas-dev/pandas / parse

Method parse

pandas/io/formats/css.py:401–425  ·  view source on GitHub ↗

Generates (prop, value) pairs from declarations. In a future version may generate parsed tokens from tinycss/tinycss2 Parameters ---------- declarations_str : str

(self, declarations_str: str)

Source from the content-addressed store, hash-verified

399 yield prop, value
400
401 def parse(self, declarations_str: str) -> Iterator[tuple[str, str]]:
402 """
403 Generates (prop, value) pairs from declarations.
404
405 In a future version may generate parsed tokens from tinycss/tinycss2
406
407 Parameters
408 ----------
409 declarations_str : str
410 """
411 for decl in declarations_str.split(";"):
412 if not decl.strip():
413 continue
414 prop, sep, val = decl.partition(":")
415 prop = prop.strip().lower()
416 # TODO: don't lowercase case sensitive parts of values (strings)
417 val = val.strip().lower()
418 if sep:
419 yield prop, val
420 else:
421 warnings.warn(
422 f"Ill-formatted attribute: expected a colon in {decl!r}",
423 CSSWarning,
424 stacklevel=find_stack_level(),
425 )

Callers 1

__call__Method · 0.95

Calls 5

find_stack_levelFunction · 0.90
splitMethod · 0.80
stripMethod · 0.80
partitionMethod · 0.80
lowerMethod · 0.80

Tested by

no test coverage detected