appwrite-cli 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/.github/workflows/npm-publish.yml +41 -0
  2. package/Formula/appwrite.rb +19 -0
  3. package/LICENSE.md +12 -0
  4. package/README.md +102 -0
  5. package/docs/examples/account/create-anonymous-session.md +1 -0
  6. package/docs/examples/account/create-j-w-t.md +1 -0
  7. package/docs/examples/account/create-magic-u-r-l-session.md +4 -0
  8. package/docs/examples/account/create-o-auth2session.md +5 -0
  9. package/docs/examples/account/create-recovery.md +3 -0
  10. package/docs/examples/account/create-session.md +3 -0
  11. package/docs/examples/account/create-verification.md +2 -0
  12. package/docs/examples/account/create.md +5 -0
  13. package/docs/examples/account/delete-session.md +2 -0
  14. package/docs/examples/account/delete-sessions.md +1 -0
  15. package/docs/examples/account/delete.md +1 -0
  16. package/docs/examples/account/get-logs.md +3 -0
  17. package/docs/examples/account/get-prefs.md +1 -0
  18. package/docs/examples/account/get-session.md +2 -0
  19. package/docs/examples/account/get-sessions.md +1 -0
  20. package/docs/examples/account/get.md +1 -0
  21. package/docs/examples/account/update-email.md +3 -0
  22. package/docs/examples/account/update-magic-u-r-l-session.md +3 -0
  23. package/docs/examples/account/update-name.md +2 -0
  24. package/docs/examples/account/update-password.md +3 -0
  25. package/docs/examples/account/update-prefs.md +2 -0
  26. package/docs/examples/account/update-recovery.md +5 -0
  27. package/docs/examples/account/update-session.md +2 -0
  28. package/docs/examples/account/update-verification.md +3 -0
  29. package/docs/examples/avatars/get-browser.md +5 -0
  30. package/docs/examples/avatars/get-credit-card.md +5 -0
  31. package/docs/examples/avatars/get-favicon.md +2 -0
  32. package/docs/examples/avatars/get-flag.md +5 -0
  33. package/docs/examples/avatars/get-image.md +4 -0
  34. package/docs/examples/avatars/get-initials.md +6 -0
  35. package/docs/examples/avatars/get-q-r.md +5 -0
  36. package/docs/examples/database/create-boolean-attribute.md +6 -0
  37. package/docs/examples/database/create-collection.md +6 -0
  38. package/docs/examples/database/create-document.md +6 -0
  39. package/docs/examples/database/create-email-attribute.md +6 -0
  40. package/docs/examples/database/create-enum-attribute.md +7 -0
  41. package/docs/examples/database/create-float-attribute.md +8 -0
  42. package/docs/examples/database/create-index.md +6 -0
  43. package/docs/examples/database/create-integer-attribute.md +8 -0
  44. package/docs/examples/database/create-ip-attribute.md +6 -0
  45. package/docs/examples/database/create-string-attribute.md +7 -0
  46. package/docs/examples/database/create-url-attribute.md +6 -0
  47. package/docs/examples/database/delete-attribute.md +3 -0
  48. package/docs/examples/database/delete-collection.md +2 -0
  49. package/docs/examples/database/delete-document.md +3 -0
  50. package/docs/examples/database/delete-index.md +3 -0
  51. package/docs/examples/database/get-attribute.md +3 -0
  52. package/docs/examples/database/get-collection-usage.md +3 -0
  53. package/docs/examples/database/get-collection.md +2 -0
  54. package/docs/examples/database/get-document.md +3 -0
  55. package/docs/examples/database/get-index.md +3 -0
  56. package/docs/examples/database/get-usage.md +2 -0
  57. package/docs/examples/database/list-attributes.md +2 -0
  58. package/docs/examples/database/list-collection-logs.md +4 -0
  59. package/docs/examples/database/list-collections.md +7 -0
  60. package/docs/examples/database/list-document-logs.md +5 -0
  61. package/docs/examples/database/list-documents.md +9 -0
  62. package/docs/examples/database/list-indexes.md +2 -0
  63. package/docs/examples/database/update-collection.md +7 -0
  64. package/docs/examples/database/update-document.md +6 -0
  65. package/docs/examples/functions/create-deployment.md +5 -0
  66. package/docs/examples/functions/create-execution.md +4 -0
  67. package/docs/examples/functions/create.md +9 -0
  68. package/docs/examples/functions/delete-deployment.md +3 -0
  69. package/docs/examples/functions/delete.md +2 -0
  70. package/docs/examples/functions/get-deployment.md +3 -0
  71. package/docs/examples/functions/get-execution.md +3 -0
  72. package/docs/examples/functions/get-usage.md +3 -0
  73. package/docs/examples/functions/get.md +2 -0
  74. package/docs/examples/functions/list-deployments.md +8 -0
  75. package/docs/examples/functions/list-executions.md +7 -0
  76. package/docs/examples/functions/list-runtimes.md +1 -0
  77. package/docs/examples/functions/list.md +7 -0
  78. package/docs/examples/functions/retry-build.md +4 -0
  79. package/docs/examples/functions/update-deployment.md +3 -0
  80. package/docs/examples/functions/update.md +8 -0
  81. package/docs/examples/health/get-antivirus.md +1 -0
  82. package/docs/examples/health/get-cache.md +1 -0
  83. package/docs/examples/health/get-d-b.md +1 -0
  84. package/docs/examples/health/get-queue-certificates.md +1 -0
  85. package/docs/examples/health/get-queue-functions.md +1 -0
  86. package/docs/examples/health/get-queue-logs.md +1 -0
  87. package/docs/examples/health/get-queue-usage.md +1 -0
  88. package/docs/examples/health/get-queue-webhooks.md +1 -0
  89. package/docs/examples/health/get-storage-local.md +1 -0
  90. package/docs/examples/health/get-time.md +1 -0
  91. package/docs/examples/health/get.md +1 -0
  92. package/docs/examples/locale/get-continents.md +1 -0
  93. package/docs/examples/locale/get-countries-e-u.md +1 -0
  94. package/docs/examples/locale/get-countries-phones.md +1 -0
  95. package/docs/examples/locale/get-countries.md +1 -0
  96. package/docs/examples/locale/get-currencies.md +1 -0
  97. package/docs/examples/locale/get-languages.md +1 -0
  98. package/docs/examples/locale/get.md +1 -0
  99. package/docs/examples/projects/create-domain.md +3 -0
  100. package/docs/examples/projects/create-key.md +4 -0
  101. package/docs/examples/projects/create-platform.md +7 -0
  102. package/docs/examples/projects/create-webhook.md +8 -0
  103. package/docs/examples/projects/create.md +13 -0
  104. package/docs/examples/projects/delete-domain.md +3 -0
  105. package/docs/examples/projects/delete-key.md +3 -0
  106. package/docs/examples/projects/delete-platform.md +3 -0
  107. package/docs/examples/projects/delete-webhook.md +3 -0
  108. package/docs/examples/projects/delete.md +3 -0
  109. package/docs/examples/projects/get-domain.md +3 -0
  110. package/docs/examples/projects/get-key.md +3 -0
  111. package/docs/examples/projects/get-platform.md +3 -0
  112. package/docs/examples/projects/get-usage.md +3 -0
  113. package/docs/examples/projects/get-webhook.md +3 -0
  114. package/docs/examples/projects/get.md +2 -0
  115. package/docs/examples/projects/list-domains.md +2 -0
  116. package/docs/examples/projects/list-keys.md +2 -0
  117. package/docs/examples/projects/list-platforms.md +2 -0
  118. package/docs/examples/projects/list-webhooks.md +2 -0
  119. package/docs/examples/projects/list.md +7 -0
  120. package/docs/examples/projects/update-auth-limit.md +3 -0
  121. package/docs/examples/projects/update-auth-status.md +4 -0
  122. package/docs/examples/projects/update-domain-verification.md +3 -0
  123. package/docs/examples/projects/update-key.md +5 -0
  124. package/docs/examples/projects/update-o-auth2.md +5 -0
  125. package/docs/examples/projects/update-platform.md +7 -0
  126. package/docs/examples/projects/update-service-status.md +4 -0
  127. package/docs/examples/projects/update-webhook.md +9 -0
  128. package/docs/examples/projects/update.md +12 -0
  129. package/docs/examples/storage/create-bucket.md +11 -0
  130. package/docs/examples/storage/create-file.md +6 -0
  131. package/docs/examples/storage/delete-bucket.md +2 -0
  132. package/docs/examples/storage/delete-file.md +3 -0
  133. package/docs/examples/storage/get-bucket-usage.md +3 -0
  134. package/docs/examples/storage/get-bucket.md +2 -0
  135. package/docs/examples/storage/get-file-download.md +3 -0
  136. package/docs/examples/storage/get-file-preview.md +14 -0
  137. package/docs/examples/storage/get-file-view.md +3 -0
  138. package/docs/examples/storage/get-file.md +3 -0
  139. package/docs/examples/storage/get-usage.md +2 -0
  140. package/docs/examples/storage/list-buckets.md +7 -0
  141. package/docs/examples/storage/list-files.md +8 -0
  142. package/docs/examples/storage/update-bucket.md +11 -0
  143. package/docs/examples/storage/update-file.md +5 -0
  144. package/docs/examples/teams/create-membership.md +6 -0
  145. package/docs/examples/teams/create.md +4 -0
  146. package/docs/examples/teams/delete-membership.md +3 -0
  147. package/docs/examples/teams/delete.md +2 -0
  148. package/docs/examples/teams/get-membership.md +3 -0
  149. package/docs/examples/teams/get-memberships.md +8 -0
  150. package/docs/examples/teams/get.md +2 -0
  151. package/docs/examples/teams/list.md +7 -0
  152. package/docs/examples/teams/update-membership-roles.md +4 -0
  153. package/docs/examples/teams/update-membership-status.md +5 -0
  154. package/docs/examples/teams/update.md +3 -0
  155. package/docs/examples/users/create.md +5 -0
  156. package/docs/examples/users/delete-session.md +3 -0
  157. package/docs/examples/users/delete-sessions.md +2 -0
  158. package/docs/examples/users/delete.md +2 -0
  159. package/docs/examples/users/get-logs.md +4 -0
  160. package/docs/examples/users/get-prefs.md +2 -0
  161. package/docs/examples/users/get-sessions.md +2 -0
  162. package/docs/examples/users/get-usage.md +3 -0
  163. package/docs/examples/users/get.md +2 -0
  164. package/docs/examples/users/list.md +7 -0
  165. package/docs/examples/users/update-email.md +3 -0
  166. package/docs/examples/users/update-name.md +3 -0
  167. package/docs/examples/users/update-password.md +3 -0
  168. package/docs/examples/users/update-prefs.md +3 -0
  169. package/docs/examples/users/update-status.md +3 -0
  170. package/docs/examples/users/update-verification.md +3 -0
  171. package/index.js +49 -0
  172. package/install.sh +165 -0
  173. package/ldid/COPYING +661 -0
  174. package/ldid/Makefile +51 -0
  175. package/ldid/control +12 -0
  176. package/ldid/control.sh +5 -0
  177. package/ldid/deb.sh +10 -0
  178. package/ldid/ios.sh +2 -0
  179. package/ldid/ldid.cpp +3253 -0
  180. package/ldid/ldid.hpp +164 -0
  181. package/ldid/libplist/.github/workflows/build.yml +62 -0
  182. package/ldid/libplist/.github/workflows/codeql-analysis.yml +71 -0
  183. package/ldid/libplist/AUTHORS +28 -0
  184. package/ldid/libplist/COPYING +340 -0
  185. package/ldid/libplist/COPYING.LESSER +502 -0
  186. package/ldid/libplist/Makefile.am +20 -0
  187. package/ldid/libplist/NEWS +252 -0
  188. package/ldid/libplist/README.md +114 -0
  189. package/ldid/libplist/aclocal.m4 +1729 -0
  190. package/ldid/libplist/autogen.sh +26 -0
  191. package/ldid/libplist/configure.ac +292 -0
  192. package/ldid/libplist/cython/Makefile.am +53 -0
  193. package/ldid/libplist/cython/plist.pxd +78 -0
  194. package/ldid/libplist/cython/plist.pyx +947 -0
  195. package/ldid/libplist/cython/plist_util.c +40 -0
  196. package/ldid/libplist/cython/plist_util.h +5 -0
  197. package/ldid/libplist/docs/Makefile.am +3 -0
  198. package/ldid/libplist/docs/plistutil.1 +62 -0
  199. package/ldid/libplist/fuzz/Makefile.am +43 -0
  200. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-4766291097288704 +0 -0
  201. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-4930725262393344 +0 -0
  202. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-5421965105954816 +0 -0
  203. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-5556177727389696 +0 -0
  204. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-6557963011489792 +0 -0
  205. package/ldid/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-6605859144597504 +0 -0
  206. package/ldid/libplist/fuzz/bplist-crashes/crash-0ce4dd483b645bc05ec45a97d285dcf1933ee840 +0 -0
  207. package/ldid/libplist/fuzz/bplist-crashes/crash-0d59cdcb5c3416c2790612b78a631ce9f5622800 +0 -0
  208. package/ldid/libplist/fuzz/bplist-crashes/crash-17d635ab460fef74df1ac7561f1253533a6359c5 +0 -0
  209. package/ldid/libplist/fuzz/bplist-crashes/crash-33a67313fa7864cd627ef92d12017a127d342f28 +0 -0
  210. package/ldid/libplist/fuzz/bplist-crashes/crash-39f1347115f8fe9ac25cdc9332e3fc5cd32c7f7b +0 -0
  211. package/ldid/libplist/fuzz/bplist-crashes/crash-4bd78175fe01d07c5ee90104fbc68d95dd092210 +0 -0
  212. package/ldid/libplist/fuzz/bplist-crashes/crash-4c5404453bb7425aef9b953a5f6f3f0afcc48392 +0 -0
  213. package/ldid/libplist/fuzz/bplist-crashes/crash-52775e25f6af20af351cd616834e602fc988a032 +0 -0
  214. package/ldid/libplist/fuzz/bplist-crashes/crash-6d1399685b745d3d49fadc91072fabcdde8d16fa +0 -0
  215. package/ldid/libplist/fuzz/bplist-crashes/crash-94b3725900d63c6258448fd757559c81002de9c9 +0 -0
  216. package/ldid/libplist/fuzz/bplist-crashes/crash-a47195acbabc3f5b2cda9c6ebda42f2afc1cc5af +0 -0
  217. package/ldid/libplist/fuzz/bplist-crashes/crash-ce852bae6aeeffc4698a93660236f1b995ce966e +0 -0
  218. package/ldid/libplist/fuzz/bplist-crashes/crash-daddb6e82e3d1ed76e20e4131462f5247a6fb131 +0 -0
  219. package/ldid/libplist/fuzz/bplist-crashes/crash-f21be4ebce7f9c337bf96b93cec7e252f5c75a21 +0 -0
  220. package/ldid/libplist/fuzz/bplist-crashes/crash-f779dafccc0164684d1a264976e56037188b40e2 +0 -0
  221. package/ldid/libplist/fuzz/bplist-leaks/leak-96fb453b3ba18d31e164831795a708183b5a0dac +0 -0
  222. package/ldid/libplist/fuzz/bplist-leaks/leak-acb3c00a83d7635638a476a4e70fc1f1caa1a5b1 +0 -0
  223. package/ldid/libplist/fuzz/bplist-leaks/leak-fe2cd4b1f67e0c9b21e6225a4fb4ca19eab80074 +0 -0
  224. package/ldid/libplist/fuzz/bplist.dict +1 -0
  225. package/ldid/libplist/fuzz/bplist_fuzzer.cc +32 -0
  226. package/ldid/libplist/fuzz/bplist_fuzzer.options +3 -0
  227. package/ldid/libplist/fuzz/fuzzers.test +8 -0
  228. package/ldid/libplist/fuzz/init-fuzzers.sh +23 -0
  229. package/ldid/libplist/fuzz/test-fuzzers.sh +33 -0
  230. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-4516959125241856 +0 -0
  231. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-4663876528373760 +5 -0
  232. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-5799076113154048 +45 -0
  233. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-5922404220010496 +0 -0
  234. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6015098361479168 +0 -0
  235. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6043836860071936 +0 -0
  236. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6047509906456576 +10050 -0
  237. package/ldid/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6482601374121984 +0 -0
  238. package/ldid/libplist/fuzz/xplist-crashes/crash-09788d7acb46b4b177422f9c4ee54556a3ad1f17 +53 -0
  239. package/ldid/libplist/fuzz/xplist-crashes/crash-155c60d5c4b2778110fb4a633caa7d64eb9b99c1 +9 -0
  240. package/ldid/libplist/fuzz/xplist-crashes/crash-348c909a0b3532977185f551eb5d2ed04e694883 +11 -0
  241. package/ldid/libplist/fuzz/xplist-crashes/crash-7bc172e27a2b1d4fcaf031f59d1f08fb83081e4a +8 -0
  242. package/ldid/libplist/fuzz/xplist-crashes/crash-80c28b0e2a446665e68927dd4441c10c9a68e64e +0 -0
  243. package/ldid/libplist/fuzz/xplist-crashes/crash-8acf177da60ecf13c36d0da1b8e25de891980ea6 +5 -0
  244. package/ldid/libplist/fuzz/xplist-crashes/crash-94276cf69a50e78dd6cdf079c208cb80f357cd33 +0 -0
  245. package/ldid/libplist/fuzz/xplist-crashes/crash-9ddb891a0ec42401eb4629e6b99e01aef7909eb9 +0 -0
  246. package/ldid/libplist/fuzz/xplist-crashes/crash-a8b44e1f5be4f75f00a937016ec5405bce77a0f9 +0 -0
  247. package/ldid/libplist/fuzz/xplist-crashes/crash-da39a3ee5e6b4b0d3255bfef95601890afd80709 +0 -0
  248. package/ldid/libplist/fuzz/xplist-crashes/crash-f03c680ee1c4d84c28e731752df77a61e213a24d +72 -0
  249. package/ldid/libplist/fuzz/xplist-leaks/clusterfuzz-testcase-4634751103139840 +187 -0
  250. package/ldid/libplist/fuzz/xplist-leaks/clusterfuzz-testcase-6056412121661440 +12 -0
  251. package/ldid/libplist/fuzz/xplist-leaks/leak-47b0a9f21d3affab6cfc898e5140bb53265ada07 +0 -0
  252. package/ldid/libplist/fuzz/xplist-leaks/leak-4c81aae70b20d9b9408b78d40999a54205bdcfb7 +0 -0
  253. package/ldid/libplist/fuzz/xplist-leaks/leak-53bc466851eda790bd891733da5db0a7482886bf +6 -0
  254. package/ldid/libplist/fuzz/xplist.dict +51 -0
  255. package/ldid/libplist/fuzz/xplist_fuzzer.cc +32 -0
  256. package/ldid/libplist/fuzz/xplist_fuzzer.options +3 -0
  257. package/ldid/libplist/include/Makefile.am +15 -0
  258. package/ldid/libplist/include/plist/Array.h +55 -0
  259. package/ldid/libplist/include/plist/Boolean.h +48 -0
  260. package/ldid/libplist/include/plist/Data.h +49 -0
  261. package/ldid/libplist/include/plist/Date.h +50 -0
  262. package/ldid/libplist/include/plist/Dictionary.h +68 -0
  263. package/ldid/libplist/include/plist/Integer.h +48 -0
  264. package/ldid/libplist/include/plist/Key.h +49 -0
  265. package/ldid/libplist/include/plist/Node.h +57 -0
  266. package/ldid/libplist/include/plist/Real.h +48 -0
  267. package/ldid/libplist/include/plist/String.h +49 -0
  268. package/ldid/libplist/include/plist/Structure.h +59 -0
  269. package/ldid/libplist/include/plist/Uid.h +48 -0
  270. package/ldid/libplist/include/plist/plist++.h +39 -0
  271. package/ldid/libplist/include/plist/plist.h +953 -0
  272. package/ldid/libplist/libcnary/COPYING +502 -0
  273. package/ldid/libplist/libcnary/Makefile.am +15 -0
  274. package/ldid/libplist/libcnary/README +5 -0
  275. package/ldid/libplist/libcnary/cnary.c +46 -0
  276. package/ldid/libplist/libcnary/include/node.h +65 -0
  277. package/ldid/libplist/libcnary/include/node_list.h +47 -0
  278. package/ldid/libplist/libcnary/include/object.h +41 -0
  279. package/ldid/libplist/libcnary/node.c +216 -0
  280. package/ldid/libplist/libcnary/node_list.c +157 -0
  281. package/ldid/libplist/m4/ac_pkg_cython.m4 +67 -0
  282. package/ldid/libplist/m4/as-compiler-flag.m4 +62 -0
  283. package/ldid/libplist/m4/ax_pthread.m4 +485 -0
  284. package/ldid/libplist/m4/ax_python_devel.m4 +327 -0
  285. package/ldid/libplist/m4/cython_python.m4 +7 -0
  286. package/ldid/libplist/src/Array.cpp +148 -0
  287. package/ldid/libplist/src/Boolean.cpp +73 -0
  288. package/ldid/libplist/src/Data.cpp +79 -0
  289. package/ldid/libplist/src/Date.cpp +76 -0
  290. package/ldid/libplist/src/Dictionary.cpp +182 -0
  291. package/ldid/libplist/src/Integer.cpp +73 -0
  292. package/ldid/libplist/src/Key.cpp +80 -0
  293. package/ldid/libplist/src/Makefile.am +63 -0
  294. package/ldid/libplist/src/Node.cpp +166 -0
  295. package/ldid/libplist/src/Real.cpp +73 -0
  296. package/ldid/libplist/src/String.cpp +80 -0
  297. package/ldid/libplist/src/Structure.cpp +123 -0
  298. package/ldid/libplist/src/Uid.cpp +73 -0
  299. package/ldid/libplist/src/base64.c +119 -0
  300. package/ldid/libplist/src/base64.h +28 -0
  301. package/ldid/libplist/src/bplist.c +1381 -0
  302. package/ldid/libplist/src/bytearray.c +61 -0
  303. package/ldid/libplist/src/bytearray.h +36 -0
  304. package/ldid/libplist/src/hashtable.c +140 -0
  305. package/ldid/libplist/src/hashtable.h +50 -0
  306. package/ldid/libplist/src/plist.c +1356 -0
  307. package/ldid/libplist/src/plist.h +74 -0
  308. package/ldid/libplist/src/ptrarray.c +96 -0
  309. package/ldid/libplist/src/ptrarray.h +40 -0
  310. package/ldid/libplist/src/strbuf.h +34 -0
  311. package/ldid/libplist/src/time64.c +814 -0
  312. package/ldid/libplist/src/time64.h +81 -0
  313. package/ldid/libplist/src/time64_limits.h +97 -0
  314. package/ldid/libplist/src/xplist.c +1435 -0
  315. package/ldid/libplist/test/Makefile.am +93 -0
  316. package/ldid/libplist/test/amp.test +14 -0
  317. package/ldid/libplist/test/bigarray.test +15 -0
  318. package/ldid/libplist/test/cdata.test +12 -0
  319. package/ldid/libplist/test/data/1.plist +35 -0
  320. package/ldid/libplist/test/data/2.plist +100 -0
  321. package/ldid/libplist/test/data/3.plist +420 -0
  322. package/ldid/libplist/test/data/4.plist +5037 -0
  323. package/ldid/libplist/test/data/5.plist +55053 -0
  324. package/ldid/libplist/test/data/6.plist +4006 -0
  325. package/ldid/libplist/test/data/7.plist +14 -0
  326. package/ldid/libplist/test/data/amp.plist +6 -0
  327. package/ldid/libplist/test/data/cdata.plist +6 -0
  328. package/ldid/libplist/test/data/dictref1byte.bplist +0 -0
  329. package/ldid/libplist/test/data/dictref2bytes.bplist +0 -0
  330. package/ldid/libplist/test/data/dictref3bytes.bplist +0 -0
  331. package/ldid/libplist/test/data/dictref4bytes.bplist +0 -0
  332. package/ldid/libplist/test/data/dictref5bytes.bplist +0 -0
  333. package/ldid/libplist/test/data/dictref6bytes.bplist +0 -0
  334. package/ldid/libplist/test/data/dictref7bytes.bplist +0 -0
  335. package/ldid/libplist/test/data/dictref8bytes.bplist +0 -0
  336. package/ldid/libplist/test/data/empty_keys.plist +8 -0
  337. package/ldid/libplist/test/data/entities.plist +57 -0
  338. package/ldid/libplist/test/data/hex.plist +5 -0
  339. package/ldid/libplist/test/data/invalid_tag.plist +6 -0
  340. package/ldid/libplist/test/data/malformed_dict.bplist +0 -0
  341. package/ldid/libplist/test/data/off1byte.bplist +0 -0
  342. package/ldid/libplist/test/data/off2bytes.bplist +0 -0
  343. package/ldid/libplist/test/data/off3bytes.bplist +0 -0
  344. package/ldid/libplist/test/data/off4bytes.bplist +0 -0
  345. package/ldid/libplist/test/data/off5bytes.bplist +0 -0
  346. package/ldid/libplist/test/data/off6bytes.bplist +0 -0
  347. package/ldid/libplist/test/data/off7bytes.bplist +0 -0
  348. package/ldid/libplist/test/data/off8bytes.bplist +0 -0
  349. package/ldid/libplist/test/data/offxml.plist +8 -0
  350. package/ldid/libplist/test/data/order.bplist +0 -0
  351. package/ldid/libplist/test/data/order.plist +27 -0
  352. package/ldid/libplist/test/data/recursion.bplist +0 -0
  353. package/ldid/libplist/test/data/signed.bplist +0 -0
  354. package/ldid/libplist/test/data/signed.plist +5 -0
  355. package/ldid/libplist/test/data/signedunsigned.bplist +0 -0
  356. package/ldid/libplist/test/data/signedunsigned.plist +11 -0
  357. package/ldid/libplist/test/data/unsigned.bplist +0 -0
  358. package/ldid/libplist/test/data/unsigned.plist +5 -0
  359. package/ldid/libplist/test/dates.test +15 -0
  360. package/ldid/libplist/test/empty.test +15 -0
  361. package/ldid/libplist/test/empty_keys.test +12 -0
  362. package/ldid/libplist/test/entities.test +12 -0
  363. package/ldid/libplist/test/hex.test +12 -0
  364. package/ldid/libplist/test/huge.test +15 -0
  365. package/ldid/libplist/test/invalid_tag.test +14 -0
  366. package/ldid/libplist/test/large.test +15 -0
  367. package/ldid/libplist/test/malformed_dict.test +11 -0
  368. package/ldid/libplist/test/medium.test +15 -0
  369. package/ldid/libplist/test/offsetsize.test +12 -0
  370. package/ldid/libplist/test/order.test +13 -0
  371. package/ldid/libplist/test/plist_cmp.c +158 -0
  372. package/ldid/libplist/test/plist_test.c +135 -0
  373. package/ldid/libplist/test/recursion.test +11 -0
  374. package/ldid/libplist/test/refsize.test +12 -0
  375. package/ldid/libplist/test/signedunsigned1.test +23 -0
  376. package/ldid/libplist/test/signedunsigned2.test +23 -0
  377. package/ldid/libplist/test/signedunsigned3.test +23 -0
  378. package/ldid/libplist/test/small.test +15 -0
  379. package/ldid/libplist/test/timezone1.test +17 -0
  380. package/ldid/libplist/test/timezone2.test +21 -0
  381. package/ldid/libplist/tools/Makefile.am +10 -0
  382. package/ldid/libplist/tools/plistutil.c +299 -0
  383. package/ldid/lookup2.c +416 -0
  384. package/ldid/make.sh +90 -0
  385. package/ldid/minimal/hexdump.h +76 -0
  386. package/ldid/minimal/mapping.h +72 -0
  387. package/ldid/minimal/sqlite3.h +71 -0
  388. package/ldid/minimal/stdlib.h +129 -0
  389. package/ldid/minimal/string.h +51 -0
  390. package/ldid/plist.sh +2 -0
  391. package/ldid/sha1.h +64 -0
  392. package/ldid/sysroot.sh +31 -0
  393. package/ldid/version.sh +2 -0
  394. package/lib/client.js +243 -0
  395. package/lib/commands/account.js +785 -0
  396. package/lib/commands/avatars.js +349 -0
  397. package/lib/commands/database.js +1238 -0
  398. package/lib/commands/deploy.js +477 -0
  399. package/lib/commands/functions.js +689 -0
  400. package/lib/commands/generic.js +106 -0
  401. package/lib/commands/health.js +269 -0
  402. package/lib/commands/init.js +148 -0
  403. package/lib/commands/locale.js +177 -0
  404. package/lib/commands/projects.js +1191 -0
  405. package/lib/commands/storage.js +743 -0
  406. package/lib/commands/teams.js +435 -0
  407. package/lib/commands/users.js +542 -0
  408. package/lib/config.js +264 -0
  409. package/lib/exception.js +9 -0
  410. package/lib/parser.js +179 -0
  411. package/lib/questions.js +223 -0
  412. package/lib/sdks.js +82 -0
  413. package/package.json +41 -0
@@ -0,0 +1,947 @@
1
+ cimport cpython
2
+ cimport libc.stdlib
3
+ from libc.stdint cimport *
4
+
5
+ cdef extern from *:
6
+ ctypedef enum plist_type:
7
+ PLIST_BOOLEAN,
8
+ PLIST_UINT,
9
+ PLIST_REAL,
10
+ PLIST_STRING,
11
+ PLIST_ARRAY,
12
+ PLIST_DICT,
13
+ PLIST_DATE,
14
+ PLIST_DATA,
15
+ PLIST_KEY,
16
+ PLIST_UID,
17
+ PLIST_NONE
18
+
19
+ plist_t plist_new_bool(uint8_t val)
20
+ void plist_get_bool_val(plist_t node, uint8_t *val)
21
+ void plist_set_bool_val(plist_t node, uint8_t val)
22
+
23
+ plist_t plist_new_uint(uint64_t val)
24
+ void plist_get_uint_val(plist_t node, uint64_t *val)
25
+ void plist_set_uint_val(plist_t node, uint64_t val)
26
+
27
+ plist_t plist_new_real(double val)
28
+ void plist_get_real_val(plist_t node, double *val)
29
+ void plist_set_real_val(plist_t node, double val)
30
+
31
+ plist_t plist_new_date(int32_t sec, int32_t usec)
32
+ void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec)
33
+ void plist_set_date_val(plist_t node, int32_t sec, int32_t usec)
34
+
35
+ void plist_get_key_val(plist_t node, char **val)
36
+ void plist_set_key_val(plist_t node, char *val)
37
+
38
+ plist_t plist_new_uid(uint64_t val)
39
+ void plist_get_uid_val(plist_t node, uint64_t *val)
40
+ void plist_set_uid_val(plist_t node, uint64_t val)
41
+
42
+ plist_t plist_new_string(char *val)
43
+ void plist_get_string_val(plist_t node, char **val)
44
+ void plist_set_string_val(plist_t node, char *val)
45
+
46
+ plist_t plist_new_data(char *val, uint64_t length)
47
+ void plist_get_data_val(plist_t node, char **val, uint64_t * length)
48
+ void plist_set_data_val(plist_t node, char *val, uint64_t length)
49
+
50
+ plist_t plist_new_dict()
51
+ int plist_dict_get_size(plist_t node)
52
+ plist_t plist_dict_get_item(plist_t node, char* key)
53
+ void plist_dict_set_item(plist_t node, char* key, plist_t item)
54
+ void plist_dict_insert_item(plist_t node, char* key, plist_t item)
55
+ void plist_dict_remove_item(plist_t node, char* key)
56
+
57
+ void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
58
+ void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
59
+
60
+ plist_t plist_new_array()
61
+ uint32_t plist_array_get_size(plist_t node)
62
+ plist_t plist_array_get_item(plist_t node, uint32_t n)
63
+ uint32_t plist_array_get_item_index(plist_t node)
64
+ void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
65
+ void plist_array_append_item(plist_t node, plist_t item)
66
+ void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
67
+ void plist_array_remove_item(plist_t node, uint32_t n)
68
+
69
+ void plist_free(plist_t plist)
70
+ plist_t plist_copy(plist_t plist)
71
+ void plist_to_xml(plist_t plist, char **plist_xml, uint32_t *length)
72
+ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t *length)
73
+
74
+ plist_t plist_get_parent(plist_t node)
75
+ plist_type plist_get_node_type(plist_t node)
76
+
77
+ void plist_from_xml(char *plist_xml, uint32_t length, plist_t * plist)
78
+ void plist_from_bin(char *plist_bin, uint32_t length, plist_t * plist)
79
+
80
+ cdef class Node:
81
+ def __init__(self, *args, **kwargs):
82
+ self._c_managed = True
83
+
84
+ def __dealloc__(self):
85
+ if self._c_node is not NULL and self._c_managed:
86
+ plist_free(self._c_node)
87
+
88
+ cpdef object __deepcopy__(self, memo={}):
89
+ return plist_t_to_node(plist_copy(self._c_node))
90
+
91
+ cpdef object copy(self):
92
+ cdef plist_t c_node = NULL
93
+ c_node = plist_copy(self._c_node)
94
+ return plist_t_to_node(c_node)
95
+
96
+ cpdef unicode to_xml(self):
97
+ cdef:
98
+ char* out = NULL
99
+ uint32_t length
100
+ plist_to_xml(self._c_node, &out, &length)
101
+
102
+ try:
103
+ return cpython.PyUnicode_DecodeUTF8(out, length, 'strict')
104
+ finally:
105
+ if out != NULL:
106
+ libc.stdlib.free(out)
107
+
108
+ cpdef bytes to_bin(self):
109
+ cdef:
110
+ char* out = NULL
111
+ uint32_t length
112
+ plist_to_bin(self._c_node, &out, &length)
113
+
114
+ try:
115
+ return bytes(out[:length])
116
+ finally:
117
+ if out != NULL:
118
+ libc.stdlib.free(out)
119
+
120
+ property parent:
121
+ def __get__(self):
122
+ cdef plist_t c_parent = NULL
123
+ cdef Node node
124
+
125
+ c_parent = plist_get_parent(self._c_node)
126
+ if c_parent == NULL:
127
+ return None
128
+
129
+ return plist_t_to_node(c_parent)
130
+
131
+ def __str__(self):
132
+ return str(self.get_value())
133
+
134
+ cdef class Bool(Node):
135
+ def __cinit__(self, object value=None, *args, **kwargs):
136
+ if value is None:
137
+ self._c_node = plist_new_bool(0)
138
+ else:
139
+ self._c_node = plist_new_bool(bool(value))
140
+
141
+ def __nonzero__(self):
142
+ return self.get_value()
143
+
144
+ def __richcmp__(self, other, op):
145
+ cdef bint b = self.get_value()
146
+ if op == 0:
147
+ return b < other
148
+ if op == 1:
149
+ return b <= other
150
+ if op == 2:
151
+ return b == other
152
+ if op == 3:
153
+ return b != other
154
+ if op == 4:
155
+ return b > other
156
+ if op == 5:
157
+ return b >= other
158
+
159
+ def __repr__(self):
160
+ b = self.get_value()
161
+ return '<Bool: %s>' % b
162
+
163
+ cpdef set_value(self, object value):
164
+ plist_set_bool_val(self._c_node, bool(value))
165
+
166
+ cpdef bint get_value(self):
167
+ cdef uint8_t value
168
+ plist_get_bool_val(self._c_node, &value)
169
+ return bool(value)
170
+
171
+ cdef Bool Bool_factory(plist_t c_node, bint managed=True):
172
+ cdef Bool instance = Bool.__new__(Bool)
173
+ instance._c_managed = managed
174
+ instance._c_node = c_node
175
+ return instance
176
+
177
+ cdef class Integer(Node):
178
+ def __cinit__(self, object value=None, *args, **kwargs):
179
+ if value is None:
180
+ self._c_node = plist_new_uint(0)
181
+ else:
182
+ self._c_node = plist_new_uint(int(value))
183
+
184
+ def __repr__(self):
185
+ cdef uint64_t i = self.get_value()
186
+ return '<Integer: %s>' % i
187
+
188
+ def __int__(self):
189
+ return self.get_value()
190
+
191
+ def __float__(self):
192
+ return float(self.get_value())
193
+
194
+ def __richcmp__(self, other, op):
195
+ cdef int i = self.get_value()
196
+ if op == 0:
197
+ return i < other
198
+ if op == 1:
199
+ return i <= other
200
+ if op == 2:
201
+ return i == other
202
+ if op == 3:
203
+ return i != other
204
+ if op == 4:
205
+ return i > other
206
+ if op == 5:
207
+ return i >= other
208
+
209
+ cpdef set_value(self, object value):
210
+ plist_set_uint_val(self._c_node, int(value))
211
+
212
+ cpdef uint64_t get_value(self):
213
+ cdef uint64_t value
214
+ plist_get_uint_val(self._c_node, &value)
215
+ return value
216
+
217
+ cdef Integer Integer_factory(plist_t c_node, bint managed=True):
218
+ cdef Integer instance = Integer.__new__(Integer)
219
+ instance._c_managed = managed
220
+ instance._c_node = c_node
221
+ return instance
222
+
223
+ cdef class Real(Node):
224
+ def __cinit__(self, object value=None, *args, **kwargs):
225
+ if value is None:
226
+ self._c_node = plist_new_real(0.0)
227
+ else:
228
+ self._c_node = plist_new_real(float(value))
229
+
230
+ def __repr__(self):
231
+ r = self.get_value()
232
+ return '<Real: %s>' % r
233
+
234
+ def __float__(self):
235
+ return self.get_value()
236
+
237
+ def __int__(self):
238
+ return int(self.get_value())
239
+
240
+ def __richcmp__(self, other, op):
241
+ cdef float f = self.get_value()
242
+ if op == 0:
243
+ return f < other
244
+ if op == 1:
245
+ return f <= other
246
+ if op == 2:
247
+ return f == other
248
+ if op == 3:
249
+ return f != other
250
+ if op == 4:
251
+ return f > other
252
+ if op == 5:
253
+ return f >= other
254
+
255
+ cpdef set_value(self, object value):
256
+ plist_set_real_val(self._c_node, float(value))
257
+
258
+ cpdef float get_value(self):
259
+ cdef double value
260
+ plist_get_real_val(self._c_node, &value)
261
+ return value
262
+
263
+ cdef Real Real_factory(plist_t c_node, bint managed=True):
264
+ cdef Real instance = Real.__new__(Real)
265
+ instance._c_managed = managed
266
+ instance._c_node = c_node
267
+ return instance
268
+
269
+ cdef class Uid(Node):
270
+ def __cinit__(self, object value=None, *args, **kwargs):
271
+ if value is None:
272
+ self._c_node = plist_new_uid(0)
273
+ else:
274
+ self._c_node = plist_new_uid(int(value))
275
+
276
+ def __repr__(self):
277
+ cdef uint64_t i = self.get_value()
278
+ return '<Uid: %s>' % i
279
+
280
+ def __int__(self):
281
+ return self.get_value()
282
+
283
+ def __float__(self):
284
+ return float(self.get_value())
285
+
286
+ def __richcmp__(self, other, op):
287
+ cdef int i = self.get_value()
288
+ if op == 0:
289
+ return i < other
290
+ if op == 1:
291
+ return i <= other
292
+ if op == 2:
293
+ return i == other
294
+ if op == 3:
295
+ return i != other
296
+ if op == 4:
297
+ return i > other
298
+ if op == 5:
299
+ return i >= other
300
+
301
+ cpdef set_value(self, object value):
302
+ plist_set_uid_val(self._c_node, int(value))
303
+
304
+ cpdef uint64_t get_value(self):
305
+ cdef uint64_t value
306
+ plist_get_uid_val(self._c_node, &value)
307
+ return value
308
+
309
+ cdef Uid Uid_factory(plist_t c_node, bint managed=True):
310
+ cdef Uid instance = Uid.__new__(Uid)
311
+ instance._c_managed = managed
312
+ instance._c_node = c_node
313
+ return instance
314
+
315
+ from cpython cimport PY_MAJOR_VERSION
316
+
317
+ cdef class Key(Node):
318
+ def __cinit__(self, object value=None, *args, **kwargs):
319
+ cdef:
320
+ char* c_utf8_data = NULL
321
+ bytes utf8_data
322
+ if value is None:
323
+ raise ValueError("Requires a value")
324
+ else:
325
+ if isinstance(value, unicode):
326
+ utf8_data = value.encode('utf-8')
327
+ elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
328
+ value.encode('ascii') # trial decode
329
+ utf8_data = value.encode('ascii')
330
+ else:
331
+ raise ValueError("Requires unicode input, got %s" % type(value))
332
+ c_utf8_data = utf8_data
333
+ self._c_node = plist_new_string("")
334
+ plist_set_key_val(self._c_node, c_utf8_data)
335
+
336
+ def __repr__(self):
337
+ s = self.get_value()
338
+ return '<Key: %s>' % s.encode('utf-8')
339
+
340
+ def __richcmp__(self, other, op):
341
+ cdef unicode s = self.get_value()
342
+ if op == 0:
343
+ return s < other
344
+ if op == 1:
345
+ return s <= other
346
+ if op == 2:
347
+ return s == other
348
+ if op == 3:
349
+ return s != other
350
+ if op == 4:
351
+ return s > other
352
+ if op == 5:
353
+ return s >= other
354
+
355
+ cpdef set_value(self, object value):
356
+ cdef:
357
+ char* c_utf8_data = NULL
358
+ bytes utf8_data
359
+ if value is None:
360
+ plist_set_key_val(self._c_node, c_utf8_data)
361
+ else:
362
+ if isinstance(value, unicode):
363
+ utf8_data = value.encode('utf-8')
364
+ elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
365
+ value.encode('ascii') # trial decode
366
+ utf8_data = value.encode('ascii')
367
+ else:
368
+ raise ValueError("Requires unicode input, got %s" % type(value))
369
+ c_utf8_data = utf8_data
370
+ plist_set_key_val(self._c_node, c_utf8_data)
371
+
372
+ cpdef unicode get_value(self):
373
+ cdef:
374
+ char* c_value = NULL
375
+ plist_get_key_val(self._c_node, &c_value)
376
+ try:
377
+ return cpython.PyUnicode_DecodeUTF8(c_value, len(c_value), 'strict')
378
+ finally:
379
+ libc.stdlib.free(c_value)
380
+
381
+ cdef Key Key_factory(plist_t c_node, bint managed=True):
382
+ cdef Key instance = Key.__new__(Key)
383
+ instance._c_managed = managed
384
+ instance._c_node = c_node
385
+ return instance
386
+
387
+ cdef class String(Node):
388
+ def __cinit__(self, object value=None, *args, **kwargs):
389
+ cdef:
390
+ char* c_utf8_data = NULL
391
+ bytes utf8_data
392
+ if value is None:
393
+ self._c_node = plist_new_string("")
394
+ else:
395
+ if isinstance(value, unicode):
396
+ utf8_data = value.encode('utf-8')
397
+ elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
398
+ value.encode('ascii') # trial decode
399
+ utf8_data = value.encode('ascii')
400
+ else:
401
+ raise ValueError("Requires unicode input, got %s" % type(value))
402
+ c_utf8_data = utf8_data
403
+ self._c_node = plist_new_string(c_utf8_data)
404
+
405
+ def __repr__(self):
406
+ s = self.get_value()
407
+ return '<String: %s>' % s.encode('utf-8')
408
+
409
+ def __richcmp__(self, other, op):
410
+ cdef unicode s = self.get_value()
411
+ if op == 0:
412
+ return s < other
413
+ if op == 1:
414
+ return s <= other
415
+ if op == 2:
416
+ return s == other
417
+ if op == 3:
418
+ return s != other
419
+ if op == 4:
420
+ return s > other
421
+ if op == 5:
422
+ return s >= other
423
+
424
+ cpdef set_value(self, object value):
425
+ cdef:
426
+ char* c_utf8_data = NULL
427
+ bytes utf8_data
428
+ if value is None:
429
+ plist_set_string_val(self._c_node, c_utf8_data)
430
+ else:
431
+ if isinstance(value, unicode):
432
+ utf8_data = value.encode('utf-8')
433
+ elif (PY_MAJOR_VERSION < 3) and isinstance(value, str):
434
+ value.encode('ascii') # trial decode
435
+ utf8_data = value.encode('ascii')
436
+ else:
437
+ raise ValueError("Requires unicode input, got %s" % type(value))
438
+ c_utf8_data = utf8_data
439
+ plist_set_string_val(self._c_node, c_utf8_data)
440
+
441
+ cpdef unicode get_value(self):
442
+ cdef:
443
+ char* c_value = NULL
444
+ plist_get_string_val(self._c_node, &c_value)
445
+ try:
446
+ return cpython.PyUnicode_DecodeUTF8(c_value, len(c_value), 'strict')
447
+ finally:
448
+ libc.stdlib.free(c_value)
449
+
450
+ cdef String String_factory(plist_t c_node, bint managed=True):
451
+ cdef String instance = String.__new__(String)
452
+ instance._c_managed = managed
453
+ instance._c_node = c_node
454
+ return instance
455
+
456
+ MAC_EPOCH = 978307200
457
+
458
+ cdef extern from "plist_util.h":
459
+ void datetime_to_ints(object obj, int32_t* sec, int32_t* usec)
460
+ object ints_to_datetime(int32_t sec, int32_t usec)
461
+ int check_datetime(object obj)
462
+
463
+ cdef plist_t create_date_plist(value=None):
464
+ cdef plist_t node = NULL
465
+ cdef int32_t secs
466
+ cdef int32_t usecs
467
+ if value is None:
468
+ node = plist_new_date(0, 0)
469
+ elif check_datetime(value):
470
+ datetime_to_ints(value, &secs, &usecs)
471
+ secs -= MAC_EPOCH
472
+ node = plist_new_date(secs, usecs)
473
+ return node
474
+
475
+ cdef class Date(Node):
476
+ def __cinit__(self, object value=None, *args, **kwargs):
477
+ self._c_node = create_date_plist(value)
478
+
479
+ def __repr__(self):
480
+ d = self.get_value()
481
+ return '<Date: %s>' % d.ctime()
482
+
483
+ def __richcmp__(self, other, op):
484
+ d = self.get_value()
485
+ if op == 0:
486
+ return d < other
487
+ if op == 1:
488
+ return d <= other
489
+ if op == 2:
490
+ return d == other
491
+ if op == 3:
492
+ return d != other
493
+ if op == 4:
494
+ return d > other
495
+ if op == 5:
496
+ return d >= other
497
+
498
+ cpdef object get_value(self):
499
+ cdef int32_t secs = 0
500
+ cdef int32_t usecs = 0
501
+ plist_get_date_val(self._c_node, &secs, &usecs)
502
+ secs += MAC_EPOCH
503
+ return ints_to_datetime(secs, usecs)
504
+
505
+ cpdef set_value(self, object value):
506
+ cdef int32_t secs
507
+ cdef int32_t usecs
508
+ if not check_datetime(value):
509
+ raise ValueError("Expected a datetime")
510
+ datetime_to_ints(value, &secs, &usecs)
511
+ plist_set_date_val(self._c_node, secs, usecs)
512
+
513
+ cdef Date Date_factory(plist_t c_node, bint managed=True):
514
+ cdef Date instance = Date.__new__(Date)
515
+ instance._c_managed = managed
516
+ instance._c_node = c_node
517
+ return instance
518
+
519
+ cdef class Data(Node):
520
+ def __cinit__(self, object value=None, *args, **kwargs):
521
+ if value is None:
522
+ self._c_node = plist_new_data(NULL, 0)
523
+ else:
524
+ self._c_node = plist_new_data(value, len(value))
525
+
526
+ def __repr__(self):
527
+ d = self.get_value()
528
+ return '<Data: %s>' % d
529
+
530
+ def __richcmp__(self, other, op):
531
+ cdef bytes d = self.get_value()
532
+ if op == 0:
533
+ return d < other
534
+ if op == 1:
535
+ return d <= other
536
+ if op == 2:
537
+ return d == other
538
+ if op == 3:
539
+ return d != other
540
+ if op == 4:
541
+ return d > other
542
+ if op == 5:
543
+ return d >= other
544
+
545
+ cpdef bytes get_value(self):
546
+ cdef:
547
+ char* val = NULL
548
+ uint64_t length = 0
549
+ plist_get_data_val(self._c_node, &val, &length)
550
+
551
+ try:
552
+ return bytes(val[:length])
553
+ finally:
554
+ libc.stdlib.free(val)
555
+
556
+ cpdef set_value(self, object value):
557
+ cdef:
558
+ bytes py_val = value
559
+ plist_set_data_val(self._c_node, py_val, len(value))
560
+
561
+ cdef Data Data_factory(plist_t c_node, bint managed=True):
562
+ cdef Data instance = Data.__new__(Data)
563
+ instance._c_managed = managed
564
+ instance._c_node = c_node
565
+ return instance
566
+
567
+ cdef plist_t create_dict_plist(object value=None):
568
+ cdef plist_t node = NULL
569
+ cdef plist_t c_node = NULL
570
+ node = plist_new_dict()
571
+ if value is not None and isinstance(value, dict):
572
+ for key, item in value.items():
573
+ c_node = native_to_plist_t(item)
574
+ plist_dict_set_item(node, key, c_node)
575
+ c_node = NULL
576
+ return node
577
+
578
+ cimport cpython
579
+
580
+ cdef class Dict(Node):
581
+ def __cinit__(self, object value=None, *args, **kwargs):
582
+ self._c_node = create_dict_plist(value)
583
+
584
+ def __init__(self, value=None, *args, **kwargs):
585
+ self._init()
586
+
587
+ cdef void _init(self):
588
+ cdef plist_dict_iter it = NULL
589
+ cdef char* key = NULL
590
+ cdef plist_t subnode = NULL
591
+
592
+ self._map = cpython.PyDict_New()
593
+
594
+ plist_dict_new_iter(self._c_node, &it);
595
+ plist_dict_next_item(self._c_node, it, &key, &subnode);
596
+
597
+ while subnode is not NULL:
598
+ py_key = key
599
+
600
+ if PY_MAJOR_VERSION >= 3:
601
+ py_key = py_key.decode('utf-8')
602
+
603
+ cpython.PyDict_SetItem(self._map, py_key, plist_t_to_node(subnode, False))
604
+ subnode = NULL
605
+ libc.stdlib.free(key)
606
+ key = NULL
607
+ plist_dict_next_item(self._c_node, it, &key, &subnode);
608
+ libc.stdlib.free(it)
609
+
610
+ def __dealloc__(self):
611
+ self._map = None
612
+
613
+ def __richcmp__(self, other, op):
614
+ cdef dict d = self.get_value()
615
+ if op == 0:
616
+ return d < other
617
+ if op == 1:
618
+ return d <= other
619
+ if op == 2:
620
+ return d == other
621
+ if op == 3:
622
+ return d != other
623
+ if op == 4:
624
+ return d > other
625
+ if op == 5:
626
+ return d >= other
627
+
628
+ def __len__(self):
629
+ return cpython.PyDict_Size(self._map)
630
+
631
+ def __repr__(self):
632
+ return '<Dict: %s>' % self._map
633
+
634
+ cpdef dict get_value(self):
635
+ return dict([(key, value.get_value()) for key, value in self.items()])
636
+
637
+ cpdef set_value(self, dict value):
638
+ plist_free(self._c_node)
639
+ self._map = {}
640
+ self._c_node = NULL
641
+ self._c_node = create_dict_plist(value)
642
+ self._init()
643
+
644
+ def __iter__(self):
645
+ return self._map.__iter__()
646
+
647
+ cpdef bint has_key(self, key):
648
+ return self._map.has_key(key)
649
+
650
+ cpdef object get(self, key, default=None):
651
+ return self._map.get(key, default)
652
+
653
+ cpdef list keys(self):
654
+ return cpython.PyDict_Keys(self._map)
655
+
656
+ cpdef object iterkeys(self):
657
+ return self._map.iterkeys()
658
+
659
+ cpdef list items(self):
660
+ return cpython.PyDict_Items(self._map)
661
+
662
+ cpdef object iteritems(self):
663
+ return self._map.iteritems()
664
+
665
+ cpdef list values(self):
666
+ return cpython.PyDict_Values(self._map)
667
+
668
+ cpdef object itervalues(self):
669
+ return self._map.itervalues()
670
+
671
+ def __getitem__(self, key):
672
+ return self._map[key]
673
+
674
+ def __setitem__(self, key, value):
675
+ cdef Node n
676
+ if isinstance(value, Node):
677
+ n = value.copy()
678
+ else:
679
+ n = plist_t_to_node(native_to_plist_t(value), False)
680
+
681
+ plist_dict_set_item(self._c_node, key, n._c_node)
682
+ self._map[key] = n
683
+
684
+ def __delitem__(self, key):
685
+ cpython.PyDict_DelItem(self._map, key)
686
+ plist_dict_remove_item(self._c_node, key)
687
+
688
+ cdef Dict Dict_factory(plist_t c_node, bint managed=True):
689
+ cdef Dict instance = Dict.__new__(Dict)
690
+ instance._c_managed = managed
691
+ instance._c_node = c_node
692
+ instance._init()
693
+ return instance
694
+
695
+ cdef plist_t create_array_plist(object value=None):
696
+ cdef plist_t node = NULL
697
+ cdef plist_t c_node = NULL
698
+ node = plist_new_array()
699
+ if value is not None and (isinstance(value, list) or isinstance(value, tuple)):
700
+ for item in value:
701
+ c_node = native_to_plist_t(item)
702
+ plist_array_append_item(node, c_node)
703
+ c_node = NULL
704
+ return node
705
+
706
+ cdef class Array(Node):
707
+ def __cinit__(self, object value=None, *args, **kwargs):
708
+ self._c_node = create_array_plist(value)
709
+
710
+ def __init__(self, value=None, *args, **kwargs):
711
+ self._init()
712
+
713
+ cdef void _init(self):
714
+ self._array = []
715
+ cdef uint32_t size = plist_array_get_size(self._c_node)
716
+ cdef plist_t subnode = NULL
717
+
718
+ for i in range(size):
719
+ subnode = plist_array_get_item(self._c_node, i)
720
+ self._array.append(plist_t_to_node(subnode, False))
721
+
722
+ def __richcmp__(self, other, op):
723
+ cdef list l = self.get_value()
724
+ if op == 0:
725
+ return l < other
726
+ if op == 1:
727
+ return l <= other
728
+ if op == 2:
729
+ return l == other
730
+ if op == 3:
731
+ return l != other
732
+ if op == 4:
733
+ return l > other
734
+ if op == 5:
735
+ return l >= other
736
+
737
+ def __len__(self):
738
+ return len(self._array)
739
+
740
+ def __repr__(self):
741
+ return '<Array: %s>' % self._array
742
+
743
+ cpdef list get_value(self):
744
+ return [i.get_value() for i in self]
745
+
746
+ cpdef set_value(self, object value):
747
+ self._array = []
748
+ plist_free(self._c_node)
749
+ self._c_node = NULL
750
+ self._c_node = create_array_plist(value)
751
+ self._init()
752
+
753
+ def __iter__(self):
754
+ return self._array.__iter__()
755
+
756
+ def __getitem__(self, index):
757
+ return self._array[index]
758
+
759
+ def __setitem__(self, index, value):
760
+ cdef Node n
761
+ if isinstance(value, Node):
762
+ n = value.copy()
763
+ else:
764
+ n = plist_t_to_node(native_to_plist_t(value), False)
765
+
766
+ if index < 0:
767
+ index = len(self) + index
768
+
769
+ plist_array_set_item(self._c_node, n._c_node, index)
770
+ self._array[index] = n
771
+
772
+ def __delitem__(self, index):
773
+ if index < 0:
774
+ index = len(self) + index
775
+ del self._array[index]
776
+ plist_array_remove_item(self._c_node, index)
777
+
778
+ cpdef append(self, object item):
779
+ cdef Node n
780
+
781
+ if isinstance(item, Node):
782
+ n = item.copy()
783
+ else:
784
+ n = plist_t_to_node(native_to_plist_t(item), False)
785
+
786
+ plist_array_append_item(self._c_node, n._c_node)
787
+ self._array.append(n)
788
+
789
+ cdef Array Array_factory(plist_t c_node, bint managed=True):
790
+ cdef Array instance = Array.__new__(Array)
791
+ instance._c_managed = managed
792
+ instance._c_node = c_node
793
+ instance._init()
794
+ return instance
795
+
796
+ cpdef object from_xml(xml):
797
+ cdef plist_t c_node = NULL
798
+ plist_from_xml(xml, len(xml), &c_node)
799
+ return plist_t_to_node(c_node)
800
+
801
+ cpdef object from_bin(bytes bin):
802
+ cdef plist_t c_node = NULL
803
+ plist_from_bin(bin, len(bin), &c_node)
804
+ return plist_t_to_node(c_node)
805
+
806
+ cdef plist_t native_to_plist_t(object native):
807
+ cdef plist_t c_node
808
+ cdef plist_t child_c_node
809
+ cdef int32_t secs = 0
810
+ cdef int32_t usecs = 0
811
+ cdef Node node
812
+ if isinstance(native, Node):
813
+ node = native
814
+ return plist_copy(node._c_node)
815
+ if isinstance(native, basestring):
816
+ return plist_new_string(native)
817
+ if isinstance(native, bool):
818
+ return plist_new_bool(<bint>native)
819
+ if isinstance(native, int) or isinstance(native, long):
820
+ return plist_new_uint(native)
821
+ if isinstance(native, float):
822
+ return plist_new_real(native)
823
+ if isinstance(native, dict):
824
+ return create_dict_plist(native)
825
+ if isinstance(native, list) or isinstance(native, tuple):
826
+ return create_array_plist(native)
827
+ if check_datetime(native):
828
+ return create_date_plist(native)
829
+
830
+ cdef object plist_t_to_node(plist_t c_plist, bint managed=True):
831
+ cdef plist_type t = plist_get_node_type(c_plist)
832
+ if t == PLIST_BOOLEAN:
833
+ return Bool_factory(c_plist, managed)
834
+ if t == PLIST_UINT:
835
+ return Integer_factory(c_plist, managed)
836
+ if t == PLIST_KEY:
837
+ return Key_factory(c_plist, managed)
838
+ if t == PLIST_REAL:
839
+ return Real_factory(c_plist, managed)
840
+ if t == PLIST_STRING:
841
+ return String_factory(c_plist, managed)
842
+ if t == PLIST_ARRAY:
843
+ return Array_factory(c_plist, managed)
844
+ if t == PLIST_DICT:
845
+ return Dict_factory(c_plist, managed)
846
+ if t == PLIST_DATE:
847
+ return Date_factory(c_plist, managed)
848
+ if t == PLIST_DATA:
849
+ return Data_factory(c_plist, managed)
850
+ if t == PLIST_UID:
851
+ return Uid_factory(c_plist, managed)
852
+ if t == PLIST_NONE:
853
+ return None
854
+
855
+ # This is to match up with the new plistlib API
856
+ # http://docs.python.org/dev/library/plistlib.html
857
+ # dump() and dumps() are not yet implemented
858
+ FMT_XML = 1
859
+ FMT_BINARY = 2
860
+
861
+ cpdef object load(fp, fmt=None, use_builtin_types=True, dict_type=dict):
862
+ is_binary = fp.read(6) == 'bplist'
863
+ fp.seek(0)
864
+
865
+ cdef object cb = None
866
+
867
+ if not fmt:
868
+ if is_binary:
869
+ if 'b' not in fp.mode:
870
+ raise IOError('File handle must be opened in binary (b) mode to read binary property lists')
871
+ cb = from_bin
872
+ else:
873
+ cb = from_xml
874
+ else:
875
+ if fmt not in (FMT_XML, FMT_BINARY):
876
+ raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
877
+ if fmt == FMT_BINARY:
878
+ cb = from_bin
879
+ elif fmt == FMT_XML:
880
+ cb = from_xml
881
+
882
+ if is_binary and fmt == FMT_XML:
883
+ raise ValueError('Cannot parse binary property list as XML')
884
+ elif not is_binary and fmt == FMT_BINARY:
885
+ raise ValueError('Cannot parse XML property list as binary')
886
+
887
+ return cb(fp.read())
888
+
889
+ cpdef object loads(data, fmt=None, use_builtin_types=True, dict_type=dict):
890
+ is_binary = data[0:6] == 'bplist'
891
+
892
+ cdef object cb = None
893
+
894
+ if fmt is not None:
895
+ if fmt not in (FMT_XML, FMT_BINARY):
896
+ raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
897
+ if fmt == FMT_BINARY:
898
+ cb = from_bin
899
+ else:
900
+ cb = from_xml
901
+ else:
902
+ if is_binary:
903
+ cb = from_bin
904
+ else:
905
+ cb = from_xml
906
+
907
+ if is_binary and fmt == FMT_XML:
908
+ raise ValueError('Cannot parse binary property list as XML')
909
+ elif not is_binary and fmt == FMT_BINARY:
910
+ raise ValueError('Cannot parse XML property list as binary')
911
+
912
+ return cb(data)
913
+
914
+ cpdef object dump(value, fp, fmt=FMT_XML, sort_keys=True, skipkeys=False):
915
+ fp.write(dumps(value, fmt=fmt))
916
+
917
+ cpdef object dumps(value, fmt=FMT_XML, sort_keys=True, skipkeys=False):
918
+ if fmt not in (FMT_XML, FMT_BINARY):
919
+ raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
920
+
921
+ if check_datetime(value):
922
+ node = Date(value)
923
+ elif isinstance(value, unicode):
924
+ node = String(value)
925
+ elif PY_MAJOR_VERSION >= 3 and isinstance(value, bytes):
926
+ node = Data(value)
927
+ elif isinstance(value, str):
928
+ # See if this is binary
929
+ try:
930
+ node = String(value)
931
+ except ValueError:
932
+ node = Data(value)
933
+ elif isinstance(value, bool):
934
+ node = Bool(value)
935
+ elif isinstance(value, int):
936
+ node = Integer(value)
937
+ elif isinstance(value, float):
938
+ node = Real(value)
939
+ elif isinstance(value, dict):
940
+ node = Dict(value)
941
+ elif type(value) in (list, set, tuple):
942
+ node = Array(value)
943
+
944
+ if fmt == FMT_XML:
945
+ return node.to_xml()
946
+
947
+ return node.to_bin()