1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-03 17:10:27 +01:00
server-nalc/mods/u_skins/purge_skins.py
crabman77 d042026d0d added python script to delete skins removed when updatedb readd
-simply write int number of removed skin in removed_skins.txt (1 by line)
2015-05-02 17:20:40 +02:00

43 lines
995 B
Python
Executable File

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys, os
# if used on windows ??
# use os.path.join() -> path sep win "\" or linux "/"
p_textures = os.path.join("u_skins", "textures")
p_meta = os.path.join("u_skins", "meta")
try:
f = open("removed_skins.txt", "r")
skins_exclued = f.readlines()
except IOError as err:
sys.stderr.write("%s\n" % err)
sys.exit(1)
else:
f.close()
print("il y a %d skins exclus." % len(skins_exclued))
for skin in skins_exclued:
# if not int value, ignore
try:
skin = "character_%s" % int(skin.strip())
except ValueError as err:
sys.stderr.write("%s\n" % err)
continue
# for texture, preview and meta files
for f_skin in ( os.path.join(p_textures,"%s.png" % skin),
os.path.join(p_textures,"%s_preview.png" % skin),
os.path.join(p_meta, "%s.txt" % skin) ):
if os.path.exists(f_skin):
try:
os.remove(f_skin)
except exception as err:
print(err)
pass
else:
print('skin "%s" effacé' % f_skin)
sys.exit(0)