← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #671390]: How to build a path within an existing directory

 

Question #671390 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/671390

    Status: Open => Answered

RaiMan proposed the following answer:
This would be a function that does what your BuildFullPath() does:

def buildFullPath(base, new):
  target = os.path.join(base, new)
  try:
    os.makedirs(target)
    print "created:", target
  except:
    print "exists:", target

... and this would be a testscript:
def buildFullPath(base, new):
  target = os.path.join(base, new)
  try:
    os.makedirs(target)
    print "created:", target
  except:
    print "exists:", target

# the absolute path containig the script folder
basePath = getParentPath() 

newFolder1 = "NewFolder1"
newSubFolder1 = "NewSubFolder1"
newPath1 = os.path.join(newFolder1, newSubFolder1)

for path in (newFolder1, newSubFolder1, newPath1):
  buildFullPath(basePath, path)

... just run it twice and you will see ;-)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.