Beispiel #1
0
def loopTesting(location, LR, saveLoc, iLoop, jLoop, kLoop):
    for i in iLoop:
        #Checking to see if directory exists for /i
        assert os.path.isdir(saveLoc + '/' + lastHex(i))
        assert os.path.isdir(LR + '/' + lastHex(i))
        for j in jLoop:
            #Checking to see if directory exist for /i/j
            assert os.path.isdir(LR + '/' + lastHex(i) + '/' + lastHex(j))
            assert os.path.isdir(saveLoc + '/' + lastHex(i) + '/' + lastHex(j))
            for k in kLoop:
                #Checking to see if directory exists for /i/j/k
                assert os.path.isdir(LR + '/' + lastHex(i) + '/' + lastHex(j) +
                                     '/' + lastHex(k))
                assert os.path.isdir(saveLoc + '/' + lastHex(i) + '/' +
                                     lastHex(j) + '/' + lastHex(k))
                assert os.path.isdir(saveLoc + '/' + lastHex(i) + '/' +
                                     lastHex(j) + '/' + lastHex(k) + '/GT')
                assert os.path.isdir(saveLoc + '/' + lastHex(i) + '/' +
                                     lastHex(j) + '/' + lastHex(k) + '/LR')
                assert os.path.isdir(LR + '/' + lastHex(i) + '/' + lastHex(j) +
                                     '/' + lastHex(k) + '/LR/x4')
                #Checking to see if the numbers of pictures in LR is same as the parent directory
                LRPath = LR + '/' + lastHex(i) + '/' + lastHex(
                    j) + '/' + lastHex(k) + '/LR/x4'
                locPath = location + '/' + lastHex(i) + '/' + lastHex(
                    j) + '/' + lastHex(k)
                Low_Res_Folder_Size = len([
                    name for name in os.listdir(LRPath)
                    if os.path.isfile(os.path.join(LRPath, name))
                ])
                Initial_Folder_Size = len([
                    name for name in os.listdir(locPath)
                    if os.path.isfile(os.path.join(locPath, name))
                ])
                assert (Low_Res_Folder_Size == Initial_Folder_Size)
                #Checking to see if the pictures are 4x as small
                for aPic in os.listdir(locPath):
                    if aPic in os.listdir(LRPath):
                        locWidth = 2
                        locHeight = 2
                        lrWidth = 2
                        lrHeight = 2
                        with Image.open(locPath + '/' + aPic) as img:
                            w, h = img.size
                            locWidth = w
                            locHeight = h
                        with Image.open(LRPath + '/' + aPic) as img:
                            w, h = img.size
                            lrWidth = w
                            lrHeight = h
                        assert int(locWidth / 4) == lrWidth
                        assert int(locHeight / 4) == lrHeight
                    else:
                        print("On here for: " + str(i) + " " + str(j) + " " +
                              str(k))
                        assert False  #Picture is not the same in locPath and LRPath
Beispiel #2
0
def loopDelete(LR, saveLoc, iLoop, jLoop, kLoop):
    for i in iLoop:
        for j in jLoop:
            for k in kLoop:
                BIC = LR + '/' + lastHex(i) + '/' + lastHex(j) + '/' + lastHex(
                    k) + '/Bic'
                LRP = LR + '/' + lastHex(i) + '/' + lastHex(j) + '/' + lastHex(
                    k) + '/LR'
                HRP = LR + '/' + lastHex(i) + '/' + lastHex(j) + '/' + lastHex(
                    k) + '/HR'
                GT_Dir = saveLoc + '/' + lastHex(i) + '/' + lastHex(
                    j) + '/' + lastHex(k) + '/GT'
                LR_Dir = saveLoc + '/' + lastHex(i) + '/' + lastHex(
                    j) + '/' + lastHex(k) + '/LR'
                BICPath = BIC + '/x4'
                LRPath = LRP + '/x4'
                HRPath = HRP + '/x4'
                ##--REMOVING photos inside each folder--
                for a in os.listdir(BICPath):
                    os.remove(BICPath + '/' + a)
                for a in os.listdir(LRPath):
                    os.remove(LRPath + '/' + a)
                for a in os.listdir(HRPath):
                    os.remove(HRPath + '/' + a)

                #Removing folders and items inside GT/LR
                if not (len(os.listdir(GT_Dir)) == 0):
                    os.remove(GT_Dir + '/DIV2K800_sub.lmdb/data.mdb')
                    os.remove(GT_Dir + '/DIV2K800_sub.lmdb/lock.mdb')
                    os.remove(GT_Dir + '/DIV2K800_sub.lmdb/meta_info.pkl')
                os.rmdir(GT_Dir + '/DIV2K800_sub.lmdb')

                if not (len(os.listdir(LR_Dir)) == 0):
                    os.remove(LR_Dir + '/DIV2K800_sub.lmdb/data.mdb')
                    os.remove(LR_Dir + '/DIV2K800_sub.lmdb/lock.mdb')
                    os.remove(LR_Dir + '/DIV2K800_sub.lmdb/meta_info.pkl')
                os.rmdir(LR_Dir + '/DIV2K800_sub.lmdb')
                os.rmdir(GT_Dir)
                os.rmdir(LR_Dir)

                ##Removing the 3 folders, (BIC/x4) (LR/x4) (HR/x4)
                os.rmdir(BICPath)
                os.rmdir(LRPath)
                os.rmdir(HRPath)
                ##Removing 3 folders, BIC, LR, HR
                os.rmdir(BIC)
                os.rmdir(LRP)
                os.rmdir(HRP)
                ##Removing numbered folder from list
                os.rmdir(saveLoc + '/' + lastHex(i) + '/' + lastHex(j) + '/' +
                         lastHex(k))
                os.rmdir(LR + '/' + lastHex(i) + '/' + lastHex(j) + '/' +
                         lastHex(k))
            os.rmdir(LR + '/' + lastHex(i) + '/' + lastHex(j))
            os.rmdir(saveLoc + '/' + lastHex(i) + '/' + lastHex(j))
        os.rmdir(LR + '/' + lastHex(i))
        os.rmdir(saveLoc + '/' + lastHex(i))
    os.rmdir(LR)
    os.rmdir(saveLoc)
    return
Beispiel #3
0
	def test_lastHexTest2 (self):
		assert lastHex(10) == 'a'
Beispiel #4
0
	def test_lastHexTest3 (self):
		assert lastHex(16) == '0'
Beispiel #5
0
	def test_lastHexTest1(self):
		assert lastHex(3) == '3'