neutralino-python 0.1.0rc1__py3-none-any.whl
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.
- neutralino/__init__.py +88 -0
- neutralino/_catalog.py +297 -0
- neutralino/_data/LICENSE.neutralino-js-client +21 -0
- neutralino/_data/LICENSE.neutralinojs +1066 -0
- neutralino/_data/docs/cli.md +315 -0
- neutralino/_data/docs/custom-components.md +107 -0
- neutralino/_data/docs/custom-frontends.md +80 -0
- neutralino/_data/docs/desktop-helpers.md +296 -0
- neutralino/_data/docs/guide.md +131 -0
- neutralino/_data/docs/llms-full.txt +3921 -0
- neutralino/_data/docs/llms.txt +43 -0
- neutralino/_data/docs/manifests/components.json +20128 -0
- neutralino/_data/docs/manifests/examples.json +52 -0
- neutralino/_data/docs/manifests/native.json +3024 -0
- neutralino/_data/docs/manifests/schema.json +43 -0
- neutralino/_data/docs/manual-checklist.md +189 -0
- neutralino/_data/docs/packaging.md +252 -0
- neutralino/_data/docs/performance.md +15 -0
- neutralino/_data/docs/platforms.md +15 -0
- neutralino/_data/docs/reference/components.md +1685 -0
- neutralino/_data/docs/reference/native.md +148 -0
- neutralino/_data/docs/security.md +60 -0
- neutralino/_data/docs/ui.md +249 -0
- neutralino/_data/docs/updates.md +366 -0
- neutralino/_data/examples/README.md +6 -0
- neutralino/_data/examples/crud/README.md +36 -0
- neutralino/_data/examples/crud/app.py +243 -0
- neutralino/_data/examples/dashboard/README.md +36 -0
- neutralino/_data/examples/dashboard/app.py +367 -0
- neutralino/_data/examples/editor/README.md +35 -0
- neutralino/_data/examples/editor/app.py +190 -0
- neutralino/_data/examples/file-manager/README.md +40 -0
- neutralino/_data/examples/file-manager/app.py +120 -0
- neutralino/_data/examples/file-manager/frontend/index.html +20 -0
- neutralino/_data/examples/file-manager/frontend/main.js +55 -0
- neutralino/_data/examples/file-manager/frontend/neutralino.js +1 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/file-manager/frontend/style.css +4 -0
- neutralino/_data/examples/hybrid/README.md +48 -0
- neutralino/_data/examples/hybrid/app.py +80 -0
- neutralino/_data/examples/hybrid/components/counter.mjs +37 -0
- neutralino/_data/examples/hybrid/components/widget.mjs +23 -0
- neutralino/_data/examples/hybrid/styles.css +21 -0
- neutralino/_data/examples/hybrid/widget/package.json +20 -0
- neutralino/_data/examples/hybrid/widget/src/Widget.jsx +25 -0
- neutralino/_data/examples/hybrid/widget/vite.config.mjs +19 -0
- neutralino/_data/examples/monitor/README.md +36 -0
- neutralino/_data/examples/monitor/app.py +375 -0
- neutralino/_data/examples/react/README.md +90 -0
- neutralino/_data/examples/react/app.py +68 -0
- neutralino/_data/examples/react/frontend/.gitignore +5 -0
- neutralino/_data/examples/react/frontend/index.html +17 -0
- neutralino/_data/examples/react/frontend/package-lock.json +1232 -0
- neutralino/_data/examples/react/frontend/package.json +25 -0
- neutralino/_data/examples/react/frontend/scripts/prepare-bridge.mjs +49 -0
- neutralino/_data/examples/react/frontend/src/App.tsx +157 -0
- neutralino/_data/examples/react/frontend/src/backend.ts +21 -0
- neutralino/_data/examples/react/frontend/src/calls.test.ts +206 -0
- neutralino/_data/examples/react/frontend/src/calls.ts +306 -0
- neutralino/_data/examples/react/frontend/src/globals.d.ts +14 -0
- neutralino/_data/examples/react/frontend/src/hooks.ts +45 -0
- neutralino/_data/examples/react/frontend/src/main.tsx +13 -0
- neutralino/_data/examples/react/frontend/src/styles.css +11 -0
- neutralino/_data/examples/react/frontend/tsconfig.json +18 -0
- neutralino/_data/examples/react/frontend/vite.config.ts +9 -0
- neutralino/_data/examples/settings/README.md +38 -0
- neutralino/_data/examples/settings/app.py +440 -0
- neutralino/_data/examples/updater/.gitignore +2 -0
- neutralino/_data/examples/updater/README.md +82 -0
- neutralino/_data/examples/updater/app.py +160 -0
- neutralino/_data/examples/updater/app.toml +21 -0
- neutralino/_data/examples/updater/demo.py +107 -0
- neutralino/_data/examples/updater/requirements.txt +2 -0
- neutralino/_data/examples/updater/sources/github-private.toml +21 -0
- neutralino/_data/examples/updater/sources/github-public.toml +21 -0
- neutralino/_data/examples/vanilla/README.md +35 -0
- neutralino/_data/examples/vanilla/app.py +46 -0
- neutralino/_data/examples/vanilla/frontend/index.html +17 -0
- neutralino/_data/examples/vanilla/frontend/main.js +29 -0
- neutralino/_data/examples/vanilla/frontend/neutralino.js +1 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/vanilla/frontend/style.css +4 -0
- neutralino/_data/explorer/app.py +1328 -0
- neutralino/_data/explorer/catalogue.json +48179 -0
- neutralino/_data/explorer/explorer_previews.py +247 -0
- neutralino/_data/explorer/sources/native/always_on_top.py +55 -0
- neutralino/_data/explorer/sources/native/binary.py +125 -0
- neutralino/_data/explorer/sources/native/borderless.py +99 -0
- neutralino/_data/explorer/sources/native/broadcast.py +90 -0
- neutralino/_data/explorer/sources/native/config.py +78 -0
- neutralino/_data/explorer/sources/native/controls.py +140 -0
- neutralino/_data/explorer/sources/native/directory.py +163 -0
- neutralino/_data/explorer/sources/native/displays.py +75 -0
- neutralino/_data/explorer/sources/native/env.py +98 -0
- neutralino/_data/explorer/sources/native/events.py +124 -0
- neutralino/_data/explorer/sources/native/exec_command.py +79 -0
- neutralino/_data/explorer/sources/native/folder.py +70 -0
- neutralino/_data/explorer/sources/native/icon_badge.py +101 -0
- neutralino/_data/explorer/sources/native/image.py +119 -0
- neutralino/_data/explorer/sources/native/lifecycle.py +99 -0
- neutralino/_data/explorer/sources/native/locale.py +70 -0
- neutralino/_data/explorer/sources/native/main_menu.py +103 -0
- neutralino/_data/explorer/sources/native/message_box.py +101 -0
- neutralino/_data/explorer/sources/native/mouse.py +70 -0
- neutralino/_data/explorer/sources/native/multi_window.py +134 -0
- neutralino/_data/explorer/sources/native/notification.py +74 -0
- neutralino/_data/explorer/sources/native/open_external.py +81 -0
- neutralino/_data/explorer/sources/native/open_file.py +102 -0
- neutralino/_data/explorer/sources/native/paths.py +77 -0
- neutralino/_data/explorer/sources/native/print_snapshot.py +84 -0
- neutralino/_data/explorer/sources/native/read_write.py +192 -0
- neutralino/_data/explorer/sources/native/resources.py +110 -0
- neutralino/_data/explorer/sources/native/save_file.py +101 -0
- neutralino/_data/explorer/sources/native/server_mount.py +106 -0
- neutralino/_data/explorer/sources/native/sound.py +84 -0
- neutralino/_data/explorer/sources/native/spawn_process.py +128 -0
- neutralino/_data/explorer/sources/native/states.py +122 -0
- neutralino/_data/explorer/sources/native/stats_permissions.py +147 -0
- neutralino/_data/explorer/sources/native/storage.py +108 -0
- neutralino/_data/explorer/sources/native/system_info.py +115 -0
- neutralino/_data/explorer/sources/native/text.py +133 -0
- neutralino/_data/explorer/sources/native/trash.py +98 -0
- neutralino/_data/explorer/sources/native/tray.py +109 -0
- neutralino/_data/explorer/sources/native/watcher.py +167 -0
- neutralino/_data/explorer/sources/patterns/content_blocks.py +119 -0
- neutralino/_data/explorer/sources/patterns/dynamic_dashboard.py +121 -0
- neutralino/_data/explorer/sources/patterns/dynamic_form.py +120 -0
- neutralino/_data/explorer/sources/patterns/dynamic_table.py +109 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.mjs +24 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.py +124 -0
- neutralino/_data/explorer/sources/patterns/errors_timeouts.py +108 -0
- neutralino/_data/explorer/sources/patterns/feature_flags.py +99 -0
- neutralino/_data/explorer/sources/patterns/file_drop.py +126 -0
- neutralino/_data/explorer/sources/patterns/http_from_python.py +152 -0
- neutralino/_data/explorer/sources/patterns/keyboard_shortcuts.py +153 -0
- neutralino/_data/explorer/sources/patterns/live_config_reload.py +160 -0
- neutralino/_data/explorer/sources/patterns/logging.py +184 -0
- neutralino/_data/explorer/sources/patterns/long_tasks.py +121 -0
- neutralino/_data/explorer/sources/patterns/multi_window_sync.py +68 -0
- neutralino/_data/explorer/sources/patterns/navigation_from_backend.py +109 -0
- neutralino/_data/explorer/sources/patterns/onboarding.py +123 -0
- neutralino/_data/explorer/sources/patterns/optimistic_updates.py +89 -0
- neutralino/_data/explorer/sources/patterns/persistence.py +114 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.mjs +10 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.py +64 -0
- neutralino/_data/explorer/sources/patterns/python_push.py +84 -0
- neutralino/_data/explorer/sources/patterns/recurring_events.py +114 -0
- neutralino/_data/explorer/sources/patterns/roles_permissions.py +104 -0
- neutralino/_data/explorer/sources/patterns/scheduled_jobs.py +194 -0
- neutralino/_data/explorer/sources/patterns/settings_page.py +165 -0
- neutralino/_data/explorer/sources/patterns/sqlite.py +181 -0
- neutralino/_data/explorer/sources/patterns/streaming.py +102 -0
- neutralino/_data/explorer/sources/patterns/texts_i18n.py +81 -0
- neutralino/_data/explorer/sources/patterns/theme_from_backend.py +86 -0
- neutralino/_data/explorer/sources/patterns/updater.py +232 -0
- neutralino/_data/explorer/sources/workspace/calendar/app.py +547 -0
- neutralino/_data/explorer/sources/workspace/customers/app.py +467 -0
- neutralino/_data/explorer/sources/workspace/dashboard/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/dashboard/app.py +367 -0
- neutralino/_data/explorer/sources/workspace/documents/app.py +511 -0
- neutralino/_data/explorer/sources/workspace/inbox/app.py +439 -0
- neutralino/_data/explorer/sources/workspace/orders/app.py +491 -0
- neutralino/_data/explorer/sources/workspace/reports/app.py +386 -0
- neutralino/_data/explorer/sources/workspace/settings/README.md +38 -0
- neutralino/_data/explorer/sources/workspace/settings/app.py +440 -0
- neutralino/_data/explorer/sources/workspace/system/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/system/app.py +375 -0
- neutralino/_data/explorer/sources/workspace/tasks/app.py +462 -0
- neutralino/_data/renderer/LICENSES/@babel__runtime@7.29.17/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/@codemirror__autocomplete@6.20.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__commands@6.11.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-css@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-html@6.4.12/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-javascript@6.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-json@6.0.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-markdown@6.5.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-python@6.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-sql@6.10.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-yaml@6.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__language@6.13.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__search@6.7.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__state@6.7.6/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__view@6.44.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__accessibility@3.1.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__core@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__sortable@10.0.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__utilities@3.2.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@emoji-mart__data@1.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__core@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__dom@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react-dom@2.1.9/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react@0.27.20/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__utils@0.2.12/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@lezer__common@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__css@1.3.9/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__highlight@1.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__html@1.3.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__javascript@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__json@1.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__lr@1.4.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__markdown@1.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__python@1.1.21/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__yaml@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__carousel@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__charts@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__code-highlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__core@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dates@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dropzone@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__emoji@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__hooks@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__lightbox@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__notifications@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__nprogress@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__schedule@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__spotlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__store@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__tiptap@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@marijn__find-cluster-break@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@reduxjs__toolkit@2.16.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tabler__icons-react@3.55.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__react-virtual@3.14.32/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__virtual-core@3.19.17/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__core@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-blockquote@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-bold@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code-block@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-document@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-hard-break@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-heading@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-horizontal-rule@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-italic@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-link@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-list@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-paragraph@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-strike@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-text@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-underline@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extensions@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__react@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__starter-kit@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/attr-accept@4.0.1/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/clsx@2.1.1/license +9 -0
- neutralino/_data/renderer/LICENSES/crelt@1.0.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/d3-array@3.2.5/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-color@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-format@3.1.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-interpolate@3.0.2/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-path@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-scale@4.0.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-shape@3.2.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time-format@4.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/dayjs@1.11.23/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/decimal.js-light@2.5.1/LICENCE.md +23 -0
- neutralino/_data/renderer/LICENSES/diff@9.0.0/LICENSE +29 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE +202 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE-MPL +373 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-react@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-reactive-utils@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/NOTICE +39 -0
- neutralino/_data/renderer/LICENSES/eventemitter3@5.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/fast-equals@5.4.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/file-selector@5.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/get-nonce@1.0.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/immer@11.2.14/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/linkifyjs@4.4.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/marked@18.4.0/LICENSE +44 -0
- neutralino/_data/renderer/LICENSES/neutralino.js@6.11.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/orderedmap@2.1.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/packages.json +1838 -0
- neutralino/_data/renderer/LICENSES/prosemirror-commands@1.7.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-dropcursor@1.8.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-gapcursor@1.4.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-history@1.5.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-keymap@1.2.3/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-model@1.25.13/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-schema-list@1.6.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-state@1.4.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-transform@1.12.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-view@1.44.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/react-dom@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-dropzone@20.1.4/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/react-is@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-number-format@5.4.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-redux@9.3.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll-bar@2.3.8/MIT-react-remove-scroll-bar.txt +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll@2.7.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-style-singleton@2.2.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-transition-group@4.4.5/LICENSE +30 -0
- neutralino/_data/renderer/LICENSES/react@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/recharts@3.11.3/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/redux-thunk@3.1.0/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/redux@5.0.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/reselect@5.2.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/rolldown@1.3.4/LICENSE +25 -0
- neutralino/_data/renderer/LICENSES/rope-sequence@1.3.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/rrule@2.8.1/LICENCE +65 -0
- neutralino/_data/renderer/LICENSES/scheduler@0.28.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/style-mod@4.1.5/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/tiny-invariant@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/tslib@2.9.1/LICENSE.txt +12 -0
- neutralino/_data/renderer/LICENSES/use-callback-ref@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sidecar@1.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sync-external-store@1.7.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/victory-vendor@38.1.1/LICENSE.txt +150 -0
- neutralino/_data/renderer/LICENSES/vite@8.4.1/LICENSE.md +2320 -0
- neutralino/_data/renderer/LICENSES/w3c-keyname@2.2.8/LICENSE +19 -0
- neutralino/_data/renderer/assets/IconGripVertical-C2NUKJAE.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DHnOKa8c.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-CLVygP7p.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CXJaU0yv.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-DX0MbxKq.js +2 -0
- neutralino/_data/renderer/assets/css-BotC7byr.js +1 -0
- neutralino/_data/renderer/assets/dist-3kB5bJpS.js +23 -0
- neutralino/_data/renderer/assets/dist-6zrr4MrK.js +1 -0
- neutralino/_data/renderer/assets/dist-Beotrn8G.js +1 -0
- neutralino/_data/renderer/assets/dist-CCJHv8n0.js +11 -0
- neutralino/_data/renderer/assets/dist-CdYA9or5.js +1 -0
- neutralino/_data/renderer/assets/dist-D2p_6o_g.js +1 -0
- neutralino/_data/renderer/assets/dnd-DkNumIKC.js +5 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/dropzone-agrigkXv.js +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-_ztrE73N.js +1 -0
- neutralino/_data/renderer/assets/emoji-Cj3VQHg8.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-DbOmMyz5.js +82 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/highlight-LH6Cyuz6.js +3 -0
- neutralino/_data/renderer/assets/html-CpATC083.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-C-4QDF6w.js +1 -0
- neutralino/_data/renderer/assets/index-CqHW60Dy.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-D2QSKlDI.js +1 -0
- neutralino/_data/renderer/assets/json-D8zfYii3.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BijRfmPy.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-Cpthnhzg.js +77 -0
- neutralino/_data/renderer/assets/markdown-CsS2tf5C.js +5 -0
- neutralino/_data/renderer/assets/python-B477ud9A.js +9 -0
- neutralino/_data/renderer/assets/richtext-BwtgvH7-.js +137 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Db1pwUWd.js +1 -0
- neutralino/_data/renderer/assets/sql-DbpHRl6F.js +2 -0
- neutralino/_data/renderer/assets/with-selector-CUfuSYau.js +1 -0
- neutralino/_data/renderer/assets/yaml-BPsr1O3S.js +1 -0
- neutralino/_data/renderer/index.html +22 -0
- neutralino/_data/renderer/manifest.json +202 -0
- neutralino/_data/renderer/neutralino.js +1 -0
- neutralino/_data/renderer/shared/mantine-core.mjs +5 -0
- neutralino/_data/renderer/shared/mantine-hooks.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom-client.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom.mjs +6 -0
- neutralino/_data/renderer/shared/react-jsx-runtime.mjs +5 -0
- neutralino/_data/renderer/shared/react.mjs +6 -0
- neutralino/_data/skills/README.md +6 -0
- neutralino/_data/skills/neutralino-app-patterns/SKILL.md +101 -0
- neutralino/_data/skills/neutralino-app-patterns/references/dashboards-and-background-work.md +55 -0
- neutralino/_data/skills/neutralino-app-patterns/references/storage-and-settings.md +57 -0
- neutralino/_data/skills/neutralino-app-patterns/references/tables-and-crud.md +81 -0
- neutralino/_data/skills/neutralino-frontend/SKILL.md +121 -0
- neutralino/_data/skills/neutralino-frontend/references/bridge.md +63 -0
- neutralino/_data/skills/neutralino-frontend/references/custom-components.md +84 -0
- neutralino/_data/skills/neutralino-frontend/references/frameworks.md +61 -0
- neutralino/_data/skills/neutralino-maintenance/SKILL.md +85 -0
- neutralino/_data/skills/neutralino-maintenance/references/platforms-and-gates.md +35 -0
- neutralino/_data/skills/neutralino-maintenance/references/records.md +38 -0
- neutralino/_data/skills/neutralino-maintenance/references/review-process.md +36 -0
- neutralino/_data/skills/neutralino-native/SKILL.md +107 -0
- neutralino/_data/skills/neutralino-native/references/api-conventions.md +72 -0
- neutralino/_data/skills/neutralino-native/references/desktop-helpers.md +53 -0
- neutralino/_data/skills/neutralino-native/references/permissions-windows.md +53 -0
- neutralino/_data/skills/neutralino-packaging/SKILL.md +99 -0
- neutralino/_data/skills/neutralino-packaging/references/build-layout.md +51 -0
- neutralino/_data/skills/neutralino-packaging/references/managed-install.md +59 -0
- neutralino/_data/skills/neutralino-packaging/references/templates-and-config.md +63 -0
- neutralino/_data/skills/neutralino-python/SKILL.md +109 -0
- neutralino/_data/skills/neutralino-python/references/architecture.md +53 -0
- neutralino/_data/skills/neutralino-python/references/cli.md +60 -0
- neutralino/_data/skills/neutralino-python/references/platforms-security.md +44 -0
- neutralino/_data/skills/neutralino-rpc/SKILL.md +114 -0
- neutralino/_data/skills/neutralino-rpc/references/errors-and-limits.md +44 -0
- neutralino/_data/skills/neutralino-rpc/references/expose-and-context.md +74 -0
- neutralino/_data/skills/neutralino-rpc/references/streams-and-cancellation.md +53 -0
- neutralino/_data/skills/neutralino-ui/SKILL.md +115 -0
- neutralino/_data/skills/neutralino-ui/references/components-and-tree.md +74 -0
- neutralino/_data/skills/neutralino-ui/references/state-forms-events.md +85 -0
- neutralino/_data/skills/neutralino-ui/references/themes-profiles-assets.md +105 -0
- neutralino/_data/skills/neutralino-updates/SKILL.md +94 -0
- neutralino/_data/skills/neutralino-updates/references/config-and-api.md +80 -0
- neutralino/_data/skills/neutralino-updates/references/releases-and-install.md +77 -0
- neutralino/_data/skills/neutralino-updates/references/security-rollback.md +48 -0
- neutralino/_data/ui/contracts.json +32927 -0
- neutralino/_data/ui/emoji.json +1 -0
- neutralino/_data/upstream-lock.json +97 -0
- neutralino/_managed.py +1099 -0
- neutralino/_paths.py +220 -0
- neutralino/_platform.py +150 -0
- neutralino/_scaffold.py +344 -0
- neutralino/api/_base.py +99 -0
- neutralino/api/_custom.py +1350 -0
- neutralino/api/_dec.py +21 -0
- neutralino/api/_enc.py +80 -0
- neutralino/api/app.py +119 -0
- neutralino/api/clipboard.py +101 -0
- neutralino/api/computer.py +261 -0
- neutralino/api/custom.py +36 -0
- neutralino/api/debug.py +41 -0
- neutralino/api/extensions.py +57 -0
- neutralino/api/filesystem.py +633 -0
- neutralino/api/net.py +22 -0
- neutralino/api/os.py +508 -0
- neutralino/api/resources.py +124 -0
- neutralino/api/server.py +66 -0
- neutralino/api/storage.py +98 -0
- neutralino/api/types.py +342 -0
- neutralino/api/updater.py +22 -0
- neutralino/api/window.py +397 -0
- neutralino/application.py +1261 -0
- neutralino/bundle.py +187 -0
- neutralino/cli.py +629 -0
- neutralino/client.py +496 -0
- neutralino/config.py +671 -0
- neutralino/devtools.py +1973 -0
- neutralino/errors.py +142 -0
- neutralino/events.py +579 -0
- neutralino/execution.py +293 -0
- neutralino/extension.py +134 -0
- neutralino/frontend/python-bridge.d.ts +207 -0
- neutralino/frontend/python-bridge.mjs +854 -0
- neutralino/protocol.py +456 -0
- neutralino/py.typed +0 -0
- neutralino/rpc.py +1625 -0
- neutralino/runtime.py +591 -0
- neutralino/supervisor.py +866 -0
- neutralino/sync_client.py +376 -0
- neutralino/templates/default/app.py +32 -0
- neutralino/templates/default/frontend/app.js +28 -0
- neutralino/templates/default/frontend/index.html +26 -0
- neutralino/templates/default/frontend/neutralino.js +1 -0
- neutralino/templates/default/frontend/styles.css +8 -0
- neutralino/templates/default/gitignore.txt +3 -0
- neutralino/templates/default/neutralino.config.json +25 -0
- neutralino/templates/hybrid/README.md +17 -0
- neutralino/templates/hybrid/app.py +49 -0
- neutralino/templates/hybrid/components/counter.mjs +37 -0
- neutralino/templates/hybrid/styles.css +21 -0
- neutralino/templates/python-ui/README.md +15 -0
- neutralino/templates/python-ui/app.py +44 -0
- neutralino/templates/python-ui/gitignore.txt +3 -0
- neutralino/templates/python-ui/requirements.txt +4 -0
- neutralino/templates/react/README.md +28 -0
- neutralino/templates/react/app.py +52 -0
- neutralino/templates/react/components/widget.mjs +23 -0
- neutralino/templates/react/widget/package.json +20 -0
- neutralino/templates/react/widget/src/Widget.jsx +25 -0
- neutralino/templates/react/widget/vite.config.mjs +19 -0
- neutralino/transport.py +661 -0
- neutralino/types.py +93 -0
- neutralino/ui/__init__.py +139 -0
- neutralino/ui/_app.py +1529 -0
- neutralino/ui/_assets.py +407 -0
- neutralino/ui/_bases.py +1210 -0
- neutralino/ui/_behaviours.py +1066 -0
- neutralino/ui/_charts.py +732 -0
- neutralino/ui/_component.py +882 -0
- neutralino/ui/_dates.py +168 -0
- neutralino/ui/_desktop.py +879 -0
- neutralino/ui/_events.py +192 -0
- neutralino/ui/_filters.py +427 -0
- neutralino/ui/_forms.py +282 -0
- neutralino/ui/_protocol.py +201 -0
- neutralino/ui/_schedule.py +543 -0
- neutralino/ui/_security.py +106 -0
- neutralino/ui/_session.py +969 -0
- neutralino/ui/_state.py +199 -0
- neutralino/ui/_tables.py +256 -0
- neutralino/ui/_theme.py +154 -0
- neutralino/ui/blocks/__init__.py +19 -0
- neutralino/ui/blocks/_data.py +2239 -0
- neutralino/ui/blocks/_interactive.py +622 -0
- neutralino/ui/blocks/_layout.py +2967 -0
- neutralino/ui/components/__init__.py +81 -0
- neutralino/ui/components/_dates.py +879 -0
- neutralino/ui/components/_editors.py +217 -0
- neutralino/ui/components/_extensions.py +790 -0
- neutralino/ui/components/_extras.py +303 -0
- neutralino/ui/components/_generated.py +30565 -0
- neutralino/ui/components/_types.py +17 -0
- neutralino/ui/schema.py +824 -0
- neutralino/ui/validators.py +362 -0
- neutralino/updates/__init__.py +96 -0
- neutralino/updates/_http.py +320 -0
- neutralino/updates/_layout.py +762 -0
- neutralino/updates/archive.py +216 -0
- neutralino/updates/config.py +256 -0
- neutralino/updates/errors.py +97 -0
- neutralino/updates/install.sh.in +201 -0
- neutralino/updates/launcher.py +18 -0
- neutralino/updates/manager.py +808 -0
- neutralino/updates/manifest.py +196 -0
- neutralino/updates/release.py +314 -0
- neutralino/updates/semver.py +84 -0
- neutralino/updates/sources.py +392 -0
- neutralino/windows.py +316 -0
- neutralino_python-0.1.0rc1.dist-info/METADATA +117 -0
- neutralino_python-0.1.0rc1.dist-info/RECORD +521 -0
- neutralino_python-0.1.0rc1.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0rc1.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"""Interaction blocks built on the P04.06 extensions (P04.07).
|
|
2
|
+
|
|
3
|
+
* :class:`CardCarousel` - a carousel of cards (``variant="cards"``) or an
|
|
4
|
+
image carousel inside a product card with quantity/option controls
|
|
5
|
+
(``variant="card"``); ``action`` reports the chosen card.
|
|
6
|
+
* :class:`SortableList` - a reorderable list (``"list"``, ``"handle"``) or
|
|
7
|
+
table (``"table"``) of items; ``reorder`` reports the new key order.
|
|
8
|
+
* :class:`UploadPanel` - a Dropzone with a "Select files" button, the allowed
|
|
9
|
+
types/limits and a table of received/rejected files with read progress;
|
|
10
|
+
``upload`` delivers the validated files with their content.
|
|
11
|
+
|
|
12
|
+
Blocks are plain compositions of ``neutralino.ui`` components: each instance
|
|
13
|
+
owns its components, keeps no module state and dispatches its own typed
|
|
14
|
+
events from Python (the page cannot send block events).
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
import stat
|
|
21
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
22
|
+
from dataclasses import dataclass, field
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any, ClassVar, Literal, cast
|
|
25
|
+
|
|
26
|
+
from ...errors import RpcError, ValidationError
|
|
27
|
+
from ...types import UNSET, Unset
|
|
28
|
+
from .._component import TREE_LOCK, Component, EventSpec
|
|
29
|
+
from .._events import ChangeEvent, Event, Handler
|
|
30
|
+
from ..components import (
|
|
31
|
+
Badge,
|
|
32
|
+
Button,
|
|
33
|
+
Card,
|
|
34
|
+
CardSection,
|
|
35
|
+
Carousel,
|
|
36
|
+
CarouselSlide,
|
|
37
|
+
Code,
|
|
38
|
+
DragDropList,
|
|
39
|
+
Dropzone,
|
|
40
|
+
Group,
|
|
41
|
+
Image,
|
|
42
|
+
NumberInput,
|
|
43
|
+
Paper,
|
|
44
|
+
Progress,
|
|
45
|
+
Select,
|
|
46
|
+
Stack,
|
|
47
|
+
Table,
|
|
48
|
+
Text,
|
|
49
|
+
Title,
|
|
50
|
+
VisuallyHidden,
|
|
51
|
+
)
|
|
52
|
+
from ..components._extensions import (
|
|
53
|
+
_MIME, # pyright: ignore[reportPrivateUsage]
|
|
54
|
+
DEFAULT_MAX_FILES,
|
|
55
|
+
DEFAULT_MAX_SIZE,
|
|
56
|
+
DropEvent,
|
|
57
|
+
DroppedFile,
|
|
58
|
+
ReorderEvent,
|
|
59
|
+
_display_name, # pyright: ignore[reportPrivateUsage]
|
|
60
|
+
check_file_name,
|
|
61
|
+
file_type_allowed,
|
|
62
|
+
safe_src,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"CardActionEvent",
|
|
67
|
+
"CardCarousel",
|
|
68
|
+
"SortableList",
|
|
69
|
+
"UploadEvent",
|
|
70
|
+
"UploadPanel",
|
|
71
|
+
"UploadedFile",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class _PythonEvents(Component):
|
|
76
|
+
"""Block events are dispatched from Python only (never from the page)."""
|
|
77
|
+
|
|
78
|
+
def wire_events(self) -> list[str]:
|
|
79
|
+
return []
|
|
80
|
+
|
|
81
|
+
def _on_client_event(self, name: str, payload: Mapping[str, Any]) -> Any:
|
|
82
|
+
raise ValidationError(f"{self.TYPE}.{name}: not a page event")
|
|
83
|
+
|
|
84
|
+
def _dispatch(self, event: Event) -> None:
|
|
85
|
+
with TREE_LOCK:
|
|
86
|
+
w = self._window
|
|
87
|
+
if w is not None and w.live:
|
|
88
|
+
event.window = w
|
|
89
|
+
w.dispatch(self, event)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _text(v: Any, path: str, max_len: int = 2000) -> str:
|
|
93
|
+
if not isinstance(v, str) or len(v) > max_len:
|
|
94
|
+
raise ValidationError(f"{path}: expected a string up to {max_len} characters")
|
|
95
|
+
return v
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# ================================================================ CardCarousel
|
|
99
|
+
_CARD_KEYS = {"key", "title", "description", "image", "category", "action_label"}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@dataclass
|
|
103
|
+
class CardActionEvent(Event):
|
|
104
|
+
"""``action`` of a CardCarousel: the card ``key`` (and its ``index``);
|
|
105
|
+
for ``variant="card"`` also the chosen ``quantity`` and ``option``."""
|
|
106
|
+
|
|
107
|
+
key: str = ""
|
|
108
|
+
index: int = 0
|
|
109
|
+
quantity: int | None = None
|
|
110
|
+
option: str | None = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _card_items(items: Any) -> list[dict[str, Any]]:
|
|
114
|
+
if isinstance(items, (str, Mapping)) or not isinstance(items, Sequence):
|
|
115
|
+
raise ValidationError("CardCarousel.items: expected a list of mappings")
|
|
116
|
+
seq = list(cast("Sequence[Any]", items))
|
|
117
|
+
if not seq or len(seq) > 200:
|
|
118
|
+
raise ValidationError("CardCarousel.items: 1..200 items")
|
|
119
|
+
out: list[dict[str, Any]] = []
|
|
120
|
+
keys: set[str] = set()
|
|
121
|
+
for i, it in enumerate(seq):
|
|
122
|
+
p = f"CardCarousel.items[{i}]"
|
|
123
|
+
if not isinstance(it, Mapping):
|
|
124
|
+
raise ValidationError(f"{p}: expected a mapping")
|
|
125
|
+
m = cast("Mapping[str, Any]", it)
|
|
126
|
+
extra = set(m) - _CARD_KEYS
|
|
127
|
+
if extra:
|
|
128
|
+
raise ValidationError(f"{p}: unknown keys {sorted(extra)}")
|
|
129
|
+
key = _text(m.get("key"), f"{p}.key", 200)
|
|
130
|
+
if not key or key in keys:
|
|
131
|
+
raise ValidationError(f"{p}.key: empty or duplicate")
|
|
132
|
+
keys.add(key)
|
|
133
|
+
d: dict[str, Any] = {"key": key, "title": _text(m.get("title"), f"{p}.title", 300)}
|
|
134
|
+
for k in ("description", "category", "action_label"):
|
|
135
|
+
if m.get(k) is not None:
|
|
136
|
+
d[k] = _text(m[k], f"{p}.{k}")
|
|
137
|
+
if m.get("image") is not None:
|
|
138
|
+
d["image"] = safe_src(m["image"], f"{p}.image")
|
|
139
|
+
out.append(d)
|
|
140
|
+
return out
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class CardCarousel(_PythonEvents, Stack):
|
|
144
|
+
"""Carousel of cards (``variant="cards"``: one Paper card per item with
|
|
145
|
+
image, category, title, description and an action button) or a product
|
|
146
|
+
card whose image carousel shows the items (``variant="card"``: title,
|
|
147
|
+
price, description, quantity and option controls, one action button).
|
|
148
|
+
|
|
149
|
+
``items``: ``{key, title, description?, image?, category?, action_label?}``
|
|
150
|
+
(``image`` is an app asset path or http(s) URL). ``on_action`` receives a
|
|
151
|
+
:class:`CardActionEvent`; ``on_slide_change`` an Event with
|
|
152
|
+
``payload["value"]`` = the slide index.
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
EVENTS: ClassVar[Mapping[str, EventSpec]] = {
|
|
156
|
+
"action": EventSpec("action", "CardActionEvent"),
|
|
157
|
+
"slide_change": EventSpec("slide_change"),
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
def __init__(
|
|
161
|
+
self,
|
|
162
|
+
items: Sequence[Mapping[str, Any]],
|
|
163
|
+
*,
|
|
164
|
+
variant: Literal["cards", "card"] = "cards",
|
|
165
|
+
title: str | None = None,
|
|
166
|
+
description: str | None = None,
|
|
167
|
+
price: str | None = None,
|
|
168
|
+
options: Sequence[str] | None = None,
|
|
169
|
+
with_quantity: bool = True,
|
|
170
|
+
action_label: str = "Select",
|
|
171
|
+
slide_size: str | float | Unset = UNSET,
|
|
172
|
+
height: str | float | Unset = UNSET,
|
|
173
|
+
loop: bool = False,
|
|
174
|
+
on_action: Handler[CardActionEvent] | None = None,
|
|
175
|
+
on_slide_change: Handler[Event] | None = None,
|
|
176
|
+
visible: bool | Unset = UNSET,
|
|
177
|
+
aria_label: str | Unset = UNSET,
|
|
178
|
+
) -> None:
|
|
179
|
+
if variant not in ("cards", "card"):
|
|
180
|
+
raise ValidationError("CardCarousel.variant: 'cards' or 'card'")
|
|
181
|
+
cards = _card_items(items)
|
|
182
|
+
super().__init__(gap="sm", visible=visible, aria_label=aria_label)
|
|
183
|
+
self.variant = variant
|
|
184
|
+
self._items = cards
|
|
185
|
+
self.quantity: NumberInput | None = None
|
|
186
|
+
self.option: Select | None = None
|
|
187
|
+
self.buttons: dict[str, Button] = {}
|
|
188
|
+
with self:
|
|
189
|
+
if variant == "cards":
|
|
190
|
+
self.carousel = Carousel(
|
|
191
|
+
slide=0,
|
|
192
|
+
slide_size="70%" if slide_size is UNSET else slide_size,
|
|
193
|
+
slide_gap="md",
|
|
194
|
+
align="start",
|
|
195
|
+
loop=loop,
|
|
196
|
+
with_indicators=True,
|
|
197
|
+
height=height,
|
|
198
|
+
on_slide_change=self._slide_changed,
|
|
199
|
+
)
|
|
200
|
+
with self.carousel:
|
|
201
|
+
for i, c in enumerate(cards):
|
|
202
|
+
with (
|
|
203
|
+
CarouselSlide(),
|
|
204
|
+
Paper(shadow="md", p="lg", radius="md", with_border=True),
|
|
205
|
+
Stack(gap="xs"),
|
|
206
|
+
):
|
|
207
|
+
if c.get("image"):
|
|
208
|
+
Image(
|
|
209
|
+
src=c["image"], alt=c["title"], h=140, radius="sm", fit="cover"
|
|
210
|
+
)
|
|
211
|
+
if c.get("category"):
|
|
212
|
+
Text(c["category"], size="xs", c="dimmed", fw=700)
|
|
213
|
+
Title(c["title"], order=4)
|
|
214
|
+
if c.get("description"):
|
|
215
|
+
Text(c["description"], size="sm")
|
|
216
|
+
self.buttons[c["key"]] = Button(
|
|
217
|
+
c.get("action_label") or action_label,
|
|
218
|
+
variant="light",
|
|
219
|
+
on_click=self._clicker(i),
|
|
220
|
+
)
|
|
221
|
+
else:
|
|
222
|
+
with Card(with_border=True, radius="md", padding="md"):
|
|
223
|
+
with CardSection():
|
|
224
|
+
self.carousel = Carousel(
|
|
225
|
+
slide=0,
|
|
226
|
+
loop=loop,
|
|
227
|
+
with_indicators=True,
|
|
228
|
+
height=220 if height is UNSET else height,
|
|
229
|
+
on_slide_change=self._slide_changed,
|
|
230
|
+
)
|
|
231
|
+
with self.carousel:
|
|
232
|
+
for c in cards:
|
|
233
|
+
with CarouselSlide():
|
|
234
|
+
if c.get("image"):
|
|
235
|
+
Image(src=c["image"], alt=c["title"], h=220, fit="cover")
|
|
236
|
+
else:
|
|
237
|
+
Text(c["title"], ta="center")
|
|
238
|
+
with Stack(gap="xs", p="sm"):
|
|
239
|
+
with Group(justify="space-between"):
|
|
240
|
+
Title(
|
|
241
|
+
_text(title, "title", 300) if title else cards[0]["title"], order=4
|
|
242
|
+
)
|
|
243
|
+
if price:
|
|
244
|
+
Badge(_text(price, "price", 100), variant="light", size="lg")
|
|
245
|
+
if description:
|
|
246
|
+
Text(_text(description, "description"), size="sm", c="dimmed")
|
|
247
|
+
with Group(align="flex-end", gap="sm"):
|
|
248
|
+
if with_quantity:
|
|
249
|
+
self.quantity = NumberInput(
|
|
250
|
+
label="Quantity", value=1, min=1, max=999
|
|
251
|
+
)
|
|
252
|
+
if options:
|
|
253
|
+
opts = [_text(o, "options[]", 200) for o in options]
|
|
254
|
+
self.option = Select(label="Option", data=opts, value=opts[0])
|
|
255
|
+
self.buttons[""] = Button(action_label, on_click=self._clicker(None))
|
|
256
|
+
if on_action is not None:
|
|
257
|
+
self.on("action", on_action)
|
|
258
|
+
if on_slide_change is not None:
|
|
259
|
+
self.on("slide_change", on_slide_change)
|
|
260
|
+
|
|
261
|
+
@property
|
|
262
|
+
def items(self) -> list[dict[str, Any]]:
|
|
263
|
+
return [dict(c) for c in self._items]
|
|
264
|
+
|
|
265
|
+
@property
|
|
266
|
+
def slide(self) -> int:
|
|
267
|
+
v = self.carousel.slide
|
|
268
|
+
return v if isinstance(v, int) else 0
|
|
269
|
+
|
|
270
|
+
@slide.setter
|
|
271
|
+
def slide(self, index: int) -> None:
|
|
272
|
+
self.carousel.slide = index
|
|
273
|
+
|
|
274
|
+
async def _slide_changed(self, e: ChangeEvent[int]) -> None:
|
|
275
|
+
self._dispatch(Event(name="slide_change", sender=self, payload={"value": e.value}))
|
|
276
|
+
|
|
277
|
+
def _clicker(self, index: int | None) -> Callable[[], Any]:
|
|
278
|
+
async def click() -> None:
|
|
279
|
+
i = self.slide if index is None else index
|
|
280
|
+
i = min(max(i, 0), len(self._items) - 1)
|
|
281
|
+
q = self.quantity.value if self.quantity is not None else None
|
|
282
|
+
o = self.option.value if self.option is not None else None
|
|
283
|
+
key = cast("str", self._items[i]["key"])
|
|
284
|
+
self._dispatch(
|
|
285
|
+
CardActionEvent(
|
|
286
|
+
name="action",
|
|
287
|
+
sender=self,
|
|
288
|
+
payload={"value": key},
|
|
289
|
+
key=key,
|
|
290
|
+
index=i,
|
|
291
|
+
quantity=int(q) if isinstance(q, (int, float)) else None,
|
|
292
|
+
option=o if isinstance(o, str) else None,
|
|
293
|
+
)
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
return click
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
# ================================================================ SortableList
|
|
300
|
+
class SortableList(_PythonEvents, Stack):
|
|
301
|
+
"""Reorderable items: ``variant="list"`` (drag whole rows), ``"handle"``
|
|
302
|
+
(drag by the grip) or ``"table"`` (table rows with ``columns``, drag
|
|
303
|
+
handle column with a hidden accessible label). ``items`` as in
|
|
304
|
+
:class:`neutralino.ui.DragDropList`; ``on_reorder`` receives the
|
|
305
|
+
:class:`neutralino.ui.ReorderEvent` (``order``, ``key``, ``from_index``,
|
|
306
|
+
``to_index``) after Python stored the new order.
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
EVENTS: ClassVar[Mapping[str, EventSpec]] = {"reorder": EventSpec("reorder", "ReorderEvent")}
|
|
310
|
+
|
|
311
|
+
def __init__(
|
|
312
|
+
self,
|
|
313
|
+
items: Sequence[Mapping[str, Any]],
|
|
314
|
+
*,
|
|
315
|
+
variant: Literal["list", "handle", "table"] = "list",
|
|
316
|
+
columns: Sequence[str] | None = None,
|
|
317
|
+
title: str | None = None,
|
|
318
|
+
on_reorder: Handler[ReorderEvent] | None = None,
|
|
319
|
+
visible: bool | Unset = UNSET,
|
|
320
|
+
) -> None:
|
|
321
|
+
if variant not in ("list", "handle", "table"):
|
|
322
|
+
raise ValidationError("SortableList.variant: 'list', 'handle' or 'table'")
|
|
323
|
+
if variant == "table" and not columns:
|
|
324
|
+
raise ValidationError("SortableList: variant 'table' needs columns")
|
|
325
|
+
super().__init__(gap="xs", visible=visible)
|
|
326
|
+
self.variant = variant
|
|
327
|
+
with self:
|
|
328
|
+
if title:
|
|
329
|
+
if variant == "table":
|
|
330
|
+
with VisuallyHidden():
|
|
331
|
+
Text(title)
|
|
332
|
+
else:
|
|
333
|
+
Title(title, order=4)
|
|
334
|
+
self.list = DragDropList(
|
|
335
|
+
items=items,
|
|
336
|
+
columns=list(columns) if variant == "table" and columns else UNSET,
|
|
337
|
+
with_handle=variant in ("handle", "table"),
|
|
338
|
+
label=title or "Sortable list",
|
|
339
|
+
on_reorder=self._reordered,
|
|
340
|
+
)
|
|
341
|
+
if on_reorder is not None:
|
|
342
|
+
self.on("reorder", on_reorder)
|
|
343
|
+
|
|
344
|
+
@property
|
|
345
|
+
def keys(self) -> list[str]:
|
|
346
|
+
"""Item keys in the current order."""
|
|
347
|
+
return self.list.keys
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def items(self) -> list[dict[str, Any]]:
|
|
351
|
+
v = self.list.items
|
|
352
|
+
return [dict(x) for x in v] if isinstance(v, Sequence) else []
|
|
353
|
+
|
|
354
|
+
@items.setter
|
|
355
|
+
def items(self, value: Sequence[Mapping[str, Any]]) -> None:
|
|
356
|
+
self.list.items = value
|
|
357
|
+
|
|
358
|
+
def move(self, key: str, index: int) -> None:
|
|
359
|
+
"""Move item ``key`` to ``index`` (the page follows)."""
|
|
360
|
+
self.list.move(key, index)
|
|
361
|
+
|
|
362
|
+
async def _reordered(self, e: ReorderEvent) -> None:
|
|
363
|
+
self._dispatch(
|
|
364
|
+
ReorderEvent(
|
|
365
|
+
name="reorder",
|
|
366
|
+
sender=self,
|
|
367
|
+
payload=dict(e.payload),
|
|
368
|
+
order=list(e.order),
|
|
369
|
+
previous=list(e.previous),
|
|
370
|
+
key=e.key,
|
|
371
|
+
from_index=e.from_index,
|
|
372
|
+
to_index=e.to_index,
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
# ================================================================= UploadPanel
|
|
378
|
+
@dataclass(frozen=True)
|
|
379
|
+
class UploadedFile:
|
|
380
|
+
"""A validated file with its content: dropped/chosen in the page
|
|
381
|
+
(``path`` None) or picked with the native dialog (``path`` set)."""
|
|
382
|
+
|
|
383
|
+
name: str
|
|
384
|
+
size: int
|
|
385
|
+
mime: str
|
|
386
|
+
content: bytes = field(repr=False)
|
|
387
|
+
path: str | None = None
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
@dataclass
|
|
391
|
+
class UploadEvent(Event):
|
|
392
|
+
"""``upload`` of an UploadPanel: validated ``files`` with content and the
|
|
393
|
+
``rejected`` ones as ``(name, reasons)``."""
|
|
394
|
+
|
|
395
|
+
files: list[UploadedFile] = field(default_factory=list[UploadedFile])
|
|
396
|
+
rejected: list[tuple[str, tuple[str, ...]]] = field(
|
|
397
|
+
default_factory=list[tuple[str, tuple[str, ...]]]
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def _human(n: int) -> str:
|
|
402
|
+
if n < 1024:
|
|
403
|
+
return f"{n} B"
|
|
404
|
+
size = n / 1024
|
|
405
|
+
for unit in ("KB", "MB"):
|
|
406
|
+
if size < 1024:
|
|
407
|
+
return f"{size:.1f} {unit}"
|
|
408
|
+
size /= 1024
|
|
409
|
+
return f"{size:.1f} GB"
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
class UploadPanel(_PythonEvents, Stack):
|
|
413
|
+
"""Dropzone with a "Select files" button (``variant="dropzone-button"``),
|
|
414
|
+
the accepted types and limits, a progress bar while content is read and a
|
|
415
|
+
table of received and rejected files. Every file is validated in Python
|
|
416
|
+
(see :class:`neutralino.ui.Dropzone`); content is read in bounded chunks
|
|
417
|
+
and delivered with ``on_upload`` (:class:`UploadEvent`). Files chosen in
|
|
418
|
+
the native dialog (``await app.open_file(multiple=True)``) go through the
|
|
419
|
+
same checks with :meth:`add_paths`. ``max_total`` bounds one batch.
|
|
420
|
+
"""
|
|
421
|
+
|
|
422
|
+
EVENTS: ClassVar[Mapping[str, EventSpec]] = {"upload": EventSpec("upload", "UploadEvent")}
|
|
423
|
+
|
|
424
|
+
def __init__(
|
|
425
|
+
self,
|
|
426
|
+
*,
|
|
427
|
+
variant: Literal["dropzone-button"] = "dropzone-button",
|
|
428
|
+
accept: Sequence[str] | None = None,
|
|
429
|
+
max_size: int = DEFAULT_MAX_SIZE,
|
|
430
|
+
max_files: int = DEFAULT_MAX_FILES,
|
|
431
|
+
max_total: int = 50 * 1024 * 1024,
|
|
432
|
+
title: str = "Upload files",
|
|
433
|
+
description: str | None = None,
|
|
434
|
+
button_label: str = "Select files",
|
|
435
|
+
on_upload: Handler[UploadEvent] | None = None,
|
|
436
|
+
visible: bool | Unset = UNSET,
|
|
437
|
+
) -> None:
|
|
438
|
+
if variant != "dropzone-button":
|
|
439
|
+
raise ValidationError("UploadPanel.variant: 'dropzone-button'")
|
|
440
|
+
mt: Any = max_total
|
|
441
|
+
if isinstance(mt, bool) or not isinstance(mt, int) or not 1 <= mt <= 512 * 1024 * 1024:
|
|
442
|
+
raise ValidationError("UploadPanel.max_total: 1 byte .. 512 MiB")
|
|
443
|
+
super().__init__(gap="sm", visible=visible)
|
|
444
|
+
self.max_total = max_total
|
|
445
|
+
self._rows: list[list[str]] = []
|
|
446
|
+
self.received: list[UploadedFile] = []
|
|
447
|
+
with self:
|
|
448
|
+
self.dropzone = Dropzone(
|
|
449
|
+
accept=list(accept) if accept else UNSET,
|
|
450
|
+
max_size=max_size,
|
|
451
|
+
max_files=max_files,
|
|
452
|
+
min_height=140,
|
|
453
|
+
on_drop=self._dropped,
|
|
454
|
+
)
|
|
455
|
+
with self.dropzone, Stack(gap=4, align="center"):
|
|
456
|
+
Title(title, order=4)
|
|
457
|
+
Text(
|
|
458
|
+
description or f"Up to {max_files} files, {_human(max_size)} each",
|
|
459
|
+
size="sm",
|
|
460
|
+
c="dimmed",
|
|
461
|
+
)
|
|
462
|
+
if accept:
|
|
463
|
+
Code(", ".join(cast("list[str]", self.dropzone.accept)))
|
|
464
|
+
with Group(justify="center"):
|
|
465
|
+
self.button = Button(button_label, on_click=self.dropzone.open_picker)
|
|
466
|
+
self.progress = Progress(value=0, size="sm", visible=False)
|
|
467
|
+
self.table = Table(
|
|
468
|
+
data={"head": ["File", "Size", "Status"], "body": []},
|
|
469
|
+
striped=True,
|
|
470
|
+
visible=False,
|
|
471
|
+
)
|
|
472
|
+
if on_upload is not None:
|
|
473
|
+
self.on("upload", on_upload)
|
|
474
|
+
|
|
475
|
+
# ------------------------------------------------------------ table
|
|
476
|
+
def _set_rows(self) -> None:
|
|
477
|
+
del self._rows[:-200]
|
|
478
|
+
self.table.update(
|
|
479
|
+
data={"head": ["File", "Size", "Status"], "body": [list(r) for r in self._rows]},
|
|
480
|
+
visible=bool(self._rows),
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
def clear_files(self) -> None:
|
|
484
|
+
"""Forget the table and the received files."""
|
|
485
|
+
self._rows = []
|
|
486
|
+
self.received = []
|
|
487
|
+
self._set_rows()
|
|
488
|
+
self.progress.update(value=0, visible=False)
|
|
489
|
+
|
|
490
|
+
def _reject_row(self, name: str, size: int | None, reasons: Sequence[str]) -> None:
|
|
491
|
+
self._rows.append(
|
|
492
|
+
[name, _human(size) if size is not None else "", "rejected: " + ", ".join(reasons)]
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
# ------------------------------------------------------------- drops
|
|
496
|
+
async def _dropped(self, e: DropEvent) -> None:
|
|
497
|
+
rejected = [(r.name, r.reasons) for r in e.rejected]
|
|
498
|
+
for r in e.rejected:
|
|
499
|
+
self._reject_row(r.name, r.size, r.reasons)
|
|
500
|
+
total = 0
|
|
501
|
+
todo: list[DroppedFile] = []
|
|
502
|
+
for f in e.files:
|
|
503
|
+
if total + f.size > self.max_total:
|
|
504
|
+
rejected.append((f.name, ("total-too-large",)))
|
|
505
|
+
self._reject_row(f.name, f.size, ("total-too-large",))
|
|
506
|
+
f.release()
|
|
507
|
+
continue
|
|
508
|
+
total += f.size
|
|
509
|
+
todo.append(f)
|
|
510
|
+
self._set_rows()
|
|
511
|
+
done: list[UploadedFile] = []
|
|
512
|
+
if todo:
|
|
513
|
+
self.progress.update(value=0, visible=True)
|
|
514
|
+
got = 0
|
|
515
|
+
for f in todo:
|
|
516
|
+
try:
|
|
517
|
+
data = await f.read()
|
|
518
|
+
except (RpcError, ValidationError):
|
|
519
|
+
# the page dropped the file or reported inconsistent content
|
|
520
|
+
rejected.append((f.name, ("read-failed",)))
|
|
521
|
+
self._reject_row(f.name, f.size, ("read-failed",))
|
|
522
|
+
continue
|
|
523
|
+
finally:
|
|
524
|
+
f.release()
|
|
525
|
+
got += len(data)
|
|
526
|
+
done.append(UploadedFile(f.name, f.size, f.mime, data))
|
|
527
|
+
self._rows.append([f.name, _human(f.size), "received"])
|
|
528
|
+
self.progress.value = round(100 * got / max(total, 1), 1)
|
|
529
|
+
self._set_rows()
|
|
530
|
+
self._finish(done, rejected)
|
|
531
|
+
|
|
532
|
+
def _finish(
|
|
533
|
+
self, done: list[UploadedFile], rejected: list[tuple[str, tuple[str, ...]]]
|
|
534
|
+
) -> None:
|
|
535
|
+
self.received.extend(done)
|
|
536
|
+
del self.received[:-500]
|
|
537
|
+
summary = {
|
|
538
|
+
"files": [{"name": f.name, "size": f.size, "mime": f.mime} for f in done],
|
|
539
|
+
"rejected": [{"name": n, "reasons": list(r)} for n, r in rejected],
|
|
540
|
+
}
|
|
541
|
+
self._dispatch(
|
|
542
|
+
UploadEvent(
|
|
543
|
+
name="upload",
|
|
544
|
+
sender=self,
|
|
545
|
+
payload={"value": summary},
|
|
546
|
+
files=done,
|
|
547
|
+
rejected=rejected,
|
|
548
|
+
)
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
# ------------------------------------------------------- native paths
|
|
552
|
+
def add_paths(self, paths: Sequence[str | os.PathLike[str]]) -> list[UploadedFile]:
|
|
553
|
+
"""Validate and read files chosen in the native dialog (same limits
|
|
554
|
+
as drops: count, size, type, safe name; regular files only, symlinks
|
|
555
|
+
refused). Blocking file reads: call it from a sync callback or a
|
|
556
|
+
worker thread. Returns the accepted files and dispatches ``upload``."""
|
|
557
|
+
accept = cast("list[str]", self.dropzone.accept) if self.dropzone.accept else []
|
|
558
|
+
max_size = cast("int", self.dropzone.max_size)
|
|
559
|
+
max_files = cast("int", self.dropzone.max_files)
|
|
560
|
+
if isinstance(paths, (str, os.PathLike)):
|
|
561
|
+
raise ValidationError("add_paths: expected a list of paths")
|
|
562
|
+
plist = list(paths)
|
|
563
|
+
done: list[UploadedFile] = []
|
|
564
|
+
rejected: list[tuple[str, tuple[str, ...]]] = []
|
|
565
|
+
if len(plist) > max_files:
|
|
566
|
+
# Like a drop: the first max_files are considered, the rest refused.
|
|
567
|
+
for p in plist[max_files:]:
|
|
568
|
+
label = _display_name(Path(p).name)
|
|
569
|
+
rejected.append((label, ("too-many-files",)))
|
|
570
|
+
self._reject_row(label, None, ("too-many-files",))
|
|
571
|
+
plist = plist[:max_files]
|
|
572
|
+
total = 0
|
|
573
|
+
for raw in plist:
|
|
574
|
+
p = Path(raw)
|
|
575
|
+
reasons: list[str] = []
|
|
576
|
+
try:
|
|
577
|
+
name: str | None = check_file_name(p.name)
|
|
578
|
+
except ValidationError:
|
|
579
|
+
name = None
|
|
580
|
+
reasons.append("invalid-name")
|
|
581
|
+
try:
|
|
582
|
+
st: os.stat_result | None = os.lstat(p)
|
|
583
|
+
except OSError:
|
|
584
|
+
st = None
|
|
585
|
+
reasons.append("not-found")
|
|
586
|
+
regular = st is not None and stat.S_ISREG(st.st_mode)
|
|
587
|
+
if st is not None and not regular:
|
|
588
|
+
reasons.append("not-a-regular-file")
|
|
589
|
+
size = st.st_size if st is not None and regular else 0
|
|
590
|
+
if size > max_size:
|
|
591
|
+
reasons.append("file-too-large")
|
|
592
|
+
if name is not None and not file_type_allowed(name, "", accept):
|
|
593
|
+
reasons.append("file-invalid-type")
|
|
594
|
+
if not reasons and total + size > self.max_total:
|
|
595
|
+
reasons.append("total-too-large")
|
|
596
|
+
if reasons or name is None:
|
|
597
|
+
label = name or _display_name(p.name)
|
|
598
|
+
rejected.append((label, tuple(reasons)))
|
|
599
|
+
self._reject_row(label, size, reasons)
|
|
600
|
+
continue
|
|
601
|
+
try:
|
|
602
|
+
fd = os.open(p, os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0))
|
|
603
|
+
with os.fdopen(fd, "rb") as fh:
|
|
604
|
+
if not stat.S_ISREG(os.fstat(fh.fileno()).st_mode):
|
|
605
|
+
raise OSError("not a regular file")
|
|
606
|
+
data = fh.read(max_size + 1)
|
|
607
|
+
except OSError:
|
|
608
|
+
# replaced by a link/special file after the check, or unreadable
|
|
609
|
+
rejected.append((name, ("unreadable",)))
|
|
610
|
+
self._reject_row(name, size, ("unreadable",))
|
|
611
|
+
continue
|
|
612
|
+
if len(data) > max_size:
|
|
613
|
+
rejected.append((name, ("file-too-large",)))
|
|
614
|
+
self._reject_row(name, len(data), ("file-too-large",))
|
|
615
|
+
continue
|
|
616
|
+
total += len(data)
|
|
617
|
+
mime = _MIME.guess_type(name.lower(), strict=False)[0] or "application/octet-stream"
|
|
618
|
+
done.append(UploadedFile(name, len(data), mime, data, str(p)))
|
|
619
|
+
self._rows.append([name, _human(len(data)), "received"])
|
|
620
|
+
self._set_rows()
|
|
621
|
+
self._finish(done, rejected)
|
|
622
|
+
return done
|