Creates a valid TZif file at key under the zoneinfo root tz_root. tz_root must exist, but all folders below that will be created.
(self, key, tz_root)
| 1947 | return f.read() |
| 1948 | |
| 1949 | def touch_zone(self, key, tz_root): |
| 1950 | """Creates a valid TZif file at key under the zoneinfo root tz_root. |
| 1951 | |
| 1952 | tz_root must exist, but all folders below that will be created. |
| 1953 | """ |
| 1954 | if not os.path.exists(tz_root): |
| 1955 | raise FileNotFoundError(f"{tz_root} does not exist.") |
| 1956 | |
| 1957 | root_dir, *tail = key.rsplit("/", 1) |
| 1958 | if tail: # If there's no tail, then the first component isn't a dir |
| 1959 | os.makedirs(os.path.join(tz_root, root_dir), exist_ok=True) |
| 1960 | |
| 1961 | zonefile_path = os.path.join(tz_root, key) |
| 1962 | with open(zonefile_path, "wb") as f: |
| 1963 | f.write(self._UTC_bytes) |
| 1964 | |
| 1965 | def test_getattr_error(self): |
| 1966 | with self.assertRaises(AttributeError): |
no test coverage detected