Compare commits
869 Commits
2021.4.1
...
2025.10.19
| Author | SHA1 | Date | |
|---|---|---|---|
| dfbb0a8c1f | |||
| 472aba5990 | |||
| 9c75008c9f | |||
| df2c2b5b56 | |||
| e3b19c9984 | |||
| 91269f351b | |||
| 5d07973940 | |||
| 0a9b7b81be | |||
| 21c88bc442 | |||
| 04e0884e1c | |||
| 2ac7fa4568 | |||
| 43947055e5 | |||
| ba9edfa3fc | |||
| 6d3e435da6 | |||
| 76b44ca517 | |||
| 8ebac05dd8 | |||
| 98ed458d7c | |||
| 8d0bc13cc0 | |||
| 33728cdec3 | |||
| f1604f1477 | |||
| a02c101438 | |||
| 9647923647 | |||
| 883fa2d691 | |||
| 3c26c73b41 | |||
| faedf328cb | |||
| 849dd7a733 | |||
| 6e0ae1f25e | |||
| 45dcb400da | |||
| 104b736778 | |||
| 90ff8d466d | |||
| f1aaaf2a5b | |||
| 5f8519d4b3 | |||
| c4334f32ed | |||
| 0a6a17acf6 | |||
| c02903b009 | |||
| b6cf5962aa | |||
| d3084041a9 | |||
| d4af923e4c | |||
| 545540d05d | |||
| 3774cef56a | |||
| cdb5e4ff89 | |||
| e362b7fb61 | |||
| 262e26cb83 | |||
| 5b3872a1fe | |||
| e7e3712e08 | |||
| df69f1c725 | |||
| 39351a5eb9 | |||
| 39d06dfe48 | |||
| 3286a95cbf | |||
| 6f46b94998 | |||
| 20e5da5770 | |||
| a12a4082db | |||
| d8c60defba | |||
| ada50c693e | |||
| a35b44b3b5 | |||
| 683805137a | |||
| b0f1fb9839 | |||
| e1ab9cf0db | |||
| 685c20e3bf | |||
| e0f6e1c241 | |||
| c410a692be | |||
| 56a16cbeba | |||
| d05d947d54 | |||
| 0529269747 | |||
| e3e1703ff8 | |||
| cf4aa8291f | |||
| 55a727c482 | |||
| ecb92fca3e | |||
| 0ca5e5757a | |||
| 75417966eb | |||
| 15d3c59f02 | |||
| 6a3fdb3ebd | |||
| b49f663ae0 | |||
| 287f5e3149 | |||
| 4c8cd988cc | |||
| cdb4a0fb34 | |||
| cf8edafd39 | |||
| 01a2ff7166 | |||
| 2da6d679ad | |||
| a1cfe76047 | |||
| c71a3df62c | |||
| e296c0992b | |||
| 6639946346 | |||
| b9ac11e15f | |||
| 77d821bb6e | |||
| 86ad953ff1 | |||
| d6b7eb9b30 | |||
| 12b7c62b69 | |||
| 7fc70747bb | |||
| 6de4f3c03a | |||
| ea3055527c | |||
| 7b37748ca6 | |||
| 073b35f71a | |||
| eceff6128b | |||
| 17dfb245bf | |||
| 4f698269b5 | |||
| ddc62dfb9a | |||
| 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 |
83
.gitea/workflows/build-dev.yaml
Normal file
83
.gitea/workflows/build-dev.yaml
Normal file
@@ -0,0 +1,83 @@
|
||||
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
|
||||
|
||||
api:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, application, auth, core, dependency ]
|
||||
with:
|
||||
working_directory: src/api
|
||||
secrets: inherit
|
||||
|
||||
application:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/application
|
||||
secrets: inherit
|
||||
|
||||
auth:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency, database ]
|
||||
with:
|
||||
working_directory: src/auth
|
||||
secrets: inherit
|
||||
|
||||
cli:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core ]
|
||||
with:
|
||||
working_directory: src/cli
|
||||
secrets: inherit
|
||||
|
||||
core:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/core
|
||||
secrets: inherit
|
||||
|
||||
database:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/database
|
||||
secrets: inherit
|
||||
|
||||
dependency:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core ]
|
||||
with:
|
||||
working_directory: src/dependency
|
||||
secrets: inherit
|
||||
|
||||
mail:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/mail
|
||||
secrets: inherit
|
||||
|
||||
query:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [prepare]
|
||||
with:
|
||||
working_directory: src/query
|
||||
secrets: inherit
|
||||
|
||||
translation:
|
||||
uses: ./.gitea/workflows/package.yaml
|
||||
needs: [ prepare, core, dependency ]
|
||||
with:
|
||||
working_directory: src/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
|
||||
71
.gitea/workflows/package.yaml
Normal file
71
.gitea/workflows/package.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
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 package version
|
||||
run: |
|
||||
sed -i -E "s/^__version__ = \".*\"/__version__ = \"$(cat /workspace/sh-edraft.de/cpl/version.txt)\"/" cpl/*/__init__.py
|
||||
echo "Set version to $(cat /workspace/sh-edraft.de/cpl/version.txt)"
|
||||
cat cpl/*/__init__.py
|
||||
|
||||
- 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/*
|
||||
58
.gitea/workflows/prepare.yaml
Normal file
58
.gitea/workflows/prepare.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
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)
|
||||
if [ "$TAG_COUNT" -eq 0 ]; then
|
||||
BUILD_NUMBER=0
|
||||
else
|
||||
BUILD_NUMBER=$(($TAG_COUNT + 1))
|
||||
fi
|
||||
|
||||
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
|
||||
26
.gitea/workflows/test_before_merge.yaml
Normal file
26
.gitea/workflows/test_before_merge.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Test before pr merge
|
||||
run-name: Test before pr merge
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- reopened
|
||||
- synchronize
|
||||
- ready_for_review
|
||||
|
||||
jobs:
|
||||
test-lint:
|
||||
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: Installing black
|
||||
run: python3.12 -m pip install black
|
||||
|
||||
- name: Checking black
|
||||
run: python3.12 -m black src --check
|
||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -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,11 @@ dmypy.json
|
||||
.pyre/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
PythonImportHelper-v2-Completion.json
|
||||
|
||||
# cpl unittest stuff
|
||||
unittests/test_*_playground
|
||||
|
||||
# cpl logs
|
||||
**/logs/*.jsonl
|
||||
|
||||
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
|
||||
|
||||
22
README.md
22
README.md
@@ -1,2 +1,22 @@
|
||||
# sh_common_py_lib
|
||||
## Prepare for development
|
||||
|
||||
After cloning the repository, run the following commands to set up your development environment:
|
||||
|
||||
```bash
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
# On Windows use `.venv\Scripts\activate`
|
||||
# On Windows with git bash use `source .venv/Scripts/activate`
|
||||
bash install.sh
|
||||
```
|
||||
|
||||
Install cpl-cli as a development package:
|
||||
|
||||
```bash
|
||||
pip install -e src/core
|
||||
pip install -e src/cli
|
||||
# test with:
|
||||
cpl v
|
||||
```
|
||||
|
||||
When using Pycharm, mark all directories under `src/` as "Sources Root" and `exa` to ensure proper module resolution.
|
||||
56
cpl.json
56
cpl.json
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "sh_cpl",
|
||||
"Version": {
|
||||
"Major": "2021",
|
||||
"Minor": "04",
|
||||
"Micro": "01-15"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
"Description": "sh-edraft Common Python library",
|
||||
"LongDescription": "sh-edraft Common Python library",
|
||||
"URL": "https://www.sh-edraft.de",
|
||||
"CopyrightDate": "2020 - 2021",
|
||||
"CopyrightName": "sh-edraft.de",
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"colorama==0.4.4",
|
||||
"mysql-connector==2.2.9",
|
||||
"psutil==5.8.0",
|
||||
"packaging==20.9",
|
||||
"pyfiglet==0.8.post1",
|
||||
"pynput==1.7.3",
|
||||
"SQLAlchemy==1.4.0",
|
||||
"setuptools==54.1.2",
|
||||
"tabulate==0.8.9",
|
||||
"termcolor==1.1.0",
|
||||
"watchdog==2.0.2",
|
||||
"wheel==0.36.2"
|
||||
],
|
||||
"PythonVersion": ">=3.8",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"SourcePath": "src",
|
||||
"OutputPath": "dist",
|
||||
"Main": "cpl_cli.main",
|
||||
"EntryPoint": "cpl",
|
||||
"IncludePackageData": true,
|
||||
"Included": [
|
||||
"*/templates"
|
||||
],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {
|
||||
"cpl_cli": [
|
||||
"*.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
12
cpl.workspace.json
Normal file
12
cpl.workspace.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "cpl",
|
||||
"projects": [
|
||||
"src/cli/cpl.project.json",
|
||||
"src/core/cpl.project.json",
|
||||
"src/mail/cpl.project.json"
|
||||
],
|
||||
"defaultProject": "cpl-cli",
|
||||
"scripts": {
|
||||
"format": "black src"
|
||||
}
|
||||
}
|
||||
19
docs/cli.txt
19
docs/cli.txt
@@ -1,19 +0,0 @@
|
||||
prefix: cpl
|
||||
commands:
|
||||
build
|
||||
|
||||
generate:
|
||||
abc | a
|
||||
class | c
|
||||
configmodel | cm
|
||||
enum | e
|
||||
service | s
|
||||
|
||||
help
|
||||
new
|
||||
console
|
||||
|
||||
start
|
||||
publish
|
||||
update
|
||||
version
|
||||
@@ -1,2 +0,0 @@
|
||||
python setup.py install # for install
|
||||
python setup.py sdist bdist_wheel # for build
|
||||
11
docs/pip.txt
11
docs/pip.txt
@@ -1,11 +0,0 @@
|
||||
upload:
|
||||
prod:
|
||||
twine upload --repository-url https://pip.sh-edraft.de dist/publish/setup/*
|
||||
twine upload -r pip.sh-edraft.de dist/publish/setup/*
|
||||
|
||||
dev:
|
||||
twine upload --repository-url https://pip-dev.sh-edraft.de dist/publish/setup/*
|
||||
twine upload -r pip-dev.sh-edraft.de dist/publish/setup/*
|
||||
|
||||
install:
|
||||
pip install --extra-index-url https://pip.sh-edraft.de/ sh_cpl
|
||||
8
example/api/src/appsettings.development.json
Normal file
8
example/api/src/appsettings.development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
}
|
||||
}
|
||||
26
example/api/src/appsettings.edrafts-pc.json
Normal file
26
example/api/src/appsettings.edrafts-pc.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Log": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
},
|
||||
|
||||
"Database": {
|
||||
"Host": "localhost",
|
||||
"User": "cpl",
|
||||
"Port": 3306,
|
||||
"Password": "cpl",
|
||||
"Database": "cpl",
|
||||
"Charset": "utf8mb4",
|
||||
"UseUnicode": "true",
|
||||
"Buffered": "true"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"TimeFormatSettings": {
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"LoggingSettings": {
|
||||
"Log": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLogLevel": "ERROR",
|
||||
"FileLogLevel": "WARN"
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARNING"
|
||||
}
|
||||
}
|
||||
147
example/api/src/main.py
Normal file
147
example/api/src/main.py
Normal file
@@ -0,0 +1,147 @@
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from cpl.dependency.event_bus import EventBusABC
|
||||
from cpl.graphql.event_bus.memory import InMemoryEventBus
|
||||
from queries.cities import CityGraphType, CityFilter, CitySort
|
||||
from queries.hello import UserGraphType # , UserFilter, UserSort, UserGraphType
|
||||
from queries.user import UserFilter, UserSort
|
||||
from cpl.api.api_module import ApiModule
|
||||
from cpl.application.application_builder import ApplicationBuilder
|
||||
from cpl.auth.schema import User, Role
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.utils.cache import Cache
|
||||
from cpl.database.mysql.mysql_module import MySQLModule
|
||||
from cpl.graphql.application.graphql_app import GraphQLApp
|
||||
from cpl.graphql.auth.graphql_auth_module import GraphQLAuthModule
|
||||
from cpl.graphql.graphql_module import GraphQLModule
|
||||
from model.author_dao import AuthorDao
|
||||
from model.author_query import AuthorGraphType, AuthorFilter, AuthorSort
|
||||
from model.post_dao import PostDao
|
||||
from model.post_query import PostFilter, PostSort, PostGraphType, PostMutation, PostSubscription
|
||||
from permissions import PostPermissions
|
||||
from queries.hello import HelloQuery
|
||||
from scoped_service import ScopedService
|
||||
from service import PingService
|
||||
from test_data_seeder import TestDataSeeder
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder[GraphQLApp](GraphQLApp)
|
||||
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
|
||||
# builder.services.add_logging()
|
||||
(
|
||||
builder.services.add_structured_logging()
|
||||
.add_transient(PingService)
|
||||
.add_module(MySQLModule)
|
||||
.add_module(ApiModule)
|
||||
.add_module(GraphQLModule)
|
||||
.add_module(GraphQLAuthModule)
|
||||
.add_scoped(ScopedService)
|
||||
.add_singleton(EventBusABC, InMemoryEventBus)
|
||||
.add_cache(User)
|
||||
.add_cache(Role)
|
||||
.add_transient(CityGraphType)
|
||||
.add_transient(CityFilter)
|
||||
.add_transient(CitySort)
|
||||
.add_transient(UserGraphType)
|
||||
.add_transient(UserFilter)
|
||||
.add_transient(UserSort)
|
||||
# .add_transient(UserGraphType)
|
||||
# .add_transient(UserFilter)
|
||||
# .add_transient(UserSort)
|
||||
.add_transient(HelloQuery)
|
||||
# test data
|
||||
.add_singleton(TestDataSeeder)
|
||||
# authors
|
||||
.add_transient(AuthorDao)
|
||||
.add_transient(AuthorGraphType)
|
||||
.add_transient(AuthorFilter)
|
||||
.add_transient(AuthorSort)
|
||||
# posts
|
||||
.add_transient(PostDao)
|
||||
.add_transient(PostGraphType)
|
||||
.add_transient(PostFilter)
|
||||
.add_transient(PostSort)
|
||||
.add_transient(PostMutation)
|
||||
.add_transient(PostSubscription)
|
||||
)
|
||||
|
||||
app = builder.build()
|
||||
app.with_logging()
|
||||
app.with_migrations("./scripts")
|
||||
|
||||
app.with_authentication()
|
||||
app.with_authorization()
|
||||
|
||||
app.with_route(
|
||||
path="/route1",
|
||||
fn=lambda r: JSONResponse("route1"),
|
||||
method="GET",
|
||||
# authentication=True,
|
||||
# permissions=[Permissions.administrator],
|
||||
)
|
||||
app.with_routes_directory("routes")
|
||||
|
||||
schema = app.with_graphql()
|
||||
schema.query.string_field("ping", resolver=lambda: "pong")
|
||||
schema.query.with_query("hello", HelloQuery)
|
||||
schema.query.dao_collection_field(AuthorGraphType, AuthorDao, "authors", AuthorFilter, AuthorSort)
|
||||
(
|
||||
schema.query.dao_collection_field(PostGraphType, PostDao, "posts", PostFilter, PostSort)
|
||||
# .with_require_any_permission(PostPermissions.read)
|
||||
.with_public()
|
||||
)
|
||||
|
||||
schema.mutation.with_mutation("post", PostMutation).with_public()
|
||||
|
||||
schema.subscription.with_subscription(PostSubscription)
|
||||
|
||||
app.with_auth_root_queries(True)
|
||||
app.with_auth_root_mutations(True)
|
||||
|
||||
app.with_playground()
|
||||
app.with_graphiql()
|
||||
|
||||
app.with_permissions(PostPermissions)
|
||||
|
||||
provider = builder.service_provider
|
||||
user_cache = provider.get_service(Cache[User])
|
||||
role_cache = provider.get_service(Cache[Role])
|
||||
|
||||
if role_cache == user_cache:
|
||||
raise Exception("Cache service is not working")
|
||||
|
||||
s1 = provider.get_service(ScopedService)
|
||||
s2 = provider.get_service(ScopedService)
|
||||
|
||||
if s1.name == s2.name:
|
||||
raise Exception("Scoped service is not working")
|
||||
|
||||
with provider.create_scope() as scope:
|
||||
s3 = scope.get_service(ScopedService)
|
||||
s4 = scope.get_service(ScopedService)
|
||||
|
||||
if s3.name != s4.name:
|
||||
raise Exception("Scoped service is not working")
|
||||
|
||||
if s1.name == s3.name:
|
||||
raise Exception("Scoped service is not working")
|
||||
|
||||
Console.write_line(
|
||||
s1.name,
|
||||
s2.name,
|
||||
s3.name,
|
||||
s4.name,
|
||||
)
|
||||
|
||||
app.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
30
example/api/src/model/author.py
Normal file
30
example/api/src/model/author.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from datetime import datetime
|
||||
from typing import Self
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
|
||||
|
||||
class Author(DbModelABC[Self]):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
first_name: str,
|
||||
last_name: str,
|
||||
deleted: bool = False,
|
||||
editor_id: SerialId | None = None,
|
||||
created: datetime | None = None,
|
||||
updated: datetime | None = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._first_name = first_name
|
||||
self._last_name = last_name
|
||||
|
||||
@property
|
||||
def first_name(self) -> str:
|
||||
return self._first_name
|
||||
|
||||
@property
|
||||
def last_name(self) -> str:
|
||||
return self._last_name
|
||||
11
example/api/src/model/author_dao.py
Normal file
11
example/api/src/model/author_dao.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from model.author import Author
|
||||
|
||||
|
||||
class AuthorDao(DbModelDaoABC):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, Author, "authors")
|
||||
|
||||
self.attribute(Author.first_name, str, db_name="firstname")
|
||||
self.attribute(Author.last_name, str, db_name="lastname")
|
||||
37
example/api/src/model/author_query.py
Normal file
37
example/api/src/model/author_query.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from cpl.graphql.schema.db_model_graph_type import DbModelGraphType
|
||||
from cpl.graphql.schema.filter.db_model_filter import DbModelFilter
|
||||
from cpl.graphql.schema.sort.sort import Sort
|
||||
from cpl.graphql.schema.sort.sort_order import SortOrder
|
||||
from model.author import Author
|
||||
|
||||
class AuthorFilter(DbModelFilter[Author]):
|
||||
def __init__(self):
|
||||
DbModelFilter.__init__(self, public=True)
|
||||
self.int_field("id")
|
||||
self.string_field("firstName")
|
||||
self.string_field("lastName")
|
||||
|
||||
class AuthorSort(Sort[Author]):
|
||||
def __init__(self):
|
||||
Sort.__init__(self)
|
||||
self.field("id", SortOrder)
|
||||
self.field("firstName", SortOrder)
|
||||
self.field("lastName", SortOrder)
|
||||
|
||||
class AuthorGraphType(DbModelGraphType[Author]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelGraphType.__init__(self, public=True)
|
||||
|
||||
self.int_field(
|
||||
"id",
|
||||
resolver=lambda root: root.id,
|
||||
).with_public(True)
|
||||
self.string_field(
|
||||
"firstName",
|
||||
resolver=lambda root: root.first_name,
|
||||
).with_public(True)
|
||||
self.string_field(
|
||||
"lastName",
|
||||
resolver=lambda root: root.last_name,
|
||||
).with_public(True)
|
||||
44
example/api/src/model/post.py
Normal file
44
example/api/src/model/post.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from datetime import datetime
|
||||
from typing import Self
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc import DbModelABC
|
||||
|
||||
|
||||
class Post(DbModelABC[Self]):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
author_id: SerialId,
|
||||
title: str,
|
||||
content: str,
|
||||
deleted: bool = False,
|
||||
editor_id: SerialId | None = None,
|
||||
created: datetime | None = None,
|
||||
updated: datetime | None = None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._author_id = author_id
|
||||
self._title = title
|
||||
self._content = content
|
||||
|
||||
@property
|
||||
def author_id(self) -> SerialId:
|
||||
return self._author_id
|
||||
|
||||
@property
|
||||
def title(self) -> str:
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, value: str):
|
||||
self._title = value
|
||||
|
||||
@property
|
||||
def content(self) -> str:
|
||||
return self._content
|
||||
|
||||
@content.setter
|
||||
def content(self, value: str):
|
||||
self._content = value
|
||||
15
example/api/src/model/post_dao.py
Normal file
15
example/api/src/model/post_dao.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from model.author_dao import AuthorDao
|
||||
from model.post import Post
|
||||
|
||||
|
||||
class PostDao(DbModelDaoABC[Post]):
|
||||
|
||||
def __init__(self, authors: AuthorDao):
|
||||
DbModelDaoABC.__init__(self, Post, "posts")
|
||||
|
||||
self.attribute(Post.author_id, int, db_name="authorId")
|
||||
self.reference("author", "id", Post.author_id, "authors", authors)
|
||||
|
||||
self.attribute(Post.title, str)
|
||||
self.attribute(Post.content, str)
|
||||
148
example/api/src/model/post_query.py
Normal file
148
example/api/src/model/post_query.py
Normal file
@@ -0,0 +1,148 @@
|
||||
from cpl.dependency.event_bus import EventBusABC
|
||||
from cpl.graphql.query_context import QueryContext
|
||||
from cpl.graphql.schema.db_model_graph_type import DbModelGraphType
|
||||
from cpl.graphql.schema.filter.db_model_filter import DbModelFilter
|
||||
from cpl.graphql.schema.input import Input
|
||||
from cpl.graphql.schema.mutation import Mutation
|
||||
from cpl.graphql.schema.sort.sort import Sort
|
||||
from cpl.graphql.schema.sort.sort_order import SortOrder
|
||||
from cpl.graphql.schema.subscription import Subscription
|
||||
from model.author_dao import AuthorDao
|
||||
from model.author_query import AuthorGraphType, AuthorFilter
|
||||
from model.post import Post
|
||||
from model.post_dao import PostDao
|
||||
|
||||
|
||||
class PostFilter(DbModelFilter[Post]):
|
||||
def __init__(self):
|
||||
DbModelFilter.__init__(self, public=True)
|
||||
self.int_field("id")
|
||||
self.filter_field("author", AuthorFilter)
|
||||
self.string_field("title")
|
||||
self.string_field("content")
|
||||
|
||||
|
||||
class PostSort(Sort[Post]):
|
||||
def __init__(self):
|
||||
Sort.__init__(self)
|
||||
self.field("id", SortOrder)
|
||||
self.field("title", SortOrder)
|
||||
self.field("content", SortOrder)
|
||||
|
||||
|
||||
class PostGraphType(DbModelGraphType[Post]):
|
||||
|
||||
def __init__(self, authors: AuthorDao):
|
||||
DbModelGraphType.__init__(self, public=True)
|
||||
|
||||
self.int_field(
|
||||
"id",
|
||||
resolver=lambda root: root.id,
|
||||
).with_optional().with_public(True)
|
||||
|
||||
async def _a(root: Post):
|
||||
return await authors.get_by_id(root.author_id)
|
||||
|
||||
def r_name(ctx: QueryContext):
|
||||
return ctx.user.username == "admin"
|
||||
|
||||
self.object_field("author", AuthorGraphType, resolver=_a).with_public(True) # .with_require_any([], [r_name]))
|
||||
self.string_field(
|
||||
"title",
|
||||
resolver=lambda root: root.title,
|
||||
).with_public(True)
|
||||
self.string_field(
|
||||
"content",
|
||||
resolver=lambda root: root.content,
|
||||
).with_public(True)
|
||||
|
||||
|
||||
class PostCreateInput(Input[Post]):
|
||||
title: str
|
||||
content: str
|
||||
author_id: int
|
||||
|
||||
def __init__(self):
|
||||
Input.__init__(self)
|
||||
self.string_field("title").with_required()
|
||||
self.string_field("content").with_required()
|
||||
self.int_field("author_id").with_required()
|
||||
|
||||
|
||||
class PostUpdateInput(Input[Post]):
|
||||
title: str
|
||||
content: str
|
||||
author_id: int
|
||||
|
||||
def __init__(self):
|
||||
Input.__init__(self)
|
||||
self.int_field("id").with_required()
|
||||
self.string_field("title").with_required(False)
|
||||
self.string_field("content").with_required(False)
|
||||
|
||||
|
||||
class PostSubscription(Subscription):
|
||||
def __init__(self, bus: EventBusABC):
|
||||
Subscription.__init__(self)
|
||||
self._bus = bus
|
||||
|
||||
def selector(event: Post, info) -> bool:
|
||||
return event.id == 101
|
||||
|
||||
self.subscription_field("postChange", PostGraphType, selector).with_public()
|
||||
|
||||
|
||||
class PostMutation(Mutation):
|
||||
|
||||
def __init__(self, posts: PostDao, authors: AuthorDao, bus: EventBusABC):
|
||||
Mutation.__init__(self)
|
||||
|
||||
self._posts = posts
|
||||
self._authors = authors
|
||||
self._bus = bus
|
||||
|
||||
self.field("create", int, resolver=self.create_post).with_public().with_required().with_argument(
|
||||
"input",
|
||||
PostCreateInput,
|
||||
).with_required()
|
||||
self.field("update", bool, resolver=self.update_post).with_public().with_required().with_argument(
|
||||
"input",
|
||||
PostUpdateInput,
|
||||
).with_required()
|
||||
self.field("delete", bool, resolver=self.delete_post).with_public().with_required().with_argument(
|
||||
"id",
|
||||
int,
|
||||
).with_required()
|
||||
self.field("restore", bool, resolver=self.restore_post).with_public().with_required().with_argument(
|
||||
"id",
|
||||
int,
|
||||
).with_required()
|
||||
|
||||
async def create_post(self, input: PostCreateInput) -> int:
|
||||
return await self._posts.create(Post(0, input.author_id, input.title, input.content))
|
||||
|
||||
async def update_post(self, input: PostUpdateInput) -> bool:
|
||||
post = await self._posts.get_by_id(input.id)
|
||||
if post is None:
|
||||
return False
|
||||
|
||||
post.title = input.title if input.title is not None else post.title
|
||||
post.content = input.content if input.content is not None else post.content
|
||||
|
||||
await self._posts.update(post)
|
||||
await self._bus.publish("postChange", post)
|
||||
return True
|
||||
|
||||
async def delete_post(self, id: int) -> bool:
|
||||
post = await self._posts.get_by_id(id)
|
||||
if post is None:
|
||||
return False
|
||||
await self._posts.delete(post)
|
||||
return True
|
||||
|
||||
async def restore_post(self, id: int) -> bool:
|
||||
post = await self._posts.get_by_id(id)
|
||||
if post is None:
|
||||
return False
|
||||
await self._posts.restore(post)
|
||||
return True
|
||||
8
example/api/src/permissions.py
Normal file
8
example/api/src/permissions.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class PostPermissions(Enum):
|
||||
|
||||
read = "post.read"
|
||||
write = "post.write"
|
||||
delete = "post.delete"
|
||||
39
example/api/src/queries/cities.py
Normal file
39
example/api/src/queries/cities.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from cpl.graphql.schema.filter.filter import Filter
|
||||
from cpl.graphql.schema.graph_type import GraphType
|
||||
|
||||
from cpl.graphql.schema.sort.sort import Sort
|
||||
from cpl.graphql.schema.sort.sort_order import SortOrder
|
||||
|
||||
|
||||
class City:
|
||||
def __init__(self, id: int, name: str):
|
||||
self.id = id
|
||||
self.name = name
|
||||
|
||||
|
||||
class CityFilter(Filter[City]):
|
||||
def __init__(self):
|
||||
Filter.__init__(self)
|
||||
self.field("id", int)
|
||||
self.field("name", str)
|
||||
|
||||
|
||||
class CitySort(Sort[City]):
|
||||
def __init__(self):
|
||||
Sort.__init__(self)
|
||||
self.field("id", SortOrder)
|
||||
self.field("name", SortOrder)
|
||||
|
||||
|
||||
class CityGraphType(GraphType[City]):
|
||||
def __init__(self):
|
||||
GraphType.__init__(self)
|
||||
|
||||
self.int_field(
|
||||
"id",
|
||||
resolver=lambda root: root.id,
|
||||
)
|
||||
self.string_field(
|
||||
"name",
|
||||
resolver=lambda root: root.name,
|
||||
)
|
||||
70
example/api/src/queries/hello.py
Normal file
70
example/api/src/queries/hello.py
Normal file
@@ -0,0 +1,70 @@
|
||||
from queries.cities import CityFilter, CitySort, CityGraphType, City
|
||||
from queries.user import User, UserFilter, UserSort, UserGraphType
|
||||
from cpl.api.middleware.request import get_request
|
||||
from cpl.auth.schema import UserDao, User
|
||||
from cpl.graphql.schema.filter.filter import Filter
|
||||
from cpl.graphql.schema.graph_type import GraphType
|
||||
from cpl.graphql.schema.query import Query
|
||||
from cpl.graphql.schema.sort.sort import Sort
|
||||
from cpl.graphql.schema.sort.sort_order import SortOrder
|
||||
|
||||
users = [User(i, f"User {i}") for i in range(1, 101)]
|
||||
cities = [City(i, f"City {i}") for i in range(1, 101)]
|
||||
|
||||
# class UserFilter(Filter[User]):
|
||||
# def __init__(self):
|
||||
# Filter.__init__(self)
|
||||
# self.field("id", int)
|
||||
# self.field("username", str)
|
||||
#
|
||||
#
|
||||
# class UserSort(Sort[User]):
|
||||
# def __init__(self):
|
||||
# Sort.__init__(self)
|
||||
# self.field("id", SortOrder)
|
||||
# self.field("username", SortOrder)
|
||||
#
|
||||
# class UserGraphType(GraphType[User]):
|
||||
#
|
||||
# def __init__(self):
|
||||
# GraphType.__init__(self)
|
||||
#
|
||||
# self.int_field(
|
||||
# "id",
|
||||
# resolver=lambda root: root.id,
|
||||
# )
|
||||
# self.string_field(
|
||||
# "username",
|
||||
# resolver=lambda root: root.username,
|
||||
# )
|
||||
|
||||
|
||||
class HelloQuery(Query):
|
||||
def __init__(self):
|
||||
Query.__init__(self)
|
||||
self.string_field(
|
||||
"message",
|
||||
resolver=lambda name: f"Hello {name} {get_request().state.request_id}",
|
||||
).with_argument("name", str, "Name to greet", "world")
|
||||
|
||||
self.collection_field(
|
||||
UserGraphType,
|
||||
"users",
|
||||
UserFilter,
|
||||
UserSort,
|
||||
resolver=lambda: users,
|
||||
)
|
||||
self.collection_field(
|
||||
CityGraphType,
|
||||
"cities",
|
||||
CityFilter,
|
||||
CitySort,
|
||||
resolver=lambda: cities,
|
||||
)
|
||||
# self.dao_collection_field(
|
||||
# UserGraphType,
|
||||
# UserDao,
|
||||
# "Users",
|
||||
# UserFilter,
|
||||
# UserSort,
|
||||
# )
|
||||
39
example/api/src/queries/user.py
Normal file
39
example/api/src/queries/user.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from cpl.graphql.schema.filter.filter import Filter
|
||||
from cpl.graphql.schema.graph_type import GraphType
|
||||
from cpl.graphql.schema.sort.sort import Sort
|
||||
from cpl.graphql.schema.sort.sort_order import SortOrder
|
||||
|
||||
|
||||
class User:
|
||||
def __init__(self, id: int, name: str):
|
||||
self.id = id
|
||||
self.name = name
|
||||
|
||||
|
||||
class UserFilter(Filter[User]):
|
||||
def __init__(self):
|
||||
Filter.__init__(self)
|
||||
self.field("id", int)
|
||||
self.field("name", str)
|
||||
|
||||
|
||||
class UserSort(Sort[User]):
|
||||
def __init__(self):
|
||||
Sort.__init__(self)
|
||||
self.field("id", SortOrder)
|
||||
self.field("name", SortOrder)
|
||||
|
||||
|
||||
class UserGraphType(GraphType[User]):
|
||||
|
||||
def __init__(self):
|
||||
GraphType.__init__(self)
|
||||
|
||||
self.int_field(
|
||||
"id",
|
||||
resolver=lambda root: root.id,
|
||||
)
|
||||
self.string_field(
|
||||
"name",
|
||||
resolver=lambda root: root.name,
|
||||
)
|
||||
21
example/api/src/routes/ping.py
Normal file
21
example/api/src/routes/ping.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from urllib.request import Request
|
||||
|
||||
from service import PingService
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from cpl.api import APILogger
|
||||
from cpl.api.router import Router
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
from scoped_service import ScopedService
|
||||
|
||||
|
||||
@Router.authenticate()
|
||||
# @Router.authorize(permissions=[Permissions.administrator])
|
||||
# @Router.authorize(policies=["test"])
|
||||
@Router.get(f"/ping")
|
||||
async def ping(r: Request, ping: PingService, logger: APILogger, provider: ServiceProvider, scoped: ScopedService):
|
||||
logger.info(f"Ping: {ping}")
|
||||
|
||||
Console.write_line(scoped.name)
|
||||
return JSONResponse(ping.ping(r))
|
||||
14
example/api/src/scoped_service.py
Normal file
14
example/api/src/scoped_service.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.utils.string import String
|
||||
|
||||
|
||||
class ScopedService:
|
||||
def __init__(self):
|
||||
self._name = String.random(8)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
22
example/api/src/scripts/0-posts.sql
Normal file
22
example/api/src/scripts/0-posts.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE IF NOT EXISTS `authors` (
|
||||
`id` INT(30) NOT NULL AUTO_INCREMENT,
|
||||
`firstname` VARCHAR(64) NOT NULL,
|
||||
`lastname` VARCHAR(64) NOT NULL,
|
||||
deleted BOOLEAN 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,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `posts` (
|
||||
`id` INT(30) NOT NULL AUTO_INCREMENT,
|
||||
`authorId` INT(30) NOT NULL REFERENCES `authors`(`id`) ON DELETE CASCADE,
|
||||
`title` TEXT NOT NULL,
|
||||
`content` TEXT NOT NULL,
|
||||
deleted BOOLEAN 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,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
4
example/api/src/service.py
Normal file
4
example/api/src/service.py
Normal file
@@ -0,0 +1,4 @@
|
||||
class PingService:
|
||||
|
||||
def ping(self, r):
|
||||
return "pong"
|
||||
48
example/api/src/test_data_seeder.py
Normal file
48
example/api/src/test_data_seeder.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from faker import Faker
|
||||
|
||||
from cpl.database.abc import DataSeederABC
|
||||
from cpl.query import Enumerable
|
||||
from model.author import Author
|
||||
from model.author_dao import AuthorDao
|
||||
from model.post import Post
|
||||
from model.post_dao import PostDao
|
||||
|
||||
|
||||
fake = Faker()
|
||||
|
||||
|
||||
class TestDataSeeder(DataSeederABC):
|
||||
|
||||
def __init__(self, authors: AuthorDao, posts: PostDao):
|
||||
DataSeederABC.__init__(self)
|
||||
|
||||
self._authors = authors
|
||||
self._posts = posts
|
||||
|
||||
async def seed(self):
|
||||
if await self._authors.count() == 0:
|
||||
await self._seed_authors()
|
||||
|
||||
if await self._posts.count() == 0:
|
||||
await self._seed_posts()
|
||||
|
||||
async def _seed_authors(self):
|
||||
authors = Enumerable.range(0, 35).select(
|
||||
lambda x: Author(
|
||||
0,
|
||||
fake.first_name(),
|
||||
fake.last_name(),
|
||||
)
|
||||
).to_list()
|
||||
await self._authors.create_many(authors, skip_editor=True)
|
||||
|
||||
async def _seed_posts(self):
|
||||
posts = Enumerable.range(0, 100).select(
|
||||
lambda x: Post(
|
||||
id=0,
|
||||
author_id=fake.random_int(min=1, max=35),
|
||||
title=fake.sentence(nb_words=6),
|
||||
content=fake.paragraph(nb_sentences=6),
|
||||
)
|
||||
).to_list()
|
||||
await self._posts.create_many(posts, skip_editor=True)
|
||||
41
example/console/main.py
Normal file
41
example/console/main.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import time
|
||||
from cpl.core.console import Console, ForegroundColorEnum
|
||||
|
||||
|
||||
def test_spinner():
|
||||
Console.write_line("test1")
|
||||
Console.write_line("test2", 2)
|
||||
Console.write_line("test3", 2, 3)
|
||||
Console.write_line("test4", 2, 3, 4)
|
||||
time.sleep(2)
|
||||
Console.write_line("test5")
|
||||
|
||||
|
||||
def test_console():
|
||||
Console.write_line("Hello World")
|
||||
Console.write("\nName: ")
|
||||
Console.write_line(" Hello", Console.read_line())
|
||||
Console.write_at(5, 5, "at 5, 5")
|
||||
Console.write_at(10, 10, "at 10, 10")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Console.write_line("Hello World\n")
|
||||
Console.clear()
|
||||
Console.spinner(
|
||||
"Test:", test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color="green"
|
||||
)
|
||||
test_console()
|
||||
Console.write_line("HOLD BACK")
|
||||
opts = ["Option 1", "Option 2", "Option 3", "Option 4"]
|
||||
selected = Console.select(
|
||||
">",
|
||||
"Select item:",
|
||||
opts,
|
||||
header_foreground_color=ForegroundColorEnum.blue,
|
||||
option_foreground_color=ForegroundColorEnum.green,
|
||||
cursor_foreground_color=ForegroundColorEnum.red,
|
||||
)
|
||||
Console.write_line(f"You selected: {selected}")
|
||||
|
||||
Console.write_line()
|
||||
40
example/database/src/application.py
Normal file
40
example/database/src/application.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from cpl.application.abc import ApplicationABC
|
||||
from cpl.auth.keycloak import KeycloakAdmin
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import LoggerABC
|
||||
from cpl.dependency import ServiceProvider
|
||||
from cpl.dependency.typing import Modules
|
||||
from model.city import City
|
||||
from model.city_dao import CityDao
|
||||
from model.user import User
|
||||
from model.user_dao import UserDao
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, services: ServiceProvider, modules: Modules):
|
||||
ApplicationABC.__init__(self, services, modules)
|
||||
|
||||
self._logger = services.get_service(LoggerABC)
|
||||
|
||||
async def test_daos(self):
|
||||
userDao: UserDao = self._services.get_service(UserDao)
|
||||
cityDao: CityDao = self._services.get_service(CityDao)
|
||||
|
||||
Console.write_line(await userDao.get_all())
|
||||
|
||||
if len(await cityDao.get_all()) == 0:
|
||||
city_id = await cityDao.create(City(0, "Haren", "49733"))
|
||||
await userDao.create(User(0, "NewUser", city_id))
|
||||
|
||||
Console.write_line(await userDao.get_all())
|
||||
|
||||
async def main(self):
|
||||
self._logger.debug(f"Host: {Environment.get_host_name()}")
|
||||
self._logger.debug(f"Environment: {Environment.get_environment()}")
|
||||
|
||||
await self.test_daos()
|
||||
|
||||
kc_admin: KeycloakAdmin = self._services.get_service(KeycloakAdmin)
|
||||
x = kc_admin.get_users()
|
||||
Console.write_line(x)
|
||||
8
example/database/src/appsettings.development.json
Normal file
8
example/database/src/appsettings.development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
}
|
||||
}
|
||||
22
example/database/src/appsettings.edrafts-lapi.json
Normal file
22
example/database/src/appsettings.edrafts-lapi.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Log": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
},
|
||||
|
||||
"Database": {
|
||||
"AuthPlugin": "mysql_native_password",
|
||||
"ConnectionString": "mysql+mysqlconnector://cpl:$credentials@localhost/cpl",
|
||||
"Credentials": "Y3Bs",
|
||||
"Encoding": "utf8mb4"
|
||||
}
|
||||
}
|
||||
26
example/database/src/appsettings.edrafts-pc.json
Normal file
26
example/database/src/appsettings.edrafts-pc.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Log": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
},
|
||||
|
||||
"Database": {
|
||||
"Host": "localhost",
|
||||
"User": "cpl",
|
||||
"Port": 3306,
|
||||
"Password": "cpl",
|
||||
"Database": "cpl",
|
||||
"Charset": "utf8mb4",
|
||||
"UseUnicode": "true",
|
||||
"Buffered": "true"
|
||||
}
|
||||
}
|
||||
15
example/database/src/appsettings.json
Normal file
15
example/database/src/appsettings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Log": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARNING"
|
||||
}
|
||||
}
|
||||
5
example/database/src/custom_permissions.py
Normal file
5
example/database/src/custom_permissions.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class CustomPermissions(Enum):
|
||||
test = "test"
|
||||
19
example/database/src/main.py
Normal file
19
example/database/src/main.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from application import Application
|
||||
from cpl.application import ApplicationBuilder
|
||||
from custom_permissions import CustomPermissions
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder(Application).with_startup(Startup)
|
||||
app = builder.build()
|
||||
|
||||
app.with_logging()
|
||||
app.with_permissions(CustomPermissions)
|
||||
app.with_migrations("./scripts")
|
||||
app.with_seeders()
|
||||
app.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
27
example/database/src/main_simplified.py
Normal file
27
example/database/src/main_simplified.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from application import Application
|
||||
from cpl.application import ApplicationBuilder
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.log import LogLevel
|
||||
from cpl.database import DatabaseModule
|
||||
from custom_permissions import CustomPermissions
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder(Application).with_startup(Startup)
|
||||
builder.services.add_logging()
|
||||
app = builder.build()
|
||||
|
||||
app.with_logging(LogLevel.trace)
|
||||
app.with_permissions(CustomPermissions)
|
||||
app.with_migrations("./scripts")
|
||||
# app.with_seeders()
|
||||
|
||||
Console.write_line(CustomPermissions.test.value in PermissionsRegistry.get())
|
||||
app.run()
|
||||
Console.write_line("Hello from main_simplified.py!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
29
example/database/src/model/city.py
Normal file
29
example/database/src/model/city.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc.db_model_abc import DbModelABC
|
||||
|
||||
|
||||
class City(DbModelABC[Self]):
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
name: str,
|
||||
zip: str,
|
||||
deleted: bool = False,
|
||||
editor_id: SerialId | None = None,
|
||||
created: datetime | None= None,
|
||||
updated: datetime | None= None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._name = name
|
||||
self._zip = zip
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def zip(self) -> str:
|
||||
return self._zip
|
||||
11
example/database/src/model/city_dao.py
Normal file
11
example/database/src/model/city_dao.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from model.city import City
|
||||
|
||||
|
||||
class CityDao(DbModelDaoABC[City]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, City, "city")
|
||||
|
||||
self.attribute(City.name, str)
|
||||
self.attribute(City.zip, int)
|
||||
30
example/database/src/model/user.py
Normal file
30
example/database/src/model/user.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.typing import SerialId
|
||||
from cpl.database.abc.db_model_abc import DbModelABC
|
||||
|
||||
|
||||
class User(DbModelABC[Self]):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
name: str,
|
||||
city_id: int = 0,
|
||||
deleted: bool = False,
|
||||
editor_id: SerialId | None = None,
|
||||
created: datetime | None= None,
|
||||
updated: datetime | None= None,
|
||||
):
|
||||
DbModelABC.__init__(self, id, deleted, editor_id, created, updated)
|
||||
self._name = name
|
||||
self._city_id = city_id
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def city_id(self) -> int:
|
||||
return self._city_id
|
||||
13
example/database/src/model/user_dao.py
Normal file
13
example/database/src/model/user_dao.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from cpl.database.abc import DbModelDaoABC
|
||||
from model.user import User
|
||||
|
||||
|
||||
class UserDao(DbModelDaoABC[User]):
|
||||
|
||||
def __init__(self):
|
||||
DbModelDaoABC.__init__(self, User, "users")
|
||||
|
||||
self.attribute(User.name, str)
|
||||
self.attribute(User.city_id, int, db_name="CityId")
|
||||
|
||||
self.reference("city", "id", User.city_id, "city")
|
||||
22
example/database/src/scripts/0-initial.sql
Normal file
22
example/database/src/scripts/0-initial.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE IF NOT EXISTS `city` (
|
||||
`id` INT(30) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(64) NOT NULL,
|
||||
`zip` VARCHAR(5) NOT NULL,
|
||||
deleted BOOLEAN 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,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `users` (
|
||||
`id` INT(30) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(64) NOT NULL,
|
||||
`cityId` INT(30),
|
||||
deleted BOOLEAN 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,
|
||||
FOREIGN KEY (`cityId`) REFERENCES city(`id`),
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
35
example/database/src/startup.py
Normal file
35
example/database/src/startup.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from cpl import auth
|
||||
from cpl.application.abc.startup_abc import StartupABC
|
||||
from cpl.auth import permission
|
||||
from cpl.auth.auth_module import AuthModule
|
||||
from cpl.auth.permission.permission_module import PermissionsModule
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import Logger, LoggerABC
|
||||
from cpl.database import mysql, DatabaseModule
|
||||
from cpl.database.abc.data_access_object_abc import DataAccessObjectABC
|
||||
from cpl.database.mysql.mysql_module import MySQLModule
|
||||
from cpl.dependency import ServiceCollection
|
||||
from model.city_dao import CityDao
|
||||
from model.user_dao import UserDao
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
@staticmethod
|
||||
async def configure_configuration():
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
|
||||
@staticmethod
|
||||
async def configure_services(services: ServiceCollection):
|
||||
services.add_module(MySQLModule)
|
||||
services.add_module(DatabaseModule)
|
||||
services.add_module(AuthModule)
|
||||
services.add_module(PermissionsModule)
|
||||
|
||||
services.add_transient(DataAccessObjectABC, UserDao)
|
||||
services.add_transient(DataAccessObjectABC, CityDao)
|
||||
|
||||
services.add_singleton(LoggerABC, Logger)
|
||||
0
example/di/LICENSE
Normal file
0
example/di/LICENSE
Normal file
0
example/di/README.md
Normal file
0
example/di/README.md
Normal file
15
example/di/appsettings.json
Normal file
15
example/di/appsettings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARN"
|
||||
}
|
||||
}
|
||||
0
example/di/src/__init__.py
Normal file
0
example/di/src/__init__.py
Normal file
45
example/di/src/application.py
Normal file
45
example/di/src/application.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from cpl.application.abc import ApplicationABC
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
from test_abc import TestABC
|
||||
from test_service import TestService
|
||||
from di_tester_service import DITesterService
|
||||
from tester import Tester
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, services: ServiceProvider):
|
||||
ApplicationABC.__init__(self, services)
|
||||
|
||||
def _part_of_scoped(self):
|
||||
ts: TestService = self._services.get_service(TestService)
|
||||
ts.run()
|
||||
|
||||
def main(self):
|
||||
with self._services.create_scope() as scope:
|
||||
Console.write_line("Scope1")
|
||||
ts: TestService = scope.get_service(TestService)
|
||||
ts.run()
|
||||
dit: DITesterService = scope.get_service(DITesterService)
|
||||
dit.run()
|
||||
|
||||
if ts.name != dit.name:
|
||||
raise Exception("DI is broken!")
|
||||
|
||||
with self._services.create_scope() as scope:
|
||||
Console.write_line("Scope2")
|
||||
ts: TestService = scope.get_service(TestService)
|
||||
ts.run()
|
||||
dit: DITesterService = scope.get_service(DITesterService)
|
||||
dit.run()
|
||||
|
||||
if ts.name != dit.name:
|
||||
raise Exception("DI is broken!")
|
||||
|
||||
Console.write_line("Global")
|
||||
self._part_of_scoped()
|
||||
#from static_test import StaticTest
|
||||
#StaticTest.test()
|
||||
|
||||
self._services.get_service(Tester)
|
||||
Console.write_line(self._services.get_services(TestABC))
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "cpl-test",
|
||||
"Project": {
|
||||
"Name": "di",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
@@ -16,24 +16,29 @@
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"sh_cpl==2021.4.1.post13"
|
||||
"cpl-core==2022.12.0"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli==2022.12.0"
|
||||
],
|
||||
"PythonVersion": ">=3.9.2",
|
||||
"PythonPath": "/home/sven/Nextcloud_Sven/Schreibtisch/git_sh-edraft_de/sh_common_py_lib/src/tests/custom/general/../../../../cpl-env/bin/python3.9",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"SourcePath": "src",
|
||||
"OutputPath": "dist",
|
||||
"Main": "main",
|
||||
"EntryPoint": "cpl-test",
|
||||
"IncludePackageData": true,
|
||||
"Build": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "di.main",
|
||||
"EntryPoint": "di",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {}
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
||||
15
example/di/src/di_tester_service.py
Normal file
15
example/di/src/di_tester_service.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from cpl.core.console.console import Console
|
||||
from test_service import TestService
|
||||
|
||||
|
||||
class DITesterService:
|
||||
def __init__(self, ts: TestService):
|
||||
self._ts = ts
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._ts.name
|
||||
|
||||
def run(self):
|
||||
Console.write_line("DIT: ")
|
||||
self._ts.run()
|
||||
14
example/di/src/main.py
Normal file
14
example/di/src/main.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
27
example/di/src/startup.py
Normal file
27
example/di/src/startup.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cpl.application.abc import StartupABC
|
||||
from cpl.dependency import ServiceProvider, ServiceCollection
|
||||
from di_tester_service import DITesterService
|
||||
from test1_service import Test1Service
|
||||
from test2_service import Test2Service
|
||||
from test_abc import TestABC
|
||||
from test_service import TestService
|
||||
from tester import Tester
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
@staticmethod
|
||||
def configure_configuration(): ...
|
||||
|
||||
@staticmethod
|
||||
def configure_services(services: ServiceCollection) -> ServiceProvider:
|
||||
services.add_scoped(TestService)
|
||||
services.add_scoped(DITesterService)
|
||||
|
||||
services.add_singleton(TestABC, Test1Service)
|
||||
services.add_singleton(TestABC, Test2Service)
|
||||
services.add_singleton(Tester)
|
||||
|
||||
return services.build()
|
||||
10
example/di/src/static_test.py
Normal file
10
example/di/src/static_test.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from cpl.dependency import ServiceProvider, ServiceProvider
|
||||
from cpl.dependency.inject import inject
|
||||
from test_service import TestService
|
||||
|
||||
|
||||
class StaticTest:
|
||||
@staticmethod
|
||||
@inject
|
||||
def test(services: ServiceProvider, t1: TestService):
|
||||
t1.run()
|
||||
12
example/di/src/test1_service.py
Normal file
12
example/di/src/test1_service.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import string
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.utils.string import String
|
||||
from test_abc import TestABC
|
||||
|
||||
|
||||
class Test1Service(TestABC):
|
||||
def __init__(self):
|
||||
TestABC.__init__(self, String.random(8))
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
12
example/di/src/test2_service.py
Normal file
12
example/di/src/test2_service.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import string
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.utils.string import String
|
||||
from test_abc import TestABC
|
||||
|
||||
|
||||
class Test2Service(TestABC):
|
||||
def __init__(self):
|
||||
TestABC.__init__(self, String.random(8))
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
9
example/di/src/test_abc.py
Normal file
9
example/di/src/test_abc.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from abc import ABC
|
||||
|
||||
|
||||
class TestABC(ABC):
|
||||
def __init__(self, name: str):
|
||||
self._name = name
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{type(self).__name__} {self._name}>"
|
||||
14
example/di/src/test_service.py
Normal file
14
example/di/src/test_service.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.utils.string import String
|
||||
|
||||
|
||||
class TestService:
|
||||
def __init__(self):
|
||||
self._name = String.random(8)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
7
example/di/src/tester.py
Normal file
7
example/di/src/tester.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from cpl.core.console.console import Console
|
||||
from test_abc import TestABC
|
||||
|
||||
|
||||
class Tester:
|
||||
def __init__(self, t1: TestABC, t2: TestABC, t3: TestABC, t: list[TestABC]):
|
||||
Console.write_line("Tester:", t, t1, t2, t3)
|
||||
20
example/general/.cpl/schematic_custom.py
Normal file
20
example/general/.cpl/schematic_custom.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
|
||||
|
||||
|
||||
class Custom(GenerateSchematicABC):
|
||||
def __init__(self, *args: str):
|
||||
GenerateSchematicABC.__init__(self, *args)
|
||||
|
||||
def get_code(self) -> str:
|
||||
code = """\
|
||||
class $Name:
|
||||
|
||||
def __init__(self):
|
||||
print('hello')
|
||||
"""
|
||||
x = self.build_code_str(code, Name=self._class_name)
|
||||
return x
|
||||
|
||||
@classmethod
|
||||
def register(cls):
|
||||
GenerateSchematicABC.register(cls, "custom", ["cm", "CM"])
|
||||
0
example/general/src/__init__.py
Normal file
0
example/general/src/__init__.py
Normal file
83
example/general/src/application.py
Normal file
83
example/general/src/application.py
Normal file
@@ -0,0 +1,83 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from cpl.application.abc import ApplicationABC
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import LoggerABC
|
||||
from cpl.core.pipes import IPAddressPipe
|
||||
from cpl.dependency import ServiceProvider
|
||||
from cpl.dependency.typing import Modules
|
||||
from cpl.mail import EMail, EMailClientABC
|
||||
from cpl.query import List
|
||||
from scoped_service import ScopedService
|
||||
from test_service import TestService
|
||||
from test_settings import TestSettings
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, services: ServiceProvider, modules: Modules):
|
||||
ApplicationABC.__init__(self, services, modules)
|
||||
self._logger = self._services.get_service(LoggerABC)
|
||||
self._mailer = self._services.get_service(EMailClientABC)
|
||||
|
||||
def test_send_mail(self):
|
||||
mail = EMail()
|
||||
mail.add_header("Mime-Version: 1.0")
|
||||
mail.add_header("Content-Type: text/plain; charset=utf-8")
|
||||
mail.add_header("Content-Transfer-Encoding: quoted-printable")
|
||||
mail.add_receiver("sven.heidemann@sh-edraft.de")
|
||||
mail.subject = f"Test - {Environment.get_host_name()}"
|
||||
mail.body = "Dies ist ein Test :D"
|
||||
self._mailer.send_mail(mail)
|
||||
|
||||
@staticmethod
|
||||
def _wait(time_ms: int):
|
||||
time.sleep(time_ms)
|
||||
|
||||
async def main(self):
|
||||
self._logger.debug(f"Host: {Environment.get_host_name()}")
|
||||
self._logger.debug(f"Environment: {Environment.get_environment()}")
|
||||
Console.write_line(List(range(0, 10)).select(lambda x: f"x={x}").to_list())
|
||||
Console.spinner("Test", self._wait, 2, spinner_foreground_color="red")
|
||||
test: TestService = self._services.get_service(TestService)
|
||||
ip_pipe: IPAddressPipe = self._services.get_service(IPAddressPipe)
|
||||
test.run()
|
||||
test2: TestService = self._services.get_service(TestService)
|
||||
ip_pipe2: IPAddressPipe = self._services.get_service(IPAddressPipe)
|
||||
Console.write_line(f"DI working: {test == test2 and ip_pipe != ip_pipe2}")
|
||||
Console.write_line(self._services.get_service(LoggerABC))
|
||||
|
||||
root_scoped_service = self._services.get_service(ScopedService)
|
||||
with self._services.create_scope() as scope:
|
||||
s_srvc1 = scope.get_service(ScopedService)
|
||||
s_srvc2 = scope.get_service(ScopedService)
|
||||
|
||||
Console.write_line(root_scoped_service)
|
||||
Console.write_line(s_srvc1)
|
||||
Console.write_line(s_srvc2)
|
||||
if root_scoped_service == s_srvc1 or s_srvc1 != s_srvc2:
|
||||
raise Exception("Root scoped service should not be equal to scoped service")
|
||||
|
||||
root_scoped_service2 = self._services.get_service(ScopedService)
|
||||
Console.write_line(root_scoped_service2)
|
||||
if root_scoped_service == root_scoped_service2:
|
||||
raise Exception("Root scoped service should be equal to root scoped service 2")
|
||||
|
||||
test_settings = Configuration.get(TestSettings)
|
||||
Console.write_line(test_settings.value)
|
||||
Console.write_line("reload config")
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
test_settings1 = Configuration.get(TestSettings)
|
||||
Console.write_line(test_settings1.value)
|
||||
# self.test_send_mail()
|
||||
|
||||
x = 0
|
||||
while x < 500:
|
||||
Console.write_line("Running...")
|
||||
x += 1
|
||||
await asyncio.sleep(5)
|
||||
8
example/general/src/appsettings.development.json
Normal file
8
example/general/src/appsettings.development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,20 @@
|
||||
{
|
||||
"TimeFormatSettings": {
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"LoggingSettings": {
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"FileLogLevel": "TRACE"
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
},
|
||||
|
||||
"EMailClientSettings": {
|
||||
"EMailClient": {
|
||||
"Host": "mail.sh-edraft.de",
|
||||
"Port": "587",
|
||||
"UserName": "dev-srv@sh-edraft.de",
|
||||
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
|
||||
},
|
||||
|
||||
"DatabaseSettings": {
|
||||
"AuthPlugin": "mysql_native_password",
|
||||
"ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl",
|
||||
"Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==",
|
||||
"Encoding": "utf8mb4"
|
||||
}
|
||||
}
|
||||
37
example/general/src/appsettings.edrafts-pc.json
Normal file
37
example/general/src/appsettings.edrafts-pc.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "TRACE",
|
||||
"Level": "TRACE"
|
||||
},
|
||||
|
||||
"EMailClient": {
|
||||
"Host": "mail.sh-edraft.de",
|
||||
"Port": "587",
|
||||
"UserName": "dev-srv@sh-edraft.de",
|
||||
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
|
||||
},
|
||||
|
||||
"Database": {
|
||||
"Host": "localhost",
|
||||
"User": "sh_cpl",
|
||||
"Password": "MHZhc0Y2bjhKc1VUMWV0Qw==",
|
||||
"Database": "sh_cpl",
|
||||
"Charset": "utf8mb4",
|
||||
"UseUnicode": "true",
|
||||
"Buffered": "true",
|
||||
"AuthPlugin": "mysql_native_password"
|
||||
},
|
||||
|
||||
"Test": {
|
||||
"Value": 20
|
||||
}
|
||||
}
|
||||
15
example/general/src/appsettings.json
Normal file
15
example/general/src/appsettings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARN"
|
||||
}
|
||||
}
|
||||
1
example/general/src/db/__init__.py
Normal file
1
example/general/src/db/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
30
example/general/src/hosted_service.py
Normal file
30
example/general/src/hosted_service.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.time.cron import Cron
|
||||
from cpl.core.service.cronjob import CronjobABC
|
||||
from cpl.core.service.hosted_service import HostedService
|
||||
|
||||
|
||||
class Hosted(HostedService):
|
||||
def __init__(self):
|
||||
self._stopped = False
|
||||
|
||||
async def start(self):
|
||||
Console.write_line("Hosted Service Started")
|
||||
while not self._stopped:
|
||||
Console.write_line("Hosted Service Running")
|
||||
await asyncio.sleep(5)
|
||||
|
||||
async def stop(self):
|
||||
Console.write_line("Hosted Service Stopped")
|
||||
self._stopped = True
|
||||
|
||||
|
||||
class MyCronJob(CronjobABC):
|
||||
def __init__(self):
|
||||
CronjobABC.__init__(self, Cron("*/1 * * * *")) # Every minute
|
||||
|
||||
async def loop(self):
|
||||
Console.write_line(f"[{datetime.now()}] Hello from Cronjob!")
|
||||
17
example/general/src/main.py
Normal file
17
example/general/src/main.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from application import Application
|
||||
from cpl.application import ApplicationBuilder
|
||||
from test_extension import TestExtension
|
||||
from startup import Startup
|
||||
from test_startup_extension import TestStartupExtension
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.with_extension(TestStartupExtension)
|
||||
app_builder.with_extension(TestExtension)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
10
example/general/src/scoped_service.py
Normal file
10
example/general/src/scoped_service.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from cpl.core.console import Console
|
||||
|
||||
|
||||
class ScopedService:
|
||||
def __init__(self):
|
||||
self.value = "I am a scoped service"
|
||||
Console.write_line(self.value, self)
|
||||
|
||||
def get_value(self):
|
||||
return self.value
|
||||
28
example/general/src/startup.py
Normal file
28
example/general/src/startup.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from cpl.application.abc import StartupABC
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.pipes import IPAddressPipe
|
||||
from cpl.dependency import ServiceCollection
|
||||
from cpl.mail.mail_module import MailModule
|
||||
from hosted_service import Hosted, MyCronJob
|
||||
from scoped_service import ScopedService
|
||||
from test_service import TestService
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
@staticmethod
|
||||
def configure_configuration():
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
|
||||
@staticmethod
|
||||
def configure_services(services: ServiceCollection):
|
||||
services.add_logging()
|
||||
services.add_module(MailModule)
|
||||
services.add_transient(IPAddressPipe)
|
||||
services.add_singleton(TestService)
|
||||
services.add_scoped(ScopedService)
|
||||
services.add_hosted_service(Hosted)
|
||||
services.add_hosted_service(MyCronJob)
|
||||
10
example/general/src/test_extension.py
Normal file
10
example/general/src/test_extension.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from cpl.application.abc import ApplicationExtensionABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
|
||||
|
||||
class TestExtension(ApplicationExtensionABC):
|
||||
|
||||
@staticmethod
|
||||
def run(services: ServiceProvider):
|
||||
Console.write_line("Hello World from App Extension")
|
||||
13
example/general/src/test_service.py
Normal file
13
example/general/src/test_service.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
from cpl.core.pipes.ip_address_pipe import IPAddressPipe
|
||||
|
||||
|
||||
class TestService:
|
||||
def __init__(self, provider: ServiceProvider):
|
||||
self._provider = provider
|
||||
|
||||
def run(self):
|
||||
Console.write_line("Hello World!", self._provider)
|
||||
ip = [192, 168, 178, 30]
|
||||
Console.write_line(ip, IPAddressPipe.to_str(ip))
|
||||
6
example/general/src/test_settings.py
Normal file
6
example/general/src/test_settings.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from cpl.core.configuration import ConfigurationModelABC
|
||||
|
||||
|
||||
class TestSettings(ConfigurationModelABC):
|
||||
def __init__(self, value: int = None):
|
||||
self.value = value
|
||||
14
example/general/src/test_startup_extension.py
Normal file
14
example/general/src/test_startup_extension.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.application.abc import StartupExtensionABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceCollection
|
||||
|
||||
|
||||
class TestStartupExtension(StartupExtensionABC):
|
||||
|
||||
@staticmethod
|
||||
def configure_configuration():
|
||||
Console.write_line("config")
|
||||
|
||||
@staticmethod
|
||||
def configure_services(services: ServiceCollection):
|
||||
Console.write_line("services")
|
||||
60
example/query/main.py
Normal file
60
example/query/main.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.utils.benchmark import Benchmark
|
||||
from cpl.query.enumerable import Enumerable
|
||||
from cpl.query.immutable_list import ImmutableList
|
||||
from cpl.query.list import List
|
||||
from cpl.query.set import Set
|
||||
|
||||
|
||||
def _default():
|
||||
Console.write_line(Enumerable.empty().to_list())
|
||||
|
||||
Console.write_line(Enumerable.range(0, 100).length)
|
||||
Console.write_line(Enumerable.range(0, 100).to_list())
|
||||
|
||||
Console.write_line(Enumerable.range(0, 100).where(lambda x: x % 2 == 0).length)
|
||||
Console.write_line(
|
||||
Enumerable.range(0, 100).where(lambda x: x % 2 == 0).to_list().select(lambda x: str(x)).to_list()
|
||||
)
|
||||
Console.write_line(List)
|
||||
|
||||
s =Enumerable.range(0, 10).to_set()
|
||||
Console.write_line(s)
|
||||
s.add(1)
|
||||
Console.write_line(s)
|
||||
|
||||
data = Enumerable(
|
||||
[
|
||||
{"name": "Alice", "age": 30},
|
||||
{"name": "Dave", "age": 35},
|
||||
{"name": "Charlie", "age": 25},
|
||||
{"name": "Bob", "age": 25},
|
||||
]
|
||||
)
|
||||
|
||||
Console.write_line(data.order_by(lambda x: x["age"]).to_list())
|
||||
Console.write_line(data.order_by(lambda x: x["age"]).then_by(lambda x: x["name"]).to_list())
|
||||
Console.write_line(data.order_by(lambda x: x["name"]).then_by(lambda x: x["age"]).to_list())
|
||||
|
||||
|
||||
def t_benchmark(data: list):
|
||||
Benchmark.all("Enumerable", lambda: Enumerable(data).where(lambda x: x % 2 == 0).select(lambda x: x * 2).to_list())
|
||||
Benchmark.all("Set", lambda: Set(data).where(lambda x: x % 2 == 0).select(lambda x: x * 2).to_list())
|
||||
Benchmark.all("List", lambda: List(data).where(lambda x: x % 2 == 0).select(lambda x: x * 2).to_list())
|
||||
Benchmark.all(
|
||||
"ImmutableList", lambda: ImmutableList(data).where(lambda x: x % 2 == 0).select(lambda x: x * 2).to_list()
|
||||
)
|
||||
Benchmark.all("List comprehension", lambda: [x * 2 for x in data if x % 2 == 0])
|
||||
|
||||
|
||||
def main():
|
||||
N = 1_000_000
|
||||
data = list(range(N))
|
||||
t_benchmark(data)
|
||||
|
||||
Console.write_line()
|
||||
_default()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
0
example/translation/LICENSE
Normal file
0
example/translation/LICENSE
Normal file
0
example/translation/README.md
Normal file
0
example/translation/README.md
Normal file
9
example/translation/cpl-workspace.json
Normal file
9
example/translation/cpl-workspace.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Workspace": {
|
||||
"DefaultProject": "translation",
|
||||
"Projects": {
|
||||
"translation": "src/translation/translation.json"
|
||||
},
|
||||
"Scripts": {}
|
||||
}
|
||||
}
|
||||
0
example/translation/src/__init__.py
Normal file
0
example/translation/src/__init__.py
Normal file
27
example/translation/src/application.py
Normal file
27
example/translation/src/application.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProvider
|
||||
from cpl.translation.translate_pipe import TranslatePipe
|
||||
from cpl.translation.translation_service_abc import TranslationServiceABC
|
||||
from cpl.translation.translation_settings import TranslationSettings
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProvider):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
self._translate: TranslatePipe = services.get_service(TranslatePipe)
|
||||
self._translation: TranslationServiceABC = services.get_service(TranslationServiceABC)
|
||||
self._translation_settings: TranslationSettings = config.get_configuration(TranslationSettings)
|
||||
|
||||
self._translation.load_by_settings(config.get_configuration(TranslationSettings))
|
||||
self._translation.set_default_lang("de")
|
||||
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
self._translation.set_lang("en")
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
Console.write_line(self._translate.transform("main.text.hello"))
|
||||
23
example/translation/src/appsettings.json
Normal file
23
example/translation/src/appsettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"TimeFormat": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"Logging": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLevel": "ERROR",
|
||||
"Level": "WARN"
|
||||
},
|
||||
|
||||
"Translation": {
|
||||
"Languages":[
|
||||
"de",
|
||||
"en"
|
||||
],
|
||||
"DefaultLanguage": "en"
|
||||
}
|
||||
}
|
||||
14
example/translation/src/main.py
Normal file
14
example/translation/src/main.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from translation.application import Application
|
||||
from translation.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
17
example/translation/src/startup.py
Normal file
17
example/translation/src/startup.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from cpl.application import StartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProvider, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: Environment) -> ConfigurationABC:
|
||||
configuration.add_json_file("appsettings.json")
|
||||
return configuration
|
||||
|
||||
def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProvider:
|
||||
services.add_translation()
|
||||
return services.build()
|
||||
44
example/translation/src/translation.json
Normal file
44
example/translation/src/translation.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Project": {
|
||||
"Name": "translation",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"cpl-core>=2022.6.0"
|
||||
],
|
||||
"DevDependencies": [
|
||||
"cpl-cli>=2022.6.0"
|
||||
],
|
||||
"PythonVersion": ">=3.10.4",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"Build": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "translation.main",
|
||||
"EntryPoint": "translation",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
||||
7
example/translation/src/translation/de.json
Normal file
7
example/translation/src/translation/de.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": {
|
||||
"text": {
|
||||
"hello_world": "Hallo Welt"
|
||||
}
|
||||
}
|
||||
}
|
||||
7
example/translation/src/translation/en.json
Normal file
7
example/translation/src/translation/en.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"main": {
|
||||
"text": {
|
||||
"hello_world": "Hello World"
|
||||
}
|
||||
}
|
||||
}
|
||||
61
install.sh
Normal file
61
install.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Find and combine requirements from src/*/requirements.txt,
|
||||
# filtering out lines whose *package name* starts with "cpl-".
|
||||
# Works with pinned versions, extras, markers, editable installs, and VCS refs.
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
req_files=(src/*/requirements.txt)
|
||||
if ((${#req_files[@]} == 0)); then
|
||||
echo "No requirements files found at src/*/requirements.txt" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmp_combined="$(mktemp)"
|
||||
trap 'rm -f "$tmp_combined"' EXIT
|
||||
|
||||
# Concatenate, trim comments/whitespace, filter out cpl-* packages, dedupe.
|
||||
# We keep non-package options/flags/constraints as-is.
|
||||
awk '
|
||||
function trim(s){ sub(/^[[:space:]]+/,"",s); sub(/[[:space:]]+$/,"",s); return s }
|
||||
|
||||
{
|
||||
line=$0
|
||||
# drop full-line comments and strip inline comments
|
||||
if (line ~ /^[[:space:]]*#/) next
|
||||
sub(/#[^!].*$/,"",line) # strip trailing comment (simple heuristic)
|
||||
line=trim(line)
|
||||
if (line == "") next
|
||||
|
||||
# Determine the package *name* even for "-e", extras, pins, markers, or VCS "@"
|
||||
e = line
|
||||
sub(/^-e[[:space:]]+/,"",e) # remove editable prefix
|
||||
# Tokenize up to the first of these separators: space, [ < > = ! ~ ; @
|
||||
token = e
|
||||
sub(/\[.*/,"",token) # remove extras quickly
|
||||
n = split(token, a, /[<>=!~;@[:space:]]/)
|
||||
name = tolower(a[1])
|
||||
|
||||
# If the first token (name) starts with "cpl-", skip this requirement
|
||||
if (name ~ /^cpl-/) next
|
||||
|
||||
print line
|
||||
}
|
||||
' "${req_files[@]}" | sort -u > "$tmp_combined"
|
||||
|
||||
if ! [ -s "$tmp_combined" ]; then
|
||||
echo "Nothing to install after filtering out cpl-* packages." >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Installing dependencies (excluding cpl-*) from:"
|
||||
printf ' - %s\n' "${req_files[@]}"
|
||||
echo
|
||||
echo "Final set to install:"
|
||||
cat "$tmp_combined"
|
||||
echo
|
||||
|
||||
# Use python -m pip for reliability; change to python3 if needed.
|
||||
python -m pip install -r "$tmp_combined"
|
||||
2
pyproject.toml
Normal file
2
pyproject.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user