summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--code/directory.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/code/directory.py b/code/directory.py
index d8855432..e28bf35c 100644
--- a/code/directory.py
+++ b/code/directory.py
@@ -1,8 +1,10 @@
 class FrozenException(Exception): pass
+class NotLoadedYet(Exception): pass
 
 class Directory():
 	def __init__(self, path):
 		self.path = path
+		self.accessible = False
 		self.files_loaded = False
 		self.scheduled = False
 		self.files = None
@@ -17,9 +19,11 @@ class Directory():
 		try:
 			self.files = os.listdir(self.path)
 			self.exists = True
+			self.accessible = True
 		except OSError:
-			self.files = []
+			self.files = None
 			self.exists = False
+			self.accessible = False
 		self.files_loaded = True
 
 	def clone(self):
@@ -34,9 +38,11 @@ class Directory():
 		return clone
 
 	def __len__(self):
+		if not self.accessible: raise NotLoadedYet()
 		return len(self.files)
 	
 	def __getitem__(self, key):
+		if not self.accessible: raise NotLoadedYet()
 		return self.files[key]
 
 if __name__ == '__main__':
' href='#n107'>107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164