#!/usr/bin/python

import os
import shutil
import glob
ls = os.listdir(".")
files = ['*.deb', '*.tar.zst', '*.tar.xz', '*.rpm', '*.snap', '*.zip']

for x in ls:
    print(x)
    if os.path.isdir(x):
        os.chdir(x)
        try:
            if os.path.isdir('src'):
                shutil.rmtree('src')
            if os.path.isdir('pkg'):
                shutil.rmtree('pkg')
            for file in files:
                if glob.glob(file):
                    ffiles = glob.glob(file)
                    for ffile in ffiles:
                        print('removing', ffile)
                        os.remove(ffile)
        except OSError as e:
            print("Error: %s " % (e.strerror))
            pass
        os.chdir("..")
    else:
        print("is file ", x)
