Skip to content

Commit 0971176

Browse files
authored
fix: SG-42241: Address comment in PR 1200 (#1236)
### Summarize your change. Address comments on #1200 (reference) Small readability cleanups. Drop redundant `int()` around `math.floor`, rename f to session_file, and replace a for/write loop with writelines. ### Describe the reason for the change. These are changes that make the code more readable and follow a better design. No functionality change. ### Describe what you have tested and on which operating system. Tested on MacOS to see that previews are still working and being generated. Signed-off-by: chenl1 <ling.jie.chen@autodesk.com>
1 parent 98a33ee commit 0971176

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/plugins/rv-packages/session_manager/local_thumbnail_gen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def _pick_frames(self, start_frame: int, end_frame: int) -> list[int]:
242242
if n_frames < MAX_FILMSTRIP_FRAMES:
243243
return list(range(start_frame, end_frame + 1))
244244
incr = (n_frames - 1) / (MAX_FILMSTRIP_FRAMES - 1.0)
245-
return [int(math.floor(start_frame + i * incr)) for i in range(MAX_FILMSTRIP_FRAMES)]
245+
return [math.floor(start_frame + i * incr) for i in range(MAX_FILMSTRIP_FRAMES)]
246246

247247
def _write_filmstrip_session(
248248
self, session_path: Path, media_path: str, frames: list[int], width: int, height: int
@@ -257,8 +257,8 @@ def _write_filmstrip_session(
257257
rhs = " ".join('"defaultLayout"' for _ in frames)
258258
top_nodes = f'"defaultLayout" {lhs}'
259259

260-
with open(session_path, "w") as f:
261-
f.write(
260+
with open(session_path, "w") as session_file:
261+
session_file.write(
262262
textwrap.dedent(f"""\
263263
GTOa (3)
264264
@@ -344,9 +344,8 @@ def _write_filmstrip_session(
344344
""")
345345
)
346346

347-
for frame in frames:
348-
f.write(
349-
textwrap.dedent(f"""\
347+
session_file.writelines(
348+
textwrap.dedent(f"""\
350349
sourceGroup{frame:06d} : RVSourceGroup (1)
351350
{{
352351
ui
@@ -381,7 +380,8 @@ def _write_filmstrip_session(
381380
}}
382381
383382
""")
384-
)
383+
for frame in frames
384+
)
385385

386386
return output_width, output_height
387387

0 commit comments

Comments
 (0)