00001 "Provides access to the Ingest Catalog from python"
00002
00003 url = None
00004
00005 class SetSelection:
00006 'Internal class that contains the representation of a selection of file sets'
00007
00008 def __init__(self, lhs, rhs):
00009 """
00010 Creates an selection. If the second argument in None, then
00011 the first argument is taken to be a single selection. Otherwise
00012 both argments are taken to be instances of this class.
00013 """
00014 self.resolution = None
00015 self.content = []
00016 if (None == rhs):
00017 self.content.append(lhs)
00018 else:
00019 self.content = lhs.content + rhs.content
00020
00021 def __add__(self, others):
00022 return SetSelection(self, others)
00023
00024 def __getitem__(self, key):
00025 self.resolve()
00026 return self.resolution[key]
00027
00028 def __len__(self):
00029 self.resolve()
00030 return len(self.resolution)
00031
00032 def resolve(self):
00033 if self.resolution:
00034 return
00035
00036 from CatalogBeanService_services import CatalogBeanServiceLocator, CatalogBean_getBinaryFilesByFileSets
00037 loc = CatalogBeanServiceLocator()
00038 port = loc.getCatalogBean(url)
00039 req = CatalogBean_getBinaryFilesByFileSets()
00040 req._arg0 = self.content
00041 self.resolution = []
00042 for name in port.getBinaryFilesByFileSets(req)._return:
00043 self.resolution.append(name.encode('utf-8'))
00044
00045 def __repr__(self):
00046 self.resolve()
00047 return str(self.resolution)
00048
00049
00050 class RunSelection:
00051 'Internal class that contains the representation of a selection of Runs'
00052
00053 def __init__(self, lhs, rhs):
00054 """
00055 Creates an selection. If the second argument in None, then
00056 the first argument is taken to be a single selection. Otherwise
00057 both argments are taken to be instances of this class.
00058 """
00059 self.resolution = None
00060 self.content = []
00061 if (None == rhs):
00062 self.content.append(lhs)
00063 else:
00064 self.content = lhs.content + rhs.content
00065
00066 def __add__(self, others):
00067 return RunSelection(self, others)
00068
00069 def __getitem__(self, item):
00070 self.resolve()
00071 if isinstance(item, slice):
00072 indices = item.indices(len(self))
00073 return self.resolution[indices[0]:indices[1]:indices[2]]
00074 else:
00075 return self.resolution[item]
00076
00077 def __len__(self):
00078 self.resolve()
00079 return len(self.resolution)
00080
00081 def resolve(self):
00082 if self.resolution:
00083 return
00084
00085 from CatalogBeanService_services_types import ns0
00086 ranges = []
00087 for entry in self.content:
00088 range=ns0.runRange_Def('RunRange').pyclass()
00089 range._begin = entry[0]
00090 range._end = entry[1]
00091
00092 ranges.append(range)
00093
00094 from CatalogBeanService_services import CatalogBeanServiceLocator, CatalogBean_getBinaryFilesByRunRanges
00095 loc = CatalogBeanServiceLocator()
00096 port = loc.getCatalogBean(url)
00097 req = CatalogBean_getBinaryFilesByRunRanges()
00098 req._arg0 = ranges
00099 self.resolution = []
00100 for name in port.getBinaryFilesByRunRanges(req)._return:
00101 self.resolution.append(name.encode('utf-8'))
00102
00103 def __repr__(self):
00104 self.resolve()
00105 return str(self.resolution)
00106
00107
00108 class EntrySelection:
00109 'Internal class that contains the representation of a selection of EntryIds'
00110
00111 def __init__(self, lhs, rhs):
00112 """
00113 Creates an selection. If the second argument in None, then
00114 the first argument is taken to be a single selection. Otherwise
00115 both argments are taken to be instances of this class.
00116 """
00117 self.resolution = None
00118 self.content = []
00119 if (None == rhs):
00120 self.content.append(lhs)
00121 else:
00122 self.content = lhs.content + rhs.content
00123
00124 def __add__(self, others):
00125 return EntrySelection(self, others)
00126
00127 def __getitem__(self, key):
00128 self.resolve()
00129 return self.resolution[key]
00130
00131 def __len__(self):
00132 self.resolve()
00133 return len(self.resolution)
00134
00135 def resolve(self):
00136 if self.resolution:
00137 return
00138
00139 from CatalogBeanService_services import CatalogBeanServiceLocator, CatalogBean_getBinaryFilesByEntryIds
00140 loc = CatalogBeanServiceLocator()
00141 port = loc.getCatalogBean(url)
00142 req = CatalogBean_getBinaryFilesByEntryIds()
00143 req._arg0 = self.content
00144 self.resolution = []
00145 for name in port.getBinaryFilesByEntryIds(req)._return:
00146 self.resolution.append(name.encode('utf-8'))
00147
00148 def __repr__(self):
00149 self.resolve()
00150 return str(self.resolution)
00151
00152
00153 class FileSets:
00154
00155 def __getitem__(self, key):
00156 return SetSelection(key, None)
00157
00158
00159 class RunRange:
00160
00161 def __getitem__(self, item):
00162 if isinstance(item, slice):
00163 return RunSelection((item.start,item.stop,item.step), None)
00164 else:
00165 return RunSelection((item, item + 1, None), None)
00166
00167
00168 class EntryIds:
00169
00170 def __getitem__(self, key):
00171 return EntrySelection(key, None)
00172
00173
00174 fileSets = FileSets()
00175 runs = RunRange()
00176 ids = EntryIds()