Skip to content
Extraits de code Groupes Projets
Valider a847bf0f rédigé par Miryuni's avatar Miryuni
Parcourir les fichiers

Added colors on the scripts

parent 55373b42
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -141,6 +141,7 @@ do ...@@ -141,6 +141,7 @@ do
convert "$slug/tmp/$f.$type" -resize "128x128" "$slug/tmp/size" convert "$slug/tmp/$f.$type" -resize "128x128" "$slug/tmp/size"
width=$(identify -format "%w" "$slug/tmp/size"[0])> /dev/null width=$(identify -format "%w" "$slug/tmp/size"[0])> /dev/null
height=$(identify -format "%h" "$slug/tmp/size"[0])> /dev/null height=$(identify -format "%h" "$slug/tmp/size"[0])> /dev/null
# Appending to json # Appending to json
echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":$height,\"w\":$width,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json" echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":$height,\"w\":$width,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json"
first="," first=","
......
import json import json
import sys import sys
from colorama import Fore, Back, Style
# Check the arguments # Check the arguments
# Pack is updated only if index and description are precised # Pack is updated only if index and description are precised
update = False update = False
if len(sys.argv) <= 1 or len(sys.argv) == 3: if len(sys.argv) <= 1 or len(sys.argv) == 3:
print("Usage : python updatePack.py pack.json [sticker_index] [new_description]") print("Usage : python updatePacks.py pack.json [sticker_index] [new_description]")
exit(1) exit(1)
elif len(sys.argv) > 3: elif len(sys.argv) > 3:
update = True update = True
...@@ -23,9 +24,9 @@ if update == False: ...@@ -23,9 +24,9 @@ if update == False:
# Print the number of stickers in this pack # Print the number of stickers in this pack
print("There are " +str(nb_stickers) + " stickers in this pack: ") print("There are " +str(nb_stickers) + " stickers in this pack: ")
for i in range(nb_stickers): for i in range(nb_stickers):
print(str(i+1) + ". " + json_pack['stickers'][i]['body']) print("\t"+str(i+1) + ". " + json_pack['stickers'][i]['body'])
print("To update one of them type:") print("To update one of them replace the red arguments:")
print("python updatePack.py " + sys.argv[1] + " sticker_index 'new_description'") print(Fore.CYAN +Style.BRIGHT + "python " +Style.RESET_ALL+ "updatePacks.py " + sys.argv[1] + Fore.RED + Style.BRIGHT+" sticker_index 'new_description'")
exit(0) exit(0)
# Informations # Informations
...@@ -41,8 +42,10 @@ elif sticker_index == 0: ...@@ -41,8 +42,10 @@ elif sticker_index == 0:
else: else:
json_pack['stickers'][sticker_index-1]['body'] = new_body json_pack['stickers'][sticker_index-1]['body'] = new_body
# Print the body of all the stickers # Print the body of all the stickers
print(Fore.GREEN + 'Updated!')
print("New sticker pack:")
for i in range(nb_stickers): for i in range(nb_stickers):
print(str(i+1) + ". " + json_pack['stickers'][i]['body']) print("\t "+str(i+1) + ". " + json_pack['stickers'][i]['body'])
out_file = open(sys.argv[1], 'w') out_file = open(sys.argv[1], 'w')
json.dump(json_pack, out_file, indent = 3) 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.
Veuillez vous inscrire ou vous pour commenter