Skip to content

Commit e199b32

Browse files
authored
Merge pull request #129 from saksham-gera/dev
Fixed and tested the whitespace issue in directory paths on Windows, resolved the comparison operator bug, and removed unused variables from mkconcore.py.
2 parents 9bb8a89 + c397c7c commit e199b32

File tree

3 files changed

+59
-46
lines changed

3 files changed

+59
-46
lines changed

makestudy

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
1-
#!/bin/bash
2-
if [ $# == 0 ]
3-
then
4-
echo "Make a concore study "
1+
#!/usr/bin/env bash
2+
3+
if [ "$#" -eq 0 ]; then
4+
echo "Make a concore study"
55
echo " ./makestudy path/name.graphml"
66
echo " ./makestudy path/name.graphml study"
77
echo "In the first case, the name of the study is the same as the name of the .graphml"
88
echo "In either case, source files come from the same path as the .graphml"
99
echo "The equivalent mkconcore.py is displayed"
1010
exit
1111
fi
12-
graphml=$1
13-
if [ -e $graphml ]
14-
then
15-
sourcedir=$(dirname "$graphml")
12+
13+
graphml="$1"
14+
15+
if [ -e "$graphml" ]; then
16+
sourcedir="$(dirname "$graphml")"
1617
else
17-
graphml=$graphml'.graphml'
18-
if [ -e $graphml ]
19-
then
20-
sourcedir=$(dirname "$graphml")
18+
graphml="${graphml}.graphml"
19+
if [ -e "$graphml" ]; then
20+
sourcedir="$(dirname "$graphml")"
2121
else
2222
echo "$graphml does not exist"
2323
exit
2424
fi
2525
fi
26-
if [ $# = 1 ]
27-
then
28-
studydir=`basename ${graphml%\.*}`
26+
27+
if [ "$#" -eq 1 ]; then
28+
studydir="$(basename "${graphml%.*}")"
2929
else
30-
studydir=$2
30+
studydir="$2"
3131
fi
32-
if [ -e $studydir ]
33-
then
34-
echo "cannot make $studydir because one already exists with that name"
35-
echo "either do ./destroy $studydir, or choose a unique name as 2nd arg"
32+
33+
if [ -e "$studydir" ]; then
34+
echo "Cannot make $studydir because one already exists with that name"
35+
echo "Either do ./destroy $studydir, or choose a unique name as 2nd arg"
36+
exit
3637
else
37-
which osascript >/dev/null
38-
if [ $? == 0 ]
39-
then
40-
echo "python3 mkconcore.py $graphml $sourcedir $studydir macos"
41-
python3 mkconcore.py $graphml $sourcedir $studydir macos
38+
if command -v osascript >/dev/null; then
39+
echo "python3 mkconcore.py \"$graphml\" \"$sourcedir\" \"$studydir\" macos"
40+
python3 mkconcore.py "$graphml" "$sourcedir" "$studydir" macos
4241
else
43-
echo "python3 mkconcore.py $graphml $sourcedir $studydir ubuntu"
44-
python3 mkconcore.py $graphml $sourcedir $studydir ubuntu
42+
echo "python3 mkconcore.py \"$graphml\" \"$sourcedir\" \"$studydir\" ubuntu"
43+
python3 mkconcore.py "$graphml" "$sourcedir" "$studydir" ubuntu
4544
fi
46-
fi
45+
fi

makestudy.bat

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
@echo off
2-
if dummy%~n2 == dummy (
3-
if dummy%~x1 == dummy.graphml (
4-
echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 windows
5-
python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n1 windows
6-
) else (
7-
echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 windows
8-
python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n1 windows
9-
)
2+
setlocal EnableDelayedExpansion
3+
4+
:: Extracting parameters safely
5+
set "file1=%~f1"
6+
set "file2=%~2"
7+
set "dir1=%~dp1"
8+
set "name1=%~n1"
9+
set "ext1=%~x1"
10+
11+
:: Handling spaces in paths by ensuring the format remains intact
12+
set "file1=!file1:\=\\!"
13+
set "dir1=!dir1:\=\\!"
14+
15+
:: If the second argument (file2) is not provided
16+
if not defined file2 (
17+
if /I "%ext1%"==".graphml" (
18+
echo python mkconcore.py "!file1!" "!dir1!" "!name1!" windows
19+
python mkconcore.py "!file1!" "!dir1!" "!name1!" windows
20+
) else (
21+
echo python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!name1!" windows
22+
python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!name1!" windows
23+
)
1024
) else (
11-
if dummy%~x1 == dummy.graphml (
12-
echo python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 windows
13-
python mkconcore.py %~d1%~p1%~n1%~x1 %~d1%~p1 %~n2 windows
14-
) else (
15-
echo python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 windows
16-
python mkconcore.py %~d1%~p1%~n1.graphml %~d1%~p1 %~n2 windows
17-
)
18-
)
25+
if /I "%ext1%"==".graphml" (
26+
echo python mkconcore.py "!file1!" "!dir1!" "!file2!" windows
27+
python mkconcore.py "!file1!" "!dir1!" "!file2!" windows
28+
) else (
29+
echo python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!file2!" windows
30+
python mkconcore.py "!dir1!!name1!.graphml" "!dir1!" "!file2!" windows
31+
)
32+
)
33+
34+
endlocal

mkconcore.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
1616
VWIN = "iverilog" #Windows verilog 6/25/21
1717
VEXE = "iverilog" #Ubuntu/macOS verilog 6/25/21
18-
CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
1918
PYTHONEXE = "python3" #Ubuntu/macOS python 3
2019
PYTHONWIN = "python" #Windows python 3
2120
MATLABEXE = "matlab" #Ubuntu/macOS matlab
@@ -74,7 +73,6 @@
7473
print("if intended, remove or rename "+outdir+" first")
7574
quit()
7675

77-
currentdir = os.getcwd()
7876
os.mkdir(outdir)
7977
os.chdir(outdir)
8078
if concoretype == "windows":

0 commit comments

Comments
 (0)