Specifications

61
InfoStore_Prompt = 'Enter the desired infostore [1, %i]: ' %InfoStoresCount
while True:
InfoStore = raw_input(InfoStore_Prompt)
if not len(InfoStore): break
try:
InfoStore = int(InfoStore)
if InfoStore < 0: raise ValueError
if InfoStore > InfoStoresCount: raise ValueError
break
except ValueError:
print "WARNING: not in the range [1, %i]" %InfoStoresCount
if not InfoStore:
InfoStoreNum = DefaultInfoStoreNum
else:
InfoStoreNum = InfoStore - 1#needs to be 0-based to be used as an index
try:
ProcessedInfostoreName = cdo.Infostores[InfoStoreNum -
0].Name.encode(UnicodeEncoding)
print 'Looking for folders in %s...' %ProcessedInfostoreName,
Folders = cdo.Infostores[InfoStoreNum - 0].RootFolder.Folders
print ' OK'
except:#TODO: restrict the error type
print 'Error - Bad infostore.'
#cdo.logoff
sys.exit()
FoldersCount = Folders.Count
print '\nThere are %i folders available:' %FoldersCount
DefaultFolder = 'Indbakke'
DefaultFolderNum = 0#remove?
FolderNum = 0
FoldersList = []
for it in range(FoldersCount):
FolderName = Folders[it].Name
FoldersList.append(FolderName)
print '%i) %s' %(it+1, FolderName.encode(UnicodeEncoding))
if FolderName == DefaultFolder: DefaultFolderNum = it#+1
if DefaultFolderNum:
Folder_Prompt = 'Enter the desired folder [1, %i] (defaults to "%s"): '
%(FoldersCount, DefaultFolder.encode(UnicodeEncoding))
else:
Folder_Prompt = 'Enter the desired folder [1, %i]: '%FoldersCount
while True:
Folder = raw_input(Folder_Prompt)
if not len(Folder): break