diff --git a/awips/dataaccess/PyData.py b/awips/dataaccess/PyData.py index eaa1953..a23c757 100644 --- a/awips/dataaccess/PyData.py +++ b/awips/dataaccess/PyData.py @@ -15,6 +15,7 @@ from awips.dataaccess import IData import six + class PyData(IData): def __init__(self, dataRecord): @@ -36,7 +37,7 @@ class PyData(IData): def getLevel(self): if six.PY2: return self.__level - if type(self.__level) is not str: + if not isinstance(self.__level, str): return self.__level.decode('utf-8') return self.__level diff --git a/awips/dataaccess/PyGridData.py b/awips/dataaccess/PyGridData.py index df6589b..b353044 100644 --- a/awips/dataaccess/PyGridData.py +++ b/awips/dataaccess/PyGridData.py @@ -46,7 +46,7 @@ class PyGridData(IGridData, PyData.PyData): def getUnit(self): if six.PY2: return self.__unit - if self.__unit is not None and type(self.__unit) is not str: + if self.__unit is not None and not isinstance(self.__unit, str): return self.__unit.decode('utf-8') return self.__unit diff --git a/awips/gfe/IFPClient.py b/awips/gfe/IFPClient.py index 71d16a4..a1900b7 100644 --- a/awips/gfe/IFPClient.py +++ b/awips/gfe/IFPClient.py @@ -1,17 +1,3 @@ -from awips import ThriftClient - -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import CommitGridsRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetGridInventoryRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetParmListRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetSelectTimeRangeRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import CommitGridRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId -from dynamicserialize.dstypes.com.raytheon.uf.common.site.requests import GetActiveSitesRequest -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.message import ServerResponse - - # # Provides a Python-based interface for executing GFE requests. # @@ -26,6 +12,18 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.messa # # +from awips import ThriftClient +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import CommitGridsRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetGridInventoryRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetParmListRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import GetSelectTimeRangeRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import CommitGridRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId +from dynamicserialize.dstypes.com.raytheon.uf.common.site.requests import GetActiveSitesRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.message import ServerResponse + class IFPClient(object): def __init__(self, host, port, user, site=None, progName=None): @@ -39,7 +37,7 @@ class IFPClient(object): self.__siteId = site def commitGrid(self, request): - if type(request) is CommitGridRequest: + if isinstance(request, CommitGridRequest): return self.__commitGrid([request]) elif self.__isHomogenousIterable(request, CommitGridRequest): return self.__commitGrid([cgr for cgr in request]) @@ -82,7 +80,7 @@ class IFPClient(object): return True def getGridInventory(self, parmID): - if type(parmID) is ParmID: + if isinstance(parmID, ParmID): sr = self.__getGridInventory([parmID]) list = [] try: diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.py index 4583efc..b94faeb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.py @@ -1,6 +1,3 @@ -## -## - # File auto-generated against equivalent DynamicSerialize Java class from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID @@ -20,12 +17,12 @@ class GFERecord(object): self.dataTime = None self.parmId = None if timeRange is not None: - if type(timeRange) is TimeRange: + if isinstance(timeRange, TimeRange): self.dataTime = DataTime(refTime=timeRange.getStart(), validPeriod=timeRange) else: raise TypeError("Invalid TimeRange object specified.") if parmId is not None: - if type(parmId) is ParmID.ParmID: + if isinstance(parmId, ParmID.ParmID): self.parmId = parmId self.parmName = parmId.getParmName() self.parmLevel = parmId.getParmLevel() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/ParmID.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/ParmID.py index 9367d95..f351f8b 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/ParmID.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/ParmID.py @@ -1,11 +1,9 @@ -## -## - # File auto-generated against equivalent DynamicSerialize Java class # Modified by njensen to add __repr__ from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID + class ParmID(object): def __init__(self, parmIdentifier=None, dbId=None, level=None): @@ -19,9 +17,9 @@ class ParmID(object): if (parmIdentifier is not None) and (dbId is not None): self.parmName = parmIdentifier - if type(dbId) is DatabaseID: + if isinstance(dbId, DatabaseID): self.dbId = dbId - elif type(dbId) is str: + elif isinstance(dbId, str): self.dbId = DatabaseID(dbId) else: raise TypeError("Invalid database ID specified.") diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py index a1f413c..2c877b3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py @@ -1,6 +1,3 @@ -## -## - # File auto-generated against equivalent DynamicSerialize Java class # and then modified post-generation to add additional features to better # match Java implementation. @@ -21,10 +18,10 @@ import re from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import MasterLevel - LEVEL_NAMING_REGEX = re.compile("^(\d*(?:\.\d*)?)(?:_(\d*(?:\.\d*)?))?([a-zA-Z]+)$") INVALID_VALUE = numpy.float64(-999999) + class Level(object): def __init__(self, levelString=None): @@ -51,7 +48,7 @@ class Level(object): return hashCode def __eq__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return False else: return (self.masterLevel, self.levelonevalue, self.leveltwovalue) == \ @@ -61,7 +58,7 @@ class Level(object): return not self.__eq__(other) def __lt__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return NotImplemented elif self.masterLevel.getName() != other.masterLevel.getName(): return NotImplemented @@ -93,7 +90,7 @@ class Level(object): return False def __le__(self, other): - if not isinstance(self, other): + if not isinstance(self, type(other)): return NotImplemented elif self.masterLevel.getName() != other.masterLevel.getName(): return NotImplemented @@ -101,7 +98,7 @@ class Level(object): return self.__lt__(other) or self.__eq__(other) def __gt__(self, other): - if not isinstance(self, other): + if not isinstance(self, type(other)): return NotImplemented elif self.masterLevel.getName() != other.masterLevel.getName(): return NotImplemented @@ -128,12 +125,11 @@ class Level(object): elif otherLevel2 != INVALID_VALUE: level2Cmp = self.__compareLevelValues(compareType, myLevel1, otherLevel2) return level2Cmp == 1 - else: - return True + return True return False def __ge__(self, other): - if not isinstance(self, other): + if not isinstance(self, type(other)): return NotImplemented elif self.masterLevel.getName() != other.masterLevel.getName(): return NotImplemented diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/MasterLevel.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/MasterLevel.py index e2808df..583b25e 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/MasterLevel.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/MasterLevel.py @@ -28,7 +28,7 @@ class MasterLevel(object): return hash(self.name) def __eq__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return False else: return self.name == other.name @@ -56,7 +56,7 @@ class MasterLevel(object): def getName(self): if six.PY2: return self.name - if self.name is not None and type(self.name) is not str: + if (self.name is not None) and (not isinstance(self.name, str)): return self.name.decode('utf-8') return self.name diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py index 12589ac..1942c98 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py @@ -62,7 +62,7 @@ class DataTime(object): else: self.fcstTime = 0 self.refTime = refTime - if validPeriod is not None and type(validPeriod) is not TimeRange: + if validPeriod is not None and not isinstance(validPeriod, TimeRange): raise ValueError("Invalid validPeriod object specified for DataTime.") self.validPeriod = validPeriod self.utilityFlags = EnumSet('com.raytheon.uf.common.time.DataTime$FLAG') @@ -193,7 +193,7 @@ class DataTime(object): return hashCode def __eq__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return False if other.getRefTime() is None: @@ -207,7 +207,7 @@ class DataTime(object): return not self.__eq__(other) def __lt__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return NotImplemented myValidTime = self.getRefTime().getTime() + self.getFcstTime() @@ -230,13 +230,13 @@ class DataTime(object): return False def __le__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return NotImplemented return self.__lt__(other) or self.__eq__(other) def __gt__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return NotImplemented myValidTime = self.getRefTime().getTime() + self.getFcstTime() @@ -259,7 +259,7 @@ class DataTime(object): return False def __ge__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return NotImplemented return self.__gt__(other) or self.__eq__(other) diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py index 97310df..c0af774 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py @@ -1,6 +1,3 @@ -## -## - # File auto-generated against equivalent DynamicSerialize Java class. Then modified to add functionality # # @@ -23,6 +20,7 @@ import time MAX_TIME = 2147483647 MICROS_IN_SECOND = 1000000 + class TimeRange(object): def __init__(self, start=None, end=None, startExtraMicros=None, endExtraMicros=None): self.start = self.__convertToDateTimeWithExtra(start, startExtraMicros) @@ -35,7 +33,7 @@ class TimeRange(object): return "(" + self.start.strftime("%b %d %y %H:%M:%S %Z") + ", " + self.end.strftime("%b %d %y %H:%M:%S %Z") + ")" def __eq__(self, other): - if type(self) != type(other): + if not isinstance(self, type(other)): return False if self.isValid() and other.isValid(): @@ -117,7 +115,7 @@ class TimeRange(object): return (timeArg.start >= self.start and timeArg.end <= self.end) else: convTime = self.__convertToDateTime(timeArg) - if type(convTime) is not datetime.datetime: + if not isinstance(convTime, datetime.datetime): raise TypeError("Invalid type for argument time specified to TimeRange.contains().") if self.duration() != 0: return (convTime >= self.start and convTime < self.end)