Update name convention to PEP8

Variable name where not following PEP8 convention
This commit is contained in:
cuissedemouche 2022-12-15 16:07:45 +00:00
parent 01fa56af03
commit 03c0ad0635
4 changed files with 73 additions and 72 deletions

2
.gitignore vendored
View File

@ -122,3 +122,5 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
TODO

View File

@ -1 +1 @@
# mediainfoSama # mediaInfoSama

View File

@ -2,14 +2,14 @@ import os, subprocess, json
from shlex import quote from shlex import quote
class FileCmds: class FileCmds:
def __init__(self, filePath): def __init__(self, file_path):
super().__init__() super().__init__()
self.filePath = filePath self.file_path = file_path
self.trackCount = self.track_count() self.track_count = self.track_count()
self.basicInfo = self.generate_basic() self.basic_info = self.generate_basic()
self.advancedInfo = self.generate_advanced() self.advanced_info = self.generate_advanced()
self.tabsList = self.generate_tabs_list() self.tabs_list = self.generate_tabs_list()
self.tabsContent = self.generate_tabs_content() self.tabs_content = self.generate_tabs_content()
def execute_bash(self, cmd): def execute_bash(self, cmd):
@ -30,7 +30,7 @@ class FileCmds:
:rtype: bool :rtype: bool
''' '''
if os.path.exists(self.filePath): if os.path.exists(self.file_path):
return True return True
else: else:
print("The file doesn't exist") print("The file doesn't exist")
@ -41,11 +41,11 @@ class FileCmds:
''' '''
Execute mediainfo --Inform Execute mediainfo --Inform
:type inform: rstr :type inform: str
:rtype: str :rtype: str
''' '''
bashCommand = f"mediainfo --Inform={quote(inform)} {quote(self.filePath)}" bash_command = f"mediainfo --Inform={quote(inform)} {quote(self.file_path)}"
output = self.execute_bash(bashCommand).decode('utf-8') output = self.execute_bash(bash_command).decode('utf-8')
return output return output
@ -55,7 +55,7 @@ class FileCmds:
:rtype: dict[str,int] :rtype: dict[str,int]
''' '''
trackTypes = [ track_types = [
"Video", "Video",
"Audio", "Audio",
"Text", "Text",
@ -65,11 +65,11 @@ class FileCmds:
output = {} output = {}
for trackType in trackTypes: for track_type in track_types:
count = self.media_inform(f"General;%{trackType}Count%").replace('\n', '') count = self.media_inform(f"General;%{track_type}Count%").replace('\n', '')
if not count: if not count:
count = 0 count = 0
output[trackType] = int(count) output[track_type] = int(count)
return output return output
@ -80,32 +80,32 @@ class FileCmds:
:rtype: string :rtype: string
''' '''
informGeneral = r"General;G: %Format%, %FileSize_String%, %Duration_String%, %BitRate_String%\n" inform_general = r"General;G: %Format%, %FileSize_String%, %Duration_String%, %BitRate_String%\n"
informVideo = r"Video;V: %Format%, %Format_Profile%, %StreamSize_String%, %Width%x%Height%, %FrameRate% FPS, %BitRate_String%\n" inform_video = r"Video;V: %Format%, %Format_Profile%, %StreamSize_String%, %Width%x%Height%, %FrameRate% FPS, %BitRate_String%\n"
informAudio = r"Audio;A: %Language_String%, %Format%, %StreamSize_String%, %BitRate_String%, %Channel(s)_String%, %SamplingRate_String%\n" inform_audio = r"Audio;A: %Language_String%, %Format%, %StreamSize_String%, %BitRate_String%, %Channel(s)_String%, %SamplingRate_String%\n"
informText = r"Text;T: %Language_String%, %Format%\n" inform_text = r"Text;T: %Language_String%, %Format%\n"
informs = [informGeneral] informs = [inform_general]
if not self.trackCount["Video"] == 0: if not self.track_count["Video"] == 0:
informs.append(informVideo) informs.append(inform_video)
if not self.trackCount["Audio"] == 0: if not self.track_count["Audio"] == 0:
informs.append(informAudio) informs.append(inform_audio)
if not self.trackCount["Text"] == 0: if not self.track_count["Text"] == 0:
informs.append(informText) informs.append(inform_text)
output = "" output = ""
for inform in informs: for inform in informs:
output += self.media_inform(inform) output += self.media_inform(inform)
if not self.trackCount["Menu"] == 0: if not self.track_count["Menu"] == 0:
output += "M: Menu\n\n" output += "M: Menu\n\n"
output += "\n" output += "\n"
output += self.execute_bash(f"mediainfo {quote(self.filePath)}").decode('utf-8') output += self.execute_bash(f"mediainfo {quote(self.file_path)}").decode('utf-8')
return(output) return(output)
@ -115,7 +115,7 @@ class FileCmds:
:rtype: string :rtype: string
''' '''
output = self.execute_bash(f"mediainfo --Full {quote(self.filePath)}").decode('utf-8') output = self.execute_bash(f"mediainfo --Full {quote(self.file_path)}").decode('utf-8')
return output return output
@ -125,40 +125,40 @@ class FileCmds:
:rtype: list :rtype: list
''' '''
tabsStr = "" tab_str = ""
tabs = ["Basic", "Advanced"] tabs = ["Basic", "Advanced"]
informGeneral = r"General;General (%Format%)\n" inform_general = r"General;General (%Format%)\n"
informs = [informGeneral] informs = [inform_general]
if self.trackCount["Video"] == 1: if self.track_count["Video"] == 1:
informVideo = r'Video;Video (%Format%)\n' inform_video = r'Video;Video (%Format%)\n'
informs.append(informVideo) informs.append(inform_video)
elif self.trackCount["Video"] > 1: elif self.track_count["Video"] > 1:
informVideo = r'Video;Video #%StreamKindPos% (%Format%)\n' inform_video = r'Video;Video #%StreamKindPos% (%Format%)\n'
informs.append(informVideo) informs.append(inform_video)
if self.trackCount["Audio"] == 1: if self.track_count["Audio"] == 1:
informAudio = r'Audio;Audio (%Format%)\n' inform_audio = r'Audio;Audio (%Format%)\n'
informs.append(informAudio) informs.append(inform_audio)
elif self.trackCount["Audio"] > 1: elif self.track_count["Audio"] > 1:
informAudio = r'Audio;Audio #%StreamKindPos% (%Format%)\n' inform_audio = r'Audio;Audio #%StreamKindPos% (%Format%)\n'
informs.append(informAudio) informs.append(inform_audio)
if self.trackCount["Text"] == 1: if self.track_count["Text"] == 1:
informText = r'Text;Text (%Format%)\n' inform_text = r'Text;Text (%Format%)\n'
informs.append(informText) informs.append(inform_text)
elif self.trackCount["Text"] > 1: elif self.track_count["Text"] > 1:
informText = r'Text;Text #%StreamKindPos% (%Format%)\n' inform_text = r'Text;Text #%StreamKindPos% (%Format%)\n'
informs.append(informText) informs.append(inform_text)
for inform in informs: for inform in informs:
tabsStr += self.media_inform(inform) tab_str += self.media_inform(inform)
if not self.trackCount["Menu"] == 0: if not self.track_count["Menu"] == 0:
tabsStr += "Menu" tab_str += "Menu"
tabs.extend(list(filter(None, tabsStr.split("\n")))) tabs.extend(list(filter(None, tab_str.split("\n"))))
return tabs return tabs
@ -168,15 +168,15 @@ class FileCmds:
:rtype: dict[str:str] :rtype: dict[str:str]
''' '''
tracksList = self.advancedInfo.split("\n\n") track_list = self.advanced_info.split("\n\n")
del tracksList[-1] del track_list[-1]
tabs = {} tabs = {}
tabs["Basic"] = self.basicInfo tabs["Basic"] = self.basic_info
tabs["Advanced"] = self.advancedInfo tabs["Advanced"] = self.advanced_info
for i in range(len(tracksList)): for i in range(len(track_list)):
tabs.update({self.tabsList[i+2]: tracksList[i]}) tabs.update({self.tabs_list[i+2]: track_list[i]})
return tabs return tabs

View File

@ -1,7 +1,6 @@
from PySide6.QtWidgets import QWidget from PySide6.QtWidgets import QWidget
from ui_main_window import Ui_MainWindow from ui_main_window import Ui_MainWindow
from file_cmds import FileCmds from file_cmds import FileCmds
from PySide6.QtGui import QFont
from PySide6.QtCore import QSize from PySide6.QtCore import QSize
@ -9,8 +8,8 @@ class MainWindow(QWidget, Ui_MainWindow):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.windowTitle = "mediainfoSama" self.window_title = "mediaInfoSama"
self.setWindowTitle(self.windowTitle) self.setWindowTitle(self.window_title)
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.setupConnections() self.setupConnections()
@ -31,20 +30,20 @@ class MainWindow(QWidget, Ui_MainWindow):
def dropEvent(self, event): def dropEvent(self, event):
self.filePath = event.mimeData().urls()[0].toLocalFile() self.file_path = event.mimeData().urls()[0].toLocalFile()
self.fileCmds = FileCmds(self.filePath) self.file_cmds = FileCmds(self.file_path)
if self.fileCmds.file_exist() == False: if self.file_cmds.file_exist() == False:
return return
self.setWindowTitle(f"{self.filePath} - {self.windowTitle}") self.setWindowTitle(f"{self.file_path} - {self.window_title}")
self.populate_tabs() self.populate_tabs()
self.tracks_list_widget.item(0).setSelected(True) self.tracks_list_widget.item(0).setSelected(True)
def populate_tabs(self): def populate_tabs(self):
self.tracks_list_widget.clear() self.tracks_list_widget.clear()
self.tracks_list_widget.addItems(self.fileCmds.tabsList) self.tracks_list_widget.addItems(self.file_cmds.tabs_list)
for i in range(self.tracks_list_widget.count()): for i in range(self.tracks_list_widget.count()):
item = self.tracks_list_widget.item(i) item = self.tracks_list_widget.item(i)
@ -53,7 +52,7 @@ class MainWindow(QWidget, Ui_MainWindow):
def popuplate_content(self): def popuplate_content(self):
itemsSelected = self.tracks_list_widget.selectedItems() item_selected = self.tracks_list_widget.selectedItems()
if itemsSelected: if item_selected:
text = self.fileCmds.tabsContent[itemsSelected[0].text()] text = self.file_cmds.tabs_content[item_selected[0].text()]
self.detail_plain_text_edit.setPlainText(text) self.detail_plain_text_edit.setPlainText(text)