Skip to content
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

Non-functional python code style fixes #27733

Open
wants to merge 2 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
small code-style fixes
dmitrygribenchuk committed Jul 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 2ce56942878f2aa2953726c503d3db9ceefb6de2
14 changes: 8 additions & 6 deletions buildroot/share/dwin/bin/DWIN_ICO.py
Original file line number Diff line number Diff line change
@@ -58,12 +58,14 @@
import struct
from PIL import Image


def getJpegResolution(jpegFile):
"""Returns a 2-tuple containing the jpegFile's (width, height).
"""
img = Image.open(jpegFile)
return img.size


class DWIN_ICO_File():
def __init__(self):
self.entries = [] # list of header entries
@@ -118,14 +120,14 @@ def _splitEntryData(self, infile, outDir):
count += 1

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
resolution, and a new entry is created for each.
Each filename must have a leading number followed by a
dash, which is the icon index. E.g., "071-ICON_StepX.jpg".
'''
"""
self.entries = [Entry() for i in range(0,256)]
# 1. Scan icon directory and record all valid files
print('Scanning icon directory', iconDir)
@@ -140,7 +142,7 @@ def createFile(self, iconDir, filename):
if not (0 <= index <= 255):
print('...Ignoring invalid index on', dirEntry.path)
continue
#dirEntry.path is iconDir/name
# dirEntry.path is iconDir/name
w,h = getJpegResolution(dirEntry.path)
length = dirEntry.stat().st_size
e = self.entries[index]
@@ -171,7 +173,7 @@ def _updateHeaderOffsets(self):
continue
e.offset = offset
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))

def _combineAndWriteIcoFile(self, filename):
@@ -201,9 +203,9 @@ def _getFileContents(self, filename, length):
return contents

class Entry():
'''Entry objects record resolution and size information
"""Entry objects record resolution and size information
about each icon stored in an ICO file.
'''
"""
__slots__ = ('width', 'height', 'offset', 'length', 'filename')

def __init__(self, w=0, h=0, length=0, offset=0, filename=None):
1 change: 0 additions & 1 deletion buildroot/share/dwin/bin/makeIco.py
Original file line number Diff line number Diff line change
@@ -49,4 +49,3 @@

except Exception as e:
print('Error: ', e)