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)
| 1866 | return f.read() |
| 1867 | |
| 1868 | def touch_zone(self, key, tz_root): |
| 1869 | """Creates a valid TZif file at key under the zoneinfo root tz_root. |
| 1870 | |
| 1871 | tz_root must exist, but all folders below that will be created. |
| 1872 | """ |
| 1873 | if not os.path.exists(tz_root): |
| 1874 | raise FileNotFoundError(f"{tz_root} does not exist.") |
| 1875 | |
| 1876 | root_dir, *tail = key.rsplit("/", 1) |
| 1877 | if tail: # If there's no tail, then the first component isn't a dir |
| 1878 | os.makedirs(os.path.join(tz_root, root_dir), exist_ok=True) |
| 1879 | |
| 1880 | zonefile_path = os.path.join(tz_root, key) |
| 1881 | with open(zonefile_path, "wb") as f: |
| 1882 | f.write(self._UTC_bytes) |
| 1883 | |
| 1884 | def test_getattr_error(self): |
| 1885 | with self.assertRaises(AttributeError): |
no test coverage detected