- Create a virtualenv
$ virtualenv -p python3.8 venv
import datetime | |
from app import db | |
# from models.data_schema import ... | |
class Database: | |
"""CRUD (Create Read Update Delete) Interface | |
for Sqlite3/SQLAlachemy ORM database""" | |
def __init__(self, database): | |
self.conn = database |
prog() { | |
local w=80 p=$1; shift | |
# create a string of spaces, then change them to dots | |
printf -v dots "%*s" "$(( $p*$w/100 ))" ""; dots=${dots// /.}; | |
# print those dots on a fixed-width space plus the percentage etc. | |
printf "\r\e[K|%-*s| %3d %% %s" "$w" "$dots" "$p" "$*"; | |
} | |
# Test loop |
def clean_text(text): | |
""" | |
performs a few cleanning steps to remove non-alphabetic characters | |
:param text: | |
:return: | |
""" | |
# replace new line and carriage return with space | |
text = text.replace("\n", " ").replace("\r", " ") |
def surgery(liste): | |
if len(liste) % 2 == 0 and len(liste) != 0: | |
liste[0], liste[1] = liste[1], liste[0] | |
elif len(liste) % 2 != 0 and len(liste) != 0: | |
dernier = len(liste) - 1 | |
avant = len(liste) - 2 | |
liste[dernier], liste[avant] = liste[avant], liste[dernier] | |
else: | |
liste | |
return liste |
def counter(in_filename, out_filename): | |
f1 = open(in_filename, 'r', encoding='utf8') | |
with open(out_filename, 'w', encoding='utf8') as out_f: | |
for position, line in enumerate(f1): | |
position += 1 | |
# >> position (int) : number of words (int) : number of letters (int) : line (str) | |
out_f.write(f"{position}:{len(line.split())}:{len(line)}:{line}") | |
f1.close | |
from termcolor import colored | |
liste = [1, 4, 7, 0.4] | |
for i in liste: | |
if max(liste) == i: | |
print(colored(i, 'green')) | |
elif min(liste) == i: |
from PIL import Image, ExifTags | |
# ici on charge l'image | |
img = Image.open("./Datatest_img/FRAN_0025_0567_L.jpg") | |
print(dir(img)) | |
# [... 'getexif' ...] | |
img_exif = img.getexif() |
from lxml import etree as ET | |
import sys | |
from termcolor import colored | |
def validator_rng(source_xml, schema_rng): | |
""" a little program to validate a xml source | |
with a RelaxNG schema | |
:param source_xml: source xml name to validate | |
:type source_xml: str | |
:param schema_rng: RNG schema for validate |