Skip to content

Commit

Permalink
use f-string equal syntax added in Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Sep 18, 2022
1 parent 6e14b9f commit dcd5ef7
Show file tree
Hide file tree
Showing 39 changed files with 119 additions and 118 deletions.
6 changes: 3 additions & 3 deletions distro/base/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def main():
prefix = "/usr/local"
else:
prefix = "/usr/local"
print(f"prefix = {prefix}")
print(f"{prefix = }")

pyCmd = options.get("python", "")
if pyCmd:
Expand Down Expand Up @@ -306,6 +306,6 @@ def main():


if __name__ == "__main__":
# print(f"sourceDir = {sourceDir!r}")
# print(f"version = {version!r}")
# print(f"{sourceDir=}")
# print(f"{version=}")
sys.exit(main())
2 changes: 1 addition & 1 deletion natz/tree/tree_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _addZoneNode(parentDict, zone, zoneNamesLevel):
zoneNamesLevel,
)
else:
log.error(f"invalid path = {path}")
log.error(f"invalid {path=}")


def getZoneInfoTree():
Expand Down
14 changes: 7 additions & 7 deletions plugins/pray_times_files/pray_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def readTransFile(transPath):
log.info(f"------------- reading {transPath}")
with open(transPath, encoding="utf8") as fp:
placeTransDict.update(json.load(fp))
log.info(f"------------- len(placeTransDict) = {len(placeTransDict)}")
log.info(f"------------- {len(placeTransDict)=}")


readTransFile(join(locationsDir, f"{langSh}.json"))
Expand Down Expand Up @@ -128,7 +128,7 @@ def translatePlaceName(name: str) -> str:
if p[0] == "":
if p[1] == "":
city, lat, lng = p[2:5]
log.debug(f"city={city}")
log.debug(f"{city=}")
if len(p) > 4:
cityData.append((
country + "/" + city,
Expand All @@ -137,7 +137,7 @@ def translatePlaceName(name: str) -> str:
float(lng)
))
else:
log.debug(f"country={country}, p={p}")
log.debug(f"{country=}, {p=}")
else:
country = p[1]
return cityData
Expand Down Expand Up @@ -366,7 +366,7 @@ def doPlayAzan(self):
if not self.azanEnable:
return
# dt = tm - now()
# log.debug(f"---------------------------- doPlayAzan, dt={dt:.1f}")
# log.debug(f"---------------------------- doPlayAzan, {dt=:.1f}")
# if dt > 1:
# Timer(
# int(dt),
Expand All @@ -382,7 +382,7 @@ def doPlayPreAzan(self):
if not self.preAzanEnable:
return
# dt = tm - now()
# log.debug(f"---------------------------- doPlayPreAzan, dt={dt:.1f}")
# log.debug(f"---------------------------- doPlayPreAzan, {dt=:.1f}")
# if dt > 1:
# Timer(
# int(dt),
Expand Down Expand Up @@ -426,14 +426,14 @@ def onCurrentDateChange(self, gdate):
0,
int(preAzanSec - secondsFromMidnight)
)
log.debug(f"toPreAzanSec={toPreAzanSec:.1f}")
log.debug(f"{toPreAzanSec=:.1f}")
Timer(
toPreAzanSec,
self.doPlayPreAzan,
# midnightUtc + preAzanSec,
).start()
###
log.debug(f"toAzanSecs={toAzanSecs:.1f}")
log.debug(f"{toAzanSecs=:.1f}")
Timer(
toAzanSecs,
self.doPlayAzan,
Expand Down
4 changes: 2 additions & 2 deletions plugins/pray_times_files/pray_times_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ def sunAngleTime(self, angle, tm, direction="cw"):
t = arccos(ratio) / 15
# except:
# log.info(
# f"sunAngleTime: angle={angle}, tm={tm}" +
# f", direction={direction} ==> ratio={ratio}" +
# f"sunAngleTime: {angle=}, {tm=}" +
# f", {direction=} ==> {ratio=}" +
# )
# return 0
return noon + dirSign(direction) * t
Expand Down
26 changes: 13 additions & 13 deletions scal3/event_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def getData(self) -> str:
def setData(self, wnModeName: str) -> None:
if wnModeName not in self.weekNumModeNames:
raise BadEventFile(
f"bad rule value weekNumMode={wnModeName!r}, " +
f"bad rule value {wnModeName=}, " +
"the value for weekNumMode must be " +
f"one of {self.weekNumModeNames!r}"
)
Expand Down Expand Up @@ -2142,7 +2142,7 @@ def getPath(self):
raise RuntimeError("getPath: parent is None")
path = SObj.getPath(self)
if len(path) != 2:
raise RuntimeError(f"getPath: unexpected path={path}")
raise RuntimeError(f"getPath: unexpected {path=}")
return path

def getRevision(self, revHash):
Expand Down Expand Up @@ -2690,7 +2690,7 @@ def setEnd(self, endType, *values):
rule = DurationEventRule(self)
rule.value, rule.unit = values
else:
raise ValueError(f"invalid endType={endType!r}")
raise ValueError(f"invalid {endType=}")
self.addRule(rule)

def getStart(self):
Expand Down Expand Up @@ -2860,7 +2860,7 @@ def setEnd(self, endType, value):
rule.value = value
rule.unit = dayLen
else:
raise ValueError(f"invalid endType={endType!r}")
raise ValueError(f"invalid {endType=}")
self.addRule(rule)

def getEnd(self):
Expand Down Expand Up @@ -3761,7 +3761,7 @@ def _getEvent(self, eid):
# self.save() # FIXME
raise FileNotFoundError(
f"error while loading event file {eventFile!r}: " +
f"file not found. eid={eid}, container={self!r}"
f"file not found. {eid=}, container={self!r}"
)
with self.fs.open(eventFile) as fp:
data = jsonToData(fp.read())
Expand Down Expand Up @@ -4978,7 +4978,7 @@ def setCourses(self, courses: "List[Tuple[int, str, int]]") -> None:
"""
self.courses = courses
# self.lastCourseId = max([1]+[course[0] for course in self.courses])
# log.debug(f"setCourses: lastCourseId={self.lastCourseId}")
# log.debug(f"setCourses: {self.lastCourseId=}")

# def getCourseNamesDictById(self):
# return dict([c[:2] for c in self.courses])
Expand Down Expand Up @@ -5015,7 +5015,7 @@ def setDefaults(self) -> None:

# def getNewCourseID(self) -> int:
# self.lastCourseId += 1
# log.info(f"getNewCourseID: lastCourseId={self.lastCourseId}")
# log.info(f"getNewCourseID: {self.lastCourseId=}")
# return self.lastCourseId

def copyFrom(self, other: "EventGroup") -> None:
Expand Down Expand Up @@ -5435,7 +5435,7 @@ def getEvent(self, commit_id: str) -> "Event":
return
data = mod.getCommitInfo(self, commit_id)
if not data:
raise ValueError(f"No commit with id={commit_id!r}")
raise ValueError(f"No commit with {commit_id=}")
data["summary"] = self.title + ": " + data["summary"]
data["icon"] = self.icon
event = VcsCommitEvent(self, commit_id)
Expand Down Expand Up @@ -5612,7 +5612,7 @@ def updateOccurrence(self) -> None:
newCommitId = commitIds[-1]
oldCommitId = mod.getLatestParentBefore(self, newCommitId, epoch)
if not oldCommitId:
log.info(f"oldCommitId is empty, jd={jd}, newCommitId={newCommitId}")
log.info(f"oldCommitId is empty, {jd=}, {newCommitId=}")
continue
stat = mod.getShortStat(self, oldCommitId, newCommitId)
self.statByJd[jd] = (len(commitIds), stat)
Expand Down Expand Up @@ -5692,19 +5692,19 @@ def __setitem__(self, _id: int, obj: Any) -> None:

def insert(self, index: int, obj: Any) -> None:
if obj.id in self.idList:
raise ValueError(f"{self} already contains id={obj.id}, obj={obj}")
raise ValueError(f"{self} already contains id={obj.id}, {obj=}")
self.byId[obj.id] = obj
self.idList.insert(index, obj.id)

def append(self, obj: Any) -> None:
if obj.id in self.idList:
raise ValueError(f"{self} already contains id={obj.id}, obj={obj}")
raise ValueError(f"{self} already contains id={obj.id}, {obj=}")
self.byId[obj.id] = obj
self.idList.append(obj.id)

def delete(self, obj: Any) -> None:
if obj.id not in self.idList:
raise ValueError(f"{self} does not contains id={obj.id}, obj={obj}")
raise ValueError(f"{self} does not contains id={obj.id}, {obj=}")
try:
self.fs.removeFile(obj.file)
except Exception:
Expand Down Expand Up @@ -5734,7 +5734,7 @@ def setData(self, data: List[int]) -> None:
self.clear()
for sid in data:
if not isinstance(sid, int) or sid == 0:
raise RuntimeError(f"unexpected sid={sid}, self={self}")
raise RuntimeError(f"unexpected {sid=}, {self=}")
_id = sid
_id = abs(sid)
try:
Expand Down
9 changes: 4 additions & 5 deletions scal3/interval_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def getIntervalListByPoints(
for pos, ptype, _ in points:
if ptype in (OPEN_END, CLOSED_END):
if not startedStack:
raise RuntimeError(f"pos={pos}, start=None")
raise RuntimeError(f"{pos=}, start=None")
start = startedStack.pop()
# log.debug(f"pop {start}")
if not startedStack:
Expand Down Expand Up @@ -179,24 +179,23 @@ def intersectionOfTwoIntervalList(*lists):
if None not in openStartList:
start = max(openStartList)
if start > pos:
raise RuntimeError(f"start - pos = {start-pos}")
raise RuntimeError(f"{start - pos = }")
if pos > start or ptype == CLOSED_END:
result.append((
start,
pos,
ptype == CLOSED_END,
))
# if start == pos: # FIXME
# log.info(f"start = pos={start%(24*3600)/3600.0}, ptype={ptype}")
# log.info(f"start: pos={start%(24*3600)/3600.0}, {ptype=}")
openStartList[lst_index] = None
else: # start
# start == pos
if openStartList[lst_index] is None:
openStartList[lst_index] = pos
else:
raise RuntimeError(
f"pos={pos}, openStartList[{lst_index}]=" +
f"{openStartList[lst_index]}"
f"{pos=}, {openStartList[lst_index]=}"
)
result = humanizeIntervalList(result) # right place? FIXME
return result
4 changes: 2 additions & 2 deletions scal3/ui_gtk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def getScrollValue(gevent, last=""):
# is_scroll_stop_event is new in version 3.20.
if value == "smooth": # happens *sometimes* in PyGI (Gtk3)
# log.debug(
# f"Scroll: value={value}, delta_y={gevent.delta_y}, " +
# f"is_stop={gevent.is_stop}={gevent.is_scroll_stop_event()}"
# f"Scroll: {value=}, {gevent.delta_y=}, " +
# f"{gevent.is_stop=}={gevent.is_scroll_stop_event()}"
#)
if gevent.delta_y < 0: # -1.0 (up)
value = "up"
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/adjust_dtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def runCommand(self, cmd):
output = proc.stdout.read().strip()
if output:
log.info(output)
# log.debug(f"resCode={resCode!r}, error={error!r}, output={output!r}")
# log.debug(f"{resCode=}, {error=}, {output=}")
if error:
log.error(error)
if resCode != 0:
Expand Down
10 changes: 5 additions & 5 deletions scal3/ui_gtk/button_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def __init__(
raise ValueError("y is not given")

if x < 0 and xalign != "center":
raise ValueError(f"invalid x={x}, xalign={xalign}")
raise ValueError(f"invalid {x=}, {xalign=}")
if y < 0 and yalign != "center":
raise ValueError(f"invalid y={y}, yalign={yalign}")
raise ValueError(f"invalid {y=}, {yalign=}")
if xalign not in ("left", "right", "center"):
raise ValueError(f"invalid xalign={xalign}")
raise ValueError(f"invalid {xalign=}")
if yalign not in ("top", "buttom", "center"):
raise ValueError(f"invalid yalign={yalign}")
raise ValueError(f"invalid {yalign=}")

self.onPress = onPress
self.onRelease = onRelease
Expand Down Expand Up @@ -102,7 +102,7 @@ def __init__(
self.imageName = imageName
pixbuf = pixbufFromFile(imageName, iconSize)
if pixbuf is None:
raise RuntimeError(f"could not get pixbuf for imageName={imageName!r}")
raise RuntimeError(f"could not get pixbuf for {imageName=}")

# we assume that svg image is square
self.setSize(iconSize, iconSize)
Expand Down
4 changes: 2 additions & 2 deletions scal3/ui_gtk/cal_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def connect(self, sigName, *a, **ka):
try:
CustomizableCalObj.connect(self, sigName, *a, **ka)
except Exception:
log.exception(f"sigName={sigName}")
log.exception(f"{sigName=}")

def initCal(self):
self.initVars()
Expand Down Expand Up @@ -160,7 +160,7 @@ def dragDataRec(self, obj, context, x, y, selection, target_id, etime):
self.queue_draw()
else:
log.info(
f"Unknown dropped data type {dtype!r}, text={text!r}, " +
f"Unknown dropped data type {dtype!r}, {text=}, " +
f"data={selection.data!r}"
)
return True
Expand Down
4 changes: 2 additions & 2 deletions scal3/ui_gtk/cal_type_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get(self):
elif index == 2:
return "right"
else:
log.info(f"XAlignComboBox: unexpected index = {index}")
log.info(f"XAlignComboBox: unexpected {index = }")

def set(self, value):
if value == "left":
Expand Down Expand Up @@ -79,7 +79,7 @@ def get(self):
elif index == 2:
return "buttom"
else:
log.info(f"YAlignComboBox: unexpected index = {index}")
log.info(f"YAlignComboBox: unexpected {index = }")

def set(self, value):
if value == "top":
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def newSubPageButton(

def onClick(b, page):
if not page.pagePath:
raise ValueError(f"pagePath empty, page = {page}")
raise ValueError(f"pagePath empty, {page = }")
item.emit("goto-page", page.pagePath)

button.connect("clicked", onClick, page)
Expand Down
Loading

0 comments on commit dcd5ef7

Please sign in to comment.