Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3dce207a authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Script to check notebooks: remove the she-bang and add two arguments to...

Script to check notebooks: remove the she-bang and add two arguments to circumvent an issue with UTF 8 encoding (fix suggested there: https://www.journaldunet.fr/web-tech/developpement/1441055-corriger-l-erreur-unicodedecodeerror-utf-8-codec-can-t-decode-byte-0xff-in-position-0-invalid-start-byte/).
parent b8fdb228
Branches
Tags debian/4.3.3-7
1 merge request!7Add a pre-commit git hook to prevent commit of a notebook with executed cells within
#!python
import argparse import argparse
import sys import sys
from typing import Optional from typing import Optional
...@@ -8,7 +6,7 @@ from typing import Sequence ...@@ -8,7 +6,7 @@ from typing import Sequence
def find_executed_cell(filename): def find_executed_cell(filename):
"""Read the file and check whether there is a line with "execution_count" and a non null value.""" """Read the file and check whether there is a line with "execution_count" and a non null value."""
stream = open(filename) stream = open(filename, encoding="utf8", errors='ignore')
executed_cells = [line.strip("\n,\" ") for line in stream if "execution_count" in line and "null" not in line ] executed_cells = [line.strip("\n,\" ") for line in stream if "execution_count" in line and "null" not in line ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment