Compare commits
945 Commits
2020.12
...
2025.09.19
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a67318091 | |||
| 2be58f6577 | |||
| 9c6078f4fd | |||
| dfdc31512d | |||
| ab7ff7da93 | |||
| 41087a838b | |||
| 836b92ccbf | |||
| 8aaba22940 | |||
| 504dc5e188 | |||
| 4625b626e6 | |||
| 58dbd3ed1e | |||
| cd7dfaf2b4 | |||
| 8ad3e3bdb4 | |||
| b97bc0a3ed | |||
| 5f25400bcd | |||
| 5edabbf8c1 | |||
| 62b6435470 | |||
| d9d7802f33 | |||
| 25b4ca0696 | |||
| 3b120370b8 | |||
| aac038ef63 | |||
| 784632a0b4 | |||
| 4719c32457 | |||
| 516fa3fb7e | |||
| 2d2bb86720 | |||
| c1e65bf0dc | |||
| 688381b106 | |||
| c3e3367264 | |||
| c3d51e29fc | |||
| cae2e6d92e | |||
| 347418bdc5 | |||
| 153fc8922e | |||
| cdbfaeb013 | |||
| 4062a6ebe4 | |||
| 46ef6b3938 | |||
| c1b9c0fb4a | |||
| 8ede2998fe | |||
| 41f974fe6e | |||
| e7af5ce322 | |||
| 7881294554 | |||
| b3fd122fcd | |||
| 1dd48899d7 | |||
| f357e97ce5 | |||
| 2d8ecd424a | |||
| affbbc822d | |||
| 43ea732c5f | |||
| 708918464f | |||
| ed2377c288 | |||
| b819eb439c | |||
| b3ed7101fc | |||
| a3504af376 | |||
| 81c2f1cba9 | |||
| bea5b22251 | |||
| e04d0beb68 | |||
| 08ba097aaa | |||
| ea968d94e4 | |||
| 8e12c72b07 | |||
| 8dee4d8f70 | |||
| 315b8e631a | |||
| cbb1860f25 | |||
| 9839bcaa14 | |||
| da54337221 | |||
| a6a1e764d1 | |||
| eb6aa08c10 | |||
| 14a190a67f | |||
| cf5ae89884 | |||
| 558dfb8ced | |||
| 2ec8fc22b3 | |||
| c94700495b | |||
| 69a3bc5e31 | |||
| d189f49418 | |||
| 60fb416b67 | |||
| 792429d19d | |||
| 106975015e | |||
| 1117735f2e | |||
| 0378f8944a | |||
| 75fde0f444 | |||
| 04f610c799 | |||
| 3178b59147 | |||
| 9c7008e179 | |||
| 7ff7dbc56b | |||
| 823d524a81 | |||
| 1b60debba7 | |||
| 3fc713cc8d | |||
| bb26c7e94d | |||
| 52404cf5d3 | |||
| 32223bcfc2 | |||
| 4e2bdb2b59 | |||
| d72514205c | |||
| 9b4afdbe18 | |||
| 6751541269 | |||
| fe9918af16 | |||
| d2c56f1a3f | |||
| 8624549aa6 | |||
| 9a6ce704b7 | |||
| 9af2a1962d | |||
| a8d4a7a362 | |||
| 943f5ad50b | |||
| 4cd8fea07a | |||
| 82b3a22ac8 | |||
| 2c6367a408 | |||
| af94a0c52d | |||
| 9c374f6bb2 | |||
| d0a19458c5 | |||
| 5d6e7677de | |||
| 01309e3124 | |||
| 083e1ce4a1 | |||
| 8c012e5902 | |||
| 5e6d17cc86 | |||
| c4a71de83f | |||
| 01bc746092 | |||
| 87d023ef7f | |||
| 119052f9a2 | |||
| 43710717c9 | |||
| 7bf5e25c5e | |||
| faa030df96 | |||
| b2efe285a9 | |||
| 9e28dce5ce | |||
| 8179508248 | |||
| 2c3664c1b9 | |||
| 269f083662 | |||
| 8b40c65661 | |||
| 7be3cf38dc | |||
| b18a7297a7 | |||
| 7f46fbe87a | |||
| e0ca7c2ae6 | |||
| 6389a940bc | |||
| 48d0daabf5 | |||
| 8fc3c04720 | |||
| 351f953fdb | |||
| e1560dfab5 | |||
| c9bc6a026a | |||
| 83f0e8bd42 | |||
| 7af83b49a5 | |||
| 59263ece6e | |||
| a507ed9f46 | |||
| 6b451142e2 | |||
| 12beea05a7 | |||
| 713fa5243c | |||
| d600852bec | |||
| c09f2f8e83 | |||
| 2fb515195c | |||
| 889f51f5c5 | |||
| 742ba8314a | |||
| b95d90a191 | |||
| 46fa49a102 | |||
| d5e89d6e2a | |||
| 086fc75fec | |||
| 05c33990bb | |||
| cbae40ef4d | |||
| 002ba6b4e0 | |||
| 85f75b4677 | |||
| 95d8df5bea | |||
| ac1cd9bdde | |||
| 2d9bb79af7 | |||
| 120c9e6800 | |||
| 6f3099a8db | |||
| e46711dc54 | |||
| 59920c59e0 | |||
| 604bb8f55c | |||
| 2f8dc63cdc | |||
| 4fbb3ec838 | |||
| 6818fe9a5c | |||
| 3854fa5aa6 | |||
| 1ca459e67a | |||
| fe8ffb2839 | |||
| 42fb88c35d | |||
| db7a0786a9 | |||
| f9f2612356 | |||
| df81bb599f | |||
| 6d2492c1cf | |||
| e244535557 | |||
| 5f10603fe5 | |||
| 6b8491eea2 | |||
| b63bf41294 | |||
| f6cc3a7ddf | |||
| d1c93abe2c | |||
| d6e3b37f7f | |||
| 9840779af4 | |||
| b893ec1fcf | |||
| d5e5bfe69d | |||
| 4afe5c4581 | |||
| e054ac364e | |||
| 68e01afb5b | |||
| 2e0a8bb1ff | |||
| b02aebef35 | |||
| 099a51ed93 | |||
| e4aedb354b | |||
| 301768b842 | |||
| 856960d799 | |||
| d0877a4ea6 | |||
| 3c20ab296a | |||
| 4dc7ee3314 | |||
| 05bd5e8593 | |||
| 2fe3912a07 | |||
| 2840628443 | |||
| f0f79e7e3b | |||
| e8ae635c88 | |||
| d8f7e03815 | |||
| ba1b5e49ae | |||
| 703a2c91b5 | |||
| 4a54bb62de | |||
| 9e84c8359b | |||
| 5139876d90 | |||
| 6aef49de40 | |||
| 186b336bf3 | |||
| 1bbec27d1a | |||
| f0a8d69e22 | |||
| 8bd237206c | |||
| 6bf7c3a2bc | |||
| 2e8be741cc | |||
| abd0352750 | |||
| 25d91b85f3 | |||
| f08eb42105 | |||
| f450102c93 | |||
| db28645e98 | |||
| 23efb776e7 | |||
| 7f621b282f | |||
| 5dc7fce1e7 | |||
| 879f59b0d5 | |||
| 511622820a | |||
| 0914f969e5 | |||
| c611045290 | |||
| 89ac9e90d6 | |||
| ae2a98b3bc | |||
| bd242baa0a | |||
| 8e4caeb2a8 | |||
| 3b55b3d5a5 | |||
| cc3b1afaa1 | |||
| a22b6fdbdb | |||
| e3041c4b5b | |||
| 8ad6d50a04 | |||
| 4db000f6d7 | |||
| 3821624c3b | |||
| 60a722b4ec | |||
| 65132aa107 | |||
| 48eac124a5 | |||
| be23b18d33 | |||
| 748cc66946 | |||
| 304b2e4255 | |||
| 9fa183f143 | |||
| 82df528395 | |||
| 49e3bddc91 | |||
| c52bf961e1 | |||
| df3f9f0306 | |||
| ef2d73aadc | |||
| 1ed721cccb | |||
| a724216563 | |||
| 2bcf4d7a97 | |||
| 2dfa2dd68f | |||
| e94ed0b7f0 | |||
| c7e2f8609c | |||
| 9d2321cc9c | |||
| 61d9912950 | |||
| f23d32a92a | |||
| dc489cbf7a | |||
| 41d24aae99 | |||
| 6b50bba139 | |||
| 139422fd32 | |||
| 409e11df42 | |||
| f3a11f9791 | |||
| 8dcc5b4011 | |||
| d0f65834f1 | |||
| 47ed0a705d | |||
| ae3192b63c | |||
| bb461f5fba | |||
| 52069b7bb3 | |||
| f0ed0bd2e1 | |||
| e868a120f0 | |||
| 70652aeb4c | |||
| 28adcc4e49 | |||
| affbb1ee7b | |||
| d8a4210c9b | |||
| b16d555e33 | |||
| 4380142ccd | |||
| 91f2d6cb21 | |||
| 249b071ee9 | |||
| 53fe437100 | |||
| fc63f3616e | |||
| a528511732 | |||
| dbe1d37046 | |||
| 988965ed52 | |||
| 3c5ca594d5 | |||
| 452b30c899 | |||
| 85c5b26fdf | |||
| 92ed684866 | |||
| 88e83db330 | |||
| 55609fc691 | |||
| e0d89f967f | |||
| b2ce8a6924 | |||
| 71efbd1b42 | |||
| e36939a108 | |||
| 721461fc1b | |||
| 72ee59b2b4 | |||
| 95159da0fc | |||
| 330d702347 | |||
| cbf669d3bd | |||
| 7498fe3255 | |||
| 880998e8ca | |||
| ecc9657eaa | |||
| 125f65cf1b | |||
| 1cd9c7d669 | |||
| 5165f31066 | |||
| 10d33e5d1d | |||
| fb35e8b8b2 | |||
| 4402bcce73 | |||
| 8839b26f00 | |||
| a79358725c | |||
| 2ab1576230 | |||
| c0be380f69 | |||
| c0ae0c8389 | |||
| 4a766e8284 | |||
| 2772ea8df2 | |||
| a604f0e821 | |||
| 6995b25518 | |||
| e4f843829f | |||
| 39b6ca790c | |||
| 4c8d7a8031 | |||
| 6d75bc433e | |||
| 8bb7fbd1c4 | |||
| ad03e655e9 | |||
| 61d3974a47 | |||
| 3d852c87e2 | |||
| 0e46528f32 | |||
| bb8fa1f6a8 | |||
| 9fdaa810c0 | |||
| 4083ac0c14 | |||
| b9e0b7ccd0 | |||
| 4b9e428abb | |||
| 63ad13e09a | |||
| cc06a308a1 | |||
| e9fdd20181 | |||
| 8692686cb5 | |||
| db29ad36fe | |||
| 0710b25317 | |||
| cbd2964f42 | |||
| f51118f13c | |||
| 323e363b42 | |||
| e8a4fe6142 | |||
| 587d9b359c | |||
| c2632253ac | |||
| 45be77dd10 | |||
| 78ffbcc33d | |||
| d83d1a244e | |||
| fa002a50ac | |||
| 32507afae9 | |||
| 6de3bbdaf4 | |||
| 6e50d0cb22 | |||
| 9e978f3ece | |||
| 32478926c8 | |||
| 2925788d01 | |||
| c0789cf4f7 | |||
| 89d591ce0a | |||
| 77c560b40c | |||
| dad4913bcd | |||
| 9b56650d4b | |||
| 9fca2018e5 | |||
| e5dd890931 | |||
| beadbf8e91 | |||
| ff5f9b833d | |||
| 162f06001a | |||
| 348fad24c7 | |||
| f9748cdb76 | |||
| 56380763a9 | |||
| 3a1630b687 | |||
| a593f34cde | |||
| 49cce5fa1a | |||
| df7bd06629 | |||
| e0da77fd4b | |||
| 833dd83008 | |||
| ce0ad4013f | |||
| 698f80adfe | |||
| d0b0f4bfcb | |||
| d23ea86ccf | |||
| 15d938b172 | |||
| 6c1d7a3b29 | |||
| c28f551682 | |||
| def92c78c8 | |||
| ddff9dec11 | |||
| 9e0e85d646 | |||
| b05ca7e980 | |||
| 8f8a9f7dd7 | |||
| df32978a31 | |||
| 79b51cf8c5 | |||
| a72dd0dc2e | |||
| d937c4c0e6 | |||
| 46cceb0910 | |||
| e74e39c189 | |||
| c2706c7737 | |||
| d0e66d24bd | |||
| c1a1849ad2 | |||
| 0675105731 | |||
| 7ee0b951a8 | |||
| d8168f024c | |||
| 2654dc7c69 | |||
| 4224960837 | |||
| 907c3a8fff | |||
| 28505479ba | |||
| 84d3abce3f | |||
| 9050dffc53 | |||
| e0f69c9bdf | |||
| bbd0a60f98 | |||
| e23f4187fe | |||
| 15f200df3a | |||
| a1a3ad6fb5 | |||
| d6677d53a3 | |||
| 07e43b50d1 | |||
| ac83555b24 | |||
| 1ab358059c | |||
| 5bf83c0d77 | |||
| 03ac00c6e3 | |||
| 0122d8fc78 | |||
| a66ce96dbf | |||
| 6da8e30446 | |||
| 539ed13be4 | |||
| 036a553f64 | |||
| 976a14584b | |||
| ed69f52927 | |||
| 98847495e6 | |||
| 40f132da33 | |||
| 5feb44595a | |||
| 48c6941f1a | |||
| a8756d493a | |||
| 9f4077a073 | |||
| 3e7a3d75c5 | |||
| 477d2d87d3 | |||
| 7a65dbe39b | |||
| f83755ac77 | |||
| a590cfd066 | |||
| f317035342 | |||
| 8900bdd446 | |||
| 35ecf158a2 | |||
| 353c1d30ec | |||
| 1c94fb5bd1 | |||
| cf305aeebb | |||
| 90e97433e0 | |||
| 125a85a0af | |||
| cfb8838c73 | |||
| 824d491ebc | |||
| d694c408c0 | |||
| d1bb266d49 | |||
| 419fcc3d29 | |||
| 24ab6a51c1 | |||
| dec4a45d98 | |||
| d11c56db03 | |||
| fc23315cc7 | |||
| 1f503fe20d | |||
| 4564f7ac0e | |||
| 7b823e1141 | |||
| dac3d9c6bb | |||
| ccca904cb8 | |||
| c66a81c0ec | |||
| fb810e2943 | |||
| 5cc663dedc | |||
| 593372699b | |||
| 1899cb5b86 | |||
| 0a285f2d28 | |||
| 94c82e6701 | |||
| 0d37c86061 | |||
| 6c8e9ccd89 | |||
| e7cf545502 | |||
| 44182eec86 | |||
| 0f5b1b7586 | |||
| 4fe073580a | |||
| 2fed654c16 | |||
| 8ebd4864d3 | |||
| a495532a4d | |||
| d87ce72f07 | |||
| 50201346e2 | |||
| 773b154371 | |||
| 5b59d1d384 | |||
| dcd8583183 | |||
| 97e52b39c0 | |||
| 581013b61a | |||
| fd68d25a1d | |||
| 588f93f7b1 | |||
| 96f402dcdd | |||
| c1b7fca8d5 | |||
| 2e4e7ccc57 | |||
| ada3d133df | |||
| 61e7b9d684 | |||
| 24172c658c | |||
| 62ac976b99 | |||
| 1f445a99b2 | |||
| 025286052b | |||
| 32a856f8e8 | |||
| 21f50f3b24 | |||
| ce77d41246 | |||
| dec137220c | |||
| 01c7e155c3 | |||
| dcbcb67ce8 | |||
| d57fd10718 | |||
| 2b91db5d81 | |||
| dffa3de1ec | |||
| 403837901b | |||
| 0de725c907 | |||
| e811e08c52 | |||
| 6518ae7516 | |||
| 95b5f99f1f | |||
| de22e79b71 | |||
| 127c67e566 | |||
| 3523dbd5c5 | |||
| b526a07e19 | |||
| d9f10edbb7 | |||
| 7616cd4c69 | |||
| afe75f6848 | |||
| c0e2db8281 | |||
| 3727af11c4 | |||
| 450295cfcf | |||
| 457bce8aa9 | |||
| 0f81497ea3 | |||
| fa7ee800e1 | |||
| 56b7452e55 | |||
| 9d73566453 | |||
| 28ba0c174a | |||
| 5d0444bcc0 | |||
| 40876005d5 | |||
| ac6d941822 | |||
| 113b365a47 | |||
| 2f785536e1 | |||
| 9ab4013b4b | |||
| b3b04f03ce | |||
| 57040f85f0 | |||
| 589ef4fd4c | |||
| 4b829cc484 | |||
| 98e343a108 | |||
| 7749d5a789 | |||
| c3b48bfa41 | |||
| 470e7ab2f4 | |||
| 4ceea36926 | |||
| b3f8174663 | |||
| 58dccea28b | |||
| ca086e01d7 | |||
| c5b1a95661 | |||
| d7881774a8 | |||
| 6eec92243e | |||
| 124b236182 | |||
| 2dc96cdf3d | |||
| 6f7923debc | |||
| 90d148b4a5 | |||
| 73e2c5ec10 | |||
| f31522dcd9 | |||
| a83607fd81 | |||
| 707df3f27d | |||
| 0f43e57831 | |||
| c08ab33060 | |||
| ee2abd98b3 | |||
| e39661a42a | |||
| 9518d19580 | |||
| adf95faaf8 | |||
| 2f92e9909d | |||
| b18f2c4bcd | |||
| 784ba049ad | |||
| 4d6d19d2e5 | |||
| 6fa47f19af | |||
| fb2872422e | |||
| 8460c0fa33 | |||
| 18f95341f4 | |||
| a8011267d9 | |||
| f8ebb4f1d7 | |||
| 3903f85368 | |||
| 05a9bdbf4a | |||
| 2809a9cd82 | |||
| 1c6794dc40 | |||
| cac80657df | |||
| 11241d8f99 | |||
| 308e5c9b0c | |||
| c12ff4f9e3 | |||
| 091c89df2c | |||
| 63a67be0ee | |||
| c68224b31a | |||
| 9f219757c3 | |||
| e09a4402b3 | |||
| 6867eb0e65 | |||
| ffaa5c4a2b | |||
| b9499108d8 | |||
| 37175b7227 | |||
| 2b5831c5fe | |||
| 62c8b9c68d | |||
| a080119c44 | |||
| a26c6f1bd9 | |||
| daac14e099 | |||
| d4b5c32a21 | |||
| c115afd736 | |||
| e7863a92e0 | |||
| 82a9e3a23a | |||
| a3a0a150a8 | |||
| 6951a19670 | |||
| 669133d491 | |||
| c60598b3f6 | |||
| 45733b30ef | |||
| f8bd86692e | |||
| 5e5d86cf94 | |||
| e0b7728719 | |||
| 0f85d4b9bc | |||
| a3fff9c7d7 | |||
| 8dcf3a6768 | |||
| 94949394de | |||
| b7be439381 | |||
| 0cae3428b9 | |||
| cc7755bafc | |||
| 4e78b9c12b | |||
| 5c80cf2222 | |||
| d02548e1a8 | |||
| 51efe973e8 | |||
| 0bb272d89b | |||
| 59f6843ea9 | |||
| be6838f97b | |||
| d5b2d3605b | |||
| 7a48917fb4 | |||
| 59832742b6 | |||
| f9f04901c0 | |||
| 593ffbb068 | |||
| 3d35f2ac63 | |||
| 5bfba581cb | |||
| 8fb570468c | |||
| 128fda60b0 | |||
| ab539c15dd | |||
| b931ba6e17 | |||
| f611aa73db | |||
| 69f697e36f | |||
| 654fb69295 | |||
| 850d44a105 | |||
| 8d4597705d | |||
| fa5655414a | |||
| 6fc4cebbfe | |||
| 89f3c5833f | |||
| adf9a33e83 | |||
| 4adf6bc834 | |||
| 9026f021ed | |||
| e562c31033 | |||
| 7b90b5af57 | |||
| cda1fabd4f | |||
| 4209055d62 | |||
| ed1a4eb88c | |||
| 478f1ad0ff | |||
| 80eb1da0e1 | |||
| ae39d43ea9 | |||
| 602c48bc06 | |||
| d34d501520 | |||
| 8f3ee53915 | |||
| 7eca382cb3 | |||
| f8f5d46491 | |||
| 696c62292b | |||
| d94b25d9d8 | |||
| 93829027af | |||
| cce4b6b191 | |||
| 0876f06282 | |||
| c970412a66 | |||
| 6af9328e14 | |||
| 5987b71c80 | |||
| 79fdc0c60b | |||
| cfb6a84799 | |||
| faa7e701fd | |||
| d5b8286f68 | |||
| a3d5737eaf | |||
| 314bb1b722 | |||
| 1c353bbcdf | |||
| 036b9dcc2d | |||
| 0fec5719bc | |||
| 3572081e43 | |||
| 8cf7f494b3 | |||
| b1165e169a | |||
| 284ebe1b11 | |||
| d51659db3e | |||
| 3aa3a874c9 | |||
| 113d3199b1 | |||
| 5712a9ad67 | |||
| 1f8d420749 | |||
| 9065ef901c | |||
| b2c5d304f8 | |||
| 70ae7dd9e6 | |||
| 94b122d677 | |||
| f6fc5d09e7 | |||
| 2b5c75cc67 | |||
| 167f813bcf | |||
| 7b9765e5b1 | |||
| 7ad01d4bdd | |||
| d19c47e571 | |||
| 4bfc647b91 | |||
| 98117ed7ad | |||
| cc9b25356c | |||
| a95d6e7f8a | |||
| fe5c41ac09 | |||
| b672174960 | |||
| a8691ced5b | |||
| fc53f90ecd | |||
| 0f836b5c7d | |||
| 34ed7123d1 | |||
| 5f668e17c9 | |||
| 806888bf49 | |||
| e8756a09ca | |||
| e38988be1b | |||
| 4009c93353 | |||
| 3ba5c10fad | |||
| 2552f1d43c | |||
| 5be2e83798 | |||
| d4919e027c | |||
| 7ef238b64d | |||
| 703d20f43f | |||
| d9bd7911ef | |||
| 6a5c832288 | |||
| dc849c4f71 | |||
| 76a6ba11fb | |||
| 305a19730f | |||
| de15e81703 | |||
| b91544a0da | |||
| caca34168e | |||
| 18b8ac589d | |||
| d85e628784 | |||
| 1e150cf10c | |||
| 9b0f0b7559 | |||
| cc118b5030 | |||
| 3e7ff78861 | |||
| 448d538d21 | |||
| d368161eb3 | |||
| eef8488ca2 | |||
| b22d04b145 | |||
| 6579e54c2b | |||
| 88c0153ca2 | |||
| f28c6ab309 | |||
| 976041f812 | |||
| 7693dd462f | |||
| df5e61cf98 | |||
| df87d08be3 | |||
| 33cb35e26f | |||
| 18b2cd8f2f | |||
| 7ab2a881e8 | |||
| 960de880ee | |||
| c0d8904782 | |||
| b6d508526a | |||
| 31307485f0 | |||
| 612c3583f1 | |||
| 6cdd3376f1 | |||
| b947789779 | |||
| 0da83935fc | |||
| 3428c70b69 | |||
| 3d511ff727 | |||
| cf2f293290 | |||
| c39601a35d | |||
| 5f36e0a43e | |||
| 31fe1c5cd7 | |||
| 0cdecd893a | |||
| 260fe06be8 | |||
| 8ddfd35a82 | |||
| 099bae3d7c | |||
| 9758e1fae2 | |||
| 211143d6ab | |||
| 70b49a098a | |||
| e2544f90fe | |||
| c223524d1b | |||
| 1789e2671a | |||
| d0812bcf5c | |||
| 4d5368e5fc | |||
| f3be927440 | |||
| d0e3e1792f | |||
| 31793fb290 | |||
| 41ddc86961 | |||
| 30ef74dd18 | |||
| bc69476bb2 | |||
| 05b9fd801b | |||
| 7af7f866c1 | |||
| 069e44bee6 | |||
| 3c0dd00a99 | |||
| afb91c8f1f | |||
| ca51f88d2b | |||
| a683b70c5f | |||
| c650e87443 | |||
| 36dfedf918 | |||
| 252f2b55fe | |||
| 99091a2540 | |||
| c3fdb7a049 | |||
| 5ba02688a6 | |||
| d189d32d96 | |||
| 59e111e593 | |||
| bfa029f207 | |||
| e2e763a424 | |||
| 132d2805ee | |||
| b800152268 | |||
| e49ec43fc4 | |||
| 63599a9ade | |||
| a2313ac952 | |||
| a1cd939aa1 | |||
| f69500418e | |||
| 5669807628 | |||
| 59fc139cfc | |||
| b48754e5db | |||
| 1a61f2cd7c | |||
| 02831c71c9 | |||
| 3764f2d5bd | |||
| a12a54f671 | |||
| f35f5167f0 | |||
| dbb0a4a2df | |||
| bc99763329 | |||
| ecd3e77a38 | |||
| 8ef1416b35 | |||
|
|
dffa1ac703 | ||
| d7becdd9bc | |||
| 23a6207f54 | |||
| 2769afc1e4 | |||
| 08836c1045 | |||
| 121b9b84a0 | |||
| 26ec121079 | |||
| fdb9769fd2 | |||
| 6742023919 | |||
| d61da17ebd | |||
| 57bae9f291 | |||
| 6596364027 | |||
| 85cd9fbcbc | |||
| 3e59f01add | |||
| bdb0548bc8 | |||
| c1fe8c611c | |||
| 3f56247aa7 | |||
| 84680c0c44 | |||
| 094a3c2aa9 | |||
| 51cec3062d | |||
| 268d56c348 | |||
| d1f1627214 | |||
| a604fca5cc | |||
| c3e9803cd6 | |||
| 9e7c6a695f | |||
| f75699f4ed | |||
| 40fb4fb3f9 | |||
| ac1b4b1a2a | |||
| cbf333564c | |||
| d5d8c3f413 | |||
| a9f3f75a79 | |||
| b52930daa5 | |||
| 4390fea084 | |||
| c41e3c0d78 | |||
| 7ffd553709 | |||
| 5c012ab4a0 | |||
| 340906c3f4 | |||
| 47256ab00d | |||
| 072f58a2e9 | |||
| 02b4f78baf | |||
| 49f85acb6c | |||
| 5008594c27 | |||
| d0af34ea25 | |||
| da582a8d88 | |||
| fc12d1803d | |||
| e7796e0371 | |||
| 6094b11068 | |||
| a169c31ed5 | |||
| 0522467b76 | |||
| 534982b18d | |||
| 2778ac0b4d | |||
| 1ba698d12a | |||
| 8d49d6491c | |||
| 787d285329 | |||
| dcbd13de1e | |||
| 4af18b6c70 | |||
| 86089a037c | |||
| 3d001ade0a | |||
| 6a1e7d4063 | |||
| 15b1a82cce | |||
| 9663e542f1 | |||
| f36d8c3e9f | |||
| db21d88721 | |||
| 2580d4b6cf | |||
| b3b65f3dd2 | |||
| ac63751583 | |||
| 8a95c03038 | |||
| 650f632c17 | |||
| 570e9b0215 | |||
| c9b612d552 | |||
| 2ad97d5021 | |||
| 82ffdfe278 | |||
| 0ff9920e9e | |||
| 0b6b205819 | |||
| db34f62fde | |||
| 973fd39f44 | |||
| d6278a3f4e | |||
| ae4709b0d4 | |||
| b377710931 | |||
| d9d2003087 | |||
| 9a713129dc | |||
| c672f53d3f | |||
| 0e6b0a657b | |||
| 4e24662d90 | |||
| 1bff2ea168 | |||
| 6e33f0bcae | |||
| 9a149ec341 | |||
| 064237904a | |||
| 221017ae7e | |||
| 59206dbc32 | |||
| f4ca76d844 | |||
| 31515d2c3a | |||
| 314049f22b | |||
| 87c6899949 | |||
| e8afff0e48 | |||
| 11399d7ea7 | |||
| 35752b2ae0 | |||
| ff0830c128 | |||
| c574a44a26 | |||
| b178e884f6 | |||
| 1097477a10 | |||
| 88142ead23 | |||
| 243e48e8a9 | |||
| 22858c8d2c | |||
| 3740996db3 | |||
| 82ea419088 | |||
| 2ffb101442 | |||
| 8f46e82905 | |||
| e8538d751b | |||
| 964a44a393 | |||
| 1bbbb2d8e1 | |||
| f931ccb7dd | |||
| 3e33a8a773 | |||
| 2d7496dd6e | |||
| f9826e28a5 | |||
| 5f1b56f30b | |||
| 562bb81379 | |||
| 0a630f9316 | |||
| 49f461037a | |||
| 9a0d36ca86 | |||
| 1dfae27d88 | |||
| 570ede237e | |||
| 236597848a | |||
| d3e1d3c368 | |||
| b7f628979e | |||
| 83d0451591 | |||
| 700bf9c937 | |||
| 2c43e55f77 | |||
| 69211cc9e8 | |||
| 6452226b50 | |||
| 01ef965180 | |||
| 956a107d38 | |||
| 266f9945f4 | |||
| 3b6121c9cf | |||
| ce1f057f71 | |||
| 226123a81f | |||
| aa4931fd18 | |||
| 164c639d29 | |||
| 960607a60d | |||
| 2c2c1ede21 | |||
| 8872d1bfe7 | |||
| d5975ea7ba | |||
| 2174cf3701 | |||
| 7a2f4584b0 | |||
| 7223651322 | |||
| 9581283d7d | |||
| b32f846fcf | |||
| ed0b761502 | |||
| 68c136a16f |
69
.gitea/workflows/build-dev.yaml
Normal file
69
.gitea/workflows/build-dev.yaml
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Build on push
|
||||
run-name: Build on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
uses: ./.gitea/workflows/prepare.yaml
|
||||
with:
|
||||
version_suffix: 'dev'
|
||||
secrets: inherit
|
||||
|
||||
application:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/cpl-application
|
||||
secrets: inherit
|
||||
|
||||
auth:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency, database ]
|
||||
with:
|
||||
working_directory: src/cpl-auth
|
||||
secrets: inherit
|
||||
|
||||
core:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/cpl-core
|
||||
secrets: inherit
|
||||
|
||||
database:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/cpl-database
|
||||
secrets: inherit
|
||||
|
||||
dependency:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core ]
|
||||
with:
|
||||
working_directory: src/cpl-dependency
|
||||
secrets: inherit
|
||||
|
||||
mail:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/cpl-mail
|
||||
secrets: inherit
|
||||
|
||||
query:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/cpl-query
|
||||
secrets: inherit
|
||||
|
||||
translation:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/cpl-translation
|
||||
secrets: inherit
|
||||
39
.gitea/workflows/build.yaml
Normal file
39
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
name: Build on push
|
||||
run-name: Build on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
uses: ./.gitea/workflows/prepare.yaml
|
||||
secrets: inherit
|
||||
|
||||
core:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/cpl-core
|
||||
secrets: inherit
|
||||
|
||||
query:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/cpl-query
|
||||
secrets: inherit
|
||||
|
||||
translation:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core ]
|
||||
with:
|
||||
working_directory: src/cpl-translation
|
||||
secrets: inherit
|
||||
|
||||
mail:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core ]
|
||||
with:
|
||||
working_directory: src/cpl-mail
|
||||
secrets: inherit
|
||||
65
.gitea/workflows/package.yaml
Normal file
65
.gitea/workflows/package.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Build Package
|
||||
run-name: Build Python Package
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version_suffix:
|
||||
description: 'Suffix for version (z.B. "dev", "alpha", "beta")'
|
||||
required: false
|
||||
type: string
|
||||
working_directory:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [ runner ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Download build version artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: version
|
||||
|
||||
- name: Set version
|
||||
run: |
|
||||
sed -i -E "s/^version = \".*\"/version = \"$(cat /workspace/sh-edraft.de/cpl/version.txt)\"/" pyproject.toml
|
||||
echo "Set version to $(cat /workspace/sh-edraft.de/cpl/version.txt)"
|
||||
cat pyproject.toml
|
||||
|
||||
- name: Set pip conf
|
||||
run: |
|
||||
cat > .pip.conf <<'EOF'
|
||||
[global]
|
||||
extra-index-url = https://git.sh-edraft.de/api/packages/sh-edraft.de/pypi/simple/
|
||||
EOF
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
export PIP_CONFIG_FILE=".pip.conf"
|
||||
pip install build
|
||||
|
||||
- name: Build Package
|
||||
run: |
|
||||
python -m build --outdir dist
|
||||
|
||||
- name: Login to registry git.sh-edraft.de
|
||||
uses: https://github.com/docker/login-action@v1
|
||||
with:
|
||||
registry: git.sh-edraft.de
|
||||
username: ${{ secrets.CI_USERNAME }}
|
||||
password: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
pip install twine
|
||||
python -m twine upload --repository-url https://git.sh-edraft.de/api/packages/sh-edraft.de/pypi -u ${{ secrets.CI_USERNAME }} -p ${{ secrets.CI_ACCESS_TOKEN }} ./dist/*
|
||||
54
.gitea/workflows/prepare.yaml
Normal file
54
.gitea/workflows/prepare.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Prepare Build
|
||||
run-name: Prepare Build Version
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version_suffix:
|
||||
description: 'Suffix for version (z.B. "dev", "alpha", "beta")'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
runs-on: [ runner ]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Get Date and Build Number
|
||||
run: |
|
||||
git fetch --tags
|
||||
git tag
|
||||
DATE=$(date +'%Y.%m.%d')
|
||||
TAG_COUNT=$(git tag -l "${DATE}.*" | wc -l)
|
||||
BUILD_NUMBER=$(($TAG_COUNT + 1))
|
||||
|
||||
VERSION_SUFFIX=${{ inputs.version_suffix }}
|
||||
if [ -n "$VERSION_SUFFIX" ] && [ "$VERSION_SUFFIX" = "dev" ]; then
|
||||
BUILD_VERSION="${DATE}.dev${BUILD_NUMBER}"
|
||||
elif [ -n "$VERSION_SUFFIX" ]; then
|
||||
BUILD_VERSION="${DATE}.${BUILD_NUMBER}${VERSION_SUFFIX}"
|
||||
else
|
||||
BUILD_VERSION="${DATE}.${BUILD_NUMBER}"
|
||||
fi
|
||||
|
||||
echo "$BUILD_VERSION" > version.txt
|
||||
echo "VERSION $BUILD_VERSION"
|
||||
|
||||
- name: Create Git Tag for Build
|
||||
run: |
|
||||
git config user.name "ci"
|
||||
git config user.email "dev@sh-edraft.de"
|
||||
echo "tag $(cat version.txt)"
|
||||
git tag $(cat version.txt)
|
||||
git push origin --tags
|
||||
|
||||
- name: Upload build version artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: version
|
||||
path: version.txt
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -37,7 +37,7 @@ MANIFEST
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
# Unit model / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
@@ -106,10 +106,15 @@ celerybeat.pid
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
venv_*/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Custom Environments
|
||||
cpl-env/
|
||||
.secret
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
@@ -129,5 +134,8 @@ dmypy.json
|
||||
.pyre/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
PythonImportHelper-v2-Completion.json
|
||||
|
||||
# cpl unittest stuff
|
||||
unittests/test_*_playground
|
||||
|
||||
3
.idea/dictionaries/sven.xml
generated
3
.idea/dictionaries/sven.xml
generated
@@ -1,3 +0,0 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="sven" />
|
||||
</component>
|
||||
17
.idea/inspectionProfiles/Project_Default.xml
generated
17
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,17 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="termcolor" />
|
||||
<item index="1" class="java.lang.String" itemvalue="discord" />
|
||||
<item index="2" class="java.lang.String" itemvalue="mysql-connector" />
|
||||
<item index="3" class="java.lang.String" itemvalue="flask" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
6
.idea/inspectionProfiles/profiles_settings.xml
generated
@@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectPlainTextFileTypeManager">
|
||||
<file url="file://$PROJECT_DIR$/publish_templates/all_template.txt" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/sh_common_py_lib.iml" filepath="$PROJECT_DIR$/.idea/sh_common_py_lib.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
20
.idea/sh_common_py_lib.iml
generated
20
.idea/sh_common_py_lib.iml
generated
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/tests/logs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/tests_dev/logs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/sh_edraft.egg-info" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/dist" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/tests/old" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.vscode" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build_test" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
<changelist name="Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]" date="1606383362450" recycled="false" toDelete="true">
|
||||
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch" />
|
||||
<option name="DESCRIPTION" value="Uncommitted changes before Update at 26.11.2020 10:36 [Default Changelist]" />
|
||||
</changelist>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
868
.idea/workspace.xml
generated
868
.idea/workspace.xml
generated
@@ -1,868 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="BranchesTreeState">
|
||||
<expand>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Removed unused packages">
|
||||
<change afterPath="$PROJECT_DIR$/src/tests/publish_test/__init__.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/tests/publish_test/publisher_test.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/tests/setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sh_common_py_lib.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sh_common_py_lib.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build/app.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish/app.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/base/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/base/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/base/publisher_base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/base/publisher_base.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/model/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/publish_settings_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/model/publish_settings_model.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/publish_settings_name.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/model/publish_settings_name.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/template.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/model/template.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/model/template_enum.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/model/template_enum.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/sh_edraft/publishing/publisher.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sh_edraft/publish/publisher.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/appsettings.edrafts-lapi.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/appsettings.edrafts-lapi.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/appsettings.edrafts-pc.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/appsettings.edrafts-pc.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/build.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/build.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/service_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/service_test/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/time_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/time_test/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/tests/utils_test/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/utils_test/__init__.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Python Script" />
|
||||
<option value="Python Unit Test" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Pull.Settings">
|
||||
<option name="BRANCH" value="2020.12.6" />
|
||||
</component>
|
||||
<component name="Git.Rebase.Settings">
|
||||
<option name="NEW_BASE" value="2020.12" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="2020.12" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
<option name="RESET_MODE" value="HARD" />
|
||||
<option name="UPDATE_TYPE" value="REBASE" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1kYeNqJzjIXigSYYCzg4D16FL1E" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/tests" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/src/tests" />
|
||||
<recent name="$PROJECT_DIR$/src/tests_dev" />
|
||||
<recent name="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/database" />
|
||||
<recent name="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/publish" />
|
||||
<recent name="$PROJECT_DIR$/src" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/src/tests" />
|
||||
<recent name="$PROJECT_DIR$/src/tests/publish_test" />
|
||||
<recent name="$PROJECT_DIR$/src/tests/old" />
|
||||
<recent name="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/commands/build" />
|
||||
<recent name="$PROJECT_DIR$/src" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python tests.Unittests">
|
||||
<configuration name="cli build" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="build test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli database migration" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests_dev" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="db mig add InitialMigration" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli database update" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests_dev" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="database update" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli help" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="help" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new app" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new app ./Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new base" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new app ./Test/Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new class" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new class ./Test/Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new configmodel" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new configmodel ./Test/Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new enum" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new enum ./Test/Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli new service" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="new service ./Test/Test" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli publish" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="publish" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli version" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="version" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="cli" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/sh_edraft/cli/cpl_cli/cli.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="CPL_NAME" value="CPL_Dev_Test" />
|
||||
<env name="PYTHON_ENVIRONMENT" value="development" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests_dev" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/tests_dev/main.py" />
|
||||
<option name="PARAMETERS" value="--customer=sh-edraft.de" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Unittests" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="CPL_ENVIRONMENT" value="testing" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="_new_pattern" value="""" />
|
||||
<option name="_new_additionalArguments" value=""discover -s $PROJECT_DIR$/src/tests -p \u0027*_test.py\u0027"" />
|
||||
<option name="_new_target" value="""" />
|
||||
<option name="_new_targetType" value=""CUSTOM"" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Unittests" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
|
||||
<module name="sh_common_py_lib" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="CPL_ENVIRONMENT" value="testing" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="_new_pattern" value="""" />
|
||||
<option name="_new_additionalArguments" value=""discover -s $PROJECT_DIR$/src/tests -p \u0027*_test.py\u0027"" />
|
||||
<option name="_new_target" value="""" />
|
||||
<option name="_new_targetType" value=""CUSTOM"" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Python.cli build" />
|
||||
<item itemvalue="Python.cli database migration" />
|
||||
<item itemvalue="Python.cli database update" />
|
||||
<item itemvalue="Python.cli help" />
|
||||
<item itemvalue="Python.cli new app" />
|
||||
<item itemvalue="Python.cli new base" />
|
||||
<item itemvalue="Python.cli new class" />
|
||||
<item itemvalue="Python.cli new configmodel" />
|
||||
<item itemvalue="Python.cli new enum" />
|
||||
<item itemvalue="Python.cli new service" />
|
||||
<item itemvalue="Python.cli publish" />
|
||||
<item itemvalue="Python.cli version" />
|
||||
<item itemvalue="Python.cli" />
|
||||
<item itemvalue="Python.main" />
|
||||
<item itemvalue="Python tests.Unittests" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python tests.Unittests" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="" />
|
||||
<created>1605881914521</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1605881914521</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00031" summary="Improved database module structure">
|
||||
<created>1607285697331</created>
|
||||
<option name="number" value="00031" />
|
||||
<option name="presentableId" value="LOCAL-00031" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607285697331</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00032" summary="Improved database module structure">
|
||||
<created>1607620265254</created>
|
||||
<option name="number" value="00032" />
|
||||
<option name="presentableId" value="LOCAL-00032" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607620265254</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00033" summary="Changed DatabaseConnection">
|
||||
<created>1607712129507</created>
|
||||
<option name="number" value="00033" />
|
||||
<option name="presentableId" value="LOCAL-00033" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607712129507</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00034" summary="Improved session reference">
|
||||
<created>1607971885250</created>
|
||||
<option name="number" value="00034" />
|
||||
<option name="presentableId" value="LOCAL-00034" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607971885250</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00035" summary="Added console module">
|
||||
<created>1607976456889</created>
|
||||
<option name="number" value="00035" />
|
||||
<option name="presentableId" value="LOCAL-00035" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607976456889</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00036" summary="Added console module">
|
||||
<created>1607976626173</created>
|
||||
<option name="number" value="00036" />
|
||||
<option name="presentableId" value="LOCAL-00036" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1607976626173</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00037" summary="Improved console">
|
||||
<created>1608037411172</created>
|
||||
<option name="number" value="00037" />
|
||||
<option name="presentableId" value="LOCAL-00037" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608037411172</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00038" summary="Improved console">
|
||||
<created>1608047595029</created>
|
||||
<option name="number" value="00038" />
|
||||
<option name="presentableId" value="LOCAL-00038" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608047595029</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00039" summary="Improved ApplicationHost">
|
||||
<created>1608047655667</created>
|
||||
<option name="number" value="00039" />
|
||||
<option name="presentableId" value="LOCAL-00039" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608047655667</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00040" summary="Improved publisher">
|
||||
<created>1608048544558</created>
|
||||
<option name="number" value="00040" />
|
||||
<option name="presentableId" value="LOCAL-00040" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608048544558</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00041" summary="Improved publisher">
|
||||
<created>1608049672925</created>
|
||||
<option name="number" value="00041" />
|
||||
<option name="presentableId" value="LOCAL-00041" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608049672925</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00042" summary="Published for 2020.12.9">
|
||||
<created>1608049772153</created>
|
||||
<option name="number" value="00042" />
|
||||
<option name="presentableId" value="LOCAL-00042" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608049772153</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00043" summary="Publish improvements for pip install">
|
||||
<created>1608059323858</created>
|
||||
<option name="number" value="00043" />
|
||||
<option name="presentableId" value="LOCAL-00043" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608059323858</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00044" summary="Improved setup.py">
|
||||
<created>1608059501153</created>
|
||||
<option name="number" value="00044" />
|
||||
<option name="presentableId" value="LOCAL-00044" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608059501153</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00045" summary="Added first cli commands">
|
||||
<created>1608066984496</created>
|
||||
<option name="number" value="00045" />
|
||||
<option name="presentableId" value="LOCAL-00045" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608066984496</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00046" summary="Bugfixes and improved setup logic">
|
||||
<created>1608070231599</created>
|
||||
<option name="number" value="00046" />
|
||||
<option name="presentableId" value="LOCAL-00046" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608070231599</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00047" summary="Improved cli">
|
||||
<created>1608122289003</created>
|
||||
<option name="number" value="00047" />
|
||||
<option name="presentableId" value="LOCAL-00047" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608122289003</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00048" summary="Added version command to cli">
|
||||
<created>1608125743068</created>
|
||||
<option name="number" value="00048" />
|
||||
<option name="presentableId" value="LOCAL-00048" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608125743068</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00049" summary="Improved version command & improved help command">
|
||||
<created>1608127752645</created>
|
||||
<option name="number" value="00049" />
|
||||
<option name="presentableId" value="LOCAL-00049" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608127752645</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00050" summary="Improved cli error handling">
|
||||
<created>1608127998033</created>
|
||||
<option name="number" value="00050" />
|
||||
<option name="presentableId" value="LOCAL-00050" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608127998034</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00051" summary="Removed module template">
|
||||
<created>1608128026922</created>
|
||||
<option name="number" value="00051" />
|
||||
<option name="presentableId" value="LOCAL-00051" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608128026922</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00052" summary="Added build command to cli">
|
||||
<created>1608133651981</created>
|
||||
<option name="number" value="00052" />
|
||||
<option name="presentableId" value="LOCAL-00052" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608133651982</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00053" summary="Improved publish process">
|
||||
<created>1608136663213</created>
|
||||
<option name="number" value="00053" />
|
||||
<option name="presentableId" value="LOCAL-00053" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608136663213</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00054" summary="Improved publish process">
|
||||
<created>1608137669182</created>
|
||||
<option name="number" value="00054" />
|
||||
<option name="presentableId" value="LOCAL-00054" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608137669182</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00055" summary="Added publish command to cli">
|
||||
<created>1608138851088</created>
|
||||
<option name="number" value="00055" />
|
||||
<option name="presentableId" value="LOCAL-00055" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608138851088</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00056" summary="Added imports to cli module">
|
||||
<created>1608138986801</created>
|
||||
<option name="number" value="00056" />
|
||||
<option name="presentableId" value="LOCAL-00056" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608138986801</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00057" summary="Improved help command">
|
||||
<created>1608139067953</created>
|
||||
<option name="number" value="00057" />
|
||||
<option name="presentableId" value="LOCAL-00057" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608139067953</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00058" summary="Changed deps">
|
||||
<created>1608139239527</created>
|
||||
<option name="number" value="00058" />
|
||||
<option name="presentableId" value="LOCAL-00058" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608139239527</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00059" summary="Bugfixes">
|
||||
<created>1608139414722</created>
|
||||
<option name="number" value="00059" />
|
||||
<option name="presentableId" value="LOCAL-00059" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608139414722</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00060" summary="Bugfixes">
|
||||
<created>1608139502304</created>
|
||||
<option name="number" value="00060" />
|
||||
<option name="presentableId" value="LOCAL-00060" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608139502304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00061" summary="Removed publisher.py">
|
||||
<created>1608139612476</created>
|
||||
<option name="number" value="00061" />
|
||||
<option name="presentableId" value="LOCAL-00061" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608139612476</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00062" summary="Added first steps of database command">
|
||||
<created>1608383809354</created>
|
||||
<option name="number" value="00062" />
|
||||
<option name="presentableId" value="LOCAL-00062" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608383809355</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00063" summary="Improved error handling">
|
||||
<created>1608383870849</created>
|
||||
<option name="number" value="00063" />
|
||||
<option name="presentableId" value="LOCAL-00063" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608383870849</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00064" summary="Improved service providing">
|
||||
<created>1608472168532</created>
|
||||
<option name="number" value="00064" />
|
||||
<option name="presentableId" value="LOCAL-00064" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608472168532</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00065" summary="Added email client">
|
||||
<created>1608472183294</created>
|
||||
<option name="number" value="00065" />
|
||||
<option name="presentableId" value="LOCAL-00065" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608472183294</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00066" summary="Published">
|
||||
<created>1608474022759</created>
|
||||
<option name="number" value="00066" />
|
||||
<option name="presentableId" value="LOCAL-00066" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608474022759</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00067" summary="Improved publisher">
|
||||
<created>1608474032244</created>
|
||||
<option name="number" value="00067" />
|
||||
<option name="presentableId" value="LOCAL-00067" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608474032244</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00068" summary="Added imports">
|
||||
<created>1608474289859</created>
|
||||
<option name="number" value="00068" />
|
||||
<option name="presentableId" value="LOCAL-00068" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608474289859</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00069" summary="Removed build form gitignore, added build command">
|
||||
<created>1608813096023</created>
|
||||
<option name="number" value="00069" />
|
||||
<option name="presentableId" value="LOCAL-00069" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608813096023</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00070" summary="Added init file for build command package">
|
||||
<created>1608813152266</created>
|
||||
<option name="number" value="00070" />
|
||||
<option name="presentableId" value="LOCAL-00070" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608813152266</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00071" summary="Added pycharm files to gitignore">
|
||||
<created>1608822597300</created>
|
||||
<option name="number" value="00071" />
|
||||
<option name="presentableId" value="LOCAL-00071" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608822597311</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00072" summary="Added more development tests">
|
||||
<created>1608823061488</created>
|
||||
<option name="number" value="00072" />
|
||||
<option name="presentableId" value="LOCAL-00072" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608823061489</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00073" summary="Added new tester and CredentialManager TestCase">
|
||||
<created>1608894745271</created>
|
||||
<option name="number" value="00073" />
|
||||
<option name="presentableId" value="LOCAL-00073" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608894745274</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00074" summary="Bugfix">
|
||||
<created>1608896199033</created>
|
||||
<option name="number" value="00074" />
|
||||
<option name="presentableId" value="LOCAL-00074" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608896199034</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00075" summary="Added TimeFormatSettings Test">
|
||||
<created>1608896235005</created>
|
||||
<option name="number" value="00075" />
|
||||
<option name="presentableId" value="LOCAL-00075" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608896235006</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00076" summary="Bugfixes">
|
||||
<created>1608901608928</created>
|
||||
<option name="number" value="00076" />
|
||||
<option name="presentableId" value="LOCAL-00076" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608901608930</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00077" summary="Improved tests">
|
||||
<created>1608921175852</created>
|
||||
<option name="number" value="00077" />
|
||||
<option name="presentableId" value="LOCAL-00077" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608921175853</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00078" summary="Bugfixes and improved tests">
|
||||
<created>1608986131753</created>
|
||||
<option name="number" value="00078" />
|
||||
<option name="presentableId" value="LOCAL-00078" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1608986131755</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00079" summary="Removed unused packages">
|
||||
<created>1611431001647</created>
|
||||
<option name="number" value="00079" />
|
||||
<option name="presentableId" value="LOCAL-00079" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1611431001649</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="80" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="oldMeFiltersMigrated" value="true" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Added build command to cli" />
|
||||
<MESSAGE value="Improved publish process" />
|
||||
<MESSAGE value="Added publish command to cli" />
|
||||
<MESSAGE value="Added imports to cli module" />
|
||||
<MESSAGE value="Improved help command" />
|
||||
<MESSAGE value="Changed deps" />
|
||||
<MESSAGE value="Removed publisher.py" />
|
||||
<MESSAGE value="Added first steps of database command" />
|
||||
<MESSAGE value="Improved error handling" />
|
||||
<MESSAGE value="Improved service providing" />
|
||||
<MESSAGE value="Added email client" />
|
||||
<MESSAGE value="Published" />
|
||||
<MESSAGE value="Improved publisher" />
|
||||
<MESSAGE value="Added imports" />
|
||||
<MESSAGE value="Removed build form gitignore, added build command" />
|
||||
<MESSAGE value="Added init file for build command package" />
|
||||
<MESSAGE value="Added pycharm files to gitignore" />
|
||||
<MESSAGE value="Added more development tests" />
|
||||
<MESSAGE value="Added new tester and CredentialManager TestCase" />
|
||||
<MESSAGE value="Bugfix" />
|
||||
<MESSAGE value="Added TimeFormatSettings Test" />
|
||||
<MESSAGE value="Bugfixes" />
|
||||
<MESSAGE value="Improved tests" />
|
||||
<MESSAGE value="Bugfixes and improved tests" />
|
||||
<MESSAGE value="Removed unused packages" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Removed unused packages" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/src/tests/publish_test/publisher_test.py</url>
|
||||
<line>50</line>
|
||||
<option name="timeStamp" value="3" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
||||
2
.pip.conf
Normal file
2
.pip.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[global]
|
||||
extra-index-url = https://git.sh-edraft.de/api/packages/sh-edraft.de/pypi/simple/
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
MIT License Copyright (c) <year> <copyright holders>
|
||||
MIT License Copyright (c) 2020 - 2023 sh-edraft.de
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
prefix: cpl
|
||||
commands:
|
||||
new:
|
||||
app
|
||||
base
|
||||
class
|
||||
configmodel
|
||||
enum
|
||||
service
|
||||
@@ -1,2 +0,0 @@
|
||||
python setup.py install # for install
|
||||
python setup.py sdist bdist_wheel # for build
|
||||
@@ -1,10 +0,0 @@
|
||||
- sh_edraft
|
||||
- common # Contains Interfaces and models for the hole library
|
||||
- interface
|
||||
- model
|
||||
- configuration # Contains classes for app configuration by JSON, ENV vars and arguments
|
||||
- discord # Contains classes for better use of discord.py
|
||||
- logging # Contains classes for logging
|
||||
- mailing # Contains classes for mailing
|
||||
- messenger # Contains classes for sh_messenger_server client
|
||||
- service # Contains classes to provide and use the services defined in this library
|
||||
@@ -1,2 +0,0 @@
|
||||
- create logger
|
||||
- use logger in publisher
|
||||
@@ -1,25 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
$Name $Description
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
$LongDescription
|
||||
|
||||
:copyright: (c) $CopyrightDate $CopyrightName
|
||||
:license: $LicenseName$LicenseDescription
|
||||
|
||||
"""
|
||||
|
||||
__title__ = '$Title'
|
||||
__author__ = '$Author'
|
||||
__license__ = '$LicenseName'
|
||||
__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'
|
||||
__version__ = '$Version'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
$Imports
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)
|
||||
2
pyproject.toml
Normal file
2
pyproject.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
@@ -1,29 +0,0 @@
|
||||
aiohttp==3.6.3
|
||||
async-timeout==3.0.1
|
||||
attrs==20.3.0
|
||||
certifi==2020.11.8
|
||||
chardet==3.0.4
|
||||
click==7.1.2
|
||||
dateutils==0.6.12
|
||||
discord==1.0.1
|
||||
discord.py==1.5.1
|
||||
Flask==1.1.2
|
||||
idna==2.10
|
||||
itsdangerous==1.1.0
|
||||
Jinja2==2.11.2
|
||||
keyboard==0.13.5
|
||||
MarkupSafe==1.1.1
|
||||
multidict==4.7.6
|
||||
mysql-connector==2.2.9
|
||||
overloading==0.5.0
|
||||
python-dateutil==2.8.1
|
||||
pytz==2020.4
|
||||
six==1.15.0
|
||||
SQLAlchemy==1.3.20
|
||||
termcolor==1.1.0
|
||||
urllib3==1.26.2
|
||||
Werkzeug==1.0.1
|
||||
yarl==1.5.1
|
||||
setuptools~=49.2.1
|
||||
pyfiglet~=0.8.post1
|
||||
tabulate~=0.8.7
|
||||
@@ -1,2 +0,0 @@
|
||||
include ../ README
|
||||
recursive-include sh_edraft *.txt
|
||||
@@ -1,66 +0,0 @@
|
||||
{
|
||||
"TimeFormatSettings": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
"LoggingSettings": {
|
||||
"Path": "../build/logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLogLevel": "INFO",
|
||||
"FileLogLevel": "TRACE"
|
||||
},
|
||||
"PublishSettings": {
|
||||
"SourcePath": "./",
|
||||
"DistPath": "../build/dist",
|
||||
"Templates": [
|
||||
{
|
||||
"TemplatePath": "../publish_templates/all_template.txt",
|
||||
"Name": "all",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"CopyrightDate": "2020",
|
||||
"CopyrightName": "sh-edraft.de",
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": ", see LICENSE for more details.",
|
||||
"Title": "",
|
||||
"Author": "Sven Heidemann",
|
||||
"Version": {
|
||||
"Major": 2020,
|
||||
"Minor": 12,
|
||||
"Micro": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"TemplatePath": "../publish_templates/all_template.txt",
|
||||
"Name": "sh_edraft",
|
||||
"Description": "common python library",
|
||||
"LongDescription": "Library to share common classes and models used at sh-edraft.de",
|
||||
"CopyrightDate": "2020",
|
||||
"CopyrightName": "sh-edraft.de",
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": ", see LICENSE for more details.",
|
||||
"Title": "",
|
||||
"Author": "Sven Heidemann",
|
||||
"Version": {
|
||||
"Major": 2020,
|
||||
"Minor": 12,
|
||||
"Micro": 10
|
||||
}
|
||||
}
|
||||
],
|
||||
"IncludedFiles": [
|
||||
"./MANIFEST.in",
|
||||
"../LICENSE",
|
||||
"../README.md",
|
||||
"../requirements.txt",
|
||||
"sh_edraft/cli/cpl_cli/templates"
|
||||
],
|
||||
"ExcludedFiles": [
|
||||
"./tests",
|
||||
"./tests_dev"
|
||||
],
|
||||
"TemplateEnding": "_template.txt"
|
||||
}
|
||||
}
|
||||
1
src/cpl-application/cpl/application/__init__.py
Normal file
1
src/cpl-application/cpl/application/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .application_builder import ApplicationBuilder
|
||||
4
src/cpl-application/cpl/application/abc/__init__.py
Normal file
4
src/cpl-application/cpl/application/abc/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .application_abc import ApplicationABC
|
||||
from .application_extension_abc import ApplicationExtensionABC
|
||||
from .startup_abc import StartupABC
|
||||
from .startup_extension_abc import StartupExtensionABC
|
||||
86
src/cpl-application/cpl/application/abc/application_abc.py
Normal file
86
src/cpl-application/cpl/application/abc/application_abc.py
Normal file
@@ -0,0 +1,86 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Callable, Self
|
||||
|
||||
from cpl.application.host import Host
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.log import LogSettings
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
from cpl.core.log.logger_abc import LoggerABC
|
||||
from cpl.dependency.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
def __not_implemented__(package: str, func: Callable):
|
||||
raise NotImplementedError(f"Package {package} is required to use {func.__name__} method")
|
||||
|
||||
|
||||
class ApplicationABC(ABC):
|
||||
r"""ABC for the Application class
|
||||
|
||||
Parameters:
|
||||
services: :class:`cpl.dependency.service_provider_abc.ServiceProviderABC`
|
||||
Contains instances of prepared objects
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, services: ServiceProviderABC):
|
||||
self._services = services
|
||||
|
||||
@classmethod
|
||||
def extend(cls, name: str | Callable, func: Callable[[Self], Self]):
|
||||
r"""Extend the Application with a custom method
|
||||
|
||||
Parameters:
|
||||
name: :class:`str`
|
||||
Name of the method
|
||||
func: :class:`Callable[[Self], Self]`
|
||||
Function that takes the Application as a parameter and returns it
|
||||
"""
|
||||
if callable(name):
|
||||
name = name.__name__
|
||||
|
||||
setattr(cls, name, func)
|
||||
return cls
|
||||
|
||||
def with_logging(self, level: LogLevel = None):
|
||||
if level is None:
|
||||
from cpl.core.configuration.configuration import Configuration
|
||||
|
||||
settings = Configuration.get(LogSettings)
|
||||
level = settings.level if settings else LogLevel.info
|
||||
|
||||
logger = self._services.get_service(LoggerABC)
|
||||
logger.set_level(level)
|
||||
|
||||
def with_permissions(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-auth", self.with_permissions)
|
||||
|
||||
def with_migrations(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-database", self.with_migrations)
|
||||
|
||||
def with_seeders(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-database", self.with_seeders)
|
||||
|
||||
def with_extension(self, func: Callable[[Self, ...], None], *args, **kwargs):
|
||||
r"""Extend the Application with a custom method
|
||||
|
||||
Parameters:
|
||||
func: :class:`Callable[[Self], Self]`
|
||||
Function that takes the Application as a parameter and returns it
|
||||
"""
|
||||
assert func is not None, "func must not be None"
|
||||
assert callable(func), "func must be callable"
|
||||
|
||||
func(self, *args, **kwargs)
|
||||
|
||||
def run(self):
|
||||
r"""Entry point
|
||||
|
||||
Called by custom Application.main
|
||||
"""
|
||||
try:
|
||||
Host.run(self.main)
|
||||
except KeyboardInterrupt:
|
||||
Console.close()
|
||||
|
||||
@abstractmethod
|
||||
def main(self): ...
|
||||
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class ApplicationExtensionABC(ABC):
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def run(services: ServiceProviderABC): ...
|
||||
21
src/cpl-application/cpl/application/abc/startup_abc.py
Normal file
21
src/cpl-application/cpl/application/abc/startup_abc.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl.dependency.service_collection import ServiceCollection
|
||||
|
||||
|
||||
class StartupABC(ABC):
|
||||
r"""ABC for the startup class"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_configuration():
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_services(service: ServiceCollection):
|
||||
r"""Creates service provider
|
||||
|
||||
Parameter:
|
||||
services: :class:`cpl.dependency.service_collection`
|
||||
"""
|
||||
@@ -0,0 +1,20 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl.dependency import ServiceCollection
|
||||
|
||||
|
||||
class StartupExtensionABC(ABC):
|
||||
r"""ABC for startup extension classes"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_configuration():
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_services(services: ServiceCollection):
|
||||
r"""Creates service provider
|
||||
Parameter:
|
||||
services: :class:`cpl.dependency.service_collection`
|
||||
"""
|
||||
64
src/cpl-application/cpl/application/application_builder.py
Normal file
64
src/cpl-application/cpl/application/application_builder.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import asyncio
|
||||
from typing import Type, Optional
|
||||
|
||||
from cpl.application.abc.application_abc import ApplicationABC
|
||||
from cpl.application.abc.application_extension_abc import ApplicationExtensionABC
|
||||
from cpl.application.abc.startup_abc import StartupABC
|
||||
from cpl.application.abc.startup_extension_abc import StartupExtensionABC
|
||||
from cpl.application.host import Host
|
||||
from cpl.dependency.service_collection import ServiceCollection
|
||||
|
||||
|
||||
class ApplicationBuilder:
|
||||
r"""A builder for constructing an application with configurable services and extensions."""
|
||||
|
||||
def __init__(self, app: Type[ApplicationABC]):
|
||||
assert app is not None, "app must not be None"
|
||||
assert issubclass(app, ApplicationABC), "app must be an subclass of ApplicationABC or its subclass"
|
||||
|
||||
self._app = app if app is not None else ApplicationABC
|
||||
|
||||
self._services = ServiceCollection()
|
||||
|
||||
self._startup: Optional[StartupABC] = None
|
||||
self._app_extensions: list[Type[ApplicationExtensionABC]] = []
|
||||
self._startup_extensions: list[Type[StartupExtensionABC]] = []
|
||||
|
||||
self._async_loop = asyncio.get_event_loop()
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceCollection:
|
||||
return self._services
|
||||
|
||||
@property
|
||||
def service_provider(self):
|
||||
return self._services.build()
|
||||
|
||||
def with_startup(self, startup: Type[StartupABC]) -> "ApplicationBuilder":
|
||||
self._startup = startup
|
||||
return self
|
||||
|
||||
def with_extension(
|
||||
self,
|
||||
extension: Type[ApplicationExtensionABC | StartupExtensionABC],
|
||||
) -> "ApplicationBuilder":
|
||||
if (issubclass(extension, ApplicationExtensionABC)) and extension not in self._app_extensions:
|
||||
self._app_extensions.append(extension)
|
||||
elif (issubclass(extension, StartupExtensionABC)) and extension not in self._startup_extensions:
|
||||
self._startup_extensions.append(extension)
|
||||
|
||||
return self
|
||||
|
||||
def build(self) -> ApplicationABC:
|
||||
for extension in self._startup_extensions:
|
||||
Host.run(extension.configure_configuration)
|
||||
Host.run(extension.configure_services, self._services)
|
||||
|
||||
if self._startup is not None:
|
||||
Host.run(self._startup.configure_configuration)
|
||||
Host.run(self._startup.configure_services, self._services)
|
||||
|
||||
for extension in self._app_extensions:
|
||||
Host.run(extension.run, self.service_provider)
|
||||
|
||||
return self._app(self.service_provider)
|
||||
17
src/cpl-application/cpl/application/host.py
Normal file
17
src/cpl-application/cpl/application/host.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import asyncio
|
||||
from typing import Callable
|
||||
|
||||
|
||||
class Host:
|
||||
_loop = asyncio.get_event_loop()
|
||||
|
||||
@classmethod
|
||||
def get_loop(cls):
|
||||
return cls._loop
|
||||
|
||||
@classmethod
|
||||
def run(cls, func: Callable, *args, **kwargs):
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
return cls._loop.run_until_complete(func(*args, **kwargs))
|
||||
|
||||
return func(*args, **kwargs)
|
||||
30
src/cpl-application/pyproject.toml
Normal file
30
src/cpl-application/pyproject.toml
Normal file
@@ -0,0 +1,30 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=70.1.0", "wheel>=0.43.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "cpl-application"
|
||||
version = "2024.7.0"
|
||||
description = "CPL application"
|
||||
readme ="CPL application package"
|
||||
requires-python = ">=3.12"
|
||||
license = { text = "MIT" }
|
||||
authors = [
|
||||
{ name = "Sven Heidemann", email = "sven.heidemann@sh-edraft.de" }
|
||||
]
|
||||
keywords = ["cpl", "application", "backend", "shared", "library"]
|
||||
|
||||
dynamic = ["dependencies", "optional-dependencies"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://www.sh-edraft.de"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["cpl*"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
dependencies = { file = ["requirements.txt"] }
|
||||
optional-dependencies.dev = { file = ["requirements.dev.txt"] }
|
||||
|
||||
|
||||
1
src/cpl-application/requirements.dev.txt
Normal file
1
src/cpl-application/requirements.dev.txt
Normal file
@@ -0,0 +1 @@
|
||||
black==25.1.0
|
||||
2
src/cpl-application/requirements.txt
Normal file
2
src/cpl-application/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
cpl-core
|
||||
cpl-dependency
|
||||
82
src/cpl-auth/cpl/auth/__init__.py
Normal file
82
src/cpl-auth/cpl/auth/__init__.py
Normal file
@@ -0,0 +1,82 @@
|
||||
from enum import Enum
|
||||
from typing import Type
|
||||
|
||||
from cpl.application.abc import ApplicationABC as _ApplicationABC
|
||||
from cpl.auth import permission as _permission
|
||||
from cpl.auth.keycloak.keycloak_admin import KeycloakAdmin as _KeycloakAdmin
|
||||
from cpl.auth.keycloak.keycloak_client import KeycloakClient as _KeycloakClient
|
||||
from cpl.dependency.service_collection import ServiceCollection as _ServiceCollection
|
||||
from .auth_logger import AuthLogger
|
||||
from .keycloak_settings import KeycloakSettings
|
||||
from .permission_seeder import PermissionSeeder
|
||||
|
||||
|
||||
def _with_permissions(self: _ApplicationABC, *permissions: Type[Enum]) -> _ApplicationABC:
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
|
||||
for perm in permissions:
|
||||
PermissionsRegistry.with_enum(perm)
|
||||
return self
|
||||
|
||||
|
||||
def _add_daos(collection: _ServiceCollection):
|
||||
from .schema._administration.auth_user_dao import AuthUserDao
|
||||
from .schema._administration.api_key_dao import ApiKeyDao
|
||||
from .schema._permission.api_key_permission_dao import ApiKeyPermissionDao
|
||||
from .schema._permission.permission_dao import PermissionDao
|
||||
from .schema._permission.role_dao import RoleDao
|
||||
from .schema._permission.role_permission_dao import RolePermissionDao
|
||||
from .schema._permission.role_user_dao import RoleUserDao
|
||||
|
||||
collection.add_singleton(AuthUserDao)
|
||||
collection.add_singleton(ApiKeyDao)
|
||||
collection.add_singleton(ApiKeyPermissionDao)
|
||||
collection.add_singleton(PermissionDao)
|
||||
collection.add_singleton(RoleDao)
|
||||
collection.add_singleton(RolePermissionDao)
|
||||
collection.add_singleton(RoleUserDao)
|
||||
|
||||
|
||||
def add_auth(collection: _ServiceCollection):
|
||||
import os
|
||||
|
||||
from cpl.core.console import Console
|
||||
from cpl.database.service.migration_service import MigrationService
|
||||
from cpl.database.model.server_type import ServerType, ServerTypes
|
||||
|
||||
try:
|
||||
collection.add_singleton(_KeycloakClient)
|
||||
collection.add_singleton(_KeycloakAdmin)
|
||||
|
||||
_add_daos(collection)
|
||||
|
||||
provider = collection.build()
|
||||
migration_service: MigrationService = provider.get_service(MigrationService)
|
||||
if ServerType.server_type == ServerTypes.POSTGRES:
|
||||
migration_service.with_directory(
|
||||
os.path.join(os.path.dirname(os.path.realpath(__file__)), "scripts/postgres")
|
||||
)
|
||||
elif ServerType.server_type == ServerTypes.MYSQL:
|
||||
migration_service.with_directory(os.path.join(os.path.dirname(os.path.realpath(__file__)), "scripts/mysql"))
|
||||
except ImportError as e:
|
||||
Console.error("cpl-auth is not installed", str(e))
|
||||
|
||||
|
||||
def add_permission(collection: _ServiceCollection):
|
||||
from cpl.auth.permission_seeder import PermissionSeeder
|
||||
from cpl.database.abc.data_seeder_abc import DataSeederABC
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
|
||||
try:
|
||||
collection.add_singleton(DataSeederABC, PermissionSeeder)
|
||||
PermissionsRegistry.with_enum(Permissions)
|
||||
except ImportError as e:
|
||||
from cpl.core.console import Console
|
||||
|
||||
Console.error("cpl-auth is not installed", str(e))
|
||||
|
||||
|
||||
_ServiceCollection.with_module(add_auth, __name__)
|
||||
_ServiceCollection.with_module(add_permission, _permission.__name__)
|
||||
_ApplicationABC.extend(_ApplicationABC.with_permissions, _with_permissions)
|
||||
8
src/cpl-auth/cpl/auth/auth_logger.py
Normal file
8
src/cpl-auth/cpl/auth/auth_logger.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from cpl.core.log import Logger
|
||||
from cpl.core.typing import Source
|
||||
|
||||
|
||||
class AuthLogger(Logger):
|
||||
|
||||
def __init__(self, source: Source):
|
||||
Logger.__init__(self, source, "auth")
|
||||
3
src/cpl-auth/cpl/auth/keycloak/__init__.py
Normal file
3
src/cpl-auth/cpl/auth/keycloak/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .keycloak_admin import KeycloakAdmin
|
||||
from .keycloak_client import KeycloakClient
|
||||
from .keycloak_user import KeycloakUser
|
||||
24
src/cpl-auth/cpl/auth/keycloak/keycloak_admin.py
Normal file
24
src/cpl-auth/cpl/auth/keycloak/keycloak_admin.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from keycloak import KeycloakAdmin as _KeycloakAdmin, KeycloakOpenIDConnection
|
||||
|
||||
from cpl.auth.auth_logger import AuthLogger
|
||||
from cpl.auth.keycloak_settings import KeycloakSettings
|
||||
|
||||
_logger = AuthLogger("keycloak")
|
||||
|
||||
|
||||
class KeycloakAdmin(_KeycloakAdmin):
|
||||
|
||||
def __init__(self, settings: KeycloakSettings):
|
||||
_logger.info("Initializing Keycloak admin")
|
||||
_connection = KeycloakOpenIDConnection(
|
||||
server_url=settings.url,
|
||||
client_id=settings.client_id,
|
||||
realm_name=settings.realm,
|
||||
client_secret_key=settings.client_secret,
|
||||
)
|
||||
_KeycloakAdmin.__init__(
|
||||
self,
|
||||
connection=_connection,
|
||||
)
|
||||
|
||||
self.__connection = _connection
|
||||
26
src/cpl-auth/cpl/auth/keycloak/keycloak_client.py
Normal file
26
src/cpl-auth/cpl/auth/keycloak/keycloak_client.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from keycloak import KeycloakOpenID, KeycloakAdmin, KeycloakOpenIDConnection
|
||||
|
||||
from cpl.auth.auth_logger import AuthLogger
|
||||
from cpl.auth.keycloak_settings import KeycloakSettings
|
||||
|
||||
_logger = AuthLogger("keycloak")
|
||||
|
||||
|
||||
class KeycloakClient(KeycloakOpenID):
|
||||
|
||||
def __init__(self, settings: KeycloakSettings):
|
||||
KeycloakOpenID.__init__(
|
||||
self,
|
||||
server_url=settings.url,
|
||||
client_id=settings.client_id,
|
||||
realm_name=settings.realm,
|
||||
client_secret_key=settings.client_secret,
|
||||
)
|
||||
_logger.info("Initializing Keycloak client")
|
||||
connection = KeycloakOpenIDConnection(
|
||||
server_url=settings.url,
|
||||
client_id=settings.client_id,
|
||||
realm_name=settings.realm,
|
||||
client_secret_key=settings.client_secret,
|
||||
)
|
||||
self._admin = KeycloakAdmin(connection=connection)
|
||||
36
src/cpl-auth/cpl/auth/keycloak/keycloak_user.py
Normal file
36
src/cpl-auth/cpl/auth/keycloak/keycloak_user.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from cpl.core.utils.get_value import get_value
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class KeycloakUser:
|
||||
|
||||
def __init__(self, source: dict):
|
||||
self._username = get_value(source, "preferred_username", str)
|
||||
self._email = get_value(source, "email", str)
|
||||
self._email_verified = get_value(source, "email_verified", bool)
|
||||
self._name = get_value(source, "name", str)
|
||||
|
||||
@property
|
||||
def username(self) -> str:
|
||||
return self._username
|
||||
|
||||
@property
|
||||
def email(self) -> str:
|
||||
return self._email
|
||||
|
||||
@property
|
||||
def email_verified(self) -> bool:
|
||||
return self._email_verified
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
# Attrs from keycloak
|
||||
|
||||
@property
|
||||
def id(self) -> str:
|
||||
from cpl.auth import KeycloakAdmin
|
||||
|
||||
keycloak_admin: KeycloakAdmin = ServiceProviderABC.get_global_service(KeycloakAdmin)
|
||||
return keycloak_admin.get_user_id(self._username)
|
||||
17
src/cpl-auth/cpl/auth/keycloak_settings.py
Normal file
17
src/cpl-auth/cpl/auth/keycloak_settings.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
|
||||
|
||||
class KeycloakSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
src: Optional[dict] = None,
|
||||
):
|
||||
ConfigurationModelABC.__init__(self, src, "KEYCLOAK")
|
||||
|
||||
self.option("url", str, required=True)
|
||||
self.option("client_id", str, required=True)
|
||||
self.option("realm", str, required=True)
|
||||
self.option("client_secret", str, required=True)
|
||||
36
src/cpl-auth/cpl/auth/permission/permissions.py
Normal file
36
src/cpl-auth/cpl/auth/permission/permissions.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Permissions(Enum):
|
||||
""" """
|
||||
|
||||
"""
|
||||
Administration
|
||||
"""
|
||||
# administrator
|
||||
administrator = "administrator"
|
||||
|
||||
# api keys
|
||||
api_keys = "api_keys"
|
||||
api_keys_create = "api_keys.create"
|
||||
api_keys_update = "api_keys.update"
|
||||
api_keys_delete = "api_keys.delete"
|
||||
|
||||
# users
|
||||
users = "users"
|
||||
users_create = "users.create"
|
||||
users_update = "users.update"
|
||||
users_delete = "users.delete"
|
||||
|
||||
# settings
|
||||
settings = "settings"
|
||||
settings_update = "settings.update"
|
||||
|
||||
"""
|
||||
Permissions
|
||||
"""
|
||||
# roles
|
||||
roles = "roles"
|
||||
roles_create = "roles.create"
|
||||
roles_update = "roles.update"
|
||||
roles_delete = "roles.delete"
|
||||
24
src/cpl-auth/cpl/auth/permission/permissions_registry.py
Normal file
24
src/cpl-auth/cpl/auth/permission/permissions_registry.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from enum import Enum
|
||||
from typing import Type
|
||||
|
||||
|
||||
class PermissionsRegistry:
|
||||
_permissions: dict[str, str] = {}
|
||||
|
||||
@classmethod
|
||||
def get(cls):
|
||||
return cls._permissions.keys()
|
||||
|
||||
@classmethod
|
||||
def descriptions(cls):
|
||||
return {x: cls._permissions[x] for x in cls._permissions if cls._permissions[x] is not None}
|
||||
|
||||
@classmethod
|
||||
def set(cls, permission: str, description: str = None):
|
||||
cls._permissions[permission] = description
|
||||
|
||||
@classmethod
|
||||
def with_enum(cls, e: Type[Enum]):
|
||||
perms = [x.value for x in e]
|
||||
for perm in perms:
|
||||
cls.set(str(perm))
|
||||
120
src/cpl-auth/cpl/auth/permission_seeder.py
Normal file
120
src/cpl-auth/cpl/auth/permission_seeder.py
Normal file
@@ -0,0 +1,120 @@
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
from cpl.auth.schema import (
|
||||
Permission,
|
||||
Role,
|
||||
RolePermission,
|
||||
ApiKey,
|
||||
ApiKeyPermission,
|
||||
PermissionDao,
|
||||
RoleDao,
|
||||
RolePermissionDao,
|
||||
ApiKeyDao,
|
||||
ApiKeyPermissionDao,
|
||||
)
|
||||
from cpl.core.utils.get_value import get_value
|
||||
from cpl.database.abc.data_seeder_abc import DataSeederABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class PermissionSeeder(DataSeederABC):
|
||||
def __init__(
|
||||
self,
|
||||
permission_dao: PermissionDao,
|
||||
role_dao: RoleDao,
|
||||
role_permission_dao: RolePermissionDao,
|
||||
api_key_dao: ApiKeyDao,
|
||||
api_key_permission_dao: ApiKeyPermissionDao,
|
||||
):
|
||||
DataSeederABC.__init__(self)
|
||||
self._permission_dao = permission_dao
|
||||
self._role_dao = role_dao
|
||||
self._role_permission_dao = role_permission_dao
|
||||
self._api_key_dao = api_key_dao
|
||||
self._api_key_permission_dao = api_key_permission_dao
|
||||
|
||||
async def seed(self):
|
||||
permissions = await self._permission_dao.get_all()
|
||||
possible_permissions = [permission for permission in PermissionsRegistry.get()]
|
||||
|
||||
if len(permissions) == len(possible_permissions):
|
||||
_logger.info("Permissions already existing")
|
||||
await self._update_missing_descriptions()
|
||||
return
|
||||
|
||||
to_delete = []
|
||||
for permission in permissions:
|
||||
if permission.name in possible_permissions:
|
||||
continue
|
||||
|
||||
to_delete.append(permission)
|
||||
|
||||
await self._permission_dao.delete_many(to_delete, hard_delete=True)
|
||||
|
||||
_logger.warning("Permissions incomplete")
|
||||
permission_names = [permission.name for permission in permissions]
|
||||
await self._permission_dao.create_many(
|
||||
[
|
||||
Permission(
|
||||
0,
|
||||
permission,
|
||||
get_value(PermissionsRegistry.descriptions(), permission, str),
|
||||
)
|
||||
for permission in possible_permissions
|
||||
if permission not in permission_names
|
||||
]
|
||||
)
|
||||
await self._update_missing_descriptions()
|
||||
|
||||
await self._add_missing_to_role()
|
||||
await self._add_missing_to_api_key()
|
||||
|
||||
async def _add_missing_to_role(self):
|
||||
admin_role = await self._role_dao.find_single_by([{Role.id: 1}, {Role.name: "admin"}])
|
||||
if admin_role is None:
|
||||
return
|
||||
|
||||
admin_permissions = await self._role_permission_dao.get_by_role_id(admin_role.id, with_deleted=True)
|
||||
to_assign = [
|
||||
RolePermission(0, admin_role.id, permission.id)
|
||||
for permission in await self._permission_dao.get_all()
|
||||
if permission.id not in [x.permission_id for x in admin_permissions]
|
||||
]
|
||||
await self._role_permission_dao.create_many(to_assign)
|
||||
|
||||
async def _add_missing_to_api_key(self):
|
||||
admin_api_key = await self._api_key_dao.find_single_by([{ApiKey.id: 1}, {ApiKey.identifier: "admin"}])
|
||||
if admin_api_key is None:
|
||||
return
|
||||
|
||||
admin_permissions = await self._api_key_permission_dao.find_by_api_key_id(admin_api_key.id, with_deleted=True)
|
||||
to_assign = [
|
||||
ApiKeyPermission(0, admin_api_key.id, permission.id)
|
||||
for permission in await self._permission_dao.get_all()
|
||||
if permission.id not in [x.permission_id for x in admin_permissions]
|
||||
]
|
||||
await self._api_key_permission_dao.create_many(to_assign)
|
||||
|
||||
async def _update_missing_descriptions(self):
|
||||
permissions = {
|
||||
permission.name: permission
|
||||
for permission in await self._permission_dao.find_by([{Permission.description: None}])
|
||||
}
|
||||
to_update = []
|
||||
|
||||
if len(permissions) == 0:
|
||||
return
|
||||
|
||||
for key in PermissionsRegistry.descriptions():
|
||||
if key.value not in permissions:
|
||||
continue
|
||||
|
||||
permissions[key.value].description = PermissionsRegistry.descriptions()[key]
|
||||
to_update.append(permissions[key.value])
|
||||
|
||||
if len(to_update) == 0:
|
||||
return
|
||||
|
||||
await self._permission_dao.update_many(to_update)
|
||||
15
src/cpl-auth/cpl/auth/schema/__init__.py
Normal file
15
src/cpl-auth/cpl/auth/schema/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from ._administration.api_key import ApiKey
|
||||
from ._administration.api_key_dao import ApiKeyDao
|
||||
from ._administration.auth_user import AuthUser
|
||||
from ._administration.auth_user_dao import AuthUserDao
|
||||
|
||||
from ._permission.api_key_permission import ApiKeyPermission
|
||||
from ._permission.api_key_permission_dao import ApiKeyPermissionDao
|
||||
from ._permission.permission import Permission
|
||||
from ._permission.permission_dao import PermissionDao
|
||||
from ._permission.role import Role
|
||||
from ._permission.role_dao import RoleDao
|
||||
from ._permission.role_permission import RolePermission
|
||||
from ._permission.role_permission_dao import RolePermissionDao
|
||||
from ._permission.role_user import RoleUser
|
||||
from ._permission.role_user_dao import RoleUserDao
|
||||
66
src/cpl-auth/cpl/auth/schema/_administration/api_key.py
Normal file
66
src/cpl-auth/cpl/auth/schema/_administration/api_key.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import secrets
|
||||
from datetime import datetime
|
||||
from typing import Optional, Union
|
||||
|
||||
from async_property import async_property
|
||||
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.core.environment.environment import Environment
|
||||
from cpl.core.log.logger import Logger
|
||||
from cpl.core.typing import Id, SerialId
|
||||
from cpl.core.utils.credential_manager import CredentialManager
|
||||
from cpl.database.abc.db_model_abc import DbModelABC
|
||||
from cpl.dependency.service_provider_abc import ServiceProviderABC
|
||||
|
||||
_logger = Logger(__name__)
|
||||
|
||||
|
||||
class ApiKey(DbModelABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
identifier: str,
|
||||
key: Union[str, bytes],
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[Id] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._identifier = identifier
|
||||
self._key = key
|
||||
|
||||
@property
|
||||
def identifier(self) -> str:
|
||||
return self._identifier
|
||||
|
||||
@property
|
||||
def key(self) -> str:
|
||||
return self._key
|
||||
|
||||
@property
|
||||
def plain_key(self) -> str:
|
||||
return CredentialManager.decrypt(self.key)
|
||||
|
||||
@async_property
|
||||
async def permissions(self):
|
||||
from cpl.auth.schema._permission.api_key_permission_dao import ApiKeyPermissionDao
|
||||
|
||||
apiKeyPermissionDao = ServiceProviderABC.get_global_provider().get_service(ApiKeyPermissionDao)
|
||||
|
||||
return [await x.permission for x in await apiKeyPermissionDao.find_by_api_key_id(self.id)]
|
||||
|
||||
async def has_permission(self, permission: Permissions) -> bool:
|
||||
return permission.value in [x.name for x in await self.permissions]
|
||||
|
||||
def set_new_api_key(self):
|
||||
self._key = self.new_key()
|
||||
|
||||
@staticmethod
|
||||
def new_key() -> str:
|
||||
return CredentialManager.encrypt(f"api_{secrets.token_urlsafe(Environment.get("API_KEY_LENGTH", int, 64))}")
|
||||
|
||||
@classmethod
|
||||
def new(cls, identifier: str) -> "ApiKey":
|
||||
return ApiKey(0, identifier, cls.new_key())
|
||||
32
src/cpl-auth/cpl/auth/schema/_administration/api_key_dao.py
Normal file
32
src/cpl-auth/cpl/auth/schema/_administration/api_key_dao.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.auth.schema._administration.api_key import ApiKey
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class ApiKeyDao(DbModelDaoABC[ApiKey]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, ApiKey, TableManager.get("api_keys"))
|
||||
|
||||
self.attribute(ApiKey.identifier, str)
|
||||
self.attribute(ApiKey.key, str, "keystring")
|
||||
|
||||
async def get_by_identifier(self, ident: str) -> ApiKey:
|
||||
result = await self._db.select_map(f"SELECT * FROM {self._table_name} WHERE Identifier = '{ident}'")
|
||||
return self.to_object(result[0])
|
||||
|
||||
async def get_by_key(self, key: str) -> ApiKey:
|
||||
result = await self._db.select_map(f"SELECT * FROM {self._table_name} WHERE Keystring = '{key}'")
|
||||
return self.to_object(result[0])
|
||||
|
||||
async def find_by_key(self, key: str) -> Optional[ApiKey]:
|
||||
result = await self._db.select_map(f"SELECT * FROM {self._table_name} WHERE Keystring = '{key}'")
|
||||
if not result or len(result) == 0:
|
||||
return None
|
||||
|
||||
return self.to_object(result[0])
|
||||
89
src/cpl-auth/cpl/auth/schema/_administration/auth_user.py
Normal file
89
src/cpl-auth/cpl/auth/schema/_administration/auth_user.py
Normal file
@@ -0,0 +1,89 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from async_property import async_property
|
||||
from keycloak import KeycloakGetError
|
||||
|
||||
from cpl.auth.keycloak import KeycloakAdmin
|
||||
from cpl.auth.auth_logger import AuthLogger
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
_logger = AuthLogger(__name__)
|
||||
|
||||
|
||||
class AuthUser(DbModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
keycloak_id: str,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._keycloak_id = keycloak_id
|
||||
|
||||
@property
|
||||
def keycloak_id(self) -> str:
|
||||
return self._keycloak_id
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
if self._keycloak_id == str(uuid.UUID(int=0)):
|
||||
return "ANONYMOUS"
|
||||
|
||||
try:
|
||||
keycloak_admin: KeycloakAdmin = ServiceProviderABC.get_global_service(KeycloakAdmin)
|
||||
return keycloak_admin.get_user(self._keycloak_id).get("username")
|
||||
except KeycloakGetError as e:
|
||||
return "UNKNOWN"
|
||||
except Exception as e:
|
||||
_logger.error(f"Failed to get user {self._keycloak_id} from Keycloak", e)
|
||||
return "UNKNOWN"
|
||||
|
||||
@property
|
||||
def email(self):
|
||||
if self._keycloak_id == str(uuid.UUID(int=0)):
|
||||
return "ANONYMOUS"
|
||||
|
||||
try:
|
||||
keycloak_admin: KeycloakAdmin = ServiceProviderABC.get_global_service(KeycloakAdmin)
|
||||
return keycloak_admin.get_user(self._keycloak_id).get("email")
|
||||
except KeycloakGetError as e:
|
||||
return "UNKNOWN"
|
||||
except Exception as e:
|
||||
_logger.error(f"Failed to get user {self._keycloak_id} from Keycloak", e)
|
||||
return "UNKNOWN"
|
||||
|
||||
@async_property
|
||||
async def roles(self):
|
||||
from cpl.auth.schema._permission.role_user_dao import RoleUserDao
|
||||
|
||||
role_user_dao: RoleUserDao = ServiceProviderABC.get_global_service(RoleUserDao)
|
||||
return [await x.role for x in await role_user_dao.get_by_user_id(self.id)]
|
||||
|
||||
@async_property
|
||||
async def permissions(self):
|
||||
from cpl.auth.schema._administration.auth_user_dao import AuthUserDao
|
||||
|
||||
auth_user_dao: AuthUserDao = ServiceProviderABC.get_global_service(AuthUserDao)
|
||||
return await auth_user_dao.get_permissions(self.id)
|
||||
|
||||
async def has_permission(self, permission: Permissions) -> bool:
|
||||
from cpl.auth.schema._administration.auth_user_dao import AuthUserDao
|
||||
|
||||
auth_user_dao: AuthUserDao = ServiceProviderABC.get_global_service(AuthUserDao)
|
||||
return await auth_user_dao.has_permission(self.id, permission)
|
||||
|
||||
async def anonymize(self):
|
||||
from cpl.auth.schema._administration.auth_user_dao import AuthUserDao
|
||||
|
||||
auth_user_dao: AuthUserDao = ServiceProviderABC.get_global_service(AuthUserDao)
|
||||
|
||||
self._keycloak_id = str(uuid.UUID(int=0))
|
||||
await auth_user_dao.update(self)
|
||||
@@ -0,0 +1,72 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.auth.schema._administration.auth_user import AuthUser
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
from cpl.database.external_data_temp_table_builder import ExternalDataTempTableBuilder
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class AuthUserDao(DbModelDaoABC[AuthUser]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, AuthUser, TableManager.get("auth_users"))
|
||||
|
||||
self.attribute(AuthUser.keycloak_id, str, aliases=["keycloakId"])
|
||||
|
||||
async def get_users():
|
||||
return [(x.id, x.username, x.email) for x in await self.get_all()]
|
||||
|
||||
self.use_external_fields(
|
||||
ExternalDataTempTableBuilder()
|
||||
.with_table_name(self._table_name)
|
||||
.with_field("id", "int", True)
|
||||
.with_field("username", "text")
|
||||
.with_field("email", "text")
|
||||
.with_value_getter(get_users)
|
||||
)
|
||||
|
||||
async def get_by_keycloak_id(self, keycloak_id: str) -> AuthUser:
|
||||
return await self.get_single_by({AuthUser.keycloak_id: keycloak_id})
|
||||
|
||||
async def find_by_keycloak_id(self, keycloak_id: str) -> Optional[AuthUser]:
|
||||
return await self.find_single_by({AuthUser.keycloak_id: keycloak_id})
|
||||
|
||||
async def has_permission(self, user_id: int, permission: Union[Permissions, str]) -> bool:
|
||||
from cpl.auth.schema._permission.permission_dao import PermissionDao
|
||||
|
||||
permission_dao: PermissionDao = ServiceProviderABC.get_global_service(PermissionDao)
|
||||
p = await permission_dao.get_by_name(permission if isinstance(permission, str) else permission.value)
|
||||
result = await self._db.select_map(
|
||||
f"""
|
||||
SELECT COUNT(*)
|
||||
FROM permission.role_users ru
|
||||
JOIN permission.role_permissions rp ON ru.roleId = rp.roleId
|
||||
WHERE ru.userId = {user_id}
|
||||
AND rp.permissionId = {p.id}
|
||||
AND ru.deleted = FALSE
|
||||
AND rp.deleted = FALSE;
|
||||
"""
|
||||
)
|
||||
if result is None or len(result) == 0:
|
||||
return False
|
||||
|
||||
return result[0]["count"] > 0
|
||||
|
||||
async def get_permissions(self, user_id: int) -> list[Permissions]:
|
||||
result = await self._db.select_map(
|
||||
f"""
|
||||
SELECT p.*
|
||||
FROM permission.permissions p
|
||||
JOIN permission.role_permissions rp ON p.id = rp.permissionId
|
||||
JOIN permission.role_users ru ON rp.roleId = ru.roleId
|
||||
WHERE ru.userId = {user_id}
|
||||
AND rp.deleted = FALSE
|
||||
AND ru.deleted = FALSE;
|
||||
"""
|
||||
)
|
||||
return [Permissions(p["name"]) for p in result]
|
||||
@@ -0,0 +1,46 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from async_property import async_property
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbJoinModelABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class ApiKeyPermission(DbJoinModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
api_key_id: SerialId,
|
||||
permission_id: SerialId,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbJoinModelABC.__init__(self, api_key_id, permission_id, id, deleted, editor_id, created, updated)
|
||||
self._api_key_id = api_key_id
|
||||
self._permission_id = permission_id
|
||||
|
||||
@property
|
||||
def api_key_id(self) -> int:
|
||||
return self._api_key_id
|
||||
|
||||
@async_property
|
||||
async def api_key(self):
|
||||
from cpl.auth.schema._administration.api_key_dao import ApiKeyDao
|
||||
|
||||
api_key_dao: ApiKeyDao = ServiceProviderABC.get_global_service(ApiKeyDao)
|
||||
return await api_key_dao.get_by_id(self._api_key_id)
|
||||
|
||||
@property
|
||||
def permission_id(self) -> int:
|
||||
return self._permission_id
|
||||
|
||||
@async_property
|
||||
async def permission(self):
|
||||
from cpl.auth.schema._permission.permission_dao import PermissionDao
|
||||
|
||||
permission_dao: PermissionDao = ServiceProviderABC.get_global_service(PermissionDao)
|
||||
return await permission_dao.get_by_id(self._permission_id)
|
||||
@@ -0,0 +1,29 @@
|
||||
from cpl.auth.schema._permission.api_key_permission import ApiKeyPermission
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class ApiKeyPermissionDao(DbModelDaoABC[ApiKeyPermission]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, ApiKeyPermission, TableManager.get("api_key_permissions"))
|
||||
|
||||
self.attribute(ApiKeyPermission.api_key_id, int)
|
||||
self.attribute(ApiKeyPermission.permission_id, int)
|
||||
|
||||
async def find_by_api_key_id(self, api_key_id: int, with_deleted=False) -> list[ApiKeyPermission]:
|
||||
f = [{ApiKeyPermission.api_key_id: api_key_id}]
|
||||
if not with_deleted:
|
||||
f.append({ApiKeyPermission.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
|
||||
async def find_by_permission_id(self, permission_id: int, with_deleted=False) -> list[ApiKeyPermission]:
|
||||
f = [{ApiKeyPermission.permission_id: permission_id}]
|
||||
if not with_deleted:
|
||||
f.append({ApiKeyPermission.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
37
src/cpl-auth/cpl/auth/schema/_permission/permission.py
Normal file
37
src/cpl-auth/cpl/auth/schema/_permission/permission.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
|
||||
|
||||
class Permission(DbModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
name: str,
|
||||
description: str,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._name = name
|
||||
self._description = description
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, value: str):
|
||||
self._name = value
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return self._description
|
||||
|
||||
@description.setter
|
||||
def description(self, value: str):
|
||||
self._description = value
|
||||
21
src/cpl-auth/cpl/auth/schema/_permission/permission_dao.py
Normal file
21
src/cpl-auth/cpl/auth/schema/_permission/permission_dao.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.auth.schema._permission.permission import Permission
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class PermissionDao(DbModelDaoABC[Permission]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, Permission, TableManager.get("permissions"))
|
||||
|
||||
self.attribute(Permission.name, str)
|
||||
self.attribute(Permission.description, Optional[str])
|
||||
|
||||
async def get_by_name(self, name: str) -> Permission:
|
||||
result = await self._db.select_map(f"SELECT * FROM {self._table_name} WHERE Name = '{name}'")
|
||||
return self.to_object(result[0])
|
||||
66
src/cpl-auth/cpl/auth/schema/_permission/role.py
Normal file
66
src/cpl-auth/cpl/auth/schema/_permission/role.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from async_property import async_property
|
||||
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class Role(DbModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
name: str,
|
||||
description: str,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._name = name
|
||||
self._description = description
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, value: str):
|
||||
self._name = value
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return self._description
|
||||
|
||||
@description.setter
|
||||
def description(self, value: str):
|
||||
self._description = value
|
||||
|
||||
@async_property
|
||||
async def permissions(self):
|
||||
from cpl.auth.schema._permission.role_permission_dao import RolePermissionDao
|
||||
|
||||
role_permission_dao: RolePermissionDao = ServiceProviderABC.get_global_service(RolePermissionDao)
|
||||
return [await x.permission for x in await role_permission_dao.get_by_role_id(self.id)]
|
||||
|
||||
@async_property
|
||||
async def users(self):
|
||||
from cpl.auth.schema._permission.role_user_dao import RoleUserDao
|
||||
|
||||
role_user_dao: RoleUserDao = ServiceProviderABC.get_global_service(RoleUserDao)
|
||||
return [await x.user for x in await role_user_dao.get_by_role_id(self.id)]
|
||||
|
||||
async def has_permission(self, permission: Permissions) -> bool:
|
||||
from cpl.auth.schema._permission.permission_dao import PermissionDao
|
||||
from cpl.auth.schema._permission.role_permission_dao import RolePermissionDao
|
||||
|
||||
permission_dao: PermissionDao = ServiceProviderABC.get_global_service(PermissionDao)
|
||||
role_permission_dao: RolePermissionDao = ServiceProviderABC.get_global_service(RolePermissionDao)
|
||||
|
||||
p = await permission_dao.get_by_name(permission.value)
|
||||
|
||||
return p.id in [x.id for x in await role_permission_dao.get_by_role_id(self.id)]
|
||||
17
src/cpl-auth/cpl/auth/schema/_permission/role_dao.py
Normal file
17
src/cpl-auth/cpl/auth/schema/_permission/role_dao.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from cpl.auth.schema._permission.role import Role
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class RoleDao(DbModelDaoABC[Role]):
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, Role, TableManager.get("roles"))
|
||||
self.attribute(Role.name, str)
|
||||
self.attribute(Role.description, str)
|
||||
|
||||
async def get_by_name(self, name: str) -> Role:
|
||||
result = await self._db.select_map(f"SELECT * FROM {self._table_name} WHERE Name = '{name}'")
|
||||
return self.to_object(result[0])
|
||||
46
src/cpl-auth/cpl/auth/schema/_permission/role_permission.py
Normal file
46
src/cpl-auth/cpl/auth/schema/_permission/role_permission.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from async_property import async_property
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class RolePermission(DbModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
role_id: SerialId,
|
||||
permission_id: SerialId,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._role_id = role_id
|
||||
self._permission_id = permission_id
|
||||
|
||||
@property
|
||||
def role_id(self) -> int:
|
||||
return self._role_id
|
||||
|
||||
@async_property
|
||||
async def role(self):
|
||||
from cpl.auth.schema._permission.role_dao import RoleDao
|
||||
|
||||
role_dao: RoleDao = ServiceProviderABC.get_global_service(RoleDao)
|
||||
return await role_dao.get_by_id(self._role_id)
|
||||
|
||||
@property
|
||||
def permission_id(self) -> int:
|
||||
return self._permission_id
|
||||
|
||||
@async_property
|
||||
async def permission(self):
|
||||
from cpl.auth.schema._permission.permission_dao import PermissionDao
|
||||
|
||||
permission_dao: PermissionDao = ServiceProviderABC.get_global_service(PermissionDao)
|
||||
return await permission_dao.get_by_id(self._permission_id)
|
||||
@@ -0,0 +1,29 @@
|
||||
from cpl.auth.schema._permission.role_permission import RolePermission
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class RolePermissionDao(DbModelDaoABC[RolePermission]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, RolePermission, TableManager.get("role_permissions"))
|
||||
|
||||
self.attribute(RolePermission.role_id, int)
|
||||
self.attribute(RolePermission.permission_id, int)
|
||||
|
||||
async def get_by_role_id(self, role_id: int, with_deleted=False) -> list[RolePermission]:
|
||||
f = [{RolePermission.role_id: role_id}]
|
||||
if not with_deleted:
|
||||
f.append({RolePermission.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
|
||||
async def get_by_permission_id(self, permission_id: int, with_deleted=False) -> list[RolePermission]:
|
||||
f = [{RolePermission.permission_id: permission_id}]
|
||||
if not with_deleted:
|
||||
f.append({RolePermission.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
46
src/cpl-auth/cpl/auth/schema/_permission/role_user.py
Normal file
46
src/cpl-auth/cpl/auth/schema/_permission/role_user.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from async_property import async_property
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbJoinModelABC
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class RoleUser(DbJoinModelABC):
|
||||
def __init__(
|
||||
self,
|
||||
id: SerialId,
|
||||
user_id: SerialId,
|
||||
role_id: SerialId,
|
||||
deleted: bool = False,
|
||||
editor_id: Optional[SerialId] = None,
|
||||
created: Optional[datetime] = None,
|
||||
updated: Optional[datetime] = None,
|
||||
):
|
||||
DbJoinModelABC.__init__(self, id, user_id, role_id, deleted, editor_id, created, updated)
|
||||
self._user_id = user_id
|
||||
self._role_id = role_id
|
||||
|
||||
@property
|
||||
def user_id(self) -> int:
|
||||
return self._user_id
|
||||
|
||||
@async_property
|
||||
async def user(self):
|
||||
from cpl.auth.schema._administration.auth_user_dao import AuthUserDao
|
||||
|
||||
auth_user_dao: AuthUserDao = ServiceProviderABC.get_global_service(AuthUserDao)
|
||||
return await auth_user_dao.get_by_id(self._user_id)
|
||||
|
||||
@property
|
||||
def role_id(self) -> int:
|
||||
return self._role_id
|
||||
|
||||
@async_property
|
||||
async def role(self):
|
||||
from cpl.auth.schema._permission.role_dao import RoleDao
|
||||
|
||||
role_dao: RoleDao = ServiceProviderABC.get_global_service(RoleDao)
|
||||
return await role_dao.get_by_id(self._role_id)
|
||||
29
src/cpl-auth/cpl/auth/schema/_permission/role_user_dao.py
Normal file
29
src/cpl-auth/cpl/auth/schema/_permission/role_user_dao.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from cpl.auth.schema._permission.role_user import RoleUser
|
||||
from cpl.database import TableManager
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from cpl.database.db_logger import DBLogger
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class RoleUserDao(DbModelDaoABC[RoleUser]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, __name__, RoleUser, TableManager.get("role_users"))
|
||||
|
||||
self.attribute(RoleUser.role_id, int)
|
||||
self.attribute(RoleUser.user_id, int)
|
||||
|
||||
async def get_by_role_id(self, rid: int, with_deleted=False) -> list[RoleUser]:
|
||||
f = [{RoleUser.role_id: rid}]
|
||||
if not with_deleted:
|
||||
f.append({RoleUser.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
|
||||
async def get_by_user_id(self, uid: int, with_deleted=False) -> list[RoleUser]:
|
||||
f = [{RoleUser.user_id: uid}]
|
||||
if not with_deleted:
|
||||
f.append({RoleUser.deleted: False})
|
||||
|
||||
return await self.find_by(f)
|
||||
44
src/cpl-auth/cpl/auth/scripts/mysql/1-users.sql
Normal file
44
src/cpl-auth/cpl/auth/scripts/mysql/1-users.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
CREATE TABLE IF NOT EXISTS administration_auth_users
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
keycloakId CHAR(36) NOT NULL,
|
||||
-- for history
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT UC_KeycloakId UNIQUE (keycloakId),
|
||||
CONSTRAINT FK_EditorId FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration_auth_users_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
keycloakId CHAR(36) NOT NULL,
|
||||
-- for history
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_administration_auth_usersUpdate
|
||||
AFTER UPDATE
|
||||
ON administration_auth_users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO administration_auth_users_history
|
||||
(id, keycloakId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.keycloakId, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_administration_auth_usersDelete
|
||||
AFTER DELETE
|
||||
ON administration_auth_users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO administration_auth_users_history
|
||||
(id, keycloakId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.keycloakId, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
46
src/cpl-auth/cpl/auth/scripts/mysql/2-api-key.sql
Normal file
46
src/cpl-auth/cpl/auth/scripts/mysql/2-api-key.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
CREATE TABLE IF NOT EXISTS administration_api_keys
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
identifier VARCHAR(255) NOT NULL,
|
||||
keyString VARCHAR(255) NOT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT UC_Identifier_Key UNIQUE (identifier, keyString),
|
||||
CONSTRAINT UC_Key UNIQUE (keyString),
|
||||
CONSTRAINT FK_ApiKeys_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration_api_keys_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
identifier VARCHAR(255) NOT NULL,
|
||||
keyString VARCHAR(255) NOT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TRIGGER TR_ApiKeysUpdate
|
||||
AFTER UPDATE
|
||||
ON administration_api_keys
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO administration_api_keys_history
|
||||
(id, identifier, keyString, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.identifier, OLD.keyString, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_ApiKeysDelete
|
||||
AFTER DELETE
|
||||
ON administration_api_keys
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO administration_api_keys_history
|
||||
(id, identifier, keyString, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.identifier, OLD.keyString, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
179
src/cpl-auth/cpl/auth/scripts/mysql/3-roles-permissions.sql
Normal file
179
src/cpl-auth/cpl/auth/scripts/mysql/3-roles-permissions.sql
Normal file
@@ -0,0 +1,179 @@
|
||||
CREATE TABLE IF NOT EXISTS permission_permissions
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UQ_PermissionName UNIQUE (name),
|
||||
CONSTRAINT FK_Permissions_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_permissions_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_PermissionsUpdate
|
||||
AFTER UPDATE
|
||||
ON permission_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_permissions_history
|
||||
(id, name, description, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.name, OLD.description, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_PermissionsDelete
|
||||
AFTER DELETE
|
||||
ON permission_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_permissions_history
|
||||
(id, name, description, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.name, OLD.description, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_roles
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UQ_RoleName UNIQUE (name),
|
||||
CONSTRAINT FK_Roles_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_roles_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_RolesUpdate
|
||||
AFTER UPDATE
|
||||
ON permission_roles
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_roles_history
|
||||
(id, name, description, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.name, OLD.description, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_RolesDelete
|
||||
AFTER DELETE
|
||||
ON permission_roles
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_roles_history
|
||||
(id, name, description, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.name, OLD.description, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_role_permissions
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
RoleId INT NOT NULL,
|
||||
permissionId INT NOT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UQ_RolePermission UNIQUE (RoleId, permissionId),
|
||||
CONSTRAINT FK_RolePermissions_Role FOREIGN KEY (RoleId) REFERENCES permission_roles (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_RolePermissions_Permission FOREIGN KEY (permissionId) REFERENCES permission_permissions (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_RolePermissions_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_role_permissions_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
RoleId INT NOT NULL,
|
||||
permissionId INT NOT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_RolePermissionsUpdate
|
||||
AFTER UPDATE
|
||||
ON permission_role_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_role_permissions_history
|
||||
(id, RoleId, permissionId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.RoleId, OLD.permissionId, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_RolePermissionsDelete
|
||||
AFTER DELETE
|
||||
ON permission_role_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_role_permissions_history
|
||||
(id, RoleId, permissionId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.RoleId, OLD.permissionId, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_role_auth_users
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
RoleId INT NOT NULL,
|
||||
UserId INT NOT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UQ_RoleUser UNIQUE (RoleId, UserId),
|
||||
CONSTRAINT FK_Roleauth_users_Role FOREIGN KEY (RoleId) REFERENCES permission_roles (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_Roleauth_users_User FOREIGN KEY (UserId) REFERENCES administration_auth_users (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_Roleauth_users_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_role_auth_users_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
RoleId INT NOT NULL,
|
||||
UserId INT NOT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_Roleauth_usersUpdate
|
||||
AFTER UPDATE
|
||||
ON permission_role_auth_users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_role_auth_users_history
|
||||
(id, RoleId, UserId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.RoleId, OLD.UserId, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_Roleauth_usersDelete
|
||||
AFTER DELETE
|
||||
ON permission_role_auth_users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_role_auth_users_history
|
||||
(id, RoleId, UserId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.RoleId, OLD.UserId, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
@@ -0,0 +1,46 @@
|
||||
CREATE TABLE IF NOT EXISTS permission_api_key_permissions
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
apiKeyId INT NOT NULL,
|
||||
permissionId INT NOT NULL,
|
||||
deleted BOOL NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UQ_ApiKeyPermission UNIQUE (apiKeyId, permissionId),
|
||||
CONSTRAINT FK_ApiKeyPermissions_ApiKey FOREIGN KEY (apiKeyId) REFERENCES administration_api_keys (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_ApiKeyPermissions_Permission FOREIGN KEY (permissionId) REFERENCES permission_permissions (id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_ApiKeyPermissions_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS permission_api_key_permissions_history
|
||||
(
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
apiKeyId INT NOT NULL,
|
||||
permissionId INT NOT NULL,
|
||||
deleted BOOL NOT NULL,
|
||||
editorId INT NULL,
|
||||
created TIMESTAMP NOT NULL,
|
||||
updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TRIGGER TR_ApiKeyPermissionsUpdate
|
||||
AFTER UPDATE
|
||||
ON permission_api_key_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_api_key_permissions_history
|
||||
(id, apiKeyId, permissionId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.apiKeyId, OLD.permissionId, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
CREATE TRIGGER TR_ApiKeyPermissionsDelete
|
||||
AFTER DELETE
|
||||
ON permission_api_key_permissions
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO permission_api_key_permissions_history
|
||||
(id, apiKeyId, permissionId, deleted, editorId, created, updated)
|
||||
VALUES (OLD.id, OLD.apiKeyId, OLD.permissionId, 1, OLD.editorId, OLD.created, NOW());
|
||||
END;
|
||||
|
||||
26
src/cpl-auth/cpl/auth/scripts/postgres/1-users.sql
Normal file
26
src/cpl-auth/cpl/auth/scripts/postgres/1-users.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
CREATE SCHEMA IF NOT EXISTS administration;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration.auth_users
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
keycloakId UUID NOT NULL,
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT UC_KeycloakId UNIQUE (keycloakId)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration.auth_users_history
|
||||
(
|
||||
LIKE administration.auth_users
|
||||
);
|
||||
|
||||
CREATE TRIGGER users_history_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON administration.auth_users
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION public.history_trigger_function();
|
||||
|
||||
28
src/cpl-auth/cpl/auth/scripts/postgres/2-api-key.sql
Normal file
28
src/cpl-auth/cpl/auth/scripts/postgres/2-api-key.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
CREATE SCHEMA IF NOT EXISTS administration;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration.api_keys
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
identifier VARCHAR(255) NOT NULL,
|
||||
keyString VARCHAR(255) NOT NULL,
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT UC_Identifier_Key UNIQUE (identifier, keyString),
|
||||
CONSTRAINT UC_Key UNIQUE (keyString)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS administration.api_keys_history
|
||||
(
|
||||
LIKE administration.api_keys
|
||||
);
|
||||
|
||||
CREATE TRIGGER api_keys_history_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON administration.api_keys
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION public.history_trigger_function();
|
||||
|
||||
105
src/cpl-auth/cpl/auth/scripts/postgres/3-roles-permissions.sql
Normal file
105
src/cpl-auth/cpl/auth/scripts/postgres/3-roles-permissions.sql
Normal file
@@ -0,0 +1,105 @@
|
||||
CREATE SCHEMA IF NOT EXISTS permission;
|
||||
|
||||
-- Permissions
|
||||
CREATE TABLE permission.permissions
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT UQ_PermissionName UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE permission.permissions_history
|
||||
(
|
||||
LIKE permission.permissions
|
||||
);
|
||||
|
||||
CREATE TRIGGER versioning_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON permission.permissions
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.history_trigger_function();
|
||||
|
||||
-- Roles
|
||||
CREATE TABLE permission.roles
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT NULL,
|
||||
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT UQ_RoleName UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE permission.roles_history
|
||||
(
|
||||
LIKE permission.roles
|
||||
);
|
||||
|
||||
CREATE TRIGGER versioning_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON permission.roles
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.history_trigger_function();
|
||||
|
||||
-- Role permissions
|
||||
CREATE TABLE permission.role_permissions
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
RoleId INT NOT NULL REFERENCES permission.roles (id) ON DELETE CASCADE,
|
||||
permissionId INT NOT NULL REFERENCES permission.permissions (id) ON DELETE CASCADE,
|
||||
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT UQ_RolePermission UNIQUE (RoleId, permissionId)
|
||||
);
|
||||
|
||||
CREATE TABLE permission.role_permissions_history
|
||||
(
|
||||
LIKE permission.role_permissions
|
||||
);
|
||||
|
||||
CREATE TRIGGER versioning_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON permission.role_permissions
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.history_trigger_function();
|
||||
|
||||
-- Role user
|
||||
CREATE TABLE permission.role_users
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
RoleId INT NOT NULL REFERENCES permission.roles (id) ON DELETE CASCADE,
|
||||
UserId INT NOT NULL REFERENCES administration.auth_users (id) ON DELETE CASCADE,
|
||||
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT UQ_RoleUser UNIQUE (RoleId, UserId)
|
||||
);
|
||||
|
||||
CREATE TABLE permission.role_users_history
|
||||
(
|
||||
LIKE permission.role_users
|
||||
);
|
||||
|
||||
CREATE TRIGGER versioning_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON permission.role_users
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.history_trigger_function();
|
||||
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE permission.api_key_permissions
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
apiKeyId INT NOT NULL REFERENCES administration.api_keys (id) ON DELETE CASCADE,
|
||||
permissionId INT NOT NULL REFERENCES permission.permissions (id) ON DELETE CASCADE,
|
||||
|
||||
-- for history
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
editorId INT NULL REFERENCES administration.auth_users (id),
|
||||
created timestamptz NOT NULL DEFAULT NOW(),
|
||||
updated timestamptz NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT UQ_ApiKeyPermission UNIQUE (apiKeyId, permissionId)
|
||||
);
|
||||
|
||||
CREATE TABLE permission.api_key_permissions_history
|
||||
(
|
||||
LIKE permission.api_key_permissions
|
||||
);
|
||||
|
||||
CREATE TRIGGER versioning_trigger
|
||||
BEFORE INSERT OR UPDATE OR DELETE
|
||||
ON permission.api_key_permissions
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE public.history_trigger_function();
|
||||
30
src/cpl-auth/pyproject.toml
Normal file
30
src/cpl-auth/pyproject.toml
Normal file
@@ -0,0 +1,30 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=70.1.0", "wheel>=0.43.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "cpl-auth"
|
||||
version = "2024.7.0"
|
||||
description = "CPL auth"
|
||||
readme ="CPL auth package"
|
||||
requires-python = ">=3.12"
|
||||
license = { text = "MIT" }
|
||||
authors = [
|
||||
{ name = "Sven Heidemann", email = "sven.heidemann@sh-edraft.de" }
|
||||
]
|
||||
keywords = ["cpl", "auth", "backend", "shared", "library"]
|
||||
|
||||
dynamic = ["dependencies", "optional-dependencies"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://www.sh-edraft.de"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["cpl*"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
dependencies = { file = ["requirements.txt"] }
|
||||
optional-dependencies.dev = { file = ["requirements.dev.txt"] }
|
||||
|
||||
|
||||
1
src/cpl-auth/requirements.dev.txt
Normal file
1
src/cpl-auth/requirements.dev.txt
Normal file
@@ -0,0 +1 @@
|
||||
black==25.1.0
|
||||
4
src/cpl-auth/requirements.txt
Normal file
4
src/cpl-auth/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
cpl-core
|
||||
cpl-dependency
|
||||
cpl-database
|
||||
python-keycloak-5.8.1
|
||||
2
src/cpl-core/cpl/core/configuration/__init__.py
Normal file
2
src/cpl-core/cpl/core/configuration/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .configuration import Configuration
|
||||
from .configuration_model_abc import ConfigurationModelABC
|
||||
132
src/cpl-core/cpl/core/configuration/configuration.py
Normal file
132
src/cpl-core/cpl/core/configuration/configuration.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import inspect
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
from cpl.core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl.core.typing import D, T
|
||||
|
||||
|
||||
class Configuration:
|
||||
_config = {}
|
||||
|
||||
@staticmethod
|
||||
def _print_info(message: str):
|
||||
r"""Prints an info message
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Info name
|
||||
message: :class:`str`
|
||||
Info message
|
||||
"""
|
||||
Console.set_foreground_color(ForegroundColorEnum.green)
|
||||
Console.write_line(f"[CONFIG] {message}")
|
||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||
|
||||
@staticmethod
|
||||
def _print_warn(message: str):
|
||||
r"""Prints a warning
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Warning name
|
||||
message: :class:`str`
|
||||
Warning message
|
||||
"""
|
||||
Console.set_foreground_color(ForegroundColorEnum.yellow)
|
||||
Console.write_line(f"[CONFIG] {message}")
|
||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||
|
||||
@staticmethod
|
||||
def _print_error(message: str):
|
||||
r"""Prints an error
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Error name
|
||||
message: :class:`str`
|
||||
Error message
|
||||
"""
|
||||
Console.set_foreground_color(ForegroundColorEnum.red)
|
||||
Console.write_line(f"[CONFIG] {message}")
|
||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||
|
||||
@classmethod
|
||||
def _load_json_file(cls, file: str, output: bool) -> dict:
|
||||
r"""Reads the json file
|
||||
|
||||
Parameter:
|
||||
file: :class:`str`
|
||||
Name of the file
|
||||
output: :class:`bool`
|
||||
Specifies whether an output should take place
|
||||
|
||||
Returns:
|
||||
Object of :class:`dict`
|
||||
"""
|
||||
try:
|
||||
# open config file, create if not exists
|
||||
with open(file, encoding="utf-8") as cfg:
|
||||
# load json
|
||||
json_cfg = json.load(cfg)
|
||||
if output:
|
||||
cls._print_info(f"Loaded config file: {file}")
|
||||
|
||||
return json_cfg
|
||||
except Exception as e:
|
||||
cls._print_error(f"Cannot load config file: {file}! -> {e}")
|
||||
return {}
|
||||
|
||||
@classmethod
|
||||
def add_json_file(cls, name: str, optional: bool = None, output: bool = True, path: str = None):
|
||||
if os.path.isabs(name):
|
||||
file_path = name
|
||||
else:
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
path_root = Environment.get_cwd()
|
||||
if path is not None:
|
||||
path_root = path
|
||||
|
||||
if str(path_root).endswith("/") and not name.startswith("/"):
|
||||
file_path = f"{path_root}{name}"
|
||||
else:
|
||||
file_path = f"{path_root}/{name}"
|
||||
|
||||
if not os.path.isfile(file_path):
|
||||
if optional is not True:
|
||||
if output:
|
||||
cls._print_error(f"File not found: {file_path}")
|
||||
|
||||
sys.exit()
|
||||
|
||||
if output:
|
||||
cls._print_warn(f"Not Loaded config file: {file_path}")
|
||||
|
||||
return None
|
||||
|
||||
config_from_file = cls._load_json_file(file_path, output)
|
||||
for sub in ConfigurationModelABC.__subclasses__():
|
||||
for key, value in config_from_file.items():
|
||||
if sub.__name__ != key and sub.__name__.replace("Settings", "") != key:
|
||||
continue
|
||||
|
||||
cls.set(sub, sub(value))
|
||||
|
||||
@classmethod
|
||||
def set(cls, key: Any, value: T):
|
||||
if inspect.isclass(key):
|
||||
key = key.__name__
|
||||
|
||||
cls._config[key] = value
|
||||
|
||||
@classmethod
|
||||
def get(cls, key: Any, default: D = None) -> T | D:
|
||||
if inspect.isclass(key):
|
||||
key = key.__name__
|
||||
|
||||
return cls._config.get(key, default)
|
||||
@@ -0,0 +1,81 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional, Type, Any
|
||||
|
||||
from cpl.core.typing import T
|
||||
from cpl.core.utils.cast import cast
|
||||
from cpl.core.utils.get_value import get_value
|
||||
from cpl.core.utils.string import String
|
||||
|
||||
|
||||
class ConfigurationModelABC(ABC):
|
||||
r"""
|
||||
ABC for configuration model classes
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(
|
||||
self,
|
||||
src: Optional[dict] = None,
|
||||
env_prefix: Optional[str] = None,
|
||||
readonly: bool = True,
|
||||
):
|
||||
ABC.__init__(self)
|
||||
|
||||
self._src = src or {}
|
||||
self._options: dict[str, Any] = {}
|
||||
|
||||
self._env_prefix = env_prefix
|
||||
self._readonly = readonly
|
||||
|
||||
def __setattr__(self, attr: str, value: Any):
|
||||
if hasattr(self, "_readonly") and self._readonly:
|
||||
raise AttributeError(f"Cannot set attribute: {attr}. {type(self).__name__} is read-only")
|
||||
|
||||
super().__setattr__(attr, value)
|
||||
|
||||
def __getattr__(self, attr: str) -> Any:
|
||||
options = super().__getattribute__("_options")
|
||||
if attr in options:
|
||||
return options[attr]
|
||||
|
||||
return super().__getattribute__(attr)
|
||||
|
||||
def option(self, field: str, cast_type: Type[T], default=None, required=False, from_env=True):
|
||||
value = None
|
||||
|
||||
field_variants = [
|
||||
field,
|
||||
String.first_to_upper(field),
|
||||
String.first_to_lower(field),
|
||||
String.to_camel_case(field),
|
||||
String.to_snake_case(field),
|
||||
String.first_to_upper(String.to_camel_case(field)),
|
||||
]
|
||||
|
||||
value = None
|
||||
for variant in field_variants:
|
||||
if variant in self._src:
|
||||
value = self._src[variant]
|
||||
break
|
||||
|
||||
if value is None and from_env:
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
env_field = field.upper()
|
||||
if self._env_prefix:
|
||||
env_field = f"{self._env_prefix}_{env_field}"
|
||||
value = Environment.get(env_field, cast_type)
|
||||
|
||||
if value is None and required:
|
||||
raise ValueError(f"{field} is required")
|
||||
elif value is None:
|
||||
self._options[field] = default
|
||||
return
|
||||
|
||||
self._options[field] = cast(value, cast_type)
|
||||
|
||||
def get(self, field: str, default=None) -> Optional[T]:
|
||||
return get_value(self._src, field, self._options[field].type, default)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {field: self.get(field) for field in self._options.keys()}
|
||||
4
src/cpl-core/cpl/core/console/__init__.py
Normal file
4
src/cpl-core/cpl/core/console/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .background_color_enum import BackgroundColorEnum
|
||||
from .console import Console
|
||||
from ._call import ConsoleCall
|
||||
from .foreground_color_enum import ForegroundColorEnum
|
||||
24
src/cpl-core/cpl/core/console/_call.py
Normal file
24
src/cpl-core/cpl/core/console/_call.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
class ConsoleCall:
|
||||
r"""Represents a console call, for hold back when spinner is active
|
||||
|
||||
Parameter:
|
||||
function: :class:`Callable`
|
||||
Function to call
|
||||
args: :class:`list`
|
||||
List of arguments
|
||||
"""
|
||||
|
||||
def __init__(self, function: Callable, *args):
|
||||
self._func = function
|
||||
self._args = args
|
||||
|
||||
@property
|
||||
def function(self):
|
||||
return self._func
|
||||
|
||||
@property
|
||||
def args(self):
|
||||
return self._args
|
||||
95
src/cpl-core/cpl/core/console/_spinner.py
Normal file
95
src/cpl-core/cpl/core/console/_spinner.py
Normal file
@@ -0,0 +1,95 @@
|
||||
import os
|
||||
import sys
|
||||
import multiprocessing
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
|
||||
from termcolor import colored
|
||||
|
||||
from cpl.core.console.background_color_enum import BackgroundColorEnum
|
||||
from cpl.core.console.foreground_color_enum import ForegroundColorEnum
|
||||
|
||||
|
||||
class Spinner(Process):
|
||||
r"""Process to show spinner in terminal
|
||||
|
||||
Parameter:
|
||||
msg_len: :class:`int`
|
||||
Length of the message
|
||||
foreground_color: :class:`cpl.core.console.foreground_color.ForegroundColorEnum`
|
||||
Foreground color of the spinner
|
||||
background_color: :class:`cpl.core.console.background_color.BackgroundColorEnum`
|
||||
Background color of the spinner
|
||||
"""
|
||||
|
||||
def __init__(self, msg_len: int, foreground_color: ForegroundColorEnum, background_color: BackgroundColorEnum):
|
||||
Process.__init__(self)
|
||||
|
||||
self._msg_len = msg_len
|
||||
self._foreground_color = foreground_color
|
||||
self._background_color = background_color
|
||||
|
||||
self._is_spinning = True
|
||||
self._exit = False
|
||||
|
||||
@staticmethod
|
||||
def _spinner():
|
||||
r"""Selects active spinner char"""
|
||||
while True:
|
||||
for cursor in "|/-\\":
|
||||
yield cursor
|
||||
|
||||
def _get_color_args(self) -> list[str]:
|
||||
r"""Creates color arguments"""
|
||||
color_args = []
|
||||
if self._foreground_color is not None:
|
||||
color_args.append(str(self._foreground_color.value))
|
||||
|
||||
if self._background_color is not None:
|
||||
color_args.append(str(self._background_color.value))
|
||||
|
||||
return color_args
|
||||
|
||||
def run(self) -> None:
|
||||
r"""Entry point of process, shows the spinner"""
|
||||
columns = 0
|
||||
if sys.platform == "win32":
|
||||
columns = os.get_terminal_size().columns
|
||||
else:
|
||||
values = os.popen("stty size", "r").read().split()
|
||||
term_rows, term_columns = values if len(values) == 2 else (0, 0)
|
||||
columns = int(term_columns)
|
||||
|
||||
end_msg = "done"
|
||||
|
||||
padding = columns - self._msg_len - len(end_msg)
|
||||
if padding > 0:
|
||||
print(f'{"" : >{padding}}', end="")
|
||||
else:
|
||||
print("", end="")
|
||||
|
||||
spinner = self._spinner()
|
||||
while self._is_spinning:
|
||||
print(colored(f"{next(spinner): >{len(end_msg)}}", *self._get_color_args()), end="")
|
||||
time.sleep(0.1)
|
||||
back = ""
|
||||
for i in range(0, len(end_msg)):
|
||||
back += "\b"
|
||||
|
||||
print(back, end="")
|
||||
sys.stdout.flush()
|
||||
|
||||
if not self._exit:
|
||||
print(colored(end_msg, *self._get_color_args()), end="")
|
||||
|
||||
def stop(self):
|
||||
r"""Stops the spinner"""
|
||||
self._is_spinning = False
|
||||
super().terminate()
|
||||
time.sleep(0.1)
|
||||
|
||||
def exit(self):
|
||||
r"""Stops the spinner"""
|
||||
self._is_spinning = False
|
||||
self._exit = True
|
||||
time.sleep(0.1)
|
||||
13
src/cpl-core/cpl/core/console/background_color_enum.py
Normal file
13
src/cpl-core/cpl/core/console/background_color_enum.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class BackgroundColorEnum(Enum):
|
||||
default = "on_default"
|
||||
grey = "on_grey"
|
||||
red = "on_red"
|
||||
green = "on_green"
|
||||
yellow = "on_yellow"
|
||||
blue = "on_blue"
|
||||
magenta = "on_magenta"
|
||||
cyan = "on_cyan"
|
||||
white = "on_white"
|
||||
578
src/cpl-core/cpl/core/console/console.py
Normal file
578
src/cpl-core/cpl/core/console/console.py
Normal file
@@ -0,0 +1,578 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from typing import Union, Optional
|
||||
|
||||
from art import text2art
|
||||
import colorama
|
||||
from tabulate import tabulate
|
||||
from termcolor import colored
|
||||
|
||||
from cpl.core.console.background_color_enum import BackgroundColorEnum
|
||||
from cpl.core.console._call import ConsoleCall
|
||||
from cpl.core.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl.core.console._spinner import Spinner
|
||||
|
||||
|
||||
class Console:
|
||||
r"""Useful functions for handling with input and output"""
|
||||
|
||||
colorama.init()
|
||||
_is_first_write = True
|
||||
|
||||
_background_color: BackgroundColorEnum = BackgroundColorEnum.default
|
||||
_foreground_color: ForegroundColorEnum = ForegroundColorEnum.default
|
||||
_x: Optional[int] = None
|
||||
_y: Optional[int] = None
|
||||
_disabled: bool = False
|
||||
|
||||
_hold_back = False
|
||||
_hold_back_calls: list[ConsoleCall] = []
|
||||
|
||||
_select_menu_items: list[str] = []
|
||||
_is_first_select_menu_output = True
|
||||
_selected_menu_item_index: int = 0
|
||||
_selected_menu_item_char: str = ""
|
||||
_selected_menu_option_foreground_color: ForegroundColorEnum = ForegroundColorEnum.default
|
||||
_selected_menu_option_background_color: BackgroundColorEnum = BackgroundColorEnum.default
|
||||
_selected_menu_cursor_foreground_color: ForegroundColorEnum = ForegroundColorEnum.default
|
||||
_selected_menu_cursor_background_color: BackgroundColorEnum = BackgroundColorEnum.default
|
||||
|
||||
"""Properties"""
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def background_color(cls) -> str:
|
||||
return str(cls._background_color.value)
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def foreground_color(cls) -> str:
|
||||
return str(cls._foreground_color.value)
|
||||
|
||||
"""Settings"""
|
||||
|
||||
@classmethod
|
||||
def set_hold_back(cls, value: bool):
|
||||
cls._hold_back = value
|
||||
|
||||
@classmethod
|
||||
def set_background_color(cls, color: Union[BackgroundColorEnum, str]):
|
||||
r"""Sets the background color
|
||||
|
||||
Parameter:
|
||||
color: Union[:class:`cpl.core.console.background_color_enum.BackgroundColorEnum`, :class:`str`]
|
||||
Background color of the console
|
||||
"""
|
||||
if type(color) is str:
|
||||
cls._background_color = BackgroundColorEnum[color]
|
||||
else:
|
||||
cls._background_color = color
|
||||
|
||||
@classmethod
|
||||
def set_foreground_color(cls, color: Union[ForegroundColorEnum, str]):
|
||||
r"""Sets the foreground color
|
||||
|
||||
Parameter:
|
||||
color: Union[:class:`cpl.core.console.background_color_enum.BackgroundColorEnum`, :class:`str`]
|
||||
Foreground color of the console
|
||||
"""
|
||||
if type(color) is str:
|
||||
cls._foreground_color = ForegroundColorEnum[color]
|
||||
else:
|
||||
cls._foreground_color = color
|
||||
|
||||
@classmethod
|
||||
def reset_cursor_position(cls):
|
||||
r"""Resets cursor position"""
|
||||
cls._x = None
|
||||
cls._y = None
|
||||
|
||||
@classmethod
|
||||
def set_cursor_position(cls, x: int, y: int):
|
||||
r"""Sets cursor position
|
||||
|
||||
Parameter:
|
||||
x: :class:`int`
|
||||
X coordinate
|
||||
y: :class:`int`
|
||||
Y coordinate
|
||||
"""
|
||||
cls._x = x
|
||||
cls._y = y
|
||||
|
||||
"""Useful protected functions"""
|
||||
|
||||
@classmethod
|
||||
def _output(cls, string: str, x: int = None, y: int = None, end: str = None):
|
||||
r"""Prints given output with given format
|
||||
|
||||
Parameter:
|
||||
string: :class:`str`
|
||||
Message to print
|
||||
x: :class:`int`
|
||||
X coordinate
|
||||
y: :class:`int`
|
||||
Y coordinate
|
||||
end: :class:`str`
|
||||
End character of the message (could be \n)
|
||||
"""
|
||||
if cls._is_first_write:
|
||||
cls._is_first_write = False
|
||||
|
||||
if end is None:
|
||||
end = "\n"
|
||||
|
||||
args = []
|
||||
colored_args = []
|
||||
if x is not None and y is not None:
|
||||
args.append(f"\033[{y};{x}H")
|
||||
elif cls._x is not None and cls._y is not None:
|
||||
args.append(f"\033[{cls._y};{cls._x}H")
|
||||
|
||||
colored_args.append(string)
|
||||
if (
|
||||
cls._foreground_color != ForegroundColorEnum.default
|
||||
and cls._background_color == BackgroundColorEnum.default
|
||||
):
|
||||
colored_args.append(cls._foreground_color.value)
|
||||
elif (
|
||||
cls._foreground_color == ForegroundColorEnum.default
|
||||
and cls._background_color != BackgroundColorEnum.default
|
||||
):
|
||||
colored_args.append(cls._background_color.value)
|
||||
elif (
|
||||
cls._foreground_color != ForegroundColorEnum.default
|
||||
and cls._background_color != BackgroundColorEnum.default
|
||||
):
|
||||
colored_args.append(cls._foreground_color.value)
|
||||
colored_args.append(cls._background_color.value)
|
||||
|
||||
args.append(colored(*colored_args))
|
||||
print(*args, end=end)
|
||||
|
||||
@classmethod
|
||||
def _show_select_menu(cls):
|
||||
r"""Shows the select menu"""
|
||||
if not cls._is_first_select_menu_output:
|
||||
for _ in range(0, len(cls._select_menu_items) + 1):
|
||||
sys.stdout.write("\x1b[1A\x1b[2K")
|
||||
else:
|
||||
cls._is_first_select_menu_output = False
|
||||
|
||||
for i in range(0, len(cls._select_menu_items)):
|
||||
Console.set_foreground_color(cls._selected_menu_cursor_foreground_color)
|
||||
Console.set_background_color(cls._selected_menu_cursor_background_color)
|
||||
placeholder = ""
|
||||
for _ in cls._selected_menu_item_char:
|
||||
placeholder += " "
|
||||
|
||||
Console.write_line(
|
||||
f"{cls._selected_menu_item_char if cls._selected_menu_item_index == i else placeholder} "
|
||||
)
|
||||
Console.set_foreground_color(cls._selected_menu_option_foreground_color)
|
||||
Console.set_background_color(cls._selected_menu_option_background_color)
|
||||
Console.write(f"{cls._select_menu_items[i]}")
|
||||
|
||||
Console.write_line()
|
||||
|
||||
@classmethod
|
||||
def _select_menu_key_press(cls, key):
|
||||
r"""Event function when key press is detected
|
||||
|
||||
Parameter:
|
||||
key: :class:`pynput.keyboard.Key`
|
||||
Pressed key
|
||||
"""
|
||||
from pynput.keyboard import Key
|
||||
|
||||
if key == Key.down:
|
||||
if cls._selected_menu_item_index == len(cls._select_menu_items) - 1:
|
||||
return
|
||||
cls._selected_menu_item_index += 1
|
||||
cls._show_select_menu()
|
||||
|
||||
elif key == Key.up:
|
||||
if cls._selected_menu_item_index == 0:
|
||||
return
|
||||
cls._selected_menu_item_index -= 1
|
||||
cls._show_select_menu()
|
||||
|
||||
elif key == Key.enter:
|
||||
return False
|
||||
|
||||
""" Useful public functions"""
|
||||
|
||||
@classmethod
|
||||
def banner(cls, string: str):
|
||||
r"""Prints the string as a banner
|
||||
|
||||
Parameter:
|
||||
string: :class:`str`
|
||||
Message to print as banner
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.banner, string))
|
||||
return
|
||||
|
||||
cls.write_line(text2art(string))
|
||||
|
||||
@classmethod
|
||||
def color_reset(cls):
|
||||
r"""Resets the color settings"""
|
||||
cls._background_color = BackgroundColorEnum.default
|
||||
cls._foreground_color = ForegroundColorEnum.default
|
||||
|
||||
@classmethod
|
||||
def clear(cls):
|
||||
r"""Clears the console"""
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.clear))
|
||||
return
|
||||
|
||||
os.system("cls" if os.name == "nt" else "clear")
|
||||
|
||||
@classmethod
|
||||
def close(cls):
|
||||
r"""Closes the application"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.close))
|
||||
return
|
||||
|
||||
Console.color_reset()
|
||||
Console.write("\n\n\nPress any key to continue...")
|
||||
Console.read()
|
||||
sys.exit()
|
||||
|
||||
@classmethod
|
||||
def disable(cls):
|
||||
r"""Disables console interaction"""
|
||||
cls._disabled = True
|
||||
|
||||
@classmethod
|
||||
def error(cls, string: str, tb: str = None):
|
||||
r"""Prints an error with traceback
|
||||
|
||||
Parameter:
|
||||
string: :class:`str`
|
||||
Error message
|
||||
tb: :class:`str`
|
||||
Error traceback
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.error, string, tb))
|
||||
return
|
||||
|
||||
cls.set_foreground_color("red")
|
||||
if tb is not None:
|
||||
cls.write_line(f"{string} -> {tb}")
|
||||
else:
|
||||
cls.write_line(string)
|
||||
cls.set_foreground_color("default")
|
||||
|
||||
@classmethod
|
||||
def enable(cls):
|
||||
r"""Enables console interaction"""
|
||||
cls._disabled = False
|
||||
|
||||
@classmethod
|
||||
def read(cls, output: str = None) -> str:
|
||||
r"""Reads in line
|
||||
|
||||
Parameter:
|
||||
output: :class:`str`
|
||||
String to print before input
|
||||
|
||||
Returns:
|
||||
input()
|
||||
"""
|
||||
if output is not None and not cls._hold_back:
|
||||
cls.write_line(output)
|
||||
|
||||
return input()
|
||||
|
||||
@classmethod
|
||||
def read_line(cls, output: str = None) -> str:
|
||||
r"""Reads in next line
|
||||
|
||||
Parameter:
|
||||
output: :class:`str`
|
||||
String to print before input
|
||||
|
||||
Returns:
|
||||
input()
|
||||
"""
|
||||
if cls._disabled and not cls._hold_back:
|
||||
return ""
|
||||
|
||||
if output is not None:
|
||||
cls.write_line(output)
|
||||
|
||||
cls._output("\n", end="")
|
||||
|
||||
return input()
|
||||
|
||||
@classmethod
|
||||
def table(cls, header: list[str], values: list[list[str]]):
|
||||
r"""Prints a table with header and values
|
||||
|
||||
Parameter:
|
||||
header: List[:class:`str`]
|
||||
Header of the table
|
||||
values: List[List[:class:`str`]]
|
||||
Values of the table
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.table, header, values))
|
||||
return
|
||||
|
||||
table = tabulate(values, headers=header)
|
||||
|
||||
Console.write_line(table)
|
||||
Console.write("\n")
|
||||
|
||||
@classmethod
|
||||
def select(
|
||||
cls,
|
||||
char: str,
|
||||
message: str,
|
||||
options: list[str],
|
||||
header_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default,
|
||||
header_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default,
|
||||
option_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default,
|
||||
option_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default,
|
||||
cursor_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default,
|
||||
cursor_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default,
|
||||
) -> str:
|
||||
r"""Prints select menu
|
||||
|
||||
Parameter:
|
||||
char: :class:`str`
|
||||
Character to show which element is selected
|
||||
message: :class:`str`
|
||||
Message or header of the selection
|
||||
options: List[:class:`str`]
|
||||
Selectable options
|
||||
header_foreground_color: Union[:class:`str`, :class:`cpl.core.console.foreground_color_enum.ForegroundColorEnum`]
|
||||
Foreground color of the header
|
||||
header_background_color: Union[:class:`str`, :class:`cpl.core.console.background_color_enum.BackgroundColorEnum`]
|
||||
Background color of the header
|
||||
option_foreground_color: Union[:class:`str`, :class:`cpl.core.console.foreground_color_enum.ForegroundColorEnum`]
|
||||
Foreground color of the options
|
||||
option_background_color: Union[:class:`str`, :class:`cpl.core.console.background_color_enum.BackgroundColorEnum`]
|
||||
Background color of the options
|
||||
cursor_foreground_color: Union[:class:`str`, :class:`cpl.core.console.foreground_color_enum.ForegroundColorEnum`]
|
||||
Foreground color of the cursor
|
||||
cursor_background_color: Union[:class:`str`, :class:`cpl.core.console.background_color_enum.BackgroundColorEnum`]
|
||||
Background color of the cursor
|
||||
|
||||
Returns:
|
||||
Selected option as :class:`str`
|
||||
"""
|
||||
cls._selected_menu_item_char = char
|
||||
cls.options = options
|
||||
cls._select_menu_items = cls.options
|
||||
|
||||
if option_foreground_color is not None:
|
||||
cls._selected_menu_option_foreground_color = option_foreground_color
|
||||
if option_background_color is not None:
|
||||
cls._selected_menu_option_background_color = option_background_color
|
||||
|
||||
if cursor_foreground_color is not None:
|
||||
cls._selected_menu_cursor_foreground_color = cursor_foreground_color
|
||||
if cursor_background_color is not None:
|
||||
cls._selected_menu_cursor_background_color = cursor_background_color
|
||||
|
||||
Console.set_foreground_color(header_foreground_color)
|
||||
Console.set_background_color(header_background_color)
|
||||
Console.write_line(message, "\n")
|
||||
cls._show_select_menu()
|
||||
|
||||
from pynput import keyboard
|
||||
|
||||
with keyboard.Listener(on_press=cls._select_menu_key_press, suppress=False) as listener:
|
||||
listener.join()
|
||||
|
||||
Console.color_reset()
|
||||
return cls._select_menu_items[cls._selected_menu_item_index]
|
||||
|
||||
@classmethod
|
||||
def spinner(
|
||||
cls,
|
||||
message: str,
|
||||
call: Callable,
|
||||
*args,
|
||||
text_foreground_color: Union[str, ForegroundColorEnum] = None,
|
||||
spinner_foreground_color: Union[str, ForegroundColorEnum] = None,
|
||||
text_background_color: Union[str, BackgroundColorEnum] = None,
|
||||
spinner_background_color: Union[str, BackgroundColorEnum] = None,
|
||||
**kwargs,
|
||||
) -> any:
|
||||
r"""Shows spinner and calls given function, when function has ended the spinner stops
|
||||
|
||||
Parameter:
|
||||
message: :class:`str`
|
||||
Message of the spinner
|
||||
call: :class:`Callable`
|
||||
Function to call
|
||||
args: :class:`list`
|
||||
Arguments of the function
|
||||
text_foreground_color: Union[:class:`str`, :class:`cpl.core.console.foreground_color_enum.ForegroundColorEnum`]
|
||||
Foreground color of the text
|
||||
spinner_foreground_color: Union[:class:`str`, :class:`cpl.core.console.foreground_color_enum.ForegroundColorEnum`]
|
||||
Foreground color of the spinner
|
||||
text_background_color: Union[:class:`str`, :class:`cpl.core.console.background_color_enum.BackgroundColorEnum`]
|
||||
Background color of the text
|
||||
spinner_background_color: Union[:class:`str`, :class:`cpl.core.console.background_color_enum.BackgroundColorEnum`]
|
||||
Background color of the spinner
|
||||
kwargs: :class:`dict`
|
||||
Keyword arguments of the call
|
||||
|
||||
Returns:
|
||||
Return value of call
|
||||
"""
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.spinner, message, call, *args))
|
||||
return
|
||||
|
||||
if text_foreground_color is not None:
|
||||
cls.set_foreground_color(text_foreground_color)
|
||||
|
||||
if text_background_color is not None:
|
||||
cls.set_background_color(text_background_color)
|
||||
|
||||
if type(spinner_foreground_color) is str:
|
||||
spinner_foreground_color = ForegroundColorEnum[spinner_foreground_color]
|
||||
|
||||
if type(spinner_background_color) is str:
|
||||
spinner_background_color = BackgroundColorEnum[spinner_background_color]
|
||||
|
||||
cls.write_line(message)
|
||||
cls.set_hold_back(True)
|
||||
spinner = None
|
||||
if not cls._disabled:
|
||||
spinner = Spinner(len(message), spinner_foreground_color, spinner_background_color)
|
||||
spinner.start()
|
||||
|
||||
return_value = None
|
||||
try:
|
||||
return_value = call(*args, **kwargs)
|
||||
except KeyboardInterrupt:
|
||||
if spinner is not None:
|
||||
spinner.exit()
|
||||
cls.close()
|
||||
|
||||
if spinner is not None:
|
||||
spinner.stop()
|
||||
cls.set_hold_back(False)
|
||||
|
||||
cls.set_foreground_color(ForegroundColorEnum.default)
|
||||
cls.set_background_color(BackgroundColorEnum.default)
|
||||
|
||||
for call in cls._hold_back_calls:
|
||||
call.function(*call.args)
|
||||
|
||||
cls._hold_back_calls = []
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
return return_value
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args, end=""):
|
||||
r"""Prints in active line
|
||||
|
||||
Parameter:
|
||||
args: :class:`list`
|
||||
Elements to print
|
||||
end: :class:`str`
|
||||
Last character to print
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.write, *args))
|
||||
return
|
||||
|
||||
string = " ".join(map(str, args))
|
||||
cls._output(string, end=end)
|
||||
|
||||
@classmethod
|
||||
def write_at(cls, x: int, y: int, *args):
|
||||
r"""Prints at given position
|
||||
|
||||
Parameter:
|
||||
x: :class:`int`
|
||||
X coordinate
|
||||
y: :class:`int`
|
||||
Y coordinate
|
||||
args: :class:`list`
|
||||
Elements to print
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.write_at, x, y, *args))
|
||||
return
|
||||
|
||||
string = " ".join(map(str, args))
|
||||
cls._output(string, x, y, end="")
|
||||
|
||||
@classmethod
|
||||
def write_line(cls, *args):
|
||||
r"""Prints to new line
|
||||
|
||||
Parameter:
|
||||
args: :class:`list`
|
||||
Elements to print
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.write_line, *args))
|
||||
return
|
||||
|
||||
string = " ".join(map(str, args))
|
||||
if not cls._is_first_write:
|
||||
cls._output("")
|
||||
cls._output(string, end="")
|
||||
|
||||
@classmethod
|
||||
def write_line_at(cls, x: int, y: int, *args):
|
||||
r"""Prints new line at given position
|
||||
|
||||
Parameter:
|
||||
x: :class:`int`
|
||||
X coordinate
|
||||
y: :class:`int`
|
||||
Y coordinate
|
||||
args: :class:`list`
|
||||
Elements to print
|
||||
"""
|
||||
if cls._disabled:
|
||||
return
|
||||
|
||||
if cls._hold_back:
|
||||
cls._hold_back_calls.append(ConsoleCall(cls.write_line_at, x, y, *args))
|
||||
return
|
||||
|
||||
string = " ".join(map(str, args))
|
||||
if not cls._is_first_write:
|
||||
cls._output("", end="")
|
||||
cls._output(string, x, y, end="")
|
||||
13
src/cpl-core/cpl/core/console/foreground_color_enum.py
Normal file
13
src/cpl-core/cpl/core/console/foreground_color_enum.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ForegroundColorEnum(Enum):
|
||||
default = "default"
|
||||
grey = "grey"
|
||||
red = "red"
|
||||
green = "green"
|
||||
yellow = "yellow"
|
||||
blue = "blue"
|
||||
magenta = "magenta"
|
||||
cyan = "cyan"
|
||||
white = "white"
|
||||
1
src/cpl-core/cpl/core/ctx/__init__.py
Normal file
1
src/cpl-core/cpl/core/ctx/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .user_context import set_user, get_user
|
||||
18
src/cpl-core/cpl/core/ctx/user_context.py
Normal file
18
src/cpl-core/cpl/core/ctx/user_context.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from contextvars import ContextVar
|
||||
from typing import Optional
|
||||
|
||||
from cpl.auth.auth_logger import AuthLogger
|
||||
from cpl.auth.schema._administration.auth_user import AuthUser
|
||||
|
||||
_user_context: ContextVar[Optional[AuthUser]] = ContextVar("user", default=None)
|
||||
|
||||
_logger = AuthLogger(__name__)
|
||||
|
||||
|
||||
def set_user(user_id: Optional[AuthUser]):
|
||||
_logger.trace("Setting user context", user_id)
|
||||
_user_context.set(user_id)
|
||||
|
||||
|
||||
def get_user() -> Optional[AuthUser]:
|
||||
return _user_context.get()
|
||||
2
src/cpl-core/cpl/core/environment/__init__.py
Normal file
2
src/cpl-core/cpl/core/environment/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .environment_enum import EnvironmentEnum
|
||||
from .environment import Environment
|
||||
68
src/cpl-core/cpl/core/environment/environment.py
Normal file
68
src/cpl-core/cpl/core/environment/environment.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
from socket import gethostname
|
||||
from typing import Type
|
||||
|
||||
from cpl.core.environment.environment_enum import EnvironmentEnum
|
||||
from cpl.core.typing import T, D
|
||||
from cpl.core.utils.get_value import get_value
|
||||
|
||||
|
||||
class Environment:
|
||||
r"""Represents environment of the application
|
||||
|
||||
Parameter:
|
||||
name: :class:`cpl.core.environment.environment_name_enum.EnvironmentNameEnum`
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def get_environment(cls):
|
||||
return cls.get("ENVIRONMENT", str, EnvironmentEnum.production.value)
|
||||
|
||||
@classmethod
|
||||
def set_environment(cls, environment: str):
|
||||
assert environment is not None and environment != "", "environment must not be None or empty"
|
||||
assert environment.lower() in [
|
||||
e.value for e in EnvironmentEnum
|
||||
], f"environment must be one of {[e.value for e in EnvironmentEnum]}"
|
||||
cls.set("ENVIRONMENT", environment.lower())
|
||||
|
||||
@classmethod
|
||||
def get_app_name(cls) -> str:
|
||||
return cls.get("APP_NAME", str)
|
||||
|
||||
@classmethod
|
||||
def set_app_name(cls, app_name: str):
|
||||
cls.set("APP_NAME", app_name)
|
||||
|
||||
@staticmethod
|
||||
def get_host_name() -> str:
|
||||
return gethostname()
|
||||
|
||||
@staticmethod
|
||||
def get_cwd() -> str:
|
||||
return os.getcwd()
|
||||
|
||||
@staticmethod
|
||||
def set_cwd(working_directory: str):
|
||||
assert working_directory is not None and working_directory != "", "working_directory must not be None or empty"
|
||||
|
||||
os.chdir(working_directory)
|
||||
|
||||
@staticmethod
|
||||
def set(key: str, value: T):
|
||||
assert key is not None and key != "", "key must not be None or empty"
|
||||
|
||||
os.environ[key] = str(value)
|
||||
|
||||
@staticmethod
|
||||
def get(key: str, cast_type: Type[T], default: D = None) -> T | D:
|
||||
"""
|
||||
Get an environment variable and cast it to a specified type.
|
||||
:param str key: The name of the environment variable.
|
||||
:param Type[T] cast_type: A callable to cast the variable's value.
|
||||
:param T default: The default value to return if the variable is not found. Defaults to None.The default value to return if the variable is not found. Defaults to None.
|
||||
:return: The casted value, or None if the variable is not found.
|
||||
:rtype: T | D
|
||||
"""
|
||||
|
||||
return get_value(dict(os.environ), key, cast_type, default)
|
||||
8
src/cpl-core/cpl/core/environment/environment_enum.py
Normal file
8
src/cpl-core/cpl/core/environment/environment_enum.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class EnvironmentEnum(Enum):
|
||||
production = "production"
|
||||
staging = "staging"
|
||||
testing = "testing"
|
||||
development = "development"
|
||||
4
src/cpl-core/cpl/core/log/__init__.py
Normal file
4
src/cpl-core/cpl/core/log/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .logger import Logger
|
||||
from .logger_abc import LoggerABC
|
||||
from .log_level_enum import LogLevel
|
||||
from .logging_settings import LogSettings
|
||||
11
src/cpl-core/cpl/core/log/log_level_enum.py
Normal file
11
src/cpl-core/cpl/core/log/log_level_enum.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class LogLevel(Enum):
|
||||
off = "OFF" # Nothing
|
||||
trace = "TRC" # Detailed app information's
|
||||
debug = "DEB" # Detailed app state
|
||||
info = "INF" # Normal information's
|
||||
warning = "WAR" # Error that can later be fatal
|
||||
error = "ERR" # Non fatal error
|
||||
fatal = "FAT" # Error that cause exit
|
||||
128
src/cpl-core/cpl/core/log/logger.py
Normal file
128
src/cpl-core/cpl/core/log/logger.py
Normal file
@@ -0,0 +1,128 @@
|
||||
import os
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
from cpl.core.log.logger_abc import LoggerABC
|
||||
from cpl.core.typing import Messages, Source
|
||||
|
||||
|
||||
class Logger(LoggerABC):
|
||||
_level = LogLevel.info
|
||||
_levels = [x for x in LogLevel]
|
||||
|
||||
# ANSI color codes for different log levels
|
||||
_COLORS = {
|
||||
LogLevel.trace: "\033[37m", # Light Gray
|
||||
LogLevel.debug: "\033[94m", # Blue
|
||||
LogLevel.info: "\033[92m", # Green
|
||||
LogLevel.warning: "\033[93m", # Yellow
|
||||
LogLevel.error: "\033[91m", # Red
|
||||
LogLevel.fatal: "\033[95m", # Magenta
|
||||
}
|
||||
|
||||
def __init__(self, source: Source, file_prefix: str = None):
|
||||
LoggerABC.__init__(self)
|
||||
|
||||
if source == LoggerABC.__name__:
|
||||
source = None
|
||||
|
||||
self._source = source
|
||||
|
||||
if file_prefix is None:
|
||||
file_prefix = "app"
|
||||
|
||||
self._file_prefix = file_prefix
|
||||
self._create_log_dir()
|
||||
|
||||
@property
|
||||
def log_file(self):
|
||||
return f"logs/{self._file_prefix}_{datetime.now().strftime('%Y-%m-%d')}.log"
|
||||
|
||||
@staticmethod
|
||||
def _create_log_dir():
|
||||
if os.path.exists("logs"):
|
||||
return
|
||||
|
||||
os.makedirs("logs")
|
||||
|
||||
@classmethod
|
||||
def set_level(cls, level: LogLevel):
|
||||
if level in cls._levels:
|
||||
cls._level = level
|
||||
else:
|
||||
raise ValueError(f"Invalid log level: {level}")
|
||||
|
||||
@staticmethod
|
||||
def _ensure_file_size(log_file: str):
|
||||
if not os.path.exists(log_file) or os.path.getsize(log_file) <= 0.5 * 1024 * 1024:
|
||||
return
|
||||
|
||||
# if exists and size is greater than 300MB, create a new file
|
||||
os.rename(
|
||||
log_file,
|
||||
f"{log_file.split('.log')[0]}_{datetime.now().strftime('%H-%M-%S')}.log",
|
||||
)
|
||||
|
||||
def _write_log_to_file(self, content: str):
|
||||
file = self.log_file
|
||||
self._ensure_file_size(file)
|
||||
with open(file, "a") as log_file:
|
||||
log_file.write(content + "\n")
|
||||
log_file.close()
|
||||
|
||||
def _log(self, level: LogLevel, *messages: Messages):
|
||||
try:
|
||||
if self._levels.index(level) < self._levels.index(self._level):
|
||||
return
|
||||
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
|
||||
formatted_message = self._format_message(level.value, timestamp, *messages)
|
||||
|
||||
self._write_log_to_file(formatted_message)
|
||||
Console.write_line(f"{self._COLORS.get(level, '\033[0m')}{formatted_message}\033[0m")
|
||||
except Exception as e:
|
||||
print(f"Error while logging: {e} -> {traceback.format_exc()}")
|
||||
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str:
|
||||
if isinstance(messages, tuple):
|
||||
messages = list(messages)
|
||||
|
||||
if not isinstance(messages, list):
|
||||
messages = [messages]
|
||||
|
||||
messages = [str(message) for message in messages if message is not None]
|
||||
|
||||
message = f"<{timestamp}>"
|
||||
message += f" [{level.upper():^3}]"
|
||||
message += f" [{self._file_prefix}]"
|
||||
if self._source is not None:
|
||||
message += f" - [{self._source}]"
|
||||
|
||||
message += f": {' '.join(messages)}"
|
||||
|
||||
return message
|
||||
|
||||
def header(self, string: str):
|
||||
self._log(LogLevel.info, string)
|
||||
|
||||
def trace(self, *messages: Messages):
|
||||
self._log(LogLevel.trace, *messages)
|
||||
|
||||
def debug(self, *messages: Messages):
|
||||
self._log(LogLevel.debug, *messages)
|
||||
|
||||
def info(self, *messages: Messages):
|
||||
self._log(LogLevel.info, *messages)
|
||||
|
||||
def warning(self, *messages: Messages):
|
||||
self._log(LogLevel.warning, *messages)
|
||||
|
||||
def error(self, message, e: Exception = None):
|
||||
self._log(LogLevel.error, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
|
||||
def fatal(self, message, e: Exception = None, prevent_quit: bool = False):
|
||||
self._log(LogLevel.fatal, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
if not prevent_quit:
|
||||
exit(-1)
|
||||
93
src/cpl-core/cpl/core/log/logger_abc.py
Normal file
93
src/cpl-core/cpl/core/log/logger_abc.py
Normal file
@@ -0,0 +1,93 @@
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
from cpl.core.typing import Messages
|
||||
|
||||
|
||||
class LoggerABC(ABC):
|
||||
r"""ABC for :class:`cpl.core.log.logger_service.Logger`"""
|
||||
|
||||
@abstractmethod
|
||||
def set_level(self, level: LogLevel): ...
|
||||
|
||||
@abstractmethod
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str: ...
|
||||
|
||||
@abstractmethod
|
||||
def header(self, string: str):
|
||||
r"""Writes a header message
|
||||
|
||||
Parameter:
|
||||
string: :class:`str`
|
||||
String to write as header
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def trace(self, *messages: Messages):
|
||||
r"""Writes a trace message
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Message name
|
||||
message: :class:`str`
|
||||
Message string
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def debug(self, *messages: Messages):
|
||||
r"""Writes a debug message
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Message name
|
||||
message: :class:`str`
|
||||
Message string
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def info(self, *messages: Messages):
|
||||
r"""Writes an information
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Message name
|
||||
message: :class:`str`
|
||||
Message string
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def warning(self, *messages: Messages):
|
||||
r"""Writes an warning
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Message name
|
||||
message: :class:`str`
|
||||
Message string
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def error(self, messages: str, e: Exception = None):
|
||||
r"""Writes an error
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Error name
|
||||
message: :class:`str`
|
||||
Error message
|
||||
ex: :class:`Exception`
|
||||
Thrown exception
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def fatal(self, messages: str, e: Exception = None):
|
||||
r"""Writes an error and ends the program
|
||||
|
||||
Parameter:
|
||||
name: :class:`str`
|
||||
Error name
|
||||
message: :class:`str`
|
||||
Error message
|
||||
ex: :class:`Exception`
|
||||
Thrown exception
|
||||
"""
|
||||
18
src/cpl-core/cpl/core/log/logging_settings.py
Normal file
18
src/cpl-core/cpl/core/log/logging_settings.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
|
||||
|
||||
class LogSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
src: Optional[dict] = None,
|
||||
):
|
||||
ConfigurationModelABC.__init__(self, src)
|
||||
|
||||
self.option("path", str, default="logs")
|
||||
self.option("filename", str, default="app.log")
|
||||
self.option("console_level", LogLevel, default=LogLevel.info)
|
||||
self.option("level", LogLevel, default=LogLevel.info)
|
||||
3
src/cpl-core/cpl/core/pipes/__init__.py
Normal file
3
src/cpl-core/cpl/core/pipes/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .bool_pipe import BoolPipe
|
||||
from .ip_address_pipe import IPAddressPipe
|
||||
from .pipe_abc import PipeABC
|
||||
13
src/cpl-core/cpl/core/pipes/bool_pipe.py
Normal file
13
src/cpl-core/cpl/core/pipes/bool_pipe.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from cpl.core.pipes.pipe_abc import PipeABC
|
||||
from cpl.core.typing import T
|
||||
|
||||
|
||||
class BoolPipe[bool](PipeABC):
|
||||
|
||||
@staticmethod
|
||||
def to_str(value: T, *args):
|
||||
return str(value).lower()
|
||||
|
||||
@staticmethod
|
||||
def from_str(value: str, *args) -> T:
|
||||
return value in ("True", "true", "1", "yes", "y", "Y")
|
||||
38
src/cpl-core/cpl/core/pipes/ip_address_pipe.py
Normal file
38
src/cpl-core/cpl/core/pipes/ip_address_pipe.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from cpl.core.pipes.pipe_abc import PipeABC
|
||||
from cpl.core.typing import T
|
||||
|
||||
|
||||
class IPAddressPipe[list](PipeABC):
|
||||
@staticmethod
|
||||
def to_str(value: T, *args) -> str:
|
||||
string = ""
|
||||
|
||||
if len(value) != 4:
|
||||
raise ValueError("Invalid IP")
|
||||
|
||||
for i in range(0, len(value)):
|
||||
byte = value[i]
|
||||
if not 0 <= byte <= 255:
|
||||
raise ValueError("Invalid IP")
|
||||
|
||||
if i == len(value) - 1:
|
||||
string += f"{byte}"
|
||||
else:
|
||||
string += f"{byte}."
|
||||
|
||||
return string
|
||||
|
||||
@staticmethod
|
||||
def from_str(value: str, *args) -> T:
|
||||
parts = value.split(".")
|
||||
if len(parts) != 4:
|
||||
raise Exception("Invalid IP")
|
||||
|
||||
result = []
|
||||
for part in parts:
|
||||
byte = int(part)
|
||||
if not 0 <= byte <= 255:
|
||||
raise Exception("Invalid IP")
|
||||
result.append(byte)
|
||||
|
||||
return result
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user