Source code for pyasdm.ObservationRow

# ALMA - Atacama Large Millimeter Array
# (c) European Southern Observatory, 2002
# (c) Associated Universities Inc., 2002
# Copyright by ESO (in the framework of the ALMA collaboration),
# Copyright by AUI (in the framework of the ALMA collaboration),
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#
# Warning!
#  --------------------------------------------------------------------
# | This is generated code!  Do not modify this file.                  |
# | If you do, all changes will be lost when the file is re-generated. |
#  --------------------------------------------------------------------
#
# File ObservationRow.py
#

import pyasdm.ObservationTable

from .Parser import Parser

import pyasdm.utils

from .exceptions.ConversionException import ConversionException

# All of the extended types are imported
from pyasdm.types import *

# this will contain all of the static methods used to get each element of the row
# from an EndianInput instance
_fromBinMethods = {}


from xml.dom import minidom

import copy


[docs]class ObservationRow: """ The ObservationRow class is a row of a ObservationTable. Generated from model's revision -1, branch """ # the table to which this row belongs. _table = None # whether this row has been added to the table or not. _hasBeenAdded = False # internal attribute values appear later, with their getters and setters def __init__(self, table, row=None): """ Create a ObservationRow. When row is None, create an empty row attached to table, which must be a ObservationTable. When row is given, copy those values in to the new row. The row argument must be a ObservationRow. The returned new row is not yet added to table, but it knows about table. """ if not isinstance(table, pyasdm.ObservationTable): raise ValueError("table must be a ObservationTable") self._table = table self._hasBeenAdded = False # initialize attribute values # intrinsic attributes self._observationId = Tag() if row is not None: if not isinstance(row, ObservationRow): raise ValueError("row must be a ObservationRow") # copy constructor self._observationId = Tag(row._observationId)
[docs] def isAdded(self): self._hasBeenAdded = True
[docs] def getTable(self): """ Return the table to which this row belongs. """ return self._table
[docs] def toXML(self): """ Return this row in the form of an XML string. """ result = "" result += "<row> \n" # intrinsic attributes result += Parser.extendedValueToXML("observationId", self._observationId) # links, if any result += "</row>\n" return result
[docs] def setFromXML(self, xmlrow): """ Fill the values of this row from an XML string that was produced by the toXML() method. If xmlrow is a minidom.Element with a nodeName of row then it will be used as is. Anything else that is not a string is an error. """ rowdom = None if isinstance(xmlrow, str): xmldom = minidom.parseString(xmlrow) rowdom = xmldom.firstChild elif isinstance(xmlrow, minidom.Element): rowdom = xmlrow else: raise ConversionException( "xmlrow is not a string or a minidom.Element", "ObservationTable" ) if rowdom.nodeName != "row": raise ConversionException("the argument is not a row", "ObservationTable") # intrinsic attribute values observationIdNode = rowdom.getElementsByTagName("observationId")[0] self._observationId = Tag(observationIdNode.firstChild.data.strip())
# from link values, if any
[docs] def toBin(self, eos): """ Write this row out to the EndianOutput instance, eos. """ self._observationId.toBin(eos)
[docs] @staticmethod def observationIdFromBin(row, eis): """ Set the observationId in row from the EndianInput (eis) instance. """ row._observationId = Tag.fromBin(eis)
[docs] @staticmethod def initFromBinMethods(): global _fromBinMethods if len(_fromBinMethods) > 0: return _fromBinMethods["observationId"] = ObservationRow.observationIdFromBin
[docs] @staticmethod def fromBin(eis, table, attributesSeq): """ Given an EndianInput instance by the table (which must be a Pointing instance) and the list of attributes to be found in eis, in order, this constructs a row by pulling off values from that EndianInput in the expected order. The new row object is returned. """ global _fromBinMethods row = ObservationRow(table) for attributeName in attributesSeq: if attributeName not in _fromBinMethods: raise ConversionException( "There is not a method to read an attribute '" + attributeName + "'.", " Observation", ) method = _fromBinMethods[attributeName] method(row, eis) return row
# Intrinsice Table Attributes # ===> Attribute observationId _observationId = Tag()
[docs] def getObservationId(self): """ Get observationId. return observationId as Tag """ # make sure it is a copy of Tag return Tag(self._observationId)
[docs] def setObservationId(self, observationId): """ Set observationId with the specified Tag value. observationId The Tag value to which observationId is to be set. The value of observationId can be anything allowed by the Tag constructor. Raises a ValueError If an attempt is made to change a part of the key after is has been added to the table. """ if self._hasBeenAdded: raise ValueError( "Attempt to change the observationId field, which is part of the key, after this row has been added to this table." ) self._observationId = Tag(observationId)
# Extrinsic Table Attributes # Links # comparison methods
[docs] def equalByRequiredValue(self, otherRow): """ Return True if all required attributes of the value part are equal to their homologues in otherRow and False otherwise. """ return True
[docs] def compareRequiredValue( self, ): return True
# initialize the dictionary that maps fields to init methods ObservationRow.initFromBinMethods()