예제 #1
0
 def create_file(self, string=""):
     path = ezpath(self.path)
     if not os.path.isfile(path):
         f = open(self.path, "w")
         if string:
             f.write(string)
         f.close()
예제 #2
0
 def open_file(self, pathname, arg):
     try:
         myfilepath = ezpath(pathname)
         myfile = open(myfilepath, arg)
         return myfile
     except IOError:
         myprint("File does not exist: " + pathname + "\n", bcolors.FAIL, True)
         self.edited = False
         raise IOError
예제 #3
0
def create_dir_if_not_already_there(pathname, dir_from_github=""):
    folder = ezpath(pathname)
    if not os.path.exists(folder):
        if dir_from_github:
            subprocess.call(["git", "clone", dir_from_github, folder])

        else:
            print "Creating: " + folder
            os.makedirs(folder)
        return True
    else:
        print ("Folder already created: " + folder)
        False