Commit cb959f9b authored by Romain Casati's avatar Romain Casati
Browse files

Use of pathlib in basthon-kernel __main__ instead of os.path.

parent 0e2bd2da
......@@ -2,7 +2,7 @@
current directory.
"""
import os
from pathlib import Path
import shutil
import argparse
......@@ -12,7 +12,8 @@ from . import implementation
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--install', help='Install Basthon kernel in current directory',
parser.add_argument('--install',
help='Install Basthon kernel in current directory',
action="store_true")
args = parser.parse_args()
......@@ -21,15 +22,13 @@ def main():
print('Installing Basthon kernel {} in current directory'.format(
implementation))
data_path = os.path.join(os.path.dirname(__file__), 'data')
data_path = Path(__file__).parent / 'data'
for root, dirs, files in os.walk(data_path):
for f in files:
f = os.path.join(root, f)
shutil.copyfile(f, os.path.relpath(f, data_path))
for d in dirs:
d = os.path.join(root, d)
os.makedirs(os.path.relpath(d, data_path), exist_ok=True)
for path in data_path.rglob("*"):
if path.is_file():
shutil.copyfile(path, path.relative_to(data_path))
elif path.is_dir():
path.relative_to(data_path).mkdir(exist_ok=True)
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment