def makeShadowDirectory(self, fn): """Make a shadow directory for the **public** fn.""" x = self; path = x.shadowDirName(fn) if not g.os_path_exists(path): # Force the creation of the directories. g.makeAllNonExistentDirectories(path, c=None, force=True) return g.os_path_exists(path) and g.os_path_isdir(path)
def makeShadowDirectory(self, fn): '''Make a shadow directory for the **public** fn.''' x = self; path = x.shadowDirName(fn) if not g.os_path_exists(path): # Force the creation of the directories. g.makeAllNonExistentDirectories(path, c=None, force=True) return g.os_path_exists(path) and g.os_path_isdir(path)
def create(self, fn): '''Create the given file with empty contents.''' theDir = g.os_path_dirname(fn) g.makeAllNonExistentDirectories(theDir, c=self.c, force=True, verbose=True) # Make the directories as needed. try: f = open(fn, mode='wb') f.close() g.note('created: %s' % (fn)) except IOError: g.error('can not create: %s' % (fn)) except Exception: g.error('unexpected error creating: %s' % (fn)) g.es_exception()
def create_directory(self, fn): ''' Create the directory for fn if a) it doesn't exist and b) the user options allow it. Return True if the directory existed or was made. ''' c = self.c theDir, junk = g.os_path_split(fn) theDir = c.os_path_finalize(theDir) if g.os_path_exists(theDir): return True ok = g.makeAllNonExistentDirectories(theDir, c=c, force=False) if not ok: g.error('did not create:', theDir) return ok
def create(self, fn): """Create the given file with empty contents.""" # Make the directories as needed. theDir = g.os_path_dirname(fn) if theDir: ok = g.makeAllNonExistentDirectories(theDir) # #1453: Don't assume the directory exists. if not ok: g.error(f"did not create directory: {theDir}") return # Create the file. try: f = open(fn, mode='wb') f.close() g.note(f"created: {fn}") except IOError: g.error(f"can not create: {fn}") except Exception: g.error(f"unexpected error creating: {fn}") g.es_exception()
def createDirectoryForFile(self, fn): """ Create the directory for fn if a) it doesn't exist and b) the user options allow it. Return True if the directory existed or was made. """ c, ok = self.c, False # 1815. # Create the directory if it doesn't exist. theDir, junk = g.os_path_split(fn) theDir = g.os_path_finalize(theDir) # 1341 if g.os_path_exists(theDir): return True if c and c.config and c.config.create_nonexistent_directories: theDir = c.expand_path_expression(theDir) ok = g.makeAllNonExistentDirectories(theDir) if not ok: g.error('did not create:', theDir) return ok