-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
res = [mat.upper() for mat in m] | ||
return res | ||
return [mat.upper() for mat in m] |
There was a problem hiding this comment.
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:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
nomEmplacementSauvegarde = ou + "/" + doss | ||
nomEmplacementSauvegarde = f"{ou}/{doss}" | ||
if not os.path.exists(nomEmplacementSauvegarde): | ||
os.mkdir(nomEmplacementSauvegarde) | ||
return nomEmplacementSauvegarde | ||
else: | ||
return nomEmplacementSauvegarde | ||
return nomEmplacementSauvegarde |
There was a problem hiding this comment.
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:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
if diff < 1000: | ||
return True, diff | ||
else: | ||
return False, diff | ||
return (True, diff) if diff < 1000 else (False, diff) |
There was a problem hiding this comment.
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:
- Replace if statement with if expression (
assign-if-exp
)
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") |
There was a problem hiding this comment.
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:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
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}' |
There was a problem hiding this comment.
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:
- Simplify logical expression using De Morgan identities (
de-morgan
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
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') |
There was a problem hiding this comment.
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:
- Simplify logical expression using De Morgan identities (
de-morgan
) - Use f-string instead of string concatenation [×18] (
use-fstring-for-concatenation
) - Remove unnecessary calls to
str()
from formatted values in f-strings [×2] (remove-str-from-fstring
)
This removes the following comments ( why? ):
# sinon, si nouvelle photo
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!