Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/prd_fetch_elements.py
Дата изменения: Fri Feb 28 14:46:11 2014
Дата индексирования: Sat Mar 1 21:57:30 2014
Кодировка:

Поисковые слова: http astrokuban.info astrokuban
#MODULE build_prd_files
#
#***********************************************************************
"""

**PURPOSE** --
Fetch a list of elements from a PRDUVM library.
This module creates two lists, one containing all the elements
fetched and the other containing the log of the PRDUVM activities.


**DEVELOPER** --
k. clark

**MODIFICATION HISTORY** --

o Initial implementation 6/ 7/02
o Updated 8/ 1/03 KWC - Add numbering method.
o Updated 11/ 6/03 KWC - Increment line numbers by 10 instead of 1.
o Updated 12/ 3/03 KWC - Correct FD record count by /10.
o Updated 12/29/03 RSK - Added processing for collections and associated
tags
o Updated 03/12/04 RSK - Added method to format file without line numbers
o Updated 3/30/04 KWC - Changed module name to build_prd_files.
o Updated 4/ 9/04 KWC - Remove numbering and write methods.

"""
#***********************************************************************
import rcslib

__version__ = " 4/ 9/04"

class prd_fetch_elements:

def __init__ (self):
""" Constructor.
"""
self.prd_ele_data = []
self.UVM_log = []

def fetch_elements(self, element_list):
""" Fetches the files in the element list and returns the
element data and the UVM log.
"""
self.prd_ele_data = []
self.UVM_log = []

# Need at least one element.
if (len(element_list) > 0) :

#Create the RCS library object.
rlib = rcslib.RCS()

#Display each element in the RCS library.
for n in element_list :
# The first element in the list is a string representing the
# filename for the fd record. Each additional element is a
# tuple. The tuple contains a list of files for a particular
# subsystem, and a string that represents the associated tag.

# Get the rlog information for this element.
if type(n) != type("") :
# if we're here, we have a tuple where the first object is a
# list and the second is a tag
list_size = len(n[0])
i = 0
file_list = n[0]
tag_id = n[1]
while i < list_size:
ele_info = rlib.info(file_list[i])
if ((ele_info.state(ele_info.head()) == "Obs") and (tag_id == None)):
# Don't bother displaying obsolete elements.
pass
else:
flist, error_list = rlib.content((file_list[i],tag_id), )
self.prd_ele_data.extend(flist)
self.UVM_log.append(error_list)
i = i + 1
else:
ele_info = rlib.info(n)

# Don't bother displaying obsolete elements.
if ele_info.state(ele_info.head()) != "Obs":
tag_id = None
flist, error_list = rlib.content((n,tag_id), )
self.prd_ele_data.extend(flist)
self.UVM_log.append(error_list)

# Return lists of the data and the log.
return self.prd_ele_data, self.UVM_log

if __name__ == '__main__':

# Test cases.
element_list = []
element_list.append('/data/tigger21/sogspdb/uvm/pdb_config/ptld_ops/01_sub-engin/A-fd_rec.ptld,v')
element_list.append('/data/tigger21/sogspdb/uvm/pdb_config/ptld/acs/jshutter.ptld,v')
element_list.append('/data/tigger21/sogspdb/uvm/pdb_config/ptld/acs/jfmatsbc.ptld,v')
element_list.append('/data/tigger21/sogspdb/uvm/pdb_config/ptld/acs/jfmatwfc.ptld,v')
prd_fetch = prd_fetch_elements()
a,log = prd_fetch.fetch_elements (element_list)
for line in a:
print line