https://api.photo.2gis.com/2.0/photo/get?key=gYu1s9N1wP&object_id=70000001041515922&object_type=branch&locale=ru_RU&status=active&sort_by=position&album_code=common&preview_size=600x600,300x300,100x100&size=4&page=1
Необходимо проверить/найти
import re
source_name = '34234 334234'
pat_0 = r'\d+'
pat_1 = r'[А-В]Т\-[А-В]Ш\-[А-В]Д'
pat_2 = r'[А-В]Т\-[А-В]Ш'
pat_3 = r'[А-В]\-[А-В]Ш'
pat_4 = r'\s[А-В]\-'
pat_5 = r'\/[А-В]\-'
patterns = [pat_0, pat_1, pat_2, pat_3, pat_4, pat_5]
# Проверить
found = False
for p in patterns:
if re.search(p, source_name):
found = True
break;
if found:
print("Yes")
else:
print("No")
# Найти
for f in list(map(lambda p: re.findall(p, source_name), patterns)):
for v in [i for i in f if f]:
print(v)
Как
view_folder(arg_parser.path, arg_parser.format, arg_parser.img, arg_parser.dell, arg_parser.dir, arg_parser.del_all)
view_folder(**arg_parser)
confirm = input('\nDelete this files? press: y/n: ')
if not confirm:
del_file(difference)
sys.exit('Complete\n')
elif confirm == 'n':
sys.exit('Cancelled\n')
else:
print('Invalid input')
#Если файл в папке raw_file уже существует, создать копию
i = 1
while True:
if not pathlib.Path(file.parent / 'raw_files' / f'{p.stem}({i}){file.suffix}').is_file():
pathlib.Path(file).replace(file.parent / 'raw_files' / f'{file.stem}({i}){file.suffix}')
break
else:
i += 1
try:
pathlib.Path(f / 'raw_files').mkdir(exist_ok=True)
except FileNotFoundError:
except FileNotFoundError:
print(f'Folder {f} not found')
err += 1
continue
TRUNCATE TABLE
то остается вариант такойDELETE FROM table_name
import datetime
days_diff = 2
date_limit = (datetime.datetime.now() - datetime.timedelta(days=days_diff)).strftime("%Y-%m-%d")
DELETE FROM table_name WHERE strftime("%Y-%m-%d", created_at) <= date_limit
Слыхал про QSqlDatabase, но функционал у класа для меня будет маловато
con = QtSql.QSqlDatabase.addDatabase('QSQLITE')
con.setDatabaseName('data.sqlite')
con.open()
stm = QtSql.QSqlTableModel()
stm.setTable('table_name')
stm.select()
tv = QtWidgets.QTableView()
tv.setModel(stm)
global Dialog
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
from PyQt5 import QtWidgets
from modules.main_module import main_module
import sys
# ------------------------------------------------------------------------------- #
#
# ------------------------------------------------------------------------------- #
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = main_module()
window.show_window()
sys.exit(app.exec_())
from PyQt5 import QtWidgets, QtSql, QtCore, QtGui
import ui.ui_main as ui_main
from modules.win1_module import win1_module
from modules.win2_module import win2_module
# ------------------------------------------------------------------------------- #
#
# ------------------------------------------------------------------------------- #
class main_module(QtWidgets.QMainWindow):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
QtWidgets.QMainWindow.__init__(self, parent)
self.ui = ui_main.Ui_MainWindow()
self.ui.setupUi(self)
self.ui.btn_win1.clicked.connect(
self.on_show_win1)
self.ui.btn_win2.clicked.connect(
self.on_show_win2)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_show_win1(self):
"""
"""
self.win1 = win1_module(self)
self.win1.show()
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_show_win2(self):
"""
"""
self.win2 = win2_module(self)
self.win2.show()
# --------------------------------------------------------------------------- #
# Показывыет главное окно программы
# Отображение по середине экрана
# --------------------------------------------------------------------------- #
def show_window(self):
"""
"""
desktop = QtWidgets.QApplication.desktop()
x = (desktop.width() - self.width()) // 2
y = (desktop.height() - self.height()) // 2
self.move(x, y)
self.show()
from PyQt5 import QtWidgets, QtCore, QtSql, QtGui
import ui.ui_win1 as ui_win1
# ------------------------------------------------------------------------------- #
#
#
# ------------------------------------------------------------------------------- #
class win1_module(QtWidgets.QDialog):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
super().__init__(parent=parent)
self.setWindowModality(QtCore.Qt.WindowModal)
self.setWindowFlags(self.windowFlags() |
QtCore.Qt.WindowMaximizeButtonHint)
self.ui = ui_win1.Ui_Dialog()
self.ui.setupUi(self)
self.main = parent
self.setWindowTitle("Окно №1")
self.ui.btn_close.clicked.connect(
self.on_close)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_close(self):
"""
"""
self.close()
from PyQt5 import QtWidgets, QtCore, QtSql, QtGui
import ui.ui_win2 as ui_win2
# ------------------------------------------------------------------------------- #
#
#
# ------------------------------------------------------------------------------- #
class win2_module(QtWidgets.QDialog):
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self, parent=None):
"""
"""
super().__init__(parent=parent)
self.setWindowModality(QtCore.Qt.WindowModal)
self.setWindowFlags(self.windowFlags() |
QtCore.Qt.WindowMaximizeButtonHint)
self.ui = ui_win2.Ui_Dialog()
self.ui.setupUi(self)
self.main = parent
self.setWindowTitle("Окно №2")
self.ui.btn_close.clicked.connect(
self.on_close)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def on_close(self):
"""
"""
self.close()
class Actor:
def line(self):
print('Not Implemented')
class Pirat(Actor):
@staticmethod
def line():
print('I\'m Pirat')
class Carrot(Actor):
@staticmethod
def line():
print('I\'m Carrot')
class Customer:
@staticmethod
def line():
print('I\'m customer')
class Starter:
def play(self, who):
return who.line()
class Scene:
def __init__(self):
self.starter = Starter()
def the_play(self, who):
self.starter.play(who)
if __name__ == '__main__':
Scene().the_play(Carrot())
Scene().the_play(Customer())