#!/usr/bin/python3 """nc_nfd.py put|list — put the NFD-named twin of „Ödön születésnapja – fénykép lista.txt" into Nextcloud by WebDAV (as a Mac client would send it), then list the folder by PROPFIND and show each name's form (NFC/NFD) and bytes.""" import base64, os, sys, unicodedata, urllib.parse sys.path.insert(0, "/root/work"); from apps import http U = "odon"; H = {"Authorization": "Basic " + base64.b64encode(f"{U}:{os.environ['PW']}".encode()).decode()} d = "/root/data/nextcloud/Csalad/Kulonleges_nevek" B = f"https://cloud.tester4.test/remote.php/dav/files/{U}/Csalad/Kulonleges_nevek/" nfd = unicodedata.normalize("NFD", "Ödön születésnapja – fénykép lista.txt") if sys.argv[1] == "put": body = open(os.path.join(d, nfd), "rb").read() print("PUT NFD", http("PUT", B + urllib.parse.quote(nfd), body, H)[0]) st, out, _ = http("PROPFIND", B, None, dict(H, Depth="1")) import re for href in re.findall(rb"([^<]+)", out): name = urllib.parse.unquote(href.decode().rstrip("/").split("/")[-1]) if "rk" in name or "dön" in unicodedata.normalize("NFC", name): form = "NFC" if name == unicodedata.normalize("NFC", name) else "NFD" if name == unicodedata.normalize("NFD", name) else "mixed" print(f" {form} {len(name.encode())} bytes: {name}")