# -*- coding: utf-8 -*-
##################################################
# This file is part of WAPT Enterprise
# All right reserved, (c) Tranquil IT Systems 2023
# For more information please refer to
# https://wapt.tranquil.it/store/licences.html
##################################################
from setuphelpers import *

def install():
    ver = control.version.split("-")[0]
    bin_name = glob.glob("JOSM-macOS*-x64.zip")[0]
    mkdirs('/tmp/josm')
    unzip(bin_name, "/tmp/josm")
    if glob.glob('/Applications/JOSM*.app'):
        for app_dir in glob.glob('/Applications/JOSM*.app'):
            run(f'rm -rf {app_dir}')
    shutil.move('/tmp/josm/JOSM_24_x86_64.app', '/Applications/JOSM_24_x86_64.app')
    remove_tree("/tmp/josm")

def uninstall():
    remove_tree("/Applications/JOSM_24_x86_64.app")