Files
projects/funkce1.py
michaela.buzalkova b45a8b2d00 Initial commit
2025-09-30 08:22:44 +02:00

38 lines
1.2 KiB
Python

import os, fdb,re
import datetime
def prejmenuj_chybny_soubor(souborname,cesta):
if souborname[0]!="":
soubornovy = "" + souborname
os.rename(os.path.join(cesta,souborname),os.path.join(cesta,soubornovy))
def kontrola_struktury(souborname,connection):
if souborname.endswith('.pdf'):
#kontrola struktury
pattern=re.compile(r'(\d{9,10}) (\d{4}-\d{2}-\d{2}) (\w+, \w.+?) \[(.+?)\] \[(.*?)\]')
match=pattern.search(souborname)
# print(souborname)
vpohode=True
if match and len(match.groups())==5:
datum=match.group(2)
try:
datum_object = datetime.datetime.strptime(datum,"%Y-%m-%d").date()
# print(datum_object)
except:
vpohode=False
return vpohode
cur = connection.cursor()
cur.execute("select count(*) from kar where rodcis=?", (match.group(1),))
row = cur.fetchone()[0]
if row!=1:
vpohode = False
return vpohode
else:
vpohode=False
return vpohode
else:
vpohode=False
return vpohode
return vpohode