mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-03-10 00:23:01 +00:00
🎨 Python style tweaks (#27312)
This commit is contained in:
parent
b4dd20c0eb
commit
29469a0615
2 changed files with 6 additions and 7 deletions
buildroot/share/dwin/bin
|
@ -118,14 +118,14 @@ class DWIN_ICO_File():
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
def createFile(self, iconDir, filename):
|
def createFile(self, iconDir, filename):
|
||||||
'''Create a new .ico file from the contents of iconDir.
|
"""Create a new .ico file from the contents of iconDir.
|
||||||
|
|
||||||
The contents of iconDir are processed to get image
|
The contents of iconDir are processed to get image
|
||||||
resolution, and a new entry is created for each.
|
resolution, and a new entry is created for each.
|
||||||
|
|
||||||
Each filename must have a leading number followed by a
|
Each filename must have a leading number followed by a
|
||||||
dash, which is the icon index. E.g., "071-ICON_StepX.jpg".
|
dash, which is the icon index. E.g., "071-ICON_StepX.jpg".
|
||||||
'''
|
"""
|
||||||
self.entries = [Entry() for i in range(0,256)]
|
self.entries = [Entry() for i in range(0,256)]
|
||||||
# 1. Scan icon directory and record all valid files
|
# 1. Scan icon directory and record all valid files
|
||||||
print('Scanning icon directory', iconDir)
|
print('Scanning icon directory', iconDir)
|
||||||
|
@ -140,7 +140,7 @@ class DWIN_ICO_File():
|
||||||
if not (0 <= index <= 255):
|
if not (0 <= index <= 255):
|
||||||
print('...Ignoring invalid index on', dirEntry.path)
|
print('...Ignoring invalid index on', dirEntry.path)
|
||||||
continue
|
continue
|
||||||
#dirEntry.path is iconDir/name
|
# dirEntry.path is iconDir/name
|
||||||
w,h = getJpegResolution(dirEntry.path)
|
w,h = getJpegResolution(dirEntry.path)
|
||||||
length = dirEntry.stat().st_size
|
length = dirEntry.stat().st_size
|
||||||
e = self.entries[index]
|
e = self.entries[index]
|
||||||
|
@ -171,7 +171,7 @@ class DWIN_ICO_File():
|
||||||
continue
|
continue
|
||||||
e.offset = offset
|
e.offset = offset
|
||||||
offset += e.length
|
offset += e.length
|
||||||
#print('%03d: (%d x %d) len=%d off=%d' %
|
# print('%03d: (%d x %d) len=%d off=%d' %
|
||||||
# (i, e.width, e.height, e.length, e.offset))
|
# (i, e.width, e.height, e.length, e.offset))
|
||||||
|
|
||||||
def _combineAndWriteIcoFile(self, filename):
|
def _combineAndWriteIcoFile(self, filename):
|
||||||
|
@ -201,9 +201,9 @@ class DWIN_ICO_File():
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
class Entry():
|
class Entry():
|
||||||
'''Entry objects record resolution and size information
|
"""Entry objects record resolution and size information
|
||||||
about each icon stored in an ICO file.
|
about each icon stored in an ICO file.
|
||||||
'''
|
"""
|
||||||
__slots__ = ('width', 'height', 'offset', 'length', 'filename')
|
__slots__ = ('width', 'height', 'offset', 'length', 'filename')
|
||||||
|
|
||||||
def __init__(self, w=0, h=0, length=0, offset=0, filename=None):
|
def __init__(self, w=0, h=0, length=0, offset=0, filename=None):
|
||||||
|
|
|
@ -49,4 +49,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Error: ', e)
|
print('Error: ', e)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue