Skip to content

Commit

Permalink
Fix warnings from PyCharm IDE about Python coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Mar 5, 2024
1 parent fe551b6 commit a0a4a11
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cadastre/cadastre_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def replfunc(match):
print("%s" % msg)
return msg

def randomWord(self, length):
@staticmethod
def random_word(length: int) -> str:
"""
Return a random string of given length
"""
Expand All @@ -437,8 +438,7 @@ def createComposition(self):
# We need to set a name to the layout, otherwise, error when exporting
# more than one time:
# RuntimeError: wrapped C/C++ object of type QgsPrintLayout has been deleted
cName = self.randomWord(20)
c.setName(cName)
c.setName(self.random_word(20))
c.initializeDefaults()
c.setUnits(QgsUnitTypes.LayoutMillimeters)

Expand Down Expand Up @@ -505,15 +505,15 @@ def buildComposerLabel(self, key, item, page):

# create HTML layout item
# htmlItem = QgsLayoutItemHtml.create(self.currentComposition)
htmlItem = QgsLayoutItemHtml(self.currentComposition)
html_item = QgsLayoutItemHtml(self.currentComposition)

# add frame to layout
self.currentComposition.addMultiFrame(htmlItem)
self.currentComposition.addMultiFrame(html_item)

# create frame to show content from htmlItem
htmlItemFrame = QgsLayoutFrame(
html_item_frame = QgsLayoutFrame(
self.currentComposition,
htmlItem
html_item
)
# htmlItemFrame.attemptSetSceneRect(
# QRectF(
Expand All @@ -525,20 +525,20 @@ def buildComposerLabel(self, key, item, page):
# )

# No border
htmlItemFrame.setFrameEnabled(False)
html_item_frame.setFrameEnabled(False)

# set HTML contents
htmlItem.setContentMode(QgsLayoutItemHtml.ManualHtml)
html_item.setContentMode(QgsLayoutItemHtml.ManualHtml)
content = self.getContentForGivenItem(
key,
item,
page
)
htmlItem.setHtml(content)
htmlItem.loadHtml()
html_item.setHtml(content)
html_item.loadHtml()

# Reposition the frame
htmlItemFrame.attemptMove(
html_item_frame.attemptMove(
QgsLayoutPoint(
item['position'][0],
item['position'][1] + (dpage) * (self.pageHeight + 10),
Expand All @@ -547,7 +547,7 @@ def buildComposerLabel(self, key, item, page):
)

# Set the correct size
htmlItemFrame.attemptResize(
html_item_frame.attemptResize(
QgsLayoutSize(
item['position'][2],
item['position'][3],
Expand All @@ -556,7 +556,7 @@ def buildComposerLabel(self, key, item, page):
)

# Add frame to the HTML item
htmlItem.addFrame(htmlItemFrame)
html_item.addFrame(html_item_frame)

def addParcelleMap(self):
"""
Expand Down

0 comments on commit a0a4a11

Please sign in to comment.