Spaces:
Runtime error
Runtime error
File size: 1,063 Bytes
c893d6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
import shutil
import subprocess
from pathlib import Path
COMMON_FILES = ['.git', 'README.md', __file__.split('/')[-1]]
def remove_old_files():
filenames = os.listdir('./')
filenames = [f for f in filenames if f not in COMMON_FILES]
for file_path in filenames:
p = Path(file_path)
if p.exists():
if p.is_file():
p.unlink()
elif p.is_dir():
shutil.rmtree(p)
def clone_repository():
repo_url = 'https://github.com/KonradSzafer/hugging-face-qa-bot.git'
subprocess.run(['git', 'clone', repo_url])
def copy_files():
src = './hugging-face-qa-bot'
for item in COMMON_FILES:
full_path = os.path.join(src, item)
if os.path.isfile(full_path):
os.remove(full_path)
elif os.path.isdir(full_path):
shutil.rmtree(full_path)
for item in Path(src).iterdir():
shutil.move(str(item), '.')
shutil.rmtree(src)
if __name__ == '__main__':
remove_old_files()
clone_repository()
copy_files()
|