Skip to content

Sourcery refactored master branch #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions Screeney.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,29 @@
def get_matieres():
with open('liste_matieres.txt', 'r', encoding="utf-8") as f:
m = f.read().split('\n')
res = [mat.upper() for mat in m]
return res
return [mat.upper() for mat in m]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_matieres refactored with the following changes:


def CreerDossierSauvegarde(ou, doss):
nomEmplacementSauvegarde = ou + "/" + doss
nomEmplacementSauvegarde = f"{ou}/{doss}"
if not os.path.exists(nomEmplacementSauvegarde):
os.mkdir(nomEmplacementSauvegarde)
return nomEmplacementSauvegarde
else:
return nomEmplacementSauvegarde
return nomEmplacementSauvegarde
Comment on lines -16 to +18
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CreerDossierSauvegarde refactored with the following changes:



def SemblableFichier(fic, fic2):
a = os.path.getsize(fic)
b = os.path.getsize(fic2)
diff = abs(a - b)
print(diff)
if diff < 1000:
return True, diff
else:
return False, diff
return (True, diff) if diff < 1000 else (False, diff)
Comment on lines -29 to +26
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SemblableFichier refactored with the following changes:




def SupprimerFichier(path):
if os.path.exists(path):
os.remove(path)
else:
print("Impossible de supprimer le fichier " + path + " car il n'existe pas")
print(f"Impossible de supprimer le fichier {path} car il n'existe pas")
Comment on lines -40 to +34
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SupprimerFichier refactored with the following changes:



window = Tk()
Expand All @@ -59,15 +53,17 @@ def SupprimerFichier(path):

def open_folder():
nomMatiere = listeCombo.get()
if not nomMatiere == listeMatieres[-1]:
nomEmplacementSauvegarde = CreerDossierSauvegarde(CreerDossierSauvegarde("H:/Desktop", "SCREENEY"), "- " + nomMatiere)
if nomMatiere != listeMatieres[-1]:
nomEmplacementSauvegarde = CreerDossierSauvegarde(
CreerDossierSauvegarde("H:/Desktop", "SCREENEY"), f"- {nomMatiere}"
)

path = nomEmplacementSauvegarde
path = path.replace('/','\\')

print("open", path)
if os.path.exists(path):
command = 'explorer.exe ' + path
command = f'explorer.exe {path}'
Comment on lines -62 to +66
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function open_folder refactored with the following changes:

os.system(command)


Expand All @@ -88,41 +84,44 @@ def capturer():


nomMatiere = listeCombo.get()
if not nomMatiere == listeMatieres[-1]:
if nomMatiere != listeMatieres[-1]:
nomEmplacementSauvegarde = CreerDossierSauvegarde(
CreerDossierSauvegarde(CreerDossierSauvegarde("h:/Desktop", "SCREENEY"), "- " + nomMatiere.lower()),
datetime.datetime.now().strftime('%Y-%m-%d (%a)'))
CreerDossierSauvegarde(
CreerDossierSauvegarde("h:/Desktop", "SCREENEY"),
f"- {nomMatiere.lower()}",
),
datetime.datetime.now().strftime('%Y-%m-%d (%a)'),
)

comm = Comment.get()
comm = comm.strip()
if len(comm) > 0:
comm = ' ' + comm
comm = f' {comm}'

myDatetime = datetime.datetime.now()
nomFichier = myDatetime.strftime('%Y-%m-%d-%H%M%S' + comm)
photo = nomEmplacementSauvegarde + "/" + nomFichier + ".png"
nomFichier = myDatetime.strftime(f'%Y-%m-%d-%H%M%S{comm}')
photo = f"{nomEmplacementSauvegarde}/{nomFichier}.png"

# prendre photo
pyautogui.screenshot(photo)
print("#" + str(c) + "# " + photo)
print(f"#{str(c)}# {photo}")

# pour les photo sauf la premiere
if (c > 0):
# si photo semblable a lancienne photo alors suprr photo
semblable = SemblableFichier(photo, ancienphoto)
if semblable[0]:
print(">>> PAREIL! " + str(semblable[1]) + " # " + photo + " VS " + ancienphoto)
print(f">>> PAREIL! {str(semblable[1])} # {photo} VS {ancienphoto}")
label.config(text="Image similaire ! Je cala pas", fg='red')
SupprimerFichier(photo)
# sinon, si nouvelle photo
else:
c += 1
label.config(text="#" + str(c) + " ▪ " + photo.split('/')[-1], fg='green')
label.config(text=f"#{c} ▪ " + photo.split('/')[-1], fg='green')
ancienphoto = photo

else:
c += 1
label.config(text="#" + str(c) + " ▪ " + photo.split('/')[-1], fg='green')
label.config(text=f"#{c} ▪ " + photo.split('/')[-1], fg='green')
Comment on lines -91 to +124
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function capturer refactored with the following changes:

This removes the following comments ( why? ):

# sinon, si nouvelle photo

ancienphoto = photo

time.sleep(1)
Expand Down