def getProperty(self, respath, propertyname, propertyns): if propertyns == 'DAV:': isfile = fs.isfile(respath) if propertyname == 'creationdate': statresults = fs.stat(respath) return httpdatehelper.rfc3339(statresults.st_ctime) elif propertyname == 'getcontenttype': return self.getContentType(respath) elif propertyname == 'resourcetype': if fs.isdir(respath): return '<D:collection />' else: return '' elif propertyname == 'getlastmodified': statresults = fs.stat(respath) return httpdatehelper.getstrftime(statresults.st_mtime) elif propertyname == 'getcontentlength': if isfile: statresults = fs.stat(respath) return str(statresults.st_size) else: return '0' raise HTTPRequestException(processrequesterrorhandler.HTTP_NOT_FOUND) elif propertyname == 'getetag': return self.getEntityTag(respath) raise HTTPRequestException(processrequesterrorhandler.HTTP_NOT_FOUND)
def getResourceDescription(self, respath): if fs.isdir(respath): return "Directory" elif fs.isfile(respath): return "File" else: return "Unknown"
def getResourceDescriptor(self, respath): resdesc = self.getResourceDescription(respath) ressize = str(self.getContentLength(respath)) + " B" resmod = httpdatehelper.getstrftime(self.getLastModified(respath)) if fs.isdir(respath): ressize = "" return [resdesc, ressize, resmod]
def getDir(self): print('Input directory') path = input('>>>') if(fs.isdir(path)): self.path = path else: print('Please input a valid directory !') exit()
def test_isdir_on_non_existing_file(): assert fs.isdir(os.path.join(TEST_DIR, "foo.txt")) is False
def test_isdir_on_existing_file(): assert fs.isdir(TEST_FILE) is False
def test_isdir_on_non_existing_directory(): assert fs.isdir(os.path.join(TEST_DIR, "foo")) is False
def test_isdir_on_existing_directory(): assert fs.isdir(TEST_DIR) is True
fs.close(fa1) fs.chdir('/a') print fs.listdir('.') #this is just to test if it could delte directory with file consisted inside #not enough space in native file to create this file, if not some file are delete. fs.create('b2/fb2', 70) fb2d = fs.open('b2/fb2', 'w') fs.write(fb2d, 'this is to test if we \n could delete anythin inthe directory') fs.close(fb2d) fb21 = fs.open('b2/fb2', 'r') print fs.readlines(fb21) fs.close(fb21) fs.deldir('b2') print fs.isdir('/a/b1/c2') print fs.isdir('/a/b3/fc') #print fs.open('b2/fb2', 'r') print fs.listdir('.') def printAll(root): print "Current Directory is " + root.dirName print list(map(prn, root.contentList)) for i in root.contentList: if isinstance(i, fs.Directory): printAll(i) def printAllFiles(root):
def isCollection(self, respath): return fs.isdir(respath)
def clean(): """Clean the dist/ directory""" if (fs.isdir(DIST_DIR)): fs.truncate(DIST_DIR)
def test_isdir_on_existing_file(): assert fs.isdir(TEST_FILE) is False
def test_isdir_on_non_existing_directory(): assert fs.isdir(os.path.join(TEST_DIR, "foo")) is False
def test_isdir_on_existing_directory(): assert fs.isdir(TEST_DIR) is True
def test_isdir_on_non_existing_file(): assert fs.isdir(os.path.join(TEST_DIR, "foo.txt")) is False