MCPcopy Create free account
hub / github.com/comaps/comaps / init

Function init

tools/python/data/borders/__init__.py:17–44  ·  view source on GitHub ↗
(borders_path=None)

Source from the content-addressed store, hash-verified

15
16
17def init(borders_path=None):
18 data_path = find_data_files("omim-data")
19
20 if data_path is None:
21 logger.error("omim-data was not found.")
22 return False
23
24 if borders_path is None:
25 borders_path = os.path.join(data_path, "borders")
26
27 if not os.path.exists(borders_path):
28 tar_lzma_path = os.path.join(data_path, "borders.tar.xz")
29 lzma_stream = BytesIO()
30 with open(tar_lzma_path, mode="rb") as f:
31 decompressed = lzma.decompress(f.read())
32 lzma_stream.write(decompressed)
33
34 lzma_stream.seek(0)
35 try:
36 with tarfile.open(fileobj=lzma_stream, mode="r") as tar:
37 tar.extractall(borders_path)
38 except PermissionError as e:
39 logger.error(str(e))
40 return False
41
42 logger.info("{} was created.".format(borders_path))
43
44 return True

Callers

nothing calls this directly

Calls 6

find_data_filesFunction · 0.90
openMethod · 0.80
formatMethod · 0.80
joinMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected