Skip to content

Commit

Permalink
Fix collapsed metadata and execution count in Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
cheroliv committed Oct 17, 2024
1 parent 424a4fd commit b0d81b1
Showing 1 changed file with 25 additions and 85 deletions.
110 changes: 25 additions & 85 deletions pyschool/school.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-10-16T22:07:39.654858Z",
"start_time": "2024-10-16T22:07:39.651583Z"
}
"collapsed": true
},
"source": [
"from users.user import User\n",
"from users.signup import Signup\n",
"from pyrsistent import m\n"
],
"outputs": [],
"execution_count": 5
"execution_count": null
},
{
"metadata": {},
Expand All @@ -41,15 +37,10 @@
"id": "e096dacdce185e62"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-10-16T22:07:39.708358Z",
"start_time": "2024-10-16T22:07:39.699756Z"
}
},
"metadata": {},
"cell_type": "code",
"source": [
" # Création d'un objet avec des données Pyrsistent\n",
"# Création d'un objet avec des données Pyrsistent\n",
"signup_data = m(\n",
" login=\"johndoe\",\n",
" password=\"secret\",\n",
Expand All @@ -64,89 +55,38 @@
"# Utilisation de copy qui a été vérifié comme fonctionnel\n",
"new_signup = signup.copy(update={\"email\": \"[email protected]\"})\n",
"\n",
"print(\"Original signup:\", signup)\n",
"print(\"New signup:\", new_signup)\n",
"\n",
"# Démonstration de la conversion retour vers Pyrsistent\n",
"persistent_data = new_signup.to_persistent()\n",
"print(\"Données Pyrsistent:\", persistent_data)\n",
"\n",
"print(f\"to_json : {new_signup.to_json()}\")\n",
"\n",
"print(f\"to_xml : {new_signup.to_xml()}\")\n",
"\n",
"print(f\"to_schema json : {new_signup.to_schema()}\")\n",
"\n",
"print(f\"to_schema yaml : {new_signup.to_schema(\"yaml\")}\")\n",
"\n",
"print(f\"to_dtd : {new_signup.to_dtd()}\")\n",
"\n",
"print(f\"to_xsd : {new_signup.to_xsd()}\")"
"def display_school(signup: Signup, new_signup: Signup, persistent_data):\n",
" print(\"Original signup:\", signup)\n",
" print(\"New signup:\", new_signup)\n",
" # Démonstration de la conversion retour vers Pyrsistent\n",
" print(\"Données Pyrsistent:\", persistent_data)\n",
" print(f\"to_json : {new_signup.to_json()}\")\n",
" print(f\"to_xml : {new_signup.to_xml()}\")\n",
" print(f\"to_schema json : {new_signup.to_schema()}\")\n",
" print(f\"to_schema yaml : {new_signup.to_schema(\"yaml\")}\")\n",
" print(f\"to_dtd : {new_signup.to_dtd()}\")\n",
" print(f\"to_xsd : {new_signup.to_xsd()}\")"
],
"id": "5c4584174cb83ecf",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Original signup: login='johndoe' password='secret' repassword='secret' email='[email protected]'\n",
"New signup: login='johndoe' password='secret' repassword='secret' email='[email protected]'\n",
"Données Pyrsistent: pmap({'login': 'johndoe', 'email': '[email protected]', 'password': 'secret', 'repassword': 'secret'})\n",
"to_json : {\"login\": \"johndoe\", \"password\": \"secret\", \"repassword\": \"secret\", \"email\": \"[email protected]\"}\n",
"to_xml : <signup><login>johndoe</login><password>secret</password><repassword>secret</repassword><email>[email protected]</email></signup>\n",
"to_schema json : {'type': 'object', 'properties': {'login': {'type': 'str'}, 'password': {'type': 'str'}, 'repassword': {'type': 'str'}, 'email': {'type': 'str'}}}\n",
"to_schema yaml : properties:\n",
" email:\n",
" type: str\n",
" login:\n",
" type: str\n",
" password:\n",
" type: str\n",
" repassword:\n",
" type: str\n",
"type: object\n",
"\n",
"to_dtd : <!ELEMENT signup (<!ELEMENT login (#PCDATA)> , <!ELEMENT password (#PCDATA)> , <!ELEMENT repassword (#PCDATA)> , <!ELEMENT email (#PCDATA)>)>\n",
"to_xsd : <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
" <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n",
" <xs:element name=\"signup\">\n",
" <xs:complexType>\n",
" <xs:sequence>\n",
" \n",
" <xs:element name=\"login\" type=\"xs:string\">\n",
" <xs:annotation>\n",
" <xs:documentation>Field: login</xs:documentation>\n",
" </xs:annotation>\n",
" </xs:element>\n",
" <xs:element name=\"password\" type=\"xs:string\">\n",
" <xs:annotation>\n",
" <xs:documentation>Field: password</xs:documentation>\n",
" </xs:annotation>\n",
" </xs:element>\n",
" <xs:element name=\"repassword\" type=\"xs:string\">\n",
" <xs:annotation>\n",
" <xs:documentation>Field: repassword</xs:documentation>\n",
" </xs:annotation>\n",
" </xs:element>\n",
" <xs:element name=\"email\" type=\"xs:string\">\n",
" <xs:annotation>\n",
" <xs:documentation>Field: email</xs:documentation>\n",
" </xs:annotation>\n",
" </xs:element>\n",
" </xs:sequence>\n",
" </xs:complexType>\n",
" </xs:element>\n",
" </xs:schema>\n"
]
}
],
"execution_count": 6
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## Générons des users\n",
"id": "b30c01bf323eb272"
},
{
"metadata": {},
"cell_type": "code",
"source": "display_school(signup, new_signup, persistent_data)",
"id": "cb2eac54d0494e00",
"outputs": [],
"execution_count": null
}
],
"metadata": {
Expand Down

0 comments on commit b0d81b1

Please sign in to comment.