Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 33157854 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Try fix the gif bug

Adding gif doesn't works for the moment... but worked with the old
script... change the way files types are detected.
parent ea317015
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -171,7 +171,7 @@ file_get_height() {
echo "$HEIGHT"
}
file_get_type() { [[ "$1" =~ .*\.gif ]] && echo 'gif' || echo 'png'; }
file_get_type() { [[ "$1" == *.gif ]] && echo 'gif' || echo 'png'; }
file_get_name() { echo "$1" | cut -f1 -d'.'; }
upload_file() {
......
import json
import sys
from colorama import Fore, Back, Style
# Pack is updated only if index and description are given
update = False
if len(sys.argv) <= 1 or len(sys.argv) == 3:
print("Usage : python updatePacks.py pack.json [sticker_index] [new_description]")
exit(1)
elif len(sys.argv) > 3:
update = True
# Read the pack file
with open(sys.argv[1],'r') as myfile:
stickerpack = myfile.read()
# Parse the pack
json_pack = json.loads(stickerpack)
nb_stickers = len(json_pack['stickers'])
if update == False:
# Print the number of stickers in this pack
print("There are " + str(nb_stickers) + " stickers in this pack: ")
for i in range(nb_stickers):
print("\t"+str(i+1) + ". " + json_pack['stickers'][i]['body'])
# Print how to update the description of a sticker
print("To update a sticker, replace the arguments in red:")
print(Fore.CYAN +Style.BRIGHT + "python " +Style.RESET_ALL+ "updatePacks.py " + sys.argv[1] + Fore.RED + Style.BRIGHT+" sticker_index 'new_description'")
exit(0)
# Informations
sticker_index = int(sys.argv[2])
new_body = sys.argv[3]
# Change the body of the sticker_index
if sticker_index > nb_stickers:
print("Index out of range : "+ str(sticker_index) + " > "+str(nb_stickers))
exit(1)
elif sticker_index == 0:
print("Index starts at 1")
exit(1)
else:
# Update the body of the sticker
json_pack['stickers'][sticker_index-1]['body'] = new_body
# Print the body of all the stickers
print(Fore.GREEN + 'Updated!'+ Style.RESET_ALL)
print("New sticker pack:")
for i in range(nb_stickers):
if i == sticker_index-1:
print("\t "+Fore.GREEN+str(i+1) + ". " + json_pack['stickers'][i]['body']+Style.RESET_ALL)
else:
print("\t "+str(i+1) + ". " + json_pack['stickers'][i]['body'])
# Replace the old pack.json by the updated one
out_file = open(sys.argv[1], 'w')
json.dump(json_pack, out_file, indent = 3)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter