Skip to content

Commit

Permalink
Merge pull request #397 from katarinaking/837
Browse files Browse the repository at this point in the history
MNEMONIC-837: Enhanced Python Comments
  • Loading branch information
katarinaking authored Jul 2, 2024
2 parents eb9955f + 0de7c7a commit 5aeb58e
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions mnemonic-benches/mnemonic-sort-bench/bin/benchcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,38 @@
# limitations under the License.
#

import os
import inspect
import sys
import os # Import the os module to interact with the operating system
import inspect # Import the inspect module to get information about live objects
import sys # Import the sys module to access system-specific parameters and functions

def findHomeDir():
homedir = os.environ.get("MNEMONIC_HOME")
if not homedir:
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
while 1:
pathdeco = os.path.split(path)
if not pathdeco[1]:
print "Not found mnemonic home directory, please check \$MNEMONIC_HOME"
sys.exit(1)
if pathdeco[1] == 'mnemonic':
break
else:
path = pathdeco[0]
homedir = path
return homedir
# Try to get the MNEMONIC_HOME environment variable
homedir = os.environ.get("MNEMONIC_HOME")

if not homedir: # If MNEMONIC_HOME is not set
# Get the filename of the current file
filename = inspect.getframeinfo(inspect.currentframe()).filename
# Get the absolute path of the current file
path = os.path.dirname(os.path.abspath(filename))

while True:
# Split the path into the head (everything before the last slash) and the tail (everything after)
pathdeco = os.path.split(path)

if not pathdeco[1]: # If the tail is empty, we've reached the root directory
# Print an error message and exit the program
print("Not found mnemonic home directory, please check $MNEMONIC_HOME")
sys.exit(1)

# If the tail is 'mnemonic', we've found the home directory
if pathdeco[1] == 'mnemonic':
break
else:
# Move one directory up
path = pathdeco[0]

# Set homedir to the path where 'mnemonic' directory was found
homedir = path

return homedir # Return the home directory path

0 comments on commit 5aeb58e

Please sign in to comment.