Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
stickerpicker
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
stickerpicker
Validations
f29c1653
Valider
f29c1653
rédigé
3 years ago
par
Tulir Asokan
Parcourir les fichiers
Options
Téléchargements
Plain Diff
Merge remote-tracking branch 'aWeinzierl/fix-encoding'
parents
ec8eeeea
569d9815
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
sticker/lib/util.py
+4
-2
4 ajouts, 2 suppressions
sticker/lib/util.py
sticker/pack.py
+3
-3
3 ajouts, 3 suppressions
sticker/pack.py
sticker/scalar_convert.py
+4
-4
4 ajouts, 4 suppressions
sticker/scalar_convert.py
sticker/stickerimport.py
+2
-2
2 ajouts, 2 suppressions
sticker/stickerimport.py
avec
13 ajouts
et
11 suppressions
sticker/lib/util.py
+
4
−
2
Voir le fichier @
f29c1653
...
...
@@ -13,6 +13,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from
functools
import
partial
from
io
import
BytesIO
import
os.path
import
json
...
...
@@ -21,6 +22,7 @@ from PIL import Image
from
.
import
matrix
open_utf8
=
partial
(
open
,
encoding
=
'
UTF-8
'
)
def
convert_image
(
data
:
bytes
)
->
(
bytes
,
int
,
int
):
image
:
Image
.
Image
=
Image
.
open
(
BytesIO
(
data
)).
convert
(
"
RGBA
"
)
...
...
@@ -41,7 +43,7 @@ def convert_image(data: bytes) -> (bytes, int, int):
def
add_to_index
(
name
:
str
,
output_dir
:
str
)
->
None
:
index_path
=
os
.
path
.
join
(
output_dir
,
"
index.json
"
)
try
:
with
open
(
index_path
)
as
index_file
:
with
open
_utf8
(
index_path
)
as
index_file
:
index_data
=
json
.
load
(
index_file
)
except
(
FileNotFoundError
,
json
.
JSONDecodeError
):
index_data
=
{
"
packs
"
:
[]}
...
...
@@ -49,7 +51,7 @@ def add_to_index(name: str, output_dir: str) -> None:
index_data
[
"
homeserver_url
"
]
=
matrix
.
homeserver_url
if
name
not
in
index_data
[
"
packs
"
]:
index_data
[
"
packs
"
].
append
(
name
)
with
open
(
index_path
,
"
w
"
)
as
index_file
:
with
open
_utf8
(
index_path
,
"
w
"
)
as
index_file
:
json
.
dump
(
index_data
,
index_file
,
indent
=
"
"
)
print
(
f
"
Added
{
name
}
to
{
index_path
}
"
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
sticker/pack.py
+
3
−
3
Voir le fichier @
f29c1653
...
...
@@ -93,7 +93,7 @@ async def main(args: argparse.Namespace) -> None:
dirname
=
os
.
path
.
basename
(
os
.
path
.
abspath
(
args
.
path
))
meta_path
=
os
.
path
.
join
(
args
.
path
,
"
pack.json
"
)
try
:
with
open
(
meta_path
)
as
pack_file
:
with
util
.
open_utf8
(
meta_path
)
as
pack_file
:
pack
=
json
.
load
(
pack_file
)
print
(
f
"
Loaded existing pack meta from
{
meta_path
}
"
)
except
FileNotFoundError
:
...
...
@@ -112,14 +112,14 @@ async def main(args: argparse.Namespace) -> None:
if
sticker
:
pack
[
"
stickers
"
].
append
(
sticker
)
with
open
(
meta_path
,
"
w
"
)
as
pack_file
:
with
util
.
open_utf8
(
meta_path
,
"
w
"
)
as
pack_file
:
json
.
dump
(
pack
,
pack_file
)
print
(
f
"
Wrote pack to
{
meta_path
}
"
)
if
args
.
add_to_index
:
picker_file_name
=
f
"
{
pack
[
'
id
'
]
}
.json
"
picker_pack_path
=
os
.
path
.
join
(
args
.
add_to_index
,
picker_file_name
)
with
open
(
picker_pack_path
,
"
w
"
)
as
pack_file
:
with
util
.
open_utf8
(
picker_pack_path
,
"
w
"
)
as
pack_file
:
json
.
dump
(
pack
,
pack_file
)
print
(
f
"
Copied pack to
{
picker_pack_path
}
"
)
util
.
add_to_index
(
picker_file_name
,
args
.
add_to_index
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
sticker/scalar_convert.py
+
4
−
4
Voir le fichier @
f29c1653
...
...
@@ -19,12 +19,12 @@ import json
index_path
=
"
../web/packs/index.json
"
try
:
with
open
(
index_path
)
as
index_file
:
with
util
.
open_utf8
(
index_path
)
as
index_file
:
index_data
=
json
.
load
(
index_file
)
except
(
FileNotFoundError
,
json
.
JSONDecodeError
):
index_data
=
{
"
packs
"
:
[]}
with
open
(
sys
.
argv
[
-
1
])
as
file
:
with
util
.
open_utf8
(
sys
.
argv
[
-
1
])
as
file
:
data
=
json
.
load
(
file
)
for
pack
in
data
[
"
assets
"
]:
...
...
@@ -45,12 +45,12 @@ for pack in data["assets"]:
}
filename
=
f
"
scalar-
{
pack
[
'
name
'
].
replace
(
'
'
,
'
_
'
)
}
.json
"
pack_path
=
f
"
web/packs/
{
filename
}
"
with
open
(
pack_path
,
"
w
"
)
as
pack_file
:
with
util
.
open_utf8
(
pack_path
,
"
w
"
)
as
pack_file
:
json
.
dump
(
pack_data
,
pack_file
)
print
(
f
"
Wrote
{
title
}
to
{
pack_path
}
"
)
if
filename
not
in
index_data
[
"
packs
"
]:
index_data
[
"
packs
"
].
append
(
filename
)
with
open
(
index_path
,
"
w
"
)
as
index_file
:
with
util
.
open_utf8
(
index_path
,
"
w
"
)
as
index_file
:
json
.
dump
(
index_data
,
index_file
,
indent
=
"
"
)
print
(
f
"
Updated
{
index_path
}
"
)
Ce diff est replié.
Cliquez pour l'agrandir.
sticker/stickerimport.py
+
2
−
2
Voir le fichier @
f29c1653
...
...
@@ -71,7 +71,7 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull, output_dir
already_uploaded
=
{}
try
:
with
open
(
pack_path
)
as
pack_file
:
with
util
.
open_utf8
(
pack_path
)
as
pack_file
:
existing_pack
=
json
.
load
(
pack_file
)
already_uploaded
=
{
int
(
sticker
[
"
net.maunium.telegram.sticker
"
][
"
id
"
]):
sticker
for
sticker
in
existing_pack
[
"
stickers
"
]}
...
...
@@ -99,7 +99,7 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull, output_dir
doc
[
"
body
"
]
=
sticker
.
emoticon
doc
[
"
net.maunium.telegram.sticker
"
][
"
emoticons
"
].
append
(
sticker
.
emoticon
)
with
open
(
pack_path
,
"
w
"
)
as
pack_file
:
with
util
.
open_utf8
(
pack_path
,
"
w
"
)
as
pack_file
:
json
.
dump
({
"
title
"
:
pack
.
set
.
title
,
"
id
"
:
f
"
tg-
{
pack
.
set
.
id
}
"
,
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter