I was going to write a long post on what this script does but hopefully me just using it gives you a better idea on what it does.
cc ✙ dcc :pedomustdie: :phear_slackware: (npub1lar…q5vr)
I think it should work for most cases but it might not be perfect.
pleroma@shikiv1:~/instance/static/emoji$ pwd
/opt/pleroma/instance/static/emoji
pleroma@shikiv1:~/instance/static/emoji$ mkdir new_pack
pleroma@shikiv1:~/instance/static/emoji$ cp new_import/generate.py new_pack/
pleroma@shikiv1:~/instance/static/emoji$ cd new_pack/
pleroma@shikiv1:~/instance/static/emoji/new_pack$ cat generate.py
import os
import json
def generate_json(directory_path, excluded_extensions=[".py", ".json"]):
data = {"files": {}}
for root, dirs, files in os.walk(directory_path):
for file in sorted(files):
file_name, file_extension = os.path.splitext(file)
if file_extension.lower() not in excluded_extensions:
data["files"][file_name] = file
return json.dumps(data, indent=2)
directory_path = "./"
json_data = generate_json(directory_path)
print(json_data)
pleroma@shikiv1:~/instance/static/emoji/new_pack$ #mind the indents when you paste this
pleroma@shikiv1:~/instance/static/emoji/new_pack$ for i in 1 2 3 4; do touch $i.jpg; done
pleroma@shikiv1:~/instance/static/emoji/new_pack$ ls
1.jpg 2.jpg 3.jpg 4.jpg generate.py
pleroma@shikiv1:~/instance/static/emoji/new_pack$ python3 generate.py
{
"files": {
"1": "1.jpg",
"2": "2.jpg",
"3": "3.jpg",
"4": "4.jpg"
}
}
pleroma@shikiv1:~/instance/static/emoji/new_pack$ python3 generate.py > pack.json
pleroma@shikiv1:~/instance/static/emoji/new_pack$ cat pack.json
{
"files": {
"1": "1.jpg",
"2": "2.jpg",
"3": "3.jpg",
"4": "4.jpg"
}
}
pleroma@shikiv1:~/instance/static/emoji/new_pack$