{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipywidgets as widgets\n", "from ipyvuetify.extra import FileInput\n", "import hashlib" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_input = FileInput()\n", "file_input" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# first select some files in the FileInput above\n", "\n", "myfiles = file_input.get_files()\n", "myfiles[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_input.disabled = True\n", "\n", "def md5_sum_file(file):\n", " file['file_obj'].seek(0)\n", " data = file['file_obj'].read()\n", " md5_sum = hashlib.md5(data).hexdigest()\n", " return f'{file[\"name\"]}, md5: {md5_sum}'\n", "\n", "sums = [md5_sum_file(file) for file in myfiles]\n", "file_input.disabled = False\n", "\n", "sums" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_input.clear()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.8" } }, "nbformat": 4, "nbformat_minor": 4 }