File indexing completed on 2024-12-15 04:00:58

0001 #!/usr/bin/env python3
0002 
0003 # SPDX-FileCopyrightText: 2021 Mattia Basaglia <dev@dragon.best>
0004 # SPDX-License-Identifier: GPL-3.0-or-later
0005 
0006 import os
0007 import shutil
0008 import pathlib
0009 import argparse
0010 
0011 parser = argparse.ArgumentParser()
0012 parser.add_argument("source")
0013 parser.add_argument("dest")
0014 ns = parser.parse_args()
0015 
0016 ascii_A = 0x41
0017 emoji_A = 0x1F1E6
0018 emoji_flag = 0x1F3F4
0019 emoji_tag_A = 0xE0061
0020 emoji_tag_cancel = 0xE007F
0021 
0022 source = pathlib.Path(ns.source)
0023 dest = pathlib.Path(ns.dest)
0024 
0025 for file in source.iterdir():
0026     in_code = file.stem
0027     if "-" in in_code:
0028         out_code = [emoji_flag] + [emoji_tag_A + ord(c) - ascii_A for c in in_code.replace("-", "")] + [emoji_tag_cancel]
0029     else:
0030         out_code = [emoji_A + ord(c) - ascii_A for c in in_code]
0031 
0032     out_filename = "emoji_u" + "-".join("%x" % x for x in out_code) + file.suffix
0033     out_path = str(dest / out_filename)
0034 
0035     shutil.copyfile(str(file), out_path)