Re enabled all the prints, didnt do the log levels

This commit is contained in:
Theocat321 2021-07-09 21:33:59 +01:00
parent 5c82258228
commit a1f7c1f86d
4 changed files with 32 additions and 32 deletions

View File

@ -47,30 +47,30 @@ def readSourceFile(inputFile):
def isTablatureData(inputString): def isTablatureData(inputString):
if not inputString: if not inputString:
return return
#print("Checking '{}' for line type".format(inputString)) print("Checking '{}' for line type".format(inputString))
# Assume tablature line if any character {/, #, (, ), } # Assume tablature line if any character {/, #, (, ), }
tablatureSpecificCharacterString = r"/#" tablatureSpecificCharacterString = r"/#"
if any(elem in inputString for elem in tablatureSpecificCharacterString): 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 return True
# Assume LYRIC line if any TEXT character OTHER THAN {a, b, c, d, e, f, g, h, b, x, m, j, n} # 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" lyricSpecificCharacterString = r"abcdefghbxmjn"
for char in inputString: for char in inputString:
if char.isalpha(): if char.isalpha():
if not char.lower() in lyricSpecificCharacterString: 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 return False
# Assume tablature line if any digit # Assume tablature line if any digit
if any(char.isdigit() for char in inputString): 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 return True
# Assume LYRIC line if any character {.} # Assume LYRIC line if any character {.}
lyricSpecialChars = r"." lyricSpecialChars = r"."
if any(elem in inputString for elem in lyricSpecialChars): 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 return False
# Else warn and assume tablature line # 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 return True
"""!@brief Class containing Section specific data """!@brief Class containing Section specific data
@ -103,7 +103,7 @@ class Section:
headerWidth, headerHeight = fontTablature.getsize(self.header) headerWidth, headerHeight = fontTablature.getsize(self.header)
heightSum += headerHeight heightSum += headerHeight
maxWidth = headerWidth 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: while lineIterator < amountOfLines:
# Get chord&lyric line dimensions # Get chord&lyric line dimensions
lyricTextWidth, lyricTextHeight = fontLyrics.getsize(self.lyrics[lineIterator]) lyricTextWidth, lyricTextHeight = fontLyrics.getsize(self.lyrics[lineIterator])
@ -131,7 +131,7 @@ class Section:
continue continue
# Determine lyric or tablature line # Determine lyric or tablature line
currentIsTablature = isTablatureData(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 # Initially just fill in the first line correctly
if isFirstLine: if isFirstLine:
isFirstLine = False isFirstLine = False
@ -143,16 +143,16 @@ class Section:
# we need to insert an empty line of the other type # we need to insert an empty line of the other type
elif currentIsTablature == prevWasTablature: elif currentIsTablature == prevWasTablature:
if currentIsTablature: if currentIsTablature:
#print("Inserting empty Lyric line") print("Inserting empty Lyric line")
self.tablatures.append(line) self.tablatures.append(line)
self.lyrics.append("") self.lyrics.append("")
else: else:
#print("Inserting empty tablature line") print("Inserting empty tablature line")
self.lyrics.append(line) self.lyrics.append(line)
self.tablatures.append("") self.tablatures.append("")
# also insert the current line # also insert the current line
elif currentIsTablature: elif currentIsTablature:
#print("Inserting empty Lyric line") print("Inserting empty Lyric line")
self.tablatures.append(line) self.tablatures.append(line)
else: else:
self.lyrics.append(line) self.lyrics.append(line)
@ -244,7 +244,7 @@ class Song:
currentHeight += metadataTextHeight currentHeight += metadataTextHeight
self.metadataWidth = maxWidth self.metadataWidth = maxWidth
self.metadataHeight = currentHeight 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 """!@brief Resizes all sections by a specified amount
Also recalculates all section sizes afterwards Also recalculates all section sizes afterwards
@ -252,7 +252,7 @@ class Song:
@return None @return None
""" """
def resizeAllSections(self, mutator): 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.fontSize += mutator
self.fontLyrics = ImageFont.truetype(self.fontFamilyLyrics, self.fontSize) self.fontLyrics = ImageFont.truetype(self.fontFamilyLyrics, self.fontSize)
self.fontTablature = ImageFont.truetype(self.fontFamilyTablature, self.fontSize) self.fontTablature = ImageFont.truetype(self.fontFamilyTablature, self.fontSize)
@ -281,10 +281,10 @@ class Song:
def fitSectionsByWidth(self): def fitSectionsByWidth(self):
self.prerenderSections() self.prerenderSections()
while not self.checkOverflowX(): 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) self.resizeAllSections(-1)
while not self.checkOverflowMetadata(): 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) self.resizeMetadata(-1)
"""!@brief Checks whether we are overflowing on the width of the page """!@brief Checks whether we are overflowing on the width of the page
@ -366,8 +366,8 @@ class Song:
whitespace = self.imageHeight - curPage.totalHeight whitespace = self.imageHeight - curPage.totalHeight
amountWeAreShort = nextFirstSection.expectedHeight - whitespace amountWeAreShort = nextFirstSection.expectedHeight - whitespace
shortInPercentages = amountWeAreShort / self.imageHeight shortInPercentages = amountWeAreShort / self.imageHeight
#print("Whitespace {} vs next section height {}".format(whitespace, nextFirstSection.expectedHeight)) 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("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 # Since we also resize based on minimum required whitespaces, we can be a bit more aggressive with this
if shortInPercentages < self.tryToShrinkRatio: if shortInPercentages < self.tryToShrinkRatio:
return True return True
@ -428,7 +428,7 @@ class Song:
lines = parseData.splitlines(True) lines = parseData.splitlines(True)
if not len(lines): if not len(lines):
return 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 # Init first section by popping the delimiter
thisSection = Section() thisSection = Section()
thisSection.header = lines.pop(0) thisSection.header = lines.pop(0)
@ -448,15 +448,15 @@ class Song:
# Reset, new section # Reset, new section
thisSection = Section() thisSection = Section()
thisSection.header = line thisSection.header = line
#print("Header is '{}'".format(thisSection.header)) print("Header is '{}'".format(thisSection.header))
isTabLine = True isTabLine = True
# Else is has lines in order tabline->lyricline->repeat # Else is has lines in order tabline->lyricline->repeat
elif isTabLine: elif isTabLine:
#print("Adding Tabline is '{}'".format(line)) print("Adding Tabline is '{}'".format(line))
thisSection.tablatures.append(line) thisSection.tablatures.append(line)
isTabLine = False isTabLine = False
else: else:
#print("Adding Lyricline is '{}'".format(line)) print("Adding Lyricline is '{}'".format(line))
thisSection.lyrics.append(line) thisSection.lyrics.append(line)
isTabLine = True isTabLine = True
# Add final section data # Add final section data
@ -476,7 +476,7 @@ class Song:
self.rawData = readSourceFile(self.inputFile) self.rawData = readSourceFile(self.inputFile)
# Clean up input # Clean up input
parseData = stripEmptyLines(self.rawData) 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. # While not EOF: build sections untill new section found.
delimiterIndex = parseData.find("[") delimiterIndex = parseData.find("[")
if delimiterIndex == -1: if delimiterIndex == -1:
@ -508,7 +508,7 @@ class Song:
else: else:
# Set thisSection's data and remove it from the buffer # Set thisSection's data and remove it from the buffer
thisSection.rawData = parseData[:delimiterIndex] 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:] parseData = parseData[delimiterIndex:]
# Finally parse section data # Finally parse section data
thisSection.initSections() thisSection.initSections()

View File

@ -32,7 +32,7 @@ def initSong(filePath):
thisSong.outputLocation = filePath[:filePath.rfind('.')] thisSong.outputLocation = filePath[:filePath.rfind('.')]
# title is just the name of the .txt file # title is just the name of the .txt file
thisSong.title = thisSong.outputLocation[filePath.rfind('/')+1:] 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 return thisSong
"""!@brief Creates a list of files found in a directory and its subdirectories """!@brief Creates a list of files found in a directory and its subdirectories
@ -43,7 +43,7 @@ def initSong(filePath):
""" """
def walkDirectory(root, depth): def walkDirectory(root, depth):
pathList = [] pathList = []
#print("Walking directory '{}'".format(root)) print("Walking directory '{}'".format(root))
def do_scan(start_dir,output,depth=2): def do_scan(start_dir,output,depth=2):
for f in os.listdir(start_dir): for f in os.listdir(start_dir):
ff = os.path.join(start_dir,f) ff = os.path.join(start_dir,f)
@ -73,7 +73,7 @@ def getSongObjects():
for inputFolder in configObj['inputfolders'].split(','): for inputFolder in configObj['inputfolders'].split(','):
for filePath in walkDirectory(inputFolder, recursionDepth): for filePath in walkDirectory(inputFolder, recursionDepth):
if ((filePath[filePath.find('.'):] == ".txt" ) and configObj['readtxt'] == '1') or ((filePath[filePath.find('.'):] == ".rawtxt" ) and configObj['readraw'] == '1'): 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) txtFileLocations.append(filePath)
#else: #else:
#print("Skipping file '{}' for it is not a supported file".format(filePath)) #print("Skipping file '{}' for it is not a supported file".format(filePath))

View File

@ -31,8 +31,8 @@ def outputToImage(folderLocation, songObj):
if not os.path.exists(folderLocation): if not os.path.exists(folderLocation):
os.mkdir(folderLocation) os.mkdir(folderLocation)
print("Directory " , folderLocation , " Created ") print("Directory " , folderLocation , " Created ")
#else: else:
#print("Directory " , folderLocation , " already exists") print("Directory " , folderLocation , " already exists")
# Init image info # Init image info
imageNumber = 1 imageNumber = 1
@ -48,7 +48,7 @@ def outputToImage(folderLocation, songObj):
line = line.rstrip() line = line.rstrip()
if not line: if not line:
continue continue
#print("meta line '{}'".format(line)) print("meta line '{}'".format(line))
metadataTextWidth, metadataTextHeight = songObj.fontMetadata.getsize(line) metadataTextWidth, metadataTextHeight = songObj.fontMetadata.getsize(line)
draw.text((songObj.leftMargin,currentHeight), line, fill=songObj.metadataColour, font=songObj.fontMetadata) draw.text((songObj.leftMargin,currentHeight), line, fill=songObj.metadataColour, font=songObj.fontMetadata)
currentHeight += metadataTextHeight currentHeight += metadataTextHeight
@ -72,7 +72,7 @@ def outputToImage(folderLocation, songObj):
currentHeight += headerHeight currentHeight += headerHeight
# Write each line tablature&lyric data # Write each line tablature&lyric data
while lineIterator < amountOfLines: 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 # Get tablatures&lyric line
lyricTextWidth, lyricTextHeight = songObj.fontLyrics.getsize(section.lyrics[lineIterator]) lyricTextWidth, lyricTextHeight = songObj.fontLyrics.getsize(section.lyrics[lineIterator])
tablatureTextWidth, tablatureTextHeight = songObj.fontTablature.getsize(section.tablatures[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) draw.text((songObj.leftMargin,currentHeight), section.lyrics[lineIterator], fill=songObj.fontColour, font=songObj.fontLyrics)
currentHeight += lyricTextHeight currentHeight += lyricTextHeight
lineIterator += 1 lineIterator += 1
#print("currentheight={}".format(currentHeight)) print("currentheight={}".format(currentHeight))
# Margin between each section # Margin between each section
currentHeight += songObj.topMargin currentHeight += songObj.topMargin
# Got all sections in the page, so write it # Got all sections in the page, so write it

View File

@ -45,7 +45,7 @@ def outputToTxt(folderLocation, printRaw, songObj):
line = line.rstrip() line = line.rstrip()
if not line: if not line:
continue continue
#print("meta line '{}'".format(line)) print("meta line '{}'".format(line))
output += line + '\r\n' output += line + '\r\n'
# If exporting raw, do not include the whitespace between metadata and sections # If exporting raw, do not include the whitespace between metadata and sections
if not printRaw: if not printRaw: