MCPcopy Index your code
hub / github.com/python/cpython / _really_load

Method _really_load

Lib/http/cookiejar.py:1904–1978  ·  view source on GitHub ↗
(self, f, filename, ignore_discard, ignore_expires)

Source from the content-addressed store, hash-verified

1902 f.write(self.as_lwp_str(ignore_discard, ignore_expires))
1903
1904 def _really_load(self, f, filename, ignore_discard, ignore_expires):
1905 magic = f.readline()
1906 if not self.magic_re.search(magic):
1907 msg = ("%r does not look like a Set-Cookie3 (LWP) format "
1908 "file" % filename)
1909 raise LoadError(msg)
1910
1911 now = time.time()
1912
1913 header = "Set-Cookie3:"
1914 boolean_attrs = ("port_spec", "path_spec", "domain_dot",
1915 "secure", "discard")
1916 value_attrs = ("version",
1917 "port", "path", "domain",
1918 "expires",
1919 "comment", "commenturl")
1920
1921 try:
1922 while (line := f.readline()) != "":
1923 if not line.startswith(header):
1924 continue
1925 line = line[len(header):].strip()
1926
1927 for data in split_header_words([line]):
1928 name, value = data[0]
1929 standard = {}
1930 rest = {}
1931 for k in boolean_attrs:
1932 standard[k] = False
1933 for k, v in data[1:]:
1934 if k is not None:
1935 lc = k.lower()
1936 else:
1937 lc = None
1938 # don't lose case distinction for unknown fields
1939 if (lc in value_attrs) or (lc in boolean_attrs):
1940 k = lc
1941 if k in boolean_attrs:
1942 if v is None: v = True
1943 standard[k] = v
1944 elif k in value_attrs:
1945 standard[k] = v
1946 else:
1947 rest[k] = v
1948
1949 h = standard.get
1950 expires = h("expires")
1951 discard = h("discard")
1952 if expires is not None:
1953 expires = iso2time(expires)
1954 if expires is None:
1955 discard = True
1956 domain = h("domain")
1957 domain_specified = domain.startswith(".")
1958 c = Cookie(h("version"), name, value,
1959 h("port"), h("port_spec"),
1960 domain, domain_specified, h("domain_dot"),
1961 h("path"), h("path_spec"),

Callers 1

loadMethod · 0.45

Calls 14

is_expiredMethod · 0.95
LoadErrorClass · 0.85
split_header_wordsFunction · 0.85
iso2timeFunction · 0.85
CookieClass · 0.85
set_cookieMethod · 0.80
hFunction · 0.50
readlineMethod · 0.45
searchMethod · 0.45
timeMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected