Skip to content

[Refactor] build() endpoint has massive duplication for Windows/POSIX × Docker/Study × OutDir combinations #363

Description

@GaneshPatil7517

In main.py:84-199, the build() function contains 8 nearly identical try/except blocks:

  • Windows × Docker × with outdir
  • Windows × Docker × without outdir
  • Windows × Makestudy × with outdir
  • Windows × Makestudy × without outdir
  • POSIX × Docker × with outdir
  • POSIX × Docker × without outdir
  • POSIX × Makestudy × with outdir
  • POSIX × Makestudy × without outdir

Each block differs only in the command prefix ("makedocker" vs "makestudy", "./" prefix, shell=True). This can be refactored to ~15 lines by building the command list dynamically:

cmd_name = "makedocker" if docker == 'true' else "makestudy"
cmd = [cmd_name, makestudy_dir] + ([out_dir] if out_dir else [])
if platform.uname()[0] != 'Windows':
    cmd[0] = f"./{cmd[0]}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions