MCPcopy
hub / github.com/yt-dlp/yt-dlp / int_or_none

Function int_or_none

yt_dlp/utils/_utils.py:2021–2030  ·  view source on GitHub ↗
(v, scale=1, default=None, get_attr=None, invscale=1, base=None)

Source from the content-addressed store, hash-verified

2019
2020@partial_application
2021def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1, base=None):
2022 if get_attr and v is not None:
2023 v = getattr(v, get_attr, None)
2024 if invscale == 1 and scale < 1:
2025 invscale = int(1 / scale)
2026 scale = 1
2027 try:
2028 return (int(v) if base is None else int(v, base=base)) * invscale // scale
2029 except (ValueError, TypeError, OverflowError):
2030 return default
2031
2032
2033def str_or_none(v, default=None):

Callers 15

test_int_or_noneMethod · 0.90
__parse_tsmapMethod · 0.85
validate_optionsFunction · 0.85
_from_user_inputMethod · 0.85
__process_playlistMethod · 0.85
str_to_intFunction · 0.85
parse_playlist_itemsMethod · 0.85
version_tupleFunction · 0.85
parse_http_rangeFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_int_or_noneMethod · 0.72
_real_extractMethod · 0.68
_real_extractMethod · 0.68
entriesMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…