Feat: Eval with or without date

This commit is contained in:
Bertrand Benjamin 2019-08-04 19:28:43 +02:00
parent daf24ec90e
commit 7119fcdcdc

View File

@ -2,18 +2,20 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from IPython.display import Markdown as md\n", "from IPython.display import Markdown as md\n",
"from IPython.display import DisplayHandle\n",
"import pandas as pd\n", "import pandas as pd\n",
"from pathlib import Path" "from pathlib import Path\n",
"from datetime import datetime"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": 8,
"metadata": { "metadata": {
"tags": [ "tags": [
"parameters" "parameters"
@ -28,25 +30,43 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"split_ass = assessment.split(\"_\")\n",
"if len(split_ass) > 1:\n",
" date, *assessment = assessment.split(\"_\")\n",
" date = datetime.strptime(date, \"%y%m%d\")\n",
" assessment = ' '.join(assessment)\n",
"else:\n",
" date = None\n",
" assessment = split_ass[0]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/markdown": [ "text/markdown": [
"# Ds1 pour 308" "# dm2 (14/11/2016) pour 308"
], ],
"text/plain": [ "text/plain": [
"<IPython.core.display.Markdown object>" "<IPython.core.display.Markdown object>"
] ]
}, },
"execution_count": 39,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "display_data"
} }
], ],
"source": [ "source": [
"md(f\"# {assessment} pour {tribe}\")" "if date is None:\n",
" display(md(f\"# {assessment} pour {tribe}\"))\n",
"else:\n",
" display(md(f\"# {assessment} ({date:%d/%m/%Y}) pour {tribe}\"))"
] ]
}, },
{ {
@ -74,7 +94,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.3" "version": "3.7.4"
} }
}, },
"nbformat": 4, "nbformat": 4,