From 0798c7e180acff9bc2569e7804724dadd6f92a5d Mon Sep 17 00:00:00 2001 From: Saksham Gera Date: Tue, 18 Feb 2025 02:05:38 +0530 Subject: [PATCH 1/2] Fixing White Space In Directory Causing Failure In Study Creation --- makestudy | 55 +++++++++++++++++++++++++-------------------------- makestudy.bat | 48 +++++++++++++++++++++++++++++--------------- 2 files changed, 59 insertions(+), 44 deletions(-) diff --git a/makestudy b/makestudy index 310de02..382cb6f 100755 --- a/makestudy +++ b/makestudy @@ -1,7 +1,7 @@ -#!/bin/bash -if [ $# == 0 ] -then - echo "Make a concore study " +#!/usr/bin/env bash + +if [ "$#" -eq 0 ]; then + echo "Make a concore study" echo " ./makestudy path/name.graphml" echo " ./makestudy path/name.graphml study" echo "In the first case, the name of the study is the same as the name of the .graphml" @@ -9,38 +9,37 @@ then echo "The equivalent mkconcore.py is displayed" exit fi -graphml=$1 -if [ -e $graphml ] -then - sourcedir=$(dirname "$graphml") + +graphml="$1" + +if [ -e "$graphml" ]; then + sourcedir="$(dirname "$graphml")" else - graphml=$graphml'.graphml' - if [ -e $graphml ] - then - sourcedir=$(dirname "$graphml") + graphml="${graphml}.graphml" + if [ -e "$graphml" ]; then + sourcedir="$(dirname "$graphml")" else echo "$graphml does not exist" exit fi fi -if [ $# = 1 ] -then - studydir=`basename ${graphml%\.*}` + +if [ "$#" -eq 1 ]; then + studydir="$(basename "${graphml%.*}")" else - studydir=$2 + studydir="$2" fi -if [ -e $studydir ] -then - echo "cannot make $studydir because one already exists with that name" - echo "either do ./destroy $studydir, or choose a unique name as 2nd arg" + +if [ -e "$studydir" ]; then + echo "Cannot make $studydir because one already exists with that name" + echo "Either do ./destroy $studydir, or choose a unique name as 2nd arg" + exit else - which osascript >/dev/null - if [ $? == 0 ] - then - echo "python3 mkconcore.py $graphml $sourcedir $studydir macos" - python3 mkconcore.py $graphml $sourcedir $studydir macos + if command -v osascript >/dev/null; then + echo "python3 mkconcore.py \"$graphml\" \"$sourcedir\" \"$studydir\" macos" + python3 mkconcore.py "$graphml" "$sourcedir" "$studydir" macos else - echo "python3 mkconcore.py $graphml $sourcedir $studydir ubuntu" - python3 mkconcore.py $graphml $sourcedir $studydir ubuntu + echo "python3 mkconcore.py \"$graphml\" \"$sourcedir\" \"$studydir\" ubuntu" + python3 mkconcore.py "$graphml" "$sourcedir" "$studydir" ubuntu fi -fi +fi \ No newline at end of file diff --git a/makestudy.bat b/makestudy.bat index 118b3dc..26bf995 100644 --- a/makestudy.bat +++ b/makestudy.bat @@ -1,18 +1,34 @@ @echo off -if dummy%~n2 == dummy ( - if dummy%~x1 == dummy.graphml ( - echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 windows - python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 windows - ) else ( - echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 windows - python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 windows - ) +setlocal EnableDelayedExpansion + +:: Extracting parameters safely +set "file1=%~f1" +set "file2=%~2" +set "dir1=%~dp1" +set "name1=%~n1" +set "ext1=%~x1" + +:: Handling spaces in paths by ensuring the format remains intact +set "file1=!file1:\=\\!" +set "dir1=!dir1:\=\\!" + +:: If the second argument (file2) is not provided +if not defined file2 ( + if /I "%ext1%"==".graphml" ( + echo python mkconcore.py "!file1!" "!dir1!" "!name1!" windows + python mkconcore.py "!file1!" "!dir1!" "!name1!" windows + ) else ( + echo python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!name1!" windows + python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!name1!" windows + ) ) else ( - if dummy%~x1 == dummy.graphml ( - echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 windows - python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 windows - ) else ( - echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 windows - python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 windows - ) -) \ No newline at end of file + if /I "%ext1%"==".graphml" ( + echo python mkconcore.py "!file1!" "!dir1!" "!file2!" windows + python mkconcore.py "!file1!" "!dir1!" "!file2!" windows + ) else ( + echo python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!file2!" windows + python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!file2!" windows + ) +) + +endlocal From c397c7cbdc2602137f609b13e0586a90ef105b6f Mon Sep 17 00:00:00 2001 From: Saksham Gera Date: Tue, 18 Feb 2025 02:10:53 +0530 Subject: [PATCH 2/2] Removed Some Unused Variables From mkconcore.py --- mkconcore.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkconcore.py b/mkconcore.py index 55300c5..91aef6d 100644 --- a/mkconcore.py +++ b/mkconcore.py @@ -15,7 +15,6 @@ CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21 VWIN = "iverilog" #Windows verilog 6/25/21 VEXE = "iverilog" #Ubuntu/macOS verilog 6/25/21 -CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21 PYTHONEXE = "python3" #Ubuntu/macOS python 3 PYTHONWIN = "python" #Windows python 3 MATLABEXE = "matlab" #Ubuntu/macOS matlab @@ -74,7 +73,6 @@ print("if intended, remove or rename "+outdir+" first") quit() -currentdir = os.getcwd() os.mkdir(outdir) os.chdir(outdir) if concoretype == "windows":