From a1f7c1f86d6dcc1191ef72274617ca3cdb9f0895 Mon Sep 17 00:00:00 2001 From: Theocat321 Date: Fri, 9 Jul 2021 21:33:59 +0100 Subject: [PATCH] Re enabled all the prints, didnt do the log levels --- lib/dataStructures.py | 46 +++++++++++++++++++++---------------------- lib/initSongs.py | 6 +++--- output2img.py | 10 +++++----- output2txt.py | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/dataStructures.py b/lib/dataStructures.py index ff2d753..8ea719b 100644 --- a/lib/dataStructures.py +++ b/lib/dataStructures.py @@ -47,30 +47,30 @@ def readSourceFile(inputFile): def isTablatureData(inputString): if not inputString: return - #print("Checking '{}' for line type".format(inputString)) + print("Checking '{}' for line type".format(inputString)) # Assume tablature line if any character {/, #, (, ), } tablatureSpecificCharacterString = r"/#" if any(elem in inputString for elem in tablatureSpecificCharacterString): - #print("'{}' is a tablature line, since it contains a tablature specific character".format(inputString)) + print("'{}' is a tablature line, since it contains a tablature specific character".format(inputString)) return True # Assume LYRIC line if any TEXT character OTHER THAN {a, b, c, d, e, f, g, h, b, x, m, j, n} lyricSpecificCharacterString = r"abcdefghbxmjn" for char in inputString: if char.isalpha(): if not char.lower() in lyricSpecificCharacterString: - #print("'{}' is a LYRIC line, since it contains lyric specific text characters".format(inputString)) + print("'{}' is a LYRIC line, since it contains lyric specific text characters".format(inputString)) return False # Assume tablature line if any digit if any(char.isdigit() for char in inputString): - #print("'{}' is a tablature line, since it contains a number".format(inputString)) + print("'{}' is a tablature line, since it contains a number".format(inputString)) return True # Assume LYRIC line if any character {.} lyricSpecialChars = r"." if any(elem in inputString for elem in lyricSpecialChars): - #print("'{}' is a LYRIC line, since it contains lyric specific special characters".format(inputString)) + print("'{}' is a LYRIC line, since it contains lyric specific special characters".format(inputString)) return False # Else warn and assume tablature line - #print("Unable to identify if '{}' is a lyric or tablature line. Assuming it is a tablature line. Please improve the isTablatureData function".format(inputString)) + print("Unable to identify if '{}' is a lyric or tablature line. Assuming it is a tablature line. Please improve the isTablatureData function".format(inputString)) return True """!@brief Class containing Section specific data @@ -103,7 +103,7 @@ class Section: headerWidth, headerHeight = fontTablature.getsize(self.header) heightSum += headerHeight maxWidth = headerWidth - #print("With header, dimensions of section '{}' start at {}H{}B".format(self.header[:-2], heightSum, maxWidth)) + print("With header, dimensions of section '{}' start at {}H{}B".format(self.header[:-2], heightSum, maxWidth)) while lineIterator < amountOfLines: # Get chord&lyric line dimensions lyricTextWidth, lyricTextHeight = fontLyrics.getsize(self.lyrics[lineIterator]) @@ -131,7 +131,7 @@ class Section: continue # Determine lyric or tablature line currentIsTablature = isTablatureData(line) - #print("Have line {} isTab={}, isLyric={}".format(line, currentIsTablature, not currentIsTablature)) + print("Have line {} isTab={}, isLyric={}".format(line, currentIsTablature, not currentIsTablature)) # Initially just fill in the first line correctly if isFirstLine: isFirstLine = False @@ -143,16 +143,16 @@ class Section: # we need to insert an empty line of the other type elif currentIsTablature == prevWasTablature: if currentIsTablature: - #print("Inserting empty Lyric line") + print("Inserting empty Lyric line") self.tablatures.append(line) self.lyrics.append("") else: - #print("Inserting empty tablature line") + print("Inserting empty tablature line") self.lyrics.append(line) self.tablatures.append("") # also insert the current line elif currentIsTablature: - #print("Inserting empty Lyric line") + print("Inserting empty Lyric line") self.tablatures.append(line) else: self.lyrics.append(line) @@ -244,7 +244,7 @@ class Song: currentHeight += metadataTextHeight self.metadataWidth = maxWidth self.metadataHeight = currentHeight - #print("metadata dimensions are {}h : {}w".format(currentHeight, maxWidth)) + print("metadata dimensions are {}h : {}w".format(currentHeight, maxWidth)) """!@brief Resizes all sections by a specified amount Also recalculates all section sizes afterwards @@ -252,7 +252,7 @@ class Song: @return None """ def resizeAllSections(self, mutator): - #print("Resizing font by {} to {}".format(mutator, self.fontSize)) + print("Resizing font by {} to {}".format(mutator, self.fontSize)) self.fontSize += mutator self.fontLyrics = ImageFont.truetype(self.fontFamilyLyrics, self.fontSize) self.fontTablature = ImageFont.truetype(self.fontFamilyTablature, self.fontSize) @@ -281,10 +281,10 @@ class Song: def fitSectionsByWidth(self): self.prerenderSections() while not self.checkOverflowX(): - #print("Resizing down to prevent overflow on the width of the page") + print("Resizing down to prevent overflow on the width of the page") self.resizeAllSections(-1) while not self.checkOverflowMetadata(): - #print("Resizing down to prevent overflow on the width of the page") + print("Resizing down to prevent overflow on the width of the page") self.resizeMetadata(-1) """!@brief Checks whether we are overflowing on the width of the page @@ -366,8 +366,8 @@ class Song: whitespace = self.imageHeight - curPage.totalHeight amountWeAreShort = nextFirstSection.expectedHeight - whitespace shortInPercentages = amountWeAreShort / self.imageHeight - #print("Whitespace {} vs next section height {}".format(whitespace, nextFirstSection.expectedHeight)) - #print("We are {} short to fit the next image (total image height {} => {}% of total height)".format(amountWeAreShort, self.imageHeight, shortInPercentages*100)) + print("Whitespace {} vs next section height {}".format(whitespace, nextFirstSection.expectedHeight)) + print("We are {} short to fit the next image (total image height {} => {}% of total height)".format(amountWeAreShort, self.imageHeight, shortInPercentages*100)) # Since we also resize based on minimum required whitespaces, we can be a bit more aggressive with this if shortInPercentages < self.tryToShrinkRatio: return True @@ -428,7 +428,7 @@ class Song: lines = parseData.splitlines(True) if not len(lines): return - #print("We found {} lines of data".format(len(lines))) + print("We found {} lines of data".format(len(lines))) # Init first section by popping the delimiter thisSection = Section() thisSection.header = lines.pop(0) @@ -448,15 +448,15 @@ class Song: # Reset, new section thisSection = Section() thisSection.header = line - #print("Header is '{}'".format(thisSection.header)) + print("Header is '{}'".format(thisSection.header)) isTabLine = True # Else is has lines in order tabline->lyricline->repeat elif isTabLine: - #print("Adding Tabline is '{}'".format(line)) + print("Adding Tabline is '{}'".format(line)) thisSection.tablatures.append(line) isTabLine = False else: - #print("Adding Lyricline is '{}'".format(line)) + print("Adding Lyricline is '{}'".format(line)) thisSection.lyrics.append(line) isTabLine = True # Add final section data @@ -476,7 +476,7 @@ class Song: self.rawData = readSourceFile(self.inputFile) # Clean up input parseData = stripEmptyLines(self.rawData) - #print("Clean data='{}'\n".format(parseData)) + print("Clean data='{}'\n".format(parseData)) # While not EOF: build sections untill new section found. delimiterIndex = parseData.find("[") if delimiterIndex == -1: @@ -508,7 +508,7 @@ class Song: else: # Set thisSection's data and remove it from the buffer thisSection.rawData = parseData[:delimiterIndex] - #print("set rawData of '{}' to this section".format(thisSection.rawData)) + print("set rawData of '{}' to this section".format(thisSection.rawData)) parseData = parseData[delimiterIndex:] # Finally parse section data thisSection.initSections() diff --git a/lib/initSongs.py b/lib/initSongs.py index 4c30194..3a3864a 100644 --- a/lib/initSongs.py +++ b/lib/initSongs.py @@ -32,7 +32,7 @@ def initSong(filePath): thisSong.outputLocation = filePath[:filePath.rfind('.')] # title is just the name of the .txt file thisSong.title = thisSong.outputLocation[filePath.rfind('/')+1:] - #print("Finished init for input file '{}'.\nBase output folder is '{}'\nSong title is '{}'\n".format(thisSong.inputFile, thisSong.outputLocation, thisSong.title)) + print("Finished init for input file '{}'.\nBase output folder is '{}'\nSong title is '{}'\n".format(thisSong.inputFile, thisSong.outputLocation, thisSong.title)) return thisSong """!@brief Creates a list of files found in a directory and its subdirectories @@ -43,7 +43,7 @@ def initSong(filePath): """ def walkDirectory(root, depth): pathList = [] - #print("Walking directory '{}'".format(root)) + print("Walking directory '{}'".format(root)) def do_scan(start_dir,output,depth=2): for f in os.listdir(start_dir): ff = os.path.join(start_dir,f) @@ -73,7 +73,7 @@ def getSongObjects(): for inputFolder in configObj['inputfolders'].split(','): for filePath in walkDirectory(inputFolder, recursionDepth): if ((filePath[filePath.find('.'):] == ".txt" ) and configObj['readtxt'] == '1') or ((filePath[filePath.find('.'):] == ".rawtxt" ) and configObj['readraw'] == '1'): - #print("Found supported file '{}'".format(filePath)) + print("Found supported file '{}'".format(filePath)) txtFileLocations.append(filePath) #else: #print("Skipping file '{}' for it is not a supported file".format(filePath)) diff --git a/output2img.py b/output2img.py index ff77fbd..9b9c751 100644 --- a/output2img.py +++ b/output2img.py @@ -31,8 +31,8 @@ def outputToImage(folderLocation, songObj): if not os.path.exists(folderLocation): os.mkdir(folderLocation) print("Directory " , folderLocation , " Created ") - #else: - #print("Directory " , folderLocation , " already exists") + else: + print("Directory " , folderLocation , " already exists") # Init image info imageNumber = 1 @@ -48,7 +48,7 @@ def outputToImage(folderLocation, songObj): line = line.rstrip() if not line: continue - #print("meta line '{}'".format(line)) + print("meta line '{}'".format(line)) metadataTextWidth, metadataTextHeight = songObj.fontMetadata.getsize(line) draw.text((songObj.leftMargin,currentHeight), line, fill=songObj.metadataColour, font=songObj.fontMetadata) currentHeight += metadataTextHeight @@ -72,7 +72,7 @@ def outputToImage(folderLocation, songObj): currentHeight += headerHeight # Write each line tablature&lyric data while lineIterator < amountOfLines: - #print("Printing tablatures line {} and lyrics line {}".format(section.tablatures[lineIterator], section.lyrics[lineIterator])) + print("Printing tablatures line {} and lyrics line {}".format(section.tablatures[lineIterator], section.lyrics[lineIterator])) # Get tablatures&lyric line lyricTextWidth, lyricTextHeight = songObj.fontLyrics.getsize(section.lyrics[lineIterator]) tablatureTextWidth, tablatureTextHeight = songObj.fontTablature.getsize(section.tablatures[lineIterator]) @@ -82,7 +82,7 @@ def outputToImage(folderLocation, songObj): draw.text((songObj.leftMargin,currentHeight), section.lyrics[lineIterator], fill=songObj.fontColour, font=songObj.fontLyrics) currentHeight += lyricTextHeight lineIterator += 1 - #print("currentheight={}".format(currentHeight)) + print("currentheight={}".format(currentHeight)) # Margin between each section currentHeight += songObj.topMargin # Got all sections in the page, so write it diff --git a/output2txt.py b/output2txt.py index cf617fe..4c7a8da 100644 --- a/output2txt.py +++ b/output2txt.py @@ -45,7 +45,7 @@ def outputToTxt(folderLocation, printRaw, songObj): line = line.rstrip() if not line: continue - #print("meta line '{}'".format(line)) + print("meta line '{}'".format(line)) output += line + '\r\n' # If exporting raw, do not include the whitespace between metadata and sections if not printRaw: