diff --git a/pdm.lock b/pdm.lock index ffa6acb7..9e0b0199 100644 --- a/pdm.lock +++ b/pdm.lock @@ -415,7 +415,7 @@ files = [ [[package]] name = "tarina" -version = "0.6.1" +version = "0.6.4" requires_python = ">=3.9" summary = "A collection of common utils for Arclet" groups = ["default", "full"] @@ -423,83 +423,83 @@ dependencies = [ "typing-extensions>=4.4.0", ] files = [ - {file = "tarina-0.6.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f81108429347d78ff703061b6e071fe17183d3ec77d0e3a4386fef503ba7609e"}, - {file = "tarina-0.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:fc7ae6c003cd367a5e962c5c29ff525d7f4ec0ec0e040ba096aa13571ad36e25"}, - {file = "tarina-0.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f445dcd502de9762812c97dcd7f94ebabb33353c173f81d26e97979a080d579e"}, - {file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:651faa58c8949485a72f28daa5e1f16c79e2c57ab78eebdb0c5b1e422b5e5d27"}, - {file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:14d45da795ab3e4ef53ef0088650f31f02e5ad424ffce1f7b499ed17d56930b8"}, - {file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94d4b64e25f069ad912d258d360c136d96331ed8a04e590e576b5618edfda0e3"}, - {file = "tarina-0.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5b10559c3a4f14c051299fb8d504b6d06ecc5388fc6a58b0094450f63feeb93"}, - {file = "tarina-0.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2600bc9e113cbe7500e7deeee79dfd8bdf539b5a9a1dd7dd39c110ceb7ce2df0"}, - {file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:89fb41a2a3d0882ae3c76f59a5d59f082adc5844a1a5a9c1cd81ba392a81278d"}, - {file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:a1592ee78428163245f610629060f1de47b4fff3ee9a459e7a2fa8a37396cfeb"}, - {file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:9fc37ec243622e05f8858382541948bc95f58529fb714eeb3edfd509862d9d25"}, - {file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:4eb330aa9d0253513e6946144d633abb184df6e9412824252e26df435b4c7e6a"}, - {file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2eb88f319473117c6ce3a8adb42e72a8a1deecb25cf07a3661966d76125decd1"}, - {file = "tarina-0.6.1-cp310-cp310-win32.whl", hash = "sha256:470d4cb9e77d9950ec3c502b483d7672319033d6d9412e2505556136bbef6228"}, - {file = "tarina-0.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:6331774d2fc4b53a443c7aea765bc0f5325d704556f5a54c5b493548c30d248e"}, - {file = "tarina-0.6.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:21d0d2668bfe266e40cfc63fcaad6d4b082d48e51d5dedef68480ce9ef93f0d1"}, - {file = "tarina-0.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f89b816c22469f9f962e0546d83f2303b1ce76026ac0b01d860e78a063516ec9"}, - {file = "tarina-0.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:257f5de5dee0989f3fae910436b1033f89d59f6daf66caeaddb442ff0f300fdd"}, - {file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89bbb091209cf901d2238c750cc7f18221363b6d4df0ca5ae349b6edcc010b92"}, - {file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:06e63492d43591e68ec9d0c6a44182db831723def84047aad1aae0ed2f0b6887"}, - {file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:710d80de800abc85cd5eb70e976c6faa9eeb463a819af57b24480111de1eb4f8"}, - {file = "tarina-0.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:73dabdb38b2495978dd38b49e6972326a8554c94a079cf6a76b4f51afdabe4f2"}, - {file = "tarina-0.6.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:168897ef791944a58aefa6107859662b678284e4a423a5004abd86404d23b422"}, - {file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:444a9fae02ac1cbbd1dda606999910165dcedcf3c1dc038ae776c7a79bf6038d"}, - {file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:5f174ce1df1f39f8ca0f4f20df86f0ed3e53d9abfd834c69647179312a4d7242"}, - {file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:cace7ab14894861e562a846f5555c6089763489ce949f8e1d7da2ab0c4d98c99"}, - {file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:b67ee3b1f97e89161f4e534c607d465c671c6958ebd8a8596576b589971f002f"}, - {file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bfd4f5061e9a5d557265759d7225c24ab2bd609f73826369f700c4c4f7ae99f5"}, - {file = "tarina-0.6.1-cp311-cp311-win32.whl", hash = "sha256:e0729bd693f4a33b1656e3e5740279ea13a904ea798485040ac4017b7c38ad73"}, - {file = "tarina-0.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:3e2d202116fb37210bb6962f5fa9c7e5c4463c8d1ac179abf81659df287edb59"}, - {file = "tarina-0.6.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3c763640cdbd1a64c3572e101db8dd430f70e2ffb69ab1857f161d5858572b89"}, - {file = "tarina-0.6.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:516ab567580b1baad5f9caedeea5aea64c82a690c8a66b1488fddb86db7181c4"}, - {file = "tarina-0.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3cb0dd90866ba7041f935cbbddaecbc8a2dfedb17c4eb2d14b69aea0e9204722"}, - {file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40fb6e397ebe35935f3aa4cf6dd1635bc7481021915a3610d35a59cb33e1e1ae"}, - {file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5838c367f2d9819ece8343908c08f277d115b21a5d3bad18588f22dbc44f7410"}, - {file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b9b6870463e6bcf7e2958bccf7f2824eb4f7ffc99c88c8b27f5dd9be2fef8702"}, - {file = "tarina-0.6.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a6875f34a7f0d4e2663525a356954b0e81241e59b8e7a8df6f66f646e8ad3e7"}, - {file = "tarina-0.6.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0084193267ccc05058baffb550db7d814b3b2d8d13ee07fc363d4fe3fa947c4"}, - {file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:26ca97ef07d1ebc73ce44532c19d74f0a65087ffcd4ed193186ed98b8ca6db87"}, - {file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:bb123dde028433c612d207301d59f123a25ed25a0b2d13922b167b6595978d17"}, - {file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:3655e5cbd143be2ca7413202052f097fae36f9224cf12e5f2a790986803c5804"}, - {file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:fd70cf3b025de2fcc0d276e287aeafe2be3c05a0d2ef83a5b563c2f7d2bc9920"}, - {file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:bfd991c93400457d2fe58461b1d300e856d7e70881699c764c6912182525e0df"}, - {file = "tarina-0.6.1-cp312-cp312-win32.whl", hash = "sha256:a422689faebe0e2b701d9ca3b1a2d172e0d7434e1159fa42782c2a957f8828be"}, - {file = "tarina-0.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:3104baf80f6a9e1e0a1fb3d6fabe87f7b6bc97db7c2941267a219869628f79af"}, - {file = "tarina-0.6.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:a3be9f60c4b39eae8451f6c63adbadec585146fbc2d3698b7ed81289c8cc22d2"}, - {file = "tarina-0.6.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:af8e6f999dab61d96593fad7e32fd4ffefad64813cb993a45683e83ef486e70b"}, - {file = "tarina-0.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b2f9c59ba6852c6cf441adf5d287fc6597a0019f80040155541b1e39dcbff20e"}, - {file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0148199bcba92ef14e639029356a65894bae33ec3872b63ad1f9a1a9130ecaec"}, - {file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c69cef0e15856d4d2eb5817f00a85701f69c444e8fca0c50618d7bfde5b4104"}, - {file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b3c250ab55c75f073023d21118fbd706e661b76a49e4cac28a6cb71f0bf04873"}, - {file = "tarina-0.6.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a06308187f13c41f857d79c0b33d407eae34c16974a03a5711aa6b3bd27c129e"}, - {file = "tarina-0.6.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea1cf6026d81be5bc186882651f99a50d19ec7de33c580635848f52ecb0286e5"}, - {file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4cfa83aa4fe0fe0d394a93a70b7ec502c734a692d6dd6dc465fd4b591a0a6411"}, - {file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:608f74951318b2f24c83e4d11b068479363073cc7346785a7b54fe09386676e9"}, - {file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:98532739c0044a4afe8b345d6e07906a117af2d212ebe6e5fec7d3bca0b55dcb"}, - {file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:611f3338df2fd80261f5b979e18554d3edc5608dcf2b5873d312123142f18031"}, - {file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:c76ce872ef3cb3ed3fc7cd4dc6048f210218fe26cb2b951902b7102fe94698c1"}, - {file = "tarina-0.6.1-cp313-cp313-win32.whl", hash = "sha256:3059bf2b308d9fa77be7f18506061b6a2aee4c0fd633d0281ad6b4299bc418f0"}, - {file = "tarina-0.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:51aa1e65bff323838fb9205a66e5bdc299d507b8c52c62e9759949f77d68439a"}, - {file = "tarina-0.6.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:dbf72954eee214be1171c4d36216e6da253a8b2ce2ca6a1509489960bee4adbd"}, - {file = "tarina-0.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:15b8e4ebefd74a90c73151c3020ee335b83a24cc6255a4b0a8c58a90f40e2d7d"}, - {file = "tarina-0.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:761f61009f628a26b4ff1ed800c6b858bbc82372ba45775b19382136b48e60f8"}, - {file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:98a4229f4eb15a4a9b397684173a0013b5941273c68923e7ef464111e7ccf81f"}, - {file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:21f733def0ba7e9e4bef88bbacbfa978d1763dfc392abf8a5a3127812127d61a"}, - {file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e24cd3a9fed98af412a3dc8c6a82143fb00e9a448337fe846cbf36d27f002214"}, - {file = "tarina-0.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bde8c549a5ac165acd2e7578f501477c54ce47283b1a4cc09d468f9d93990d96"}, - {file = "tarina-0.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f37682c6e6984ef51ee2692dc71f3949d0eb390efb660635459c53802c2948"}, - {file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:0730ab7a8c0a3be19ce3e3bbfaad893c946acaa2cf2d191f5287ba35c9bf9a11"}, - {file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1d9186b7584d6884be799b038e7cf93011177cea2184080ff9849b17aa8ce2a6"}, - {file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:246eabe13f1496c19c6ea9e975398db5e78a936ebb784182cbfb5101593e8b8e"}, - {file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:835b93ee5ca9e302e993666a692b175ebc8514831c67e09368c1bf3e08d04be6"}, - {file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:33539f80a6de9360f1c187370057988762d598fed5eae1f4789db4952f39a59d"}, - {file = "tarina-0.6.1-cp39-cp39-win32.whl", hash = "sha256:e260313f2d62946121df941c37a7b4521e1849fa92c65236a7f35e328e77e947"}, - {file = "tarina-0.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:d59a5e3164a1c4f5095f8b8e16de1dbfd81eeb53a506a14ca1545ff7d0edbe2a"}, - {file = "tarina-0.6.1-py3-none-any.whl", hash = "sha256:cb9b95b62b2fee8fe86758af0acac147afa4646a7b0a7f272e0e74f3fc60cf3e"}, - {file = "tarina-0.6.1.tar.gz", hash = "sha256:153a415df95da7c08cf2a75a88c9f587e6d12fd8ec5caae01586bbbd2083f81c"}, + {file = "tarina-0.6.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7103d59fbea2374ef2baaa44f28771fa432070801662f81671212e9046564efc"}, + {file = "tarina-0.6.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8b69eadb9cadbe68b158d576ad1c19036cd9631af2ee451983c80bd7922d6432"}, + {file = "tarina-0.6.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5dcf32e68ffc8b45bf9424d5f9677e7e86aa0e93776b9f35d25f6724f8ff1852"}, + {file = "tarina-0.6.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77963877fbf6459d46b8048449a11c4568dd238b2769b2cc5f66b204d7867fb7"}, + {file = "tarina-0.6.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2234cffddbf8e41dd124d5499d6106e842d5e7b36a957ebd1f2ac29f2d3158d7"}, + {file = "tarina-0.6.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd78306553b61fcc685c2b259e02107297e771122f82f8ceb6f99ddad92c239e"}, + {file = "tarina-0.6.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ec086cb37f39942439691c2eb0e184356b7e56c7931b04aca4dbcf0a814dcf"}, + {file = "tarina-0.6.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fd57cee3ae8da2149b87ce9c983f0bbe95b808d2e9ef9173a08354570bee0770"}, + {file = "tarina-0.6.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:e30c68a4efa08c942cd764ba4bc4baba065cab90423510e2af58a0b5a4aa5573"}, + {file = "tarina-0.6.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e83ac84458886b8ee1fc5ad2124fb18fd4b96fc357612aa43d9a00d4c61d97a7"}, + {file = "tarina-0.6.4-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:9acbc120d67b1ac8286b830df979530b9062b2e3c3d18c0c22aecd8643b2bd2b"}, + {file = "tarina-0.6.4-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:8829afe680709ae74a165080aac6cbd59d7a4d2d922c3710113c1e41163569ba"}, + {file = "tarina-0.6.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f47536a38b6af1ae9ebd1d56bd61b81aa01976c7f8d8f3b1ed77d5ae2d60cbc5"}, + {file = "tarina-0.6.4-cp310-cp310-win32.whl", hash = "sha256:a43e93e7650163f8aa8351516c445ed5a591af0ff99d2d477cd5465eab16ca7b"}, + {file = "tarina-0.6.4-cp310-cp310-win_amd64.whl", hash = "sha256:d8f9f26840a68283b4d1e0bf86a528849a87156aedfc2fc6d1fbdf538a4d9a64"}, + {file = "tarina-0.6.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:34979ecf4fa23b4db00988fc8adbf48d4531642c3bdd8ddfab1dfd807c0ba99c"}, + {file = "tarina-0.6.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:be77d77d4eb2f5876eefe949a684f1ad3e15e9748665958c393ef8c680453a07"}, + {file = "tarina-0.6.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d8b4859919692d4a2ded6afdcbe1bf20eca9b2b490378da32dacd67f34ec53d2"}, + {file = "tarina-0.6.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f9063814d57eb05504427cfe2639f70609fb9785da9a2cf50a1d48f157c87f4"}, + {file = "tarina-0.6.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8aaccfb073b771853bd25b55a44a27e2b8edbefd1461998e72c6ee5ced59352c"}, + {file = "tarina-0.6.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c339e1f886fabd01d8e5ac7849ce59db335cce9d89e71e823828b133631f3096"}, + {file = "tarina-0.6.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d40add588014d164a3443fe8dea1646719af1aabe400e0e3f4e223d1a9217714"}, + {file = "tarina-0.6.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:41a2a99b4c14853e1a120ccf4deae39ac57461f013a14a89ecd3a8e49492449c"}, + {file = "tarina-0.6.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7c2b1c9cc7bb7eceb658c9c2866b59b45a807e746f88ec7a92fc658dc1f8d796"}, + {file = "tarina-0.6.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:121ec81d8bacdf1bc9cd2b928f390cb67dbacc1891182100f6ca8fd93546ee53"}, + {file = "tarina-0.6.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:ca81a5ce03348b5e7207bbb83595fd6fe37a8e70eb2355c5a1c774fc14d80f36"}, + {file = "tarina-0.6.4-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:acd34f3808dcb8e1c5fae21ee23aae5483997b80528e28e635e60e79c3e3a54e"}, + {file = "tarina-0.6.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:d3f18231c434463aff3af0a59f78fb845be48e656c370bfbc966c9bc1a90eedc"}, + {file = "tarina-0.6.4-cp311-cp311-win32.whl", hash = "sha256:7307c20afd1c7336cdd0e4612462a97aa0e93172d03036ebb346a99e9627d45a"}, + {file = "tarina-0.6.4-cp311-cp311-win_amd64.whl", hash = "sha256:e6ba7e793d7ca742d31f0a1daef073b0f0b2a61dd69308e3cadaeedff46a495f"}, + {file = "tarina-0.6.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:32bf3a98a830a3890a1fe345ac220e03599d6c9ce3145de11a681d6ee325bd0e"}, + {file = "tarina-0.6.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f5fd44e216c7a37062716c38fdd536e673e74263942af88fa8df0def1f5627ce"}, + {file = "tarina-0.6.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ae5059820bb1f123f7c4439011edf7baf4730b80ed271f7d7a7c7ae0255b8f52"}, + {file = "tarina-0.6.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:477b6575723da912ed8e22ad7658b41590dfe44271e694601ae57f528d950217"}, + {file = "tarina-0.6.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a5f9eb741674d9c2a63c09e1fae0e152c1888174eeb66602e97d80c923a68a05"}, + {file = "tarina-0.6.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a655c855e3fca93b54d9fec28145bc5717e661734a2eab1e9ee442565bc5dcdf"}, + {file = "tarina-0.6.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f29f718468538671b29ae2e39b90219dc74c0cced512eeb297fe5dbf9b7a6761"}, + {file = "tarina-0.6.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:801d0a1943a9682eafd98118c1116f97b3874066f2f5dc4d4b190c653d13a422"}, + {file = "tarina-0.6.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bcf4822d3ac9aa932dd2de70938baa2916bbcc0ac46e4cdb4516d178505da0bd"}, + {file = "tarina-0.6.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:56b30d3273756a3301c29b26fb3c06a07cd86019a633be2a8da3c5a8c480d893"}, + {file = "tarina-0.6.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:03d3adebd3cfe3d97cb03c73cc3a7c9a730a08137a11a26a814cead595c65614"}, + {file = "tarina-0.6.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:7febfdc6da11d399289046532016c375d759730ac72e8bf67fc8c60b3402d5da"}, + {file = "tarina-0.6.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8a3fb282773aa899fb1a61232f434abe914941ba35b7ae943c17d93433940e65"}, + {file = "tarina-0.6.4-cp312-cp312-win32.whl", hash = "sha256:df976004f1108781d538cca27278abcb6acd219f596de565c3259276cc31eb78"}, + {file = "tarina-0.6.4-cp312-cp312-win_amd64.whl", hash = "sha256:71e352b3e36b3d4554e98650e60faa62143bc8ec610b15ce5bfe82fa259b57a9"}, + {file = "tarina-0.6.4-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ba2326b7c5ecf9d9c064e7e445c51f33b1157f05beaf005b7b360c247b2a5e32"}, + {file = "tarina-0.6.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6913707eb4b81bf3fc60cac7293f1985c0c62cec97bb988422bfc073f39c9c74"}, + {file = "tarina-0.6.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:264e6fdf19ebda5e61ac307a1291349162e6c20cf3e3700fcea0e5737d801074"}, + {file = "tarina-0.6.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2650e12b58683b399590873b6ce39048418a333cfc986673fbfda3e942da5aee"}, + {file = "tarina-0.6.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cf24713bcc41a427b8891cb3682f1df3854190500fc6c30046166b5ff3c341ad"}, + {file = "tarina-0.6.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f541d714f5ec51c4fad929151fb941b43e98248235d161a8216c874f171a2a29"}, + {file = "tarina-0.6.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f79fda582466fa93d2462f2633ce542422f376441a71f07e0aee6ddb156e249c"}, + {file = "tarina-0.6.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aeb029f6e6be4f715ba9ba67d6f4c5213a31dc82c5ae83833fd034811dec40d1"}, + {file = "tarina-0.6.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0dc2f4ead738fd3d8c202a8b56117b25e9ea2bd7fe458a9bd4e9ec030468ece3"}, + {file = "tarina-0.6.4-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:a5532c4010c598928f9541aff07ad13c4f5bd77e756acef6e2d2fac39c8b195f"}, + {file = "tarina-0.6.4-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:04a83ec7f85e33f1b6a89e17f1e9d413d8474945fcc9a130fec8a224a2018765"}, + {file = "tarina-0.6.4-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:d9640caebf4cc96307a009f7323342404526fd6d70b92e0b1f4a8fcf695cb3c0"}, + {file = "tarina-0.6.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:398df8fb33e569d29acb04f16e0d14f90ed4b5dc3752e302908122042314420c"}, + {file = "tarina-0.6.4-cp313-cp313-win32.whl", hash = "sha256:3f18496c48cc1ef58353575eaab7ebd182347fc0dddd7ddf2a18bb00246d282a"}, + {file = "tarina-0.6.4-cp313-cp313-win_amd64.whl", hash = "sha256:ff83b121168a08b30c91dd6686fa3e27e7f9833ac6809d00abeb1f96be551229"}, + {file = "tarina-0.6.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:47a12ac3da9c7f116eb042615a77e34b1d9db985797c45402decde3f5602504c"}, + {file = "tarina-0.6.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ae246657043414cc190ab0585712723de8d7a24b57781542da47d8dfbedbec8e"}, + {file = "tarina-0.6.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d0beee6ad97d3b4b2c6c49623d39a163152ec8a466220db0135976090ead9327"}, + {file = "tarina-0.6.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5ec09acd6976f63606da3f154279e834dd56190cfa7df33c49bc2c6995d0c75"}, + {file = "tarina-0.6.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:888173bb30a4dec321ae1bc902aa91bba6e79656dc8df2c00b5e9ded8cbc79d2"}, + {file = "tarina-0.6.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:291c96f3b14d02fb18a3831963b4a5299e932d6aba33eff324a81c4e3fb0b758"}, + {file = "tarina-0.6.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea32160c94ea4687ceb39696459ac3d9edbcce12ee7614dfccdb1dfda587b42a"}, + {file = "tarina-0.6.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:998afedbeb1f55aae176315726a4494b81d8824be61aeb541332afb564264854"}, + {file = "tarina-0.6.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:42eacd4cba265349b358cf95b273f64662a759c269cdecd8a0ba29ba28c871a7"}, + {file = "tarina-0.6.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:c63bfbd60f590c5fc244e8f7ac162c6b2287c825cd557e3bb47c8be16491a0d0"}, + {file = "tarina-0.6.4-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:31980539da8ee0ba707c5cfcaf7d396ff8e5c6821337060611b9b45e3281cdbc"}, + {file = "tarina-0.6.4-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:363d4886399b1301aa1cba68619f1664034324cb32cf6ce58e4647f5ce006226"}, + {file = "tarina-0.6.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:945031cc48da4b381904c1fa6f278abe5062636e32b74b2d537480b5fac8ba3e"}, + {file = "tarina-0.6.4-cp39-cp39-win32.whl", hash = "sha256:8b9fdedb406583b82692a64a0b53e331ab29bc66fa563d9497521227992e60f5"}, + {file = "tarina-0.6.4-cp39-cp39-win_amd64.whl", hash = "sha256:85ddc413dd7163adbe825a9ad1328d53749a50c7adab817741d255d244a5707d"}, + {file = "tarina-0.6.4-py3-none-any.whl", hash = "sha256:f808c5eb5f59a2568c715131a99f665a0aff4ad697ed9c13dc7aa39d8086c75b"}, + {file = "tarina-0.6.4.tar.gz", hash = "sha256:a421bec7e5e6b2af9728984cf749d379d2b05a215f55790a9181fb0c452a5520"}, ] [[package]] diff --git a/src/arclet/alconna/args.py b/src/arclet/alconna/args.py index 433eb38b..4e80b869 100644 --- a/src/arclet/alconna/args.py +++ b/src/arclet/alconna/args.py @@ -9,8 +9,9 @@ from typing_extensions import dataclass_transform, ParamSpec, Concatenate, TypeAlias from nepattern import NONE, Pattern, RawStr, UnionPattern, parser -from tarina import Empty, lang +from tarina import Empty +from .i18n import i18n from ._dcls import safe_dcls_kw, safe_field_kw from .exceptions import InvalidArgs from .utils import TAValue, parent_frame_namespace, merge_cls_and_parent_ns @@ -122,16 +123,16 @@ def __init__( **kwargs, ): if not isinstance(name, str) or name.startswith("$"): - raise InvalidArgs(lang.require("args", "name_error")) + raise InvalidArgs(i18n.require("args.name_error")) if not name.strip(): - raise InvalidArgs(lang.require("args", "name_empty")) + raise InvalidArgs(i18n.require("args.name_empty")) self.name = name _value = parser(type_ or RawStr(name)) default = field if isinstance(field, Field) else Field(field) if isinstance(_value, UnionPattern) and _value.optional: default.default = None if default.default is Empty else default.default # type: ignore if _value == NONE: - raise InvalidArgs(lang.require("args", "value_error").format(target=name)) + raise InvalidArgs(i18n.require("args.value_error").format(target=name)) self.type_ = _value # type: ignore self.field = default @@ -236,12 +237,12 @@ def __check_vars__(self): raise InvalidArgs("varkey cannot use the same sep as varpos's Arg") self.vars_keyword.append((flag, arg)) elif self.keyword_only: - raise InvalidArgs(lang.require("args", "exclude_mutable_args")) + raise InvalidArgs(i18n.require("args.exclude_mutable_args")) else: self.vars_positional.append((flag, arg)) elif arg.field.kw_only: if self.vars_keyword: - raise InvalidArgs(lang.require("args", "exclude_mutable_args")) + raise InvalidArgs(i18n.require("args.exclude_mutable_args")) self.keyword_only[arg.name] = arg else: self.normal.append(arg) diff --git a/src/arclet/alconna/base.py b/src/arclet/alconna/base.py index b03c7b28..2b68d93e 100644 --- a/src/arclet/alconna/base.py +++ b/src/arclet/alconna/base.py @@ -8,8 +8,9 @@ from nepattern import TPattern from typing_extensions import Self -from tarina import Empty, lang +from tarina import Empty +from .i18n import i18n from .action import Action, store from .args import ARGS_PARAM, Arg, ArgsBase, ArgsBuilder, _Args, handle_args from .exceptions import InvalidArgs @@ -162,7 +163,7 @@ def check_fuzzy(self, source: str, threshold: float): headers_text.append(f"{prefix} {command}") for ht in headers_text: if levenshtein(source, ht) >= threshold: - return lang.require("fuzzy", "matched").format(target=source, source=ht) + return i18n.require("fuzzy.matched").format(target=source, source=ht) def _handle_default(node: CommandNode): @@ -251,7 +252,7 @@ def __init__( name = _aliases[0] aliases.extend(_aliases[1:]) if not name: - raise InvalidArgs(lang.require("common", "name_empty")) + raise InvalidArgs(i18n.require("common.name_empty")) aliases.insert(0, name) self.name = name self.aliases = frozenset(aliases) diff --git a/src/arclet/alconna/builtin.py b/src/arclet/alconna/builtin.py index d5e43440..9ef4dbde 100644 --- a/src/arclet/alconna/builtin.py +++ b/src/arclet/alconna/builtin.py @@ -5,8 +5,8 @@ from tarina import Empty +from .i18n import i18n from .arparma import Arparma, ArparmaBehavior -from .config import lang from .exceptions import BehaveCancelled from .base import OptionResult, SubcommandResult @@ -22,10 +22,10 @@ class ConflictWith(ArparmaBehavior): def get_type(self, res): if isinstance(res, OptionResult): - return lang.require("builtin", "conflict.option") + return i18n.require("builtin.conflict.option") if isinstance(res, SubcommandResult): - return lang.require("builtin", "conflict.subcommand") - return lang.require("builtin", "conflict.arg") + return i18n.require("builtin.conflict.subcommand") + return i18n.require("builtin.conflict.arg") def operate(self, interface: Arparma): if (s_r := interface.query(self.source, Empty)) is not Empty and (t_r := interface.query(self.target, Empty)) is not Empty: @@ -35,7 +35,7 @@ def operate(self, interface: Arparma): return if self.target_limiter and not self.target_limiter(t_r): return - interface.behave_fail(lang.require("builtin", "conflict.msg").format( + interface.behave_fail(i18n.require("builtin.conflict.msg").format( source_type=source_type, target_type=target_type, source=self.source, diff --git a/src/arclet/alconna/config.py b/src/arclet/alconna/config.py index e88a312f..7218212e 100644 --- a/src/arclet/alconna/config.py +++ b/src/arclet/alconna/config.py @@ -1,9 +1,9 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import TYPE_CHECKING, Any, Callable, ContextManager, Literal, TypedDict +from typing import TYPE_CHECKING, Any, Callable, ContextManager, TypedDict -from .i18n import lang as lang +from .i18n import i18n as i18n from .base import Config from .utils import DataCollection @@ -123,4 +123,4 @@ def default_namespace(self, np: str | Namespace): global_config = _AlconnaConfig() -__all__ = ["global_config", "Namespace", "namespace", "lang"] +__all__ = ["global_config", "Namespace", "namespace", "i18n"] diff --git a/src/arclet/alconna/core.py b/src/arclet/alconna/core.py index 6a1fd606..3965adc0 100644 --- a/src/arclet/alconna/core.py +++ b/src/arclet/alconna/core.py @@ -11,8 +11,9 @@ from weakref import WeakSet from nepattern import TPattern -from tarina import init_spec, lang, Empty +from tarina import init_spec, Empty +from .i18n import i18n from .ingedia._analyser import Analyser from .ingedia._handlers import analyse_header from .ingedia._argv import Argv, __argv_type__ @@ -50,7 +51,7 @@ def handle_argv(): def add_builtin_options(options: list[Option | Subcommand], router: Router, conf: Config) -> None: if "help" not in conf.disable_builtin_options: - options.append(hlp := Help("|".join(conf.builtin_option_name["help"]), dest="$help", help_text=lang.require("builtin", "option_help"), soft_keyword=False)) # noqa: E501 + options.append(hlp := Help("|".join(conf.builtin_option_name["help"]), dest="$help", help_text=i18n.require("builtin.option_help"), soft_keyword=False)) # noqa: E501 @router.route(f"*.{hlp.name}") @router.route("$help") @@ -67,7 +68,7 @@ def _(command: Alconna, arp: Arparma): "|".join(conf.builtin_option_name["shortcut"]), Args.action("delete|list", optional=True).name(str, optional=True).command(str, optional=True), dest="$shortcut", - help_text=lang.require("builtin", "option_shortcut"), + help_text=i18n.require("builtin.option_shortcut"), soft_keyword=False, ) ) @@ -81,7 +82,7 @@ def _(command: Alconna, arp: Arparma): arp.output = "\n".join(data) return True if not res.args.get("name"): - raise ValueError(lang.require("shortcut", "name_require")) + raise ValueError(i18n.require("shortcut.name_require")) if res.args.get("action") == "delete": msg = command.shortcut(res.args["name"], delete=True) else: @@ -92,7 +93,7 @@ def _(command: Alconna, arp: Arparma): router._routes.pop("$shortcut", None) if "completion" not in conf.disable_builtin_options: - options.append(comp := Completion("|".join(conf.builtin_option_name["completion"]), dest="$completion", help_text=lang.require("builtin", "option_completion"), soft_keyword=False)) # noqa: E501 + options.append(comp := Completion("|".join(conf.builtin_option_name["completion"]), dest="$completion", help_text=i18n.require("builtin.option_completion"), soft_keyword=False)) # noqa: E501 @router.route(f"*.{comp.name}") @router.route("$completion") @@ -110,8 +111,8 @@ def _(command: Alconna, arp: Arparma): [*arp.value_result.keys()], trigger ): - prompt_other = lang.require("completion", "prompt_other") - node = lang.require('completion', 'node') + prompt_other = i18n.require("completion.prompt_other") + node = i18n.require('completion', 'node') node = f"{node}\n" if node else "" arp.output = f"{node}{prompt_other}" + f"\n{prompt_other}".join([i.text for i in res]) return True diff --git a/src/arclet/alconna/formatter.py b/src/arclet/alconna/formatter.py index 7670ca6a..3c6f55a0 100644 --- a/src/arclet/alconna/formatter.py +++ b/src/arclet/alconna/formatter.py @@ -4,8 +4,9 @@ from typing import TYPE_CHECKING, Any, TypedDict from nepattern import ANY, AnyString -from tarina import Empty, lang +from tarina import Empty +from .i18n import i18n from .args import Arg, _Args from .base import Option, Subcommand from .utils import AllParam @@ -179,7 +180,7 @@ def parameters(self, args: _Args) -> str: res += self.param(arg) + sep notice = [(arg.name, arg.field.notice) for arg in args.data if arg.field.notice] return ( - (f"{res}\n## {lang.require('format', 'notice')}\n " + "\n ".join([f"{v[0]}: {v[1]}" for v in notice])) + (f"{res}\n## {i18n.require('format', 'notice')}\n " + "\n ".join([f"{v[0]}: {v[1]}" for v in notice])) if notice else res ) @@ -191,8 +192,8 @@ def header(self, root: TraceHead) -> tuple[str, str, str, str]: root (TraceHead): 头部节点数据 """ help_string = f"{desc}" if (desc := root["description"]) else "" - usage = f"{lang.require('format', 'usage')}:\n{usage}" if (usage := root.get("usage")) else "" - example = f"{lang.require('format', 'example')}:\n{example}" if (example := root.get("example")) else "" + usage = f"{i18n.require('format', 'usage')}:\n{usage}" if (usage := root.get("usage")) else "" + example = f"{i18n.require('format', 'example')}:\n{example}" if (example := root.get("example")) else "" return root["name"], help_string, usage, example def opt(self, node: Option) -> str: @@ -212,8 +213,8 @@ def sub(self, node: Subcommand) -> str: for sub in filter(lambda x: isinstance(x, Subcommand), node.options) ] ) - opt_help = f" {lang.require('format', 'subcommands.opts')}:\n " if opt_string else "" - sub_help = f" {lang.require('format', 'subcommands.subs')}:\n " if sub_string else "" + opt_help = f" {i18n.require('format', 'subcommands.opts')}:\n " if opt_string else "" + sub_help = f" {i18n.require('format', 'subcommands.subs')}:\n " if sub_string else "" return ( f"* {node.help_text}\n" f" {alias_text}{node.separators[0]}{self.parameters(node.args)}\n" @@ -227,8 +228,8 @@ def body(self, parts: list[Option | Subcommand]) -> str: [self.opt(opt) for opt in parts if isinstance(opt, Option) and opt.name not in self.ignore_names] ) subcommand_string = "".join([self.sub(sub) for sub in parts if isinstance(sub, Subcommand)]) - option_help = f"{lang.require('format', 'options')}:\n" if option_string else "" - subcommand_help = f"{lang.require('format', 'subcommands')}:\n" if subcommand_string else "" + option_help = f"{i18n.require('format', 'options')}:\n" if option_string else "" + subcommand_help = f"{i18n.require('format', 'subcommands')}:\n" if subcommand_string else "" return f"{subcommand_help}{subcommand_string}{option_help}{option_string}" def shortcut(self, shortcuts: dict[str, Any]) -> str: @@ -243,7 +244,7 @@ def shortcut(self, shortcuts: dict[str, Any]) -> str: result.append(f"'{prefixes}{_key}' => {prefixes}{short.command} {' '.join(map(str, short.args))}") else: result.append(f"'{key}' => {short.origin!r}") - return f"{lang.require('format', 'shortcuts')}:\n" + "\n".join(result) + return f"{i18n.require('format', 'shortcuts')}:\n" + "\n".join(result) __all__ = ["TextFormatter", "Trace", "TraceHead"] diff --git a/src/arclet/alconna/i18n/.config.json b/src/arclet/alconna/i18n/.config.json index 0ecb9784..812c0762 100644 --- a/src/arclet/alconna/i18n/.config.json +++ b/src/arclet/alconna/i18n/.config.json @@ -1,9 +1,9 @@ { "default": "zh-CN", "frozen": [ - "builtin" + "alconna.builtin" ], "require": [ - "builtin" + "alconna.builtin" ] } \ No newline at end of file diff --git a/src/arclet/alconna/i18n/.lang.schema.json b/src/arclet/alconna/i18n/.lang.schema.json index 47afa90f..20fa8348 100644 --- a/src/arclet/alconna/i18n/.lang.schema.json +++ b/src/arclet/alconna/i18n/.lang.schema.json @@ -3,465 +3,473 @@ "description": "Schema for lang file", "type": "object", "properties": { - "common": { - "title": "Common", - "description": "Scope 'common' of lang item", + "alconna": { + "title": "Alconna", + "description": "Scope 'alconna' of lang item", "type": "object", "additionalProperties": false, "properties": { - "custom_type_error": { - "title": "custom_type_error", - "description": "value of lang item type 'custom_type_error'", - "type": "string" - }, - "name_empty": { - "title": "name_empty", - "description": "value of lang item type 'name_empty'", - "type": "string" - } - } - }, - "completion": { - "title": "Completion", - "description": "Scope 'completion' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "node": { - "title": "node", - "description": "value of lang item type 'node'", - "type": "string" - }, - "prompt_select": { - "title": "prompt_select", - "description": "value of lang item type 'prompt_select'", - "type": "string" - }, - "prompt_other": { - "title": "prompt_other", - "description": "value of lang item type 'prompt_other'", - "type": "string" - }, - "prompt_empty": { - "title": "prompt_empty", - "description": "value of lang item type 'prompt_empty'", - "type": "string" - }, - "prompt_unavailable": { - "title": "prompt_unavailable", - "description": "value of lang item type 'prompt_unavailable'", - "type": "string" - } - } - }, - "fuzzy": { - "title": "Fuzzy", - "description": "Scope 'fuzzy' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "matched": { - "title": "matched", - "description": "value of lang item type 'matched'", - "type": "string" - } - } - }, - "action": { - "title": "Action", - "description": "Scope 'action' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "length_error": { - "title": "length_error", - "description": "value of lang item type 'length_error'", - "type": "string" - }, - "args_error": { - "title": "args_error", - "description": "value of lang item type 'args_error'", - "type": "string" - }, - "args_not_same": { - "title": "args_not_same", - "description": "value of lang item type 'args_not_same'", - "type": "string" - }, - "args_empty": { - "title": "args_empty", - "description": "value of lang item type 'args_empty'", - "type": "string" - } - } - }, - "argv": { - "title": "Argv", - "description": "Scope 'argv' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "null_message": { - "title": "null_message", - "description": "value of lang item type 'null_message'", - "type": "string" - } - } - }, - "analyser": { - "title": "Analyser", - "description": "Scope 'analyser' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "param_unmatched": { - "title": "param_unmatched", - "description": "value of lang item type 'param_unmatched'", - "type": "string" - }, - "param_missing": { - "title": "param_missing", - "description": "value of lang item type 'param_missing'", - "type": "string" - } - } - }, - "header": { - "title": "Header", - "description": "Scope 'header' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "error": { - "title": "error", - "description": "value of lang item type 'error'", - "type": "string" - }, - "prefix_error": { - "title": "prefix_error", - "description": "value of lang item type 'prefix_error'", - "type": "string" - } - } - }, - "option": { - "title": "Option", - "description": "Scope 'option' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "name_error": { - "title": "name_error", - "description": "value of lang item type 'name_error'", - "type": "string" - }, - "require_error": { - "title": "require_error", - "description": "value of lang item type 'require_error'", - "type": "string" - } - } - }, - "subcommand": { - "title": "Subcommand", - "description": "Scope 'subcommand' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "name_error": { - "title": "name_error", - "description": "value of lang item type 'name_error'", - "type": "string" - }, - "require_error": { - "title": "require_error", - "description": "value of lang item type 'require_error'", - "type": "string" - }, - "args_missing": { - "title": "args_missing", - "description": "value of lang item type 'args_missing'", - "type": "string" - } - } - }, - "args": { - "title": "Args", - "description": "Scope 'args' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "name_error": { - "title": "name_error", - "description": "value of lang item type 'name_error'", - "type": "string" - }, - "name_empty": { - "title": "name_empty", - "description": "value of lang item type 'name_empty'", - "type": "string" - }, - "value_error": { - "title": "value_error", - "description": "value of lang item type 'value_error'", - "type": "string" - }, - "duplicate_kwargs": { - "title": "duplicate_kwargs", - "description": "value of lang item type 'duplicate_kwargs'", - "type": "string" - }, - "duplicate_varargs": { - "title": "duplicate_varargs", - "description": "value of lang item type 'duplicate_varargs'", - "type": "string" - }, - "exclude_mutable_args": { - "title": "exclude_mutable_args", - "description": "value of lang item type 'exclude_mutable_args'", - "type": "string" - }, - "key_not_found": { - "title": "key_not_found", - "description": "value of lang item type 'key_not_found'", - "type": "string" - }, - "missing": { - "title": "missing", - "description": "value of lang item type 'missing'", - "type": "string" - }, - "key_missing": { - "title": "key_missing", - "description": "value of lang item type 'key_missing'", - "type": "string" - } - } - }, - "shortcut": { - "title": "Shortcut", - "description": "Scope 'shortcut' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "name_require": { - "title": "name_require", - "description": "value of lang item type 'name_require'", - "type": "string" - }, - "delete_success": { - "title": "delete_success", - "description": "value of lang item type 'delete_success'", - "type": "string" - }, - "add_success": { - "title": "add_success", - "description": "value of lang item type 'add_success'", - "type": "string" - }, - "recent_command_error": { - "title": "recent_command_error", - "description": "value of lang item type 'recent_command_error'", - "type": "string" - } - } - }, - "manager": { - "title": "Manager", - "description": "Scope 'manager' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "undefined_command": { - "title": "undefined_command", - "description": "value of lang item type 'undefined_command'", - "type": "string" + "common": { + "title": "Common", + "description": "Scope 'common' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "custom_type_error": { + "title": "custom_type_error", + "description": "value of lang item type 'custom_type_error'", + "type": "string" + }, + "name_empty": { + "title": "name_empty", + "description": "value of lang item type 'name_empty'", + "type": "string" + } + } }, - "incorrect_shortcut": { - "title": "incorrect_shortcut", - "description": "value of lang item type 'incorrect_shortcut'", - "type": "string" + "completion": { + "title": "Completion", + "description": "Scope 'completion' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "node": { + "title": "node", + "description": "value of lang item type 'node'", + "type": "string" + }, + "prompt_select": { + "title": "prompt_select", + "description": "value of lang item type 'prompt_select'", + "type": "string" + }, + "prompt_other": { + "title": "prompt_other", + "description": "value of lang item type 'prompt_other'", + "type": "string" + }, + "prompt_empty": { + "title": "prompt_empty", + "description": "value of lang item type 'prompt_empty'", + "type": "string" + }, + "prompt_unavailable": { + "title": "prompt_unavailable", + "description": "value of lang item type 'prompt_unavailable'", + "type": "string" + } + } }, - "undefined_shortcut": { - "title": "undefined_shortcut", - "description": "value of lang item type 'undefined_shortcut'", - "type": "string" + "fuzzy": { + "title": "Fuzzy", + "description": "Scope 'fuzzy' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "matched": { + "title": "matched", + "description": "value of lang item type 'matched'", + "type": "string" + } + } }, - "shortcut_parse_error": { - "title": "shortcut_parse_error", - "description": "value of lang item type 'shortcut_parse_error'", - "type": "string" + "action": { + "title": "Action", + "description": "Scope 'action' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "length_error": { + "title": "length_error", + "description": "value of lang item type 'length_error'", + "type": "string" + }, + "args_error": { + "title": "args_error", + "description": "value of lang item type 'args_error'", + "type": "string" + }, + "args_not_same": { + "title": "args_not_same", + "description": "value of lang item type 'args_not_same'", + "type": "string" + }, + "args_empty": { + "title": "args_empty", + "description": "value of lang item type 'args_empty'", + "type": "string" + } + } }, - "help_header": { - "title": "help_header", - "description": "value of lang item type 'help_header'", - "type": "string" + "argv": { + "title": "Argv", + "description": "Scope 'argv' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "null_message": { + "title": "null_message", + "description": "value of lang item type 'null_message'", + "type": "string" + } + } }, - "help_pages": { - "title": "help_pages", - "description": "value of lang item type 'help_pages'", - "type": "string" + "analyser": { + "title": "Analyser", + "description": "Scope 'analyser' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "param_unmatched": { + "title": "param_unmatched", + "description": "value of lang item type 'param_unmatched'", + "type": "string" + }, + "param_missing": { + "title": "param_missing", + "description": "value of lang item type 'param_missing'", + "type": "string" + } + } }, - "help_footer": { - "title": "help_footer", - "description": "value of lang item type 'help_footer'", - "type": "string" - } - } - }, - "arparma": { - "title": "Arparma", - "description": "Scope 'arparma' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "ambiguous_name": { - "title": "ambiguous_name", - "description": "value of lang item type 'ambiguous_name'", - "type": "string" - } - } - }, - "stub": { - "title": "Stub", - "description": "Scope 'stub' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "key_error": { - "title": "key_error", - "description": "value of lang item type 'key_error'", - "type": "string" - } - } - }, - "duplication": { - "title": "Duplication", - "description": "Scope 'duplication' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "stub_type_error": { - "title": "stub_type_error", - "description": "value of lang item type 'stub_type_error'", - "type": "string" - } - } - }, - "behavior": { - "title": "Behavior", - "description": "Scope 'behavior' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "exclude_matched": { - "title": "exclude_matched", - "description": "value of lang item type 'exclude_matched'", - "type": "string" + "header": { + "title": "Header", + "description": "Scope 'header' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "error": { + "title": "error", + "description": "value of lang item type 'error'", + "type": "string" + }, + "prefix_error": { + "title": "prefix_error", + "description": "value of lang item type 'prefix_error'", + "type": "string" + } + } }, - "cooldown_matched": { - "title": "cooldown_matched", - "description": "value of lang item type 'cooldown_matched'", - "type": "string" - } - } - }, - "builtin": { - "title": "Builtin", - "description": "Scope 'builtin' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "option_help": { - "title": "option_help", - "description": "value of lang item type 'option_help'", - "type": "string" + "option": { + "title": "Option", + "description": "Scope 'option' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "name_error": { + "title": "name_error", + "description": "value of lang item type 'name_error'", + "type": "string" + }, + "require_error": { + "title": "require_error", + "description": "value of lang item type 'require_error'", + "type": "string" + } + } }, - "option_shortcut": { - "title": "option_shortcut", - "description": "value of lang item type 'option_shortcut'", - "type": "string" + "subcommand": { + "title": "Subcommand", + "description": "Scope 'subcommand' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "name_error": { + "title": "name_error", + "description": "value of lang item type 'name_error'", + "type": "string" + }, + "require_error": { + "title": "require_error", + "description": "value of lang item type 'require_error'", + "type": "string" + }, + "args_missing": { + "title": "args_missing", + "description": "value of lang item type 'args_missing'", + "type": "string" + } + } }, - "option_completion": { - "title": "option_completion", - "description": "value of lang item type 'option_completion'", - "type": "string" + "args": { + "title": "Args", + "description": "Scope 'args' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "name_error": { + "title": "name_error", + "description": "value of lang item type 'name_error'", + "type": "string" + }, + "name_empty": { + "title": "name_empty", + "description": "value of lang item type 'name_empty'", + "type": "string" + }, + "value_error": { + "title": "value_error", + "description": "value of lang item type 'value_error'", + "type": "string" + }, + "duplicate_kwargs": { + "title": "duplicate_kwargs", + "description": "value of lang item type 'duplicate_kwargs'", + "type": "string" + }, + "duplicate_varargs": { + "title": "duplicate_varargs", + "description": "value of lang item type 'duplicate_varargs'", + "type": "string" + }, + "exclude_mutable_args": { + "title": "exclude_mutable_args", + "description": "value of lang item type 'exclude_mutable_args'", + "type": "string" + }, + "key_not_found": { + "title": "key_not_found", + "description": "value of lang item type 'key_not_found'", + "type": "string" + }, + "missing": { + "title": "missing", + "description": "value of lang item type 'missing'", + "type": "string" + }, + "key_missing": { + "title": "key_missing", + "description": "value of lang item type 'key_missing'", + "type": "string" + } + } }, - "conflict": { - "title": "Conflict", - "description": "Scope 'conflict' of lang item", + "shortcut": { + "title": "Shortcut", + "description": "Scope 'shortcut' of lang item", "type": "object", "additionalProperties": false, "properties": { - "option": { - "title": "option", - "description": "value of lang item type 'option'", + "name_require": { + "title": "name_require", + "description": "value of lang item type 'name_require'", "type": "string" }, - "subcommand": { - "title": "subcommand", - "description": "value of lang item type 'subcommand'", + "delete_success": { + "title": "delete_success", + "description": "value of lang item type 'delete_success'", "type": "string" }, - "arg": { - "title": "arg", - "description": "value of lang item type 'arg'", + "add_success": { + "title": "add_success", + "description": "value of lang item type 'add_success'", "type": "string" }, - "msg": { - "title": "msg", - "description": "value of lang item type 'msg'", + "recent_command_error": { + "title": "recent_command_error", + "description": "value of lang item type 'recent_command_error'", "type": "string" } } - } - } - }, - "format": { - "title": "Format", - "description": "Scope 'format' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { - "notice": { - "title": "notice", - "description": "value of lang item type 'notice'", - "type": "string" }, - "usage": { - "title": "usage", - "description": "value of lang item type 'usage'", - "type": "string" + "manager": { + "title": "Manager", + "description": "Scope 'manager' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "undefined_command": { + "title": "undefined_command", + "description": "value of lang item type 'undefined_command'", + "type": "string" + }, + "incorrect_shortcut": { + "title": "incorrect_shortcut", + "description": "value of lang item type 'incorrect_shortcut'", + "type": "string" + }, + "undefined_shortcut": { + "title": "undefined_shortcut", + "description": "value of lang item type 'undefined_shortcut'", + "type": "string" + }, + "shortcut_parse_error": { + "title": "shortcut_parse_error", + "description": "value of lang item type 'shortcut_parse_error'", + "type": "string" + }, + "help_header": { + "title": "help_header", + "description": "value of lang item type 'help_header'", + "type": "string" + }, + "help_pages": { + "title": "help_pages", + "description": "value of lang item type 'help_pages'", + "type": "string" + }, + "help_footer": { + "title": "help_footer", + "description": "value of lang item type 'help_footer'", + "type": "string" + } + } }, - "example": { - "title": "example", - "description": "value of lang item type 'example'", - "type": "string" + "arparma": { + "title": "Arparma", + "description": "Scope 'arparma' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "ambiguous_name": { + "title": "ambiguous_name", + "description": "value of lang item type 'ambiguous_name'", + "type": "string" + } + } }, - "shortcuts": { - "title": "shortcuts", - "description": "value of lang item type 'shortcuts'", - "type": "string" + "stub": { + "title": "Stub", + "description": "Scope 'stub' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "key_error": { + "title": "key_error", + "description": "value of lang item type 'key_error'", + "type": "string" + } + } }, - "subcommands": { - "title": "subcommands", - "description": "value of lang item type 'subcommands'", - "type": "string" + "duplication": { + "title": "Duplication", + "description": "Scope 'duplication' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "stub_type_error": { + "title": "stub_type_error", + "description": "value of lang item type 'stub_type_error'", + "type": "string" + } + } }, - "subcommands.subs": { - "title": "subcommands.subs", - "description": "value of lang item type 'subcommands.subs'", - "type": "string" + "behavior": { + "title": "Behavior", + "description": "Scope 'behavior' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "exclude_matched": { + "title": "exclude_matched", + "description": "value of lang item type 'exclude_matched'", + "type": "string" + }, + "cooldown_matched": { + "title": "cooldown_matched", + "description": "value of lang item type 'cooldown_matched'", + "type": "string" + } + } }, - "subcommands.opts": { - "title": "subcommands.opts", - "description": "value of lang item type 'subcommands.opts'", - "type": "string" + "builtin": { + "title": "Builtin", + "description": "Scope 'builtin' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "option_help": { + "title": "option_help", + "description": "value of lang item type 'option_help'", + "type": "string" + }, + "option_shortcut": { + "title": "option_shortcut", + "description": "value of lang item type 'option_shortcut'", + "type": "string" + }, + "option_completion": { + "title": "option_completion", + "description": "value of lang item type 'option_completion'", + "type": "string" + }, + "conflict": { + "title": "Conflict", + "description": "Scope 'conflict' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "option": { + "title": "option", + "description": "value of lang item type 'option'", + "type": "string" + }, + "subcommand": { + "title": "subcommand", + "description": "value of lang item type 'subcommand'", + "type": "string" + }, + "arg": { + "title": "arg", + "description": "value of lang item type 'arg'", + "type": "string" + }, + "msg": { + "title": "msg", + "description": "value of lang item type 'msg'", + "type": "string" + } + } + } + } }, - "options": { - "title": "options", - "description": "value of lang item type 'options'", - "type": "string" + "format": { + "title": "Format", + "description": "Scope 'format' of lang item", + "type": "object", + "additionalProperties": false, + "properties": { + "notice": { + "title": "notice", + "description": "value of lang item type 'notice'", + "type": "string" + }, + "usage": { + "title": "usage", + "description": "value of lang item type 'usage'", + "type": "string" + }, + "example": { + "title": "example", + "description": "value of lang item type 'example'", + "type": "string" + }, + "shortcuts": { + "title": "shortcuts", + "description": "value of lang item type 'shortcuts'", + "type": "string" + }, + "subcommands": { + "title": "subcommands", + "description": "value of lang item type 'subcommands'", + "type": "string" + }, + "subcommands.subs": { + "title": "subcommands.subs", + "description": "value of lang item type 'subcommands.subs'", + "type": "string" + }, + "subcommands.opts": { + "title": "subcommands.opts", + "description": "value of lang item type 'subcommands.opts'", + "type": "string" + }, + "options": { + "title": "options", + "description": "value of lang item type 'options'", + "type": "string" + } + } } } } diff --git a/src/arclet/alconna/i18n/.template.json b/src/arclet/alconna/i18n/.template.json index ddc5776a..cbb4c03e 100644 --- a/src/arclet/alconna/i18n/.template.json +++ b/src/arclet/alconna/i18n/.template.json @@ -3,161 +3,166 @@ "$schema": "./.template.schema.json", "scopes": [ { - "scope": "common", + "scope": "alconna", "types": [ - "custom_type_error", - "name_empty" - ] - }, - { - "scope": "completion", - "types": [ - "node", - "prompt_select", - "prompt_other", - "prompt_empty", - "prompt_unavailable" - ] - }, - { - "scope": "fuzzy", - "types": [ - "matched" - ] - }, - { - "scope": "action", - "types": [ - "length_error", - "args_error", - "args_not_same", - "args_empty" - ] - }, - { - "scope": "argv", - "types": [ - "null_message" - ] - }, - { - "scope": "analyser", - "types": [ - "param_unmatched", - "param_missing" - ] - }, - { - "scope": "header", - "types": [ - "error", - "prefix_error" - ] - }, - { - "scope": "option", - "types": [ - "name_error", - "require_error" - ] - }, - { - "scope": "subcommand", - "types": [ - "name_error", - "require_error", - "args_missing" - ] - }, - { - "scope": "args", - "types": [ - "name_error", - "name_empty", - "value_error", - "duplicate_kwargs", - "duplicate_varargs", - "exclude_mutable_args", - "key_not_found", - "missing", - "key_missing" - ] - }, - { - "scope": "shortcut", - "types": [ - "name_require", - "delete_success", - "add_success", - "recent_command_error" - ] - }, - { - "scope": "manager", - "types": [ - "undefined_command", - "incorrect_shortcut", - "undefined_shortcut", - "shortcut_parse_error", - "help_header", - "help_pages", - "help_footer" - ] - }, - { - "scope": "arparma", - "types": [ - "ambiguous_name" - ] - }, - { - "scope": "stub", - "types": [ - "key_error" - ] - }, - { - "scope": "duplication", - "types": [ - "stub_type_error" - ] - }, - { - "scope": "behavior", - "types": [ - "exclude_matched", - "cooldown_matched" - ] - }, - { - "scope": "builtin", - "types": [ - "option_help", - "option_shortcut", - "option_completion", { - "subtype": "conflict", + "subtype": "common", + "types": [ + "custom_type_error", + "name_empty" + ] + }, + { + "subtype": "completion", "types": [ - "option", - "subcommand", - "arg", - "msg" + "node", + "prompt_select", + "prompt_other", + "prompt_empty", + "prompt_unavailable" + ] + }, + { + "subtype": "fuzzy", + "types": [ + "matched" + ] + }, + { + "subtype": "action", + "types": [ + "length_error", + "args_error", + "args_not_same", + "args_empty" + ] + }, + { + "subtype": "argv", + "types": [ + "null_message" + ] + }, + { + "subtype": "analyser", + "types": [ + "param_unmatched", + "param_missing" + ] + }, + { + "subtype": "header", + "types": [ + "error", + "prefix_error" + ] + }, + { + "subtype": "option", + "types": [ + "name_error", + "require_error" + ] + }, + { + "subtype": "subcommand", + "types": [ + "name_error", + "require_error", + "args_missing" + ] + }, + { + "subtype": "args", + "types": [ + "name_error", + "name_empty", + "value_error", + "duplicate_kwargs", + "duplicate_varargs", + "exclude_mutable_args", + "key_not_found", + "missing", + "key_missing" + ] + }, + { + "subtype": "shortcut", + "types": [ + "name_require", + "delete_success", + "add_success", + "recent_command_error" + ] + }, + { + "subtype": "manager", + "types": [ + "undefined_command", + "incorrect_shortcut", + "undefined_shortcut", + "shortcut_parse_error", + "help_header", + "help_pages", + "help_footer" + ] + }, + { + "subtype": "arparma", + "types": [ + "ambiguous_name" + ] + }, + { + "subtype": "stub", + "types": [ + "key_error" + ] + }, + { + "subtype": "duplication", + "types": [ + "stub_type_error" + ] + }, + { + "subtype": "behavior", + "types": [ + "exclude_matched", + "cooldown_matched" + ] + }, + { + "subtype": "builtin", + "types": [ + "option_help", + "option_shortcut", + "option_completion", + { + "subtype": "conflict", + "types": [ + "option", + "subcommand", + "arg", + "msg" + ] + } + ] + }, + { + "subtype": "format", + "types": [ + "notice", + "usage", + "example", + "shortcuts", + "subcommands", + "subcommands.subs", + "subcommands.opts", + "options" ] } ] - }, - { - "scope": "format", - "types": [ - "notice", - "usage", - "example", - "shortcuts", - "subcommands", - "subcommands.subs", - "subcommands.opts", - "options" - ] } ] } diff --git a/src/arclet/alconna/i18n/__init__.py b/src/arclet/alconna/i18n/__init__.py index d30a12bb..f8360885 100644 --- a/src/arclet/alconna/i18n/__init__.py +++ b/src/arclet/alconna/i18n/__init__.py @@ -7,3 +7,5 @@ from tarina.lang import lang lang.load(Path(__file__).parent) + +i18n = lang.dispatch("alconna") \ No newline at end of file diff --git a/src/arclet/alconna/i18n/en-US.json b/src/arclet/alconna/i18n/en-US.json index c19fe197..d12a6759 100644 --- a/src/arclet/alconna/i18n/en-US.json +++ b/src/arclet/alconna/i18n/en-US.json @@ -1,103 +1,105 @@ { "$schema": "./.lang.schema.json", - "common": { - "custom_type_error": "The custom parameter type {target} can't be a type.", - "name_empty": "You cannot give a empty name" - }, - "completion": { - "node": "suggest input follows:", - "prompt_select": ">> ", - "prompt_other": "* ", - "prompt_empty": "No prompt available.", - "prompt_unavailable": "This prompt cannot be used." - }, - "fuzzy": { - "matched": "\"{target}\" is not matched. Do you mean \"{source}\"?" - }, - "action": { - "length_error": "The count of arguments of this action must same as the given Args", - "args_error": "The type of {target} is not same as {source} of '{key}' in Args", - "args_not_same": "The target type of {target} is not {source}", - "args_empty": "The type of {target} cannot set to {source}" - }, - "argv": { - "null_message": "You income a message without text: {target}" - }, - "analyser": { - "param_unmatched": "Unmatched params: {target}", - "param_missing": "You need more data to analyse!" - }, - "header": { - "error": "{target} dose not matched", - "prefix_error": "Prefixes cannot be tuple when command is not str" - }, - "option": { - "name_error": "{target} not matched with option {source}", - "require_error": "Option {source}'s required is not {target}" - }, - "subcommand": { - "name_error": "{target} not matched with subcommand {source}", - "require_error": "Subcommand {source}'s required is not {target}", - "args_missing": "subcommand \"{name}\" missed its args" - }, - "args": { - "name_error": "Name of arg must be a string", - "name_empty": "Name of arg cannot be empty", - "value_error": "Value of {target} cannot be empty", - "duplicate_kwargs": "You cannot set multiple kwargs at the same Args", - "duplicate_varargs": "You cannot set multiple varargs at the same Args", - "exclude_mutable_args": "This flag cannot be set when the Args is mutable", - "key_not_found": "Arg {name} not exists", - "missing": "param {key} is required", - "key_missing": "{target} missing its key. Do you forget to add '{key}='?" - }, - "shortcut": { - "name_require": "Name of shortcut cannot be empty", - "delete_success": "Delete shortcut: \"{shortcut}\" for {target} successfully", - "add_success": "Add shortcut: \"{shortcut}\" for {target} successfully", - "recent_command_error": "command {target} is not same as recent message's command {source}" - }, - "manager": { - "undefined_command": "Command {target} is not defined", - "incorrect_shortcut": "Shortcut {target} cannot be used", - "undefined_shortcut": "Shortcut {target} is not defined", - "shortcut_parse_error": "{query} is not part of the shortcut for {target}", - "help_header": "# Following commands are available:", - "help_pages": "Page {current} of {total}", - "help_footer": "# Invoke '$command {help}' to see syntax" - }, - "arparma": { - "ambiguous_name": "Name called {target} is ambiguous\nplease add prefix 'options.' or 'subcommands.'" - }, - "stub": { - "key_error": "{target} is not supported" - }, - "duplication": { - "stub_type_error": "{value} is not a valid stub" - }, - "behavior": { - "exclude_matched": "{target} and {other} cannot be both matched", - "cooldown_matched": "Your action is too frequent" - }, - "builtin": { - "option_help": "show the help information", - "option_shortcut": "set a shortcut command", - "option_completion": "give a next input suggestion of current command", - "conflict": { - "option": "Option", - "subcommand": "Subcommand", - "arg": "Arg", - "msg": "{source_type} {source} conflict with {target_type} {target}" + "alconna": { + "common": { + "custom_type_error": "The custom parameter type {target} can't be a type.", + "name_empty": "You cannot give a empty name" + }, + "completion": { + "node": "suggest input follows:", + "prompt_select": ">> ", + "prompt_other": "* ", + "prompt_empty": "No prompt available.", + "prompt_unavailable": "This prompt cannot be used." + }, + "fuzzy": { + "matched": "\"{target}\" is not matched. Do you mean \"{source}\"?" + }, + "action": { + "length_error": "The count of arguments of this action must same as the given Args", + "args_error": "The type of {target} is not same as {source} of '{key}' in Args", + "args_not_same": "The target type of {target} is not {source}", + "args_empty": "The type of {target} cannot set to {source}" + }, + "argv": { + "null_message": "You income a message without text: {target}" + }, + "analyser": { + "param_unmatched": "Unmatched params: {target}", + "param_missing": "You need more data to analyse!" + }, + "header": { + "error": "{target} dose not matched", + "prefix_error": "Prefixes cannot be tuple when command is not str" + }, + "option": { + "name_error": "{target} not matched with option {source}", + "require_error": "Option {source}'s required is not {target}" + }, + "subcommand": { + "name_error": "{target} not matched with subcommand {source}", + "require_error": "Subcommand {source}'s required is not {target}", + "args_missing": "subcommand \"{name}\" missed its args" + }, + "args": { + "name_error": "Name of arg must be a string", + "name_empty": "Name of arg cannot be empty", + "value_error": "Value of {target} cannot be empty", + "duplicate_kwargs": "You cannot set multiple kwargs at the same Args", + "duplicate_varargs": "You cannot set multiple varargs at the same Args", + "exclude_mutable_args": "This flag cannot be set when the Args is mutable", + "key_not_found": "Arg {name} not exists", + "missing": "param {key} is required", + "key_missing": "{target} missing its key. Do you forget to add '{key}='?" + }, + "shortcut": { + "name_require": "Name of shortcut cannot be empty", + "delete_success": "Delete shortcut: \"{shortcut}\" for {target} successfully", + "add_success": "Add shortcut: \"{shortcut}\" for {target} successfully", + "recent_command_error": "command {target} is not same as recent message's command {source}" + }, + "manager": { + "undefined_command": "Command {target} is not defined", + "incorrect_shortcut": "Shortcut {target} cannot be used", + "undefined_shortcut": "Shortcut {target} is not defined", + "shortcut_parse_error": "{query} is not part of the shortcut for {target}", + "help_header": "# Following commands are available:", + "help_pages": "Page {current} of {total}", + "help_footer": "# Invoke '$command {help}' to see syntax" + }, + "arparma": { + "ambiguous_name": "Name called {target} is ambiguous\nplease add prefix 'options.' or 'subcommands.'" + }, + "stub": { + "key_error": "{target} is not supported" + }, + "duplication": { + "stub_type_error": "{value} is not a valid stub" + }, + "behavior": { + "exclude_matched": "{target} and {other} cannot be both matched", + "cooldown_matched": "Your action is too frequent" + }, + "builtin": { + "option_help": "show the help information", + "option_shortcut": "set a shortcut command", + "option_completion": "give a next input suggestion of current command", + "conflict": { + "option": "Option", + "subcommand": "Subcommand", + "arg": "Arg", + "msg": "{source_type} {source} conflict with {target_type} {target}" + } + }, + "format": { + "notice": "Notice", + "usage": "Usage", + "example": "Example", + "shortcuts": "Shortcut Commands", + "subcommands": "Commands", + "subcommands.subs": "Commands in above command", + "subcommands.opts": "Options in above command", + "options": "General Options" } - }, - "format": { - "notice": "Notice", - "usage": "Usage", - "example": "Example", - "shortcuts": "Shortcut Commands", - "subcommands": "Commands", - "subcommands.subs": "Commands in above command", - "subcommands.opts": "Options in above command", - "options": "General Options" } } \ No newline at end of file diff --git a/src/arclet/alconna/i18n/zh-CN.json b/src/arclet/alconna/i18n/zh-CN.json index 23376fec..5eded9f4 100644 --- a/src/arclet/alconna/i18n/zh-CN.json +++ b/src/arclet/alconna/i18n/zh-CN.json @@ -1,103 +1,105 @@ { "$schema": "./.lang.schema.json", - "common": { - "custom_type_error": "自定义参数类型传入的不是类型而是 {target}, 这是有意而为之的吗?", - "name_empty": "名字不能为空" - }, - "completion": { - "node": "以下是建议的输入:", - "prompt_select": ">> ", - "prompt_other": "* ", - "prompt_empty": "没有可用的补全提示", - "prompt_unavailable": "选择的补全提示不可用于输入" - }, - "fuzzy": { - "matched": "无法解析 \"{target}\"。您想要输入的是不是 \"{source}\" ?" - }, - "action": { - "length_error": "该 action 接受的参数个数必须与 Args 里的一致", - "args_error": "{target} 的类型 与 Args 中 '{key}' 接受的类型 {source} 不一致", - "args_not_same": "{target} 指定的消息元素类型不是 {source}", - "args_empty": "{target} 的类型不能指定为 {source}" - }, - "argv": { - "null_message": "传入了一个无法获取文本的消息: {target}" - }, - "analyser": { - "param_unmatched": "参数 {target} 匹配失败", - "param_missing": "你应当传入更多的参数来完成解析!" - }, - "header": { - "error": "命令头部 {target} 匹配失败", - "prefix_error": "当命令名不是字符串时,命令前缀不能是元组" - }, - "option": { - "name_error": "{target} 与选项 {source} 不匹配", - "require_error": "选项 {source} 需求的前置文字并非 {target}" - }, - "subcommand": { - "name_error": "{target} 与子命令 {source} 不匹配", - "require_error": "子命令 {source} 需求的前置文字并非 {target}", - "args_missing": "子命令 \"{name}\" 缺少必要参数" - }, - "args": { - "name_error": "参数的名字只能是字符串", - "name_empty": "该参数的指示名不能为空", - "value_error": "{target} 的参数值不能为Empty", - "duplicate_kwargs": "不能同时设置多个键值对可变参数", - "duplicate_varargs": "不能同时设置多个非键值对可变参数", - "exclude_mutable_args": "该选项不能与可变参数同时使用", - "key_not_found": "参数 {name} 不存在", - "missing": "参数 {key} 丢失", - "key_missing": "{target} 缺少键. 你是不是忘了带上 '{key}=' ?" - }, - "shortcut": { - "name_require": "快捷命令的名字不能为空", - "delete_success": "{target} 的快捷指令: \"{shortcut}\" 删除成功", - "add_success": "{target} 的快捷指令: \"{shortcut}\" 添加成功", - "recent_command_error": "历史记录对应的命令 {source} 与 本命令 {target} 不一致" - }, - "manager": { - "undefined_command": "命令 {target} 不存在", - "incorrect_shortcut": "快捷命令 {target} 无法使用", - "undefined_shortcut": "快捷命令 {target} 不存在", - "shortcut_parse_error": "{query} 不属于 {target} 的快捷命令", - "help_header": "# 当前可用的命令有:", - "help_pages": "第 {current}/{total} 页", - "help_footer": "# 输入'命令名 {help}' 查看特定命令的语法" - }, - "arparma": { - "ambiguous_name": "名称 {target} 存在歧义\n请添加前缀 'options.' 或 'subcommands.'" - }, - "stub": { - "key_error": "不支持 {target}" - }, - "duplication": { - "stub_type_error": "{value} 不是一个合法的 Stub 子类" - }, - "behavior": { - "exclude_matched": "{target} 与 {other} 不能同时存在", - "cooldown_matched": "操作过于频繁" - }, - "builtin": { - "option_help": "显示帮助信息", - "option_shortcut": "设置快捷命令", - "option_completion": "补全当前命令", - "conflict": { - "option": "选项", - "subcommand": "子命令", - "arg": "参数", - "msg": "{source_type} {source} 与 {target_type} {target} 冲突" + "alconna": { + "common": { + "custom_type_error": "自定义参数类型传入的不是类型而是 {target}, 这是有意而为之的吗?", + "name_empty": "名字不能为空" + }, + "completion": { + "node": "以下是建议的输入:", + "prompt_select": ">> ", + "prompt_other": "* ", + "prompt_empty": "没有可用的补全提示", + "prompt_unavailable": "选择的补全提示不可用于输入" + }, + "fuzzy": { + "matched": "无法解析 \"{target}\"。您想要输入的是不是 \"{source}\" ?" + }, + "action": { + "length_error": "该 action 接受的参数个数必须与 Args 里的一致", + "args_error": "{target} 的类型 与 Args 中 '{key}' 接受的类型 {source} 不一致", + "args_not_same": "{target} 指定的消息元素类型不是 {source}", + "args_empty": "{target} 的类型不能指定为 {source}" + }, + "argv": { + "null_message": "传入了一个无法获取文本的消息: {target}" + }, + "analyser": { + "param_unmatched": "参数 {target} 匹配失败", + "param_missing": "你应当传入更多的参数来完成解析!" + }, + "header": { + "error": "命令头部 {target} 匹配失败", + "prefix_error": "当命令名不是字符串时,命令前缀不能是元组" + }, + "option": { + "name_error": "{target} 与选项 {source} 不匹配", + "require_error": "选项 {source} 需求的前置文字并非 {target}" + }, + "subcommand": { + "name_error": "{target} 与子命令 {source} 不匹配", + "require_error": "子命令 {source} 需求的前置文字并非 {target}", + "args_missing": "子命令 \"{name}\" 缺少必要参数" + }, + "args": { + "name_error": "参数的名字只能是字符串", + "name_empty": "该参数的指示名不能为空", + "value_error": "{target} 的参数值不能为Empty", + "duplicate_kwargs": "不能同时设置多个键值对可变参数", + "duplicate_varargs": "不能同时设置多个非键值对可变参数", + "exclude_mutable_args": "该选项不能与可变参数同时使用", + "key_not_found": "参数 {name} 不存在", + "missing": "参数 {key} 丢失", + "key_missing": "{target} 缺少键. 你是不是忘了带上 '{key}=' ?" + }, + "shortcut": { + "name_require": "快捷命令的名字不能为空", + "delete_success": "{target} 的快捷指令: \"{shortcut}\" 删除成功", + "add_success": "{target} 的快捷指令: \"{shortcut}\" 添加成功", + "recent_command_error": "历史记录对应的命令 {source} 与 本命令 {target} 不一致" + }, + "manager": { + "undefined_command": "命令 {target} 不存在", + "incorrect_shortcut": "快捷命令 {target} 无法使用", + "undefined_shortcut": "快捷命令 {target} 不存在", + "shortcut_parse_error": "{query} 不属于 {target} 的快捷命令", + "help_header": "# 当前可用的命令有:", + "help_pages": "第 {current}/{total} 页", + "help_footer": "# 输入'命令名 {help}' 查看特定命令的语法" + }, + "arparma": { + "ambiguous_name": "名称 {target} 存在歧义\n请添加前缀 'options.' 或 'subcommands.'" + }, + "stub": { + "key_error": "不支持 {target}" + }, + "duplication": { + "stub_type_error": "{value} 不是一个合法的 Stub 子类" + }, + "behavior": { + "exclude_matched": "{target} 与 {other} 不能同时存在", + "cooldown_matched": "操作过于频繁" + }, + "builtin": { + "option_help": "显示帮助信息", + "option_shortcut": "设置快捷命令", + "option_completion": "补全当前命令", + "conflict": { + "option": "选项", + "subcommand": "子命令", + "arg": "参数", + "msg": "{source_type} {source} 与 {target_type} {target} 冲突" + } + }, + "format": { + "notice": "注释", + "usage": "用法", + "example": "使用示例", + "shortcuts": "快捷命令", + "subcommands": "可用的子命令有", + "subcommands.subs": "该子命令内可用的子命令有", + "subcommands.opts": "该子命令内可用的选项有", + "options": "可用的选项有" } - }, - "format": { - "notice": "注释", - "usage": "用法", - "example": "使用示例", - "shortcuts": "快捷命令", - "subcommands": "可用的子命令有", - "subcommands.subs": "该子命令内可用的子命令有", - "subcommands.opts": "该子命令内可用的选项有", - "options": "可用的选项有" } } \ No newline at end of file diff --git a/src/arclet/alconna/ingedia/_analyser.py b/src/arclet/alconna/ingedia/_analyser.py index d5c2e8ca..b5718cf6 100644 --- a/src/arclet/alconna/ingedia/_analyser.py +++ b/src/arclet/alconna/ingedia/_analyser.py @@ -2,8 +2,9 @@ from typing import TYPE_CHECKING, Any -from tarina import Empty, lang +from tarina import Empty +from ..i18n import i18n from ..action import Action from ..arparma import Arparma from ..base import Option, Subcommand, HeadResult @@ -132,7 +133,7 @@ def process(self, argv: Argv, name_validated: bool = True) -> Exception | None: except InvalidHeader as e: return e except RuntimeError: - exc = InvalidParam(lang.require("header", "error").format(target=argv.release(recover=True)[0])) + exc = InvalidParam(i18n.require("header.error").format(target=argv.release(recover=True)[0])) return exc try: @@ -165,7 +166,7 @@ def process(self, argv: Argv, name_validated: bool = True) -> Exception | None: self._error = e2 return exc = ArgumentMissing( - self.command.args.data[0].field.get_missing_tips(lang.require("analyser", "param_missing")) + self.command.args.data[0].field.get_missing_tips(i18n.require("analyser.param_missing")) ) if comp_ctx.get(None): return PauseTriggered( @@ -175,7 +176,7 @@ def process(self, argv: Argv, name_validated: bool = True) -> Exception | None: argv ) return exc - return ParamsUnmatched(lang.require("analyser", "param_unmatched").format(target=argv.next()[0])) + return ParamsUnmatched(i18n.require("analyser.param_unmatched").format(target=argv.next()[0])) def export( self, diff --git a/src/arclet/alconna/ingedia/_argv.py b/src/arclet/alconna/ingedia/_argv.py index 2ef63b40..3f135afe 100644 --- a/src/arclet/alconna/ingedia/_argv.py +++ b/src/arclet/alconna/ingedia/_argv.py @@ -4,8 +4,9 @@ from typing import Any, Callable, ClassVar, Generic, Iterable, Literal from typing_extensions import Self from contextvars import ContextVar -from tarina import lang, split, split_once +from tarina import split, split_once +from ..i18n import i18n from ..base import Config from ..config import Namespace, global_config from ..constraint import ARGV_OVERRIDES @@ -124,7 +125,7 @@ def build(self, data: TDC) -> Self: raw_data.append(res) i += 1 if i < 1: - raise NullMessage(lang.require("argv", "null_message").format(target=data)) + raise NullMessage(i18n.require("argv.null_message").format(target=data)) self.ndata = i self.bak_data = raw_data.copy() if self.message_cache: diff --git a/src/arclet/alconna/ingedia/_completion.py b/src/arclet/alconna/ingedia/_completion.py index f74ff65e..fe4b5f26 100644 --- a/src/arclet/alconna/ingedia/_completion.py +++ b/src/arclet/alconna/ingedia/_completion.py @@ -2,8 +2,9 @@ from typing import TYPE_CHECKING -from tarina import ContextModel, lang +from tarina import ContextModel +from ..i18n import i18n from ..exceptions import InvalidParam, ParamsUnmatched, PauseTriggered from ..manager import command_manager from ..prompt import Prompt, EnterResult @@ -63,7 +64,7 @@ def available(self): def current(self): """获取当前选中的补全选项的文本。""" if not self.prompts: - raise ValueError(lang.require("completion", "prompt_empty")) + raise ValueError(i18n.require("completion.prompt_empty")) return self.prompts[self.index].text def tab(self, offset: int = 1): @@ -79,7 +80,7 @@ def tab(self, offset: int = 1): ValueError: 当前没有可用的补全选项。 """ if not self.prompts: - raise ValueError(lang.require("completion", "prompt_empty")) + raise ValueError(i18n.require("completion.prompt_empty")) self.index += offset self.index %= len(self.prompts) return self.prompts[self.index].text @@ -104,10 +105,10 @@ def enter(self, content: list | None = None) -> EnterResult: input_ = content else: if not self.prompts: - return EnterResult(exception=ValueError(lang.require("completion", "prompt_empty"))) + return EnterResult(exception=ValueError(i18n.require("completion.prompt_empty"))) prompt = self.prompts[self.index] if not prompt.can_use: - return EnterResult(exception=ValueError(lang.require("completion", "prompt_unavailable"))) + return EnterResult(exception=ValueError(i18n.require("completion.prompt_unavailable"))) if prompt.removal_prefix: argv.bak_data[-1] = argv.bak_data[-1][: -len(prompt.removal_prefix)] argv.next() @@ -172,12 +173,12 @@ def exit(self): def lines(self): """获取补全选项的文本列表。""" - select = lang.require("completion", "prompt_select") - other = lang.require("completion", "prompt_other") + select = i18n.require("completion.prompt_select") + other = i18n.require("completion.prompt_other") return [f"{select if self.index == index else other}{sug.text}" for index, sug in enumerate(self.prompts)] def __repr__(self): - node = lang.require('completion', 'node') + node = i18n.require('completion', 'node') node = f"{node}\n" if node else "" return node + "\n".join(self.lines()) diff --git a/src/arclet/alconna/ingedia/_handlers.py b/src/arclet/alconna/ingedia/_handlers.py index 4177da44..d9de38f2 100644 --- a/src/arclet/alconna/ingedia/_handlers.py +++ b/src/arclet/alconna/ingedia/_handlers.py @@ -4,8 +4,9 @@ from typing import TYPE_CHECKING, Any, Iterable, Literal from nepattern import ANY, STRING, AnyString, Pattern -from tarina import Empty, lang, safe_eval, split_once +from tarina import Empty, safe_eval, split_once, lang +from ..i18n import i18n from ..args import Arg, _Args from ..base import Option, Subcommand, Header, HeadResult from ..config import global_config @@ -42,10 +43,10 @@ def _context(argv: Argv, target: Arg[Any], _arg: str): try: return safe_eval(name, ctx) except NameError: - raise ArgumentMissing(target.field.get_missing_tips(lang.require("args", "missing").format(key=target.name)), target) + raise ArgumentMissing(target.field.get_missing_tips(i18n.require("args.missing").format(key=target.name)), target) except Exception as e: raise InvalidParam( - target.field.get_unmatch_tips(_arg, lang.require("nepattern", "context_error").format(target=target.name, expected=name)), + target.field.get_unmatch_tips(_arg, lang.require("nepattern", "error.content").format(target=target.name, expected=name)), target ) @@ -110,7 +111,7 @@ def step_varpos(ana: Analyser, argv: Argv, args: _Args, slot: tuple[int | Litera elif arg.field.optional: return else: - raise ArgumentMissing(arg.field.get_missing_tips(lang.require("args", "missing").format(key=key)), arg) + raise ArgumentMissing(arg.field.get_missing_tips(i18n.require("args.missing").format(key=key)), arg) if flag == "str": result[key] = arg.field.seps[0].join(_result) else: @@ -154,7 +155,7 @@ def step_varkey(ana: Analyser, argv: Argv, slot: tuple[int | Literal["+", "*", " elif arg.field.optional: return else: - raise ArgumentMissing(arg.field.get_missing_tips(lang.require("args", "missing").format(key=name)), arg) + raise ArgumentMissing(arg.field.get_missing_tips(i18n.require("args.missing").format(key=name)), arg) result[name] = _result @@ -184,11 +185,11 @@ def step_keyword(ana: Analyser, argv: Argv, args: _Args, result: dict[str, Any]) break for arg in args.keyword_only.values(): if arg.type_.execute(may_arg).success: - raise InvalidParam(lang.require("args", "key_missing").format(target=may_arg, key=arg.name), arg) + raise InvalidParam(i18n.require("args.key_missing").format(target=may_arg, key=arg.name), arg) for name in args.keyword_only: if levenshtein(_key, name) >= argv.fuzzy_threshold: - raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=name, target=_key)) - raise InvalidParam(lang.require("args", "key_not_found").format(name=_key), args) + raise FuzzyMatchSuccess(i18n.require("fuzzy.matched").format(source=name, target=_key)) + raise InvalidParam(i18n.require("args.key_not_found").format(name=_key), args) arg = args.keyword_only[_key] value = arg.type_ if not _m_arg: @@ -206,7 +207,7 @@ def step_keyword(ana: Analyser, argv: Argv, args: _Args, result: dict[str, Any]) if (default_val := arg.field.get_default()) is not Empty: result[key] = default_val elif not arg.field.optional: - raise ArgumentMissing(arg.field.get_missing_tips(lang.require("args", "missing").format(key=key)), arg) + raise ArgumentMissing(arg.field.get_missing_tips(i18n.require("args.missing").format(key=key)), arg) def _raise(target: Arg, arg: Any, res: Any): @@ -237,7 +238,7 @@ def analyse_args(analyser: Analyser, argv: Argv, args: _Args) -> dict[str, Any]: if (de := arg.field.get_default()) is not Empty: result[arg.name] = de elif not field.optional: - raise ArgumentMissing(field.get_missing_tips(lang.require("args", "missing").format(key=arg.name)), arg) + raise ArgumentMissing(field.get_missing_tips(i18n.require("args.missing").format(key=arg.name)), arg) continue if value.alias == "*": if TYPE_CHECKING: @@ -299,11 +300,11 @@ def analyse_option(analyser: Analyser, opt: Option, argv: Argv, path: tuple[str, if error: argv.rollback(name) if not argv.fuzzy_match: - raise InvalidParam(lang.require("option", "name_error").format(source=opt.dest, target=name), opt) + raise InvalidParam(i18n.require("option.name_error").format(source=opt.dest, target=name), opt) for al in opt.aliases: if levenshtein(name, al) >= argv.fuzzy_threshold: - raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=al, target=name)) - raise InvalidParam(lang.require("option", "name_error").format(source=opt.dest, target=name), opt) + raise FuzzyMatchSuccess(i18n.require("fuzzy.matched").format(source=al, target=name)) + raise InvalidParam(i18n.require("option.name_error").format(source=opt.dest, target=name), opt) args = analyse_args(analyser, argv, opt.args) if opt.nargs else {} if path not in analyser.value_result: analyser.args_result[path] = args @@ -339,11 +340,11 @@ def analyse_subcommand(analyser: Analyser, sub: Subcommand, argv: Argv, path: tu if name not in sub.aliases: argv.rollback(name) if not argv.fuzzy_match: - raise InvalidParam(lang.require("subcommand", "name_error").format(source=sub.dest, target=name), sub) + raise InvalidParam(i18n.require("subcommand.name_error").format(source=sub.dest, target=name), sub) for al in sub.aliases: if levenshtein(name, al) >= argv.fuzzy_threshold: - raise FuzzyMatchSuccess(lang.require("fuzzy", "matched").format(source=al, target=name), sub) - raise InvalidParam(lang.require("subcommand", "name_error").format(source=sub.dest, target=name), sub) + raise FuzzyMatchSuccess(i18n.require("fuzzy.matched").format(source=al, target=name), sub) + raise InvalidParam(i18n.require("subcommand.name_error").format(source=sub.dest, target=name), sub) analyser.value_result[path] = ... analyser.update(sub, path) while analyse_param(analyser, sub, argv, path, sub.separators) and argv.current_index != argv.ndata: @@ -353,7 +354,7 @@ def analyse_subcommand(analyser: Analyser, sub: Subcommand, argv: Argv, path: tu if not analyser.args_optional[path]: raise ArgumentMissing( sub.args.data[0].field.get_missing_tips( - lang.require("subcommand", "args_missing").format(name=".".join(path)) + i18n.require("subcommand.args_missing").format(name=".".join(path)) ), sub ) @@ -443,7 +444,7 @@ def analyse_param(analyser: Analyser, current: Subcommand, argv: Argv, prefixes: # 给 Completion 打的洞,若此时 analyser 属于主命令, 则让其先解析完主命令 elif _str and _text and not prefixes: if not analyser._error: - analyser._error = ParamsUnmatched(lang.require("analyser", "param_unmatched").format(target=_text)) + analyser._error = ParamsUnmatched(i18n.require("analyser.param_unmatched").format(target=_text)) argv.next() return True return False @@ -468,9 +469,9 @@ def analyse_header(header: "Header", argv: Argv): # _after_analyse_header if _str: argv.rollback(may_cmd) - raise InvalidHeader(lang.require("header", "error").format(target=head_text), head_text) + raise InvalidHeader(i18n.require("header.error").format(target=head_text), head_text) if _m_str and may_cmd: cmd = f"{head_text}{argv.separators[0]}{may_cmd}" - raise InvalidHeader(lang.require("header", "error").format(target=cmd), cmd) + raise InvalidHeader(i18n.require("header.error").format(target=cmd), cmd) argv.rollback(may_cmd) - raise InvalidHeader(lang.require("header", "error").format(target=head_text), None) + raise InvalidHeader(i18n.require("header.error").format(target=head_text), None) diff --git a/src/arclet/alconna/manager.py b/src/arclet/alconna/manager.py index 2078e271..dfde0df2 100644 --- a/src/arclet/alconna/manager.py +++ b/src/arclet/alconna/manager.py @@ -13,8 +13,9 @@ from weakref import WeakValueDictionary from nepattern import TPattern -from tarina import LRU, lang +from tarina import LRU +from .i18n import i18n from .arparma import Arparma from .base import Header, Metadata from .config import Namespace, global_config @@ -136,7 +137,7 @@ def require(self, command: Alconna) -> Analyser: return self.__analysers[cmd_hash] # type: ignore except KeyError as e: namespace, name = self._command_part(command.path) - raise ValueError(lang.require("manager", "undefined_command").format(target=f"{namespace}.{name}")) from e + raise ValueError(i18n.require("manager.undefined_command").format(target=f"{namespace}.{name}")) from e def delete(self, command: Alconna) -> None: """删除命令""" @@ -153,7 +154,7 @@ def update(self, command: Alconna): """同步命令更改""" cmd_hash = command._hash if cmd_hash not in self.__analysers: - raise ValueError(lang.require("manager", "undefined_command").format(target=command.path)) + raise ValueError(i18n.require("manager.undefined_command").format(target=command.path)) self.clear_result(command) command.formatter.remove(command) del self.__analysers[cmd_hash] @@ -207,7 +208,7 @@ def add_shortcut(self, target: Alconna, key: str | TPattern, source: ShortcutArg flags=_flags, ) out.append( - lang.require("shortcut", "add_success").format(shortcut=f"{prefix}{_key}", target=target.path) + i18n.require("shortcut.add_success").format(shortcut=f"{prefix}{_key}", target=target.path) ) _shortcut[0][humanize or _key] = InnerShortcutArgs( **{**source, "command": argv.converter(source.get("command", str(target.command))), "prefixes": target.prefixes}, @@ -220,7 +221,7 @@ def add_shortcut(self, target: Alconna, key: str | TPattern, source: ShortcutArg flags=_flags, ) target.formatter.update_shortcut(target) - return lang.require("shortcut", "add_success").format(shortcut=_key, target=target.path) + return i18n.require("shortcut.add_success").format(shortcut=_key, target=target.path) def get_shortcut(self, target: Alconna) -> dict[str, InnerShortcutArgs]: """列出快捷命令 @@ -234,7 +235,7 @@ def get_shortcut(self, target: Alconna) -> dict[str, InnerShortcutArgs]: namespace, name = self._command_part(target.path) cmd_hash = target._hash if cmd_hash not in self.__analysers: - raise ValueError(lang.require("manager", "undefined_command").format(target=f"{namespace}.{name}")) + raise ValueError(i18n.require("manager.undefined_command").format(target=f"{namespace}.{name}")) shortcuts = self._shortcuts.get(f"{namespace}::{name}", {}) if not shortcuts: return {} @@ -254,31 +255,31 @@ def find_shortcut( """ namespace, name = self._command_part(target.path) if not (_shortcut := self._shortcuts.get(f"{namespace}::{name}")): - raise ValueError(lang.require("manager", "undefined_command").format(target=f"{namespace}.{name}")) + raise ValueError(i18n.require("manager.undefined_command").format(target=f"{namespace}.{name}")) if res := _find_shortcut(_shortcut[1], data.copy(), target.separators): return res raise ValueError( - lang.require("manager", "shortcut_parse_error").format(target=f"{namespace}.{name}", query=data) + i18n.require("manager.shortcut_parse_error").format(target=f"{namespace}.{name}", query=data) ) def delete_shortcut(self, target: Alconna, key: str | TPattern | None = None): """删除快捷命令""" namespace, name = self._command_part(target.path) if not (_shortcut := self._shortcuts.get(f"{namespace}::{name}")): - raise ValueError(lang.require("manager", "undefined_command").format(target=f"{namespace}.{name}")) + raise ValueError(i18n.require("manager.undefined_command").format(target=f"{namespace}.{name}")) if key: _key = key if isinstance(key, str) else key.pattern try: _shortcut[0].pop(_key, None) del _shortcut[1][_key] - return lang.require("shortcut", "delete_success").format(shortcut=_key, target=target.path) + return i18n.require("shortcut.delete_success").format(shortcut=_key, target=target.path) except KeyError as e: raise ValueError( - lang.require("manager", "shortcut_parse_error").format(target=f"{namespace}.{name}", query=_key) + i18n.require("manager.shortcut_parse_error").format(target=f"{namespace}.{name}", query=_key) ) from e else: self._shortcuts.pop(f"{namespace}.{name}") - return lang.require("shortcut", "delete_success").format(shortcut="all", target=target.path) + return i18n.require("shortcut.delete_success").format(shortcut="all", target=target.path) def get_command(self, command: str) -> Alconna: """获取命令""" @@ -286,7 +287,7 @@ def get_command(self, command: str) -> Alconna: namespace, name = self._command_part(command) if ana.command.namespace == namespace and (ana.command.command == name or ana.command.name == name): return ana.command - raise ValueError(lang.require("manager", "undefined_command").format(target=command)) + raise ValueError(i18n.require("manager.undefined_command").format(target=command)) def get_commands(self, namespace: str | Namespace = "") -> list[Alconna]: """获取命令列表""" @@ -332,10 +333,10 @@ def all_command_help( max_length (int, optional): 单个页面展示的最大长度. Defaults to -1. page (int, optional): 当前页码. Defaults to 1. """ - pages = pages or lang.require("manager", "help_pages") + pages = pages or i18n.require("manager.help_pages") cmds = [cmd for cmd in self.get_commands(namespace or "") if not cmd.config.hide] slots = [(cmd.header_display, cmd.meta.description) for cmd in cmds] - header = header or lang.require("manager", "help_header") + header = header or i18n.require("manager.help_header") if max_length < 1: command_string = ( "\n".join(f" {str(index).rjust(len(str(len(cmds))), '0')} {slot[0]} : {slot[1]}" for index, slot in enumerate(slots)) # noqa: E501 @@ -358,7 +359,7 @@ def all_command_help( help_names = set() for i in cmds: help_names.update(i.config.builtin_option_name["help"]) - footer = footer or lang.require("manager", "help_footer").format(help="|".join(help_names)) + footer = footer or i18n.require("manager.help_footer").format(help="|".join(help_names)) return f"{header}\n{command_string}\n{footer}" def all_command_raw_help(self, namespace: str | Namespace | None = None) -> dict[str, Metadata]: diff --git a/src/arclet/alconna/shortcut.py b/src/arclet/alconna/shortcut.py index d74bd67e..5d324fda 100644 --- a/src/arclet/alconna/shortcut.py +++ b/src/arclet/alconna/shortcut.py @@ -3,10 +3,9 @@ import inspect import re from typing import Any, TypedDict, Protocol, cast - -from tarina import lang from typing_extensions import NotRequired, TypeAlias +from .i18n import i18n from .exceptions import ArgumentMissing, ParamsUnmatched @@ -252,13 +251,13 @@ def wrap_shortcut( """ result = [short.command] if not short.fuzzy and data: - raise ParamsUnmatched(lang.require("analyser", "param_unmatched").format(target=data[0])) + raise ParamsUnmatched(i18n.require("analyser.param_unmatched").format(target=data[0])) result.extend(short.args) data = _handle_shortcut_data(result, data) if not data and result and any( isinstance(i, str) and bool(re.search(r"\{%(\d+)|\*(.*?)\}", i)) for i in result ): - raise ArgumentMissing(lang.require("analyser", "param_missing")) + raise ArgumentMissing(i18n.require("analyser.param_missing")) result.extend(data) if reg: data = _handle_shortcut_reg(result, reg.groups(), reg.groupdict(), short.wrapper, ctx or {}) diff --git a/src/arclet/alconna/utils.py b/src/arclet/alconna/utils.py index 04be7c9c..55551315 100644 --- a/src/arclet/alconna/utils.py +++ b/src/arclet/alconna/utils.py @@ -81,7 +81,7 @@ def match(self, input_: Any) -> Any: # pragma: no cover if generic_isinstance(input_, self.types): # type: ignore return input_ raise MatchFailed( - lang.require("nepattern", "type_error").format( + lang.require("nepattern", "error.type").format( type=input_.__class__.__name__, target=input_, expected=" | ".join(map(lambda t: t.__name__, self.types)) ) ) diff --git a/src/arclet/alconna/v1/typing.py b/src/arclet/alconna/v1/typing.py index 6b6cfd49..e384324d 100644 --- a/src/arclet/alconna/v1/typing.py +++ b/src/arclet/alconna/v1/typing.py @@ -11,7 +11,7 @@ from nepattern import Pattern, parser from arclet.alconna.utils import TAValue -from arclet.alconna.utils import KWBool as KWBool +from arclet.alconna.utils import KWBool as KWBool # type: ignore[misc] T = TypeVar("T")