Skip to content

Commit

Permalink
Merge pull request #11 from Klaynight-dev/Klaynight-dev-patch-4
Browse files Browse the repository at this point in the history
Logs update
  • Loading branch information
Klaynight-dev authored May 16, 2024
2 parents 898896d + 6bc02e0 commit e8a21d6
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 687 deletions.
36 changes: 0 additions & 36 deletions README.md

This file was deleted.

68 changes: 0 additions & 68 deletions content/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,71 +76,3 @@ QTreeWidget QAbstractItemView QLineEdit {
background-color: #ffffff;

}

QTabWidget::pane {
border: 1px solid lightgray;
top: -1px;
background: rgb(245, 245, 245);
}

QTabBar::tab {
background: rgb(210, 210, 210);
border: 1px solid lightgray;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
}

QTabBar::tab:selected {
background: rgb(210, 250, 255);
margin-bottom: -1px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}

QTabBar::tab:hover {
background: rgb(225, 225, 225)
}

QScrollArea {
border: none;
}

QScrollBar {
background: rgb(245, 245, 245);
border-radius: 8px;
}

QScrollBar:horizontal {
height: 8px;
}

QScrollBar:vertical {
width: 8px;
}

QScrollBar::handle {
background: rgb(138, 138, 138);
border-radius: 5px;
}

QScrollBar::handle:horizontal {
height: 25px;
min-width: 10px;
}

QScrollBar::handle:vertical {
width: 25px;
min-height: 10px;
}

QScrollBar::add-line {
border: none;
background: none;
}

QScrollBar::sub-line {
border: none;
background: none;
}
11 changes: 4 additions & 7 deletions library_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,20 @@ def update_book_details(self, book):
break # Sortir de la boucle une fois le livre mis à jour

# Méthode pour afficher les livres en fonction de différents critères de recherche
def display_books(self, query=None, by_isbn=False, by_author=False, by_title=False, by_total_copies=False, by_available_copies=False, by_publisher=False, by_ID=False):
def display_books(self, query=None, by_isbn=False, by_author=False, by_title=False, by_copies=False, by_publisher=False):
if query:
filtered_books = []
for book in self.books:
if (by_isbn and query.lower() in book.isbn.lower()) or \
(by_author and query.lower() in book.author.lower()) or \
(by_title and query.lower() in book.title.lower()) or \
(by_available_copies and query.lower() in str(book.available_copies).lower()) or \
(by_publisher and query.lower() in book.publisher.lower()) or \
(by_total_copies and query.lower() in str(book.total_copies).lower()) or \
(by_ID and query.lower() in str(book.book_id).lower()):
(by_copies and query.lower() in str(book.available_copies).lower()) or \
(by_publisher and query.lower() in book.publisher.lower()): # Recherche par Publisher
filtered_books.append(book)
return filtered_books
else:
return self.books


# Méthode pour importer des livres à partir d'un fichier CSV
def import_from_csv(self, file_path):
try:
Expand Down Expand Up @@ -118,7 +115,7 @@ def import_from_csv(self, file_path):
# Méthode pour obtenir un livre par son ID
def get_book_by_id(self, book_id):
for book in self.books:
if book.book_id == int(book_id):
if book.book_id == book_id:
return book
log_action(f"Aucun livre trouvé avec l'ID={book_id}", success=False)
return None # Si aucun livre correspondant à l'ID n'est trouvé
49 changes: 24 additions & 25 deletions logs.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# logs.py

import os
from datetime import datetime

def create_log_directory():
log_directory = 'data/logs/'
if not os.path.exists(log_directory):
os.makedirs(log_directory)

def get_log_filename():
now = datetime.now()
log_directory = 'data/logs/'
return f"{log_directory}{now.strftime('%Y-%m-%d_%H')}.log"

def log_action(action, success=True, error_message=None):
log_filename = get_log_filename()
with open(log_filename, 'a') as log_file:
log_file.write(f"Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
log_file.write(f"Action: {action}\n")
log_file.write(f"Success: {'Yes' if success else 'No'}\n")
if not success and error_message:
log_file.write(f"Error: {error_message}\n")
log_file.write("\n")

# logs.py

import os
from datetime import datetime

def create_log_directory():
log_directory = 'data/logs/'
if not os.path.exists(log_directory):
os.makedirs(log_directory)

def get_log_filename():
now = datetime.now()
log_directory = 'data/logs/'
return f"{log_directory}{now.strftime('%Y-%m-%d_%H')}_log.txt"

def log_action(action, success=True, error_message=None):
log_filename = get_log_filename()
with open(log_filename, 'a') as log_file:
log_file.write(f"Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
log_file.write(f"Action: {action}\n")
log_file.write(f"Success: {'Yes' if success else 'No'}\n")
if not success and error_message:
log_file.write(f"Error: {error_message}\n")
log_file.write("\n")
Loading

0 comments on commit e8a21d6

Please sign in to comment.