mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 22:57:56 -05:00
further cleanup for built-ins and formatting/indentation
This commit is contained in:
parent
8f193191f8
commit
85680fe96c
21 changed files with 91 additions and 91 deletions
|
@ -53,7 +53,7 @@ def get_hdf5_data(idra):
|
||||||
rdat = idra[ii]
|
rdat = idra[ii]
|
||||||
elif idra[ii].getName() == "Angles":
|
elif idra[ii].getName() == "Angles":
|
||||||
azdat = idra[ii]
|
azdat = idra[ii]
|
||||||
dattyp = "radial"
|
# dattyp = "radial"
|
||||||
elif idra[ii].getName() == "DependentValues":
|
elif idra[ii].getName() == "DependentValues":
|
||||||
depVals = idra[ii].getShortData()
|
depVals = idra[ii].getShortData()
|
||||||
elif idra[ii].getName() == "Thresholds":
|
elif idra[ii].getName() == "Thresholds":
|
||||||
|
@ -62,12 +62,12 @@ def get_hdf5_data(idra):
|
||||||
return rdat,azdat,depVals,threshVals
|
return rdat,azdat,depVals,threshVals
|
||||||
|
|
||||||
|
|
||||||
def get_header(record, format, xLen, yLen, azdat, description):
|
def get_header(record, headerFormat, xLen, yLen, azdat, description):
|
||||||
# Encode dimensions, time, mapping, description, tilt, and VCP
|
# Encode dimensions, time, mapping, description, tilt, and VCP
|
||||||
mytime = get_datetime_str(record)
|
mytime = get_datetime_str(record)
|
||||||
dattyp = get_data_type(azdat)
|
dattyp = get_data_type(azdat)
|
||||||
|
|
||||||
if format :
|
if headerFormat:
|
||||||
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
dattyp + " " + str(record.getLatitude()) + " " + \
|
dattyp + " " + str(record.getLatitude()) + " " + \
|
||||||
str(record.getLongitude()) + " " + \
|
str(record.getLongitude()) + " " + \
|
||||||
|
@ -75,7 +75,6 @@ def get_header(record, format, xLen, yLen, azdat, description):
|
||||||
str(record.getElevationNumber()) + " " + \
|
str(record.getElevationNumber()) + " " + \
|
||||||
description + " " + str(record.getTrueElevationAngle()) + " " + \
|
description + " " + str(record.getTrueElevationAngle()) + " " + \
|
||||||
str(record.getVolumeCoveragePattern()) + "\n"
|
str(record.getVolumeCoveragePattern()) + "\n"
|
||||||
#"%.1f"%
|
|
||||||
else:
|
else:
|
||||||
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||||
dattyp + " " + description + " " + \
|
dattyp + " " + description + " " + \
|
||||||
|
|
|
@ -11,14 +11,9 @@
|
||||||
# 06/24/15 #4480 dgilling Initial Creation.
|
# 06/24/15 #4480 dgilling Initial Creation.
|
||||||
#
|
#
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
from shapely.geometry import Point
|
|
||||||
|
|
||||||
from awips import DateTimeConverter
|
|
||||||
from awips.dataaccess import DataAccessLayer
|
from awips.dataaccess import DataAccessLayer
|
||||||
|
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||||
|
from shapely.geometry import Point
|
||||||
|
|
||||||
|
|
||||||
def getSounding(modelName, weatherElements, levels, samplePoint, timeRange=None):
|
def getSounding(modelName, weatherElements, levels, samplePoint, timeRange=None):
|
||||||
|
|
|
@ -21,6 +21,7 @@ from awips.dataaccess import IGeometryData
|
||||||
from awips.dataaccess import PyData
|
from awips.dataaccess import PyData
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
class PyGeometryData(IGeometryData, PyData.PyData):
|
class PyGeometryData(IGeometryData, PyData.PyData):
|
||||||
|
|
||||||
def __init__(self, geoDataRecord, geometry):
|
def __init__(self, geoDataRecord, geometry):
|
||||||
|
@ -76,7 +77,7 @@ class PyGeometryData(IGeometryData, PyData.PyData):
|
||||||
def getType(self, param):
|
def getType(self, param):
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
return self.__dataMap[param][1]
|
return self.__dataMap[param][1]
|
||||||
type = self.__dataMap[param.encode('utf-8')][1]
|
datatype = self.__dataMap[param.encode('utf-8')][1]
|
||||||
if type is not None:
|
if datatype is not None:
|
||||||
return type.decode('utf-8')
|
return datatype.decode('utf-8')
|
||||||
return type
|
return datatype
|
||||||
|
|
|
@ -65,8 +65,8 @@ class IFPClient(object):
|
||||||
request.setDbIds(ids)
|
request.setDbIds(ids)
|
||||||
sr = self.__makeRequest(request)
|
sr = self.__makeRequest(request)
|
||||||
ssr.setMessages(sr.getMessages())
|
ssr.setMessages(sr.getMessages())
|
||||||
list = sr.getPayload() if sr.getPayload() is not None else []
|
parmlist = sr.getPayload() if sr.getPayload() is not None else []
|
||||||
ssr.setPayload(list)
|
ssr.setPayload(parmlist)
|
||||||
return ssr
|
return ssr
|
||||||
|
|
||||||
def __isHomogenousIterable(self, iterable, classType):
|
def __isHomogenousIterable(self, iterable, classType):
|
||||||
|
@ -82,17 +82,18 @@ class IFPClient(object):
|
||||||
def getGridInventory(self, parmID):
|
def getGridInventory(self, parmID):
|
||||||
if isinstance(parmID, ParmID):
|
if isinstance(parmID, ParmID):
|
||||||
sr = self.__getGridInventory([parmID])
|
sr = self.__getGridInventory([parmID])
|
||||||
list = []
|
inventoryList = []
|
||||||
try:
|
try:
|
||||||
list = sr.getPayload()[parmID]
|
inventoryList = sr.getPayload()[parmID]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# no-op, we've already default the TimeRange list to empty
|
# no-op, we've already default the TimeRange list to empty
|
||||||
pass
|
pass
|
||||||
sr.setPayload(list)
|
sr.setPayload(inventoryList)
|
||||||
return sr
|
return sr
|
||||||
elif self.__isHomogenousIterable(parmID, ParmID):
|
elif self.__isHomogenousIterable(parmID, ParmID):
|
||||||
return self.__getGridInventory([id for id in parmID])
|
return self.__getGridInventory([id for id in parmID])
|
||||||
raise TypeError("Invalid type: " + str(type(parmID)) + " specified to getGridInventory(). Only accepts ParmID or lists of ParmID.")
|
raise TypeError("Invalid type: " + str(type(parmID)) +
|
||||||
|
" specified to getGridInventory(). Accepts ParmID or lists of ParmID.")
|
||||||
|
|
||||||
def __getGridInventory(self, parmIDs):
|
def __getGridInventory(self, parmIDs):
|
||||||
ssr = ServerResponse()
|
ssr = ServerResponse()
|
||||||
|
|
|
@ -22,15 +22,15 @@ class DynamicSerializationManager:
|
||||||
def _deserialize(self, ctx):
|
def _deserialize(self, ctx):
|
||||||
return ctx.deserializeMessage()
|
return ctx.deserializeMessage()
|
||||||
|
|
||||||
def deserializeBytes(self, bytes):
|
def deserializeBytes(self, sbytes):
|
||||||
ctx = self._buildSerializationContext(bytes)
|
ctx = self._buildSerializationContext(sbytes)
|
||||||
ctx.readMessageStart()
|
ctx.readMessageStart()
|
||||||
obj = self._deserialize(ctx)
|
obj = self._deserialize(ctx)
|
||||||
ctx.readMessageEnd()
|
ctx.readMessageEnd()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def _buildSerializationContext(self, bytes=None):
|
def _buildSerializationContext(self, sbytes=None):
|
||||||
self.transport = TTransport.TMemoryBuffer(bytes)
|
self.transport = TTransport.TMemoryBuffer(sbytes)
|
||||||
protocol = SelfDescribingBinaryProtocol.SelfDescribingBinaryProtocol(self.transport)
|
protocol = SelfDescribingBinaryProtocol.SelfDescribingBinaryProtocol(self.transport)
|
||||||
return ThriftSerializationContext.ThriftSerializationContext(self, protocol)
|
return ThriftSerializationContext.ThriftSerializationContext(self, protocol)
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,12 @@ class SerializationException(Exception):
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def serialize(obj):
|
def serialize(obj):
|
||||||
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||||
return dsm.serializeObject(obj)
|
return dsm.serializeObject(obj)
|
||||||
|
|
||||||
def deserialize(bytes):
|
|
||||||
|
def deserialize(objbytes):
|
||||||
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||||
return dsm.deserializeBytes(bytes)
|
return dsm.deserializeBytes(objbytes)
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.response import GeometryResponseData
|
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.response import GeometryResponseData
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.response import GetGeometryDataResponse
|
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.response import GetGeometryDataResponse
|
||||||
|
|
||||||
|
|
||||||
ClassAdapter = 'com.raytheon.uf.common.dataaccess.response.GetGeometryDataResponse'
|
ClassAdapter = 'com.raytheon.uf.common.dataaccess.response.GetGeometryDataResponse'
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ def serialize(context, resp):
|
||||||
def deserialize(context):
|
def deserialize(context):
|
||||||
size = context.readI32()
|
size = context.readI32()
|
||||||
wkbs = []
|
wkbs = []
|
||||||
for i in range(size):
|
for __ in range(size):
|
||||||
wkb = context.readBinary()
|
wkb = context.readBinary()
|
||||||
wkbs.append(wkb)
|
wkbs.append(wkb)
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ def deserialize(context):
|
||||||
# parameters
|
# parameters
|
||||||
paramSize = context.readI32()
|
paramSize = context.readI32()
|
||||||
paramMap = {}
|
paramMap = {}
|
||||||
for k in range(paramSize):
|
for __ in range(paramSize):
|
||||||
paramName = context.readString()
|
paramName = context.readString()
|
||||||
value = context.readObject()
|
value = context.readObject()
|
||||||
tName = context.readString()
|
tName = context.readString()
|
||||||
|
|
|
@ -17,8 +17,8 @@ ClassAdapter = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def serialize(context, type):
|
def serialize(context, ltype):
|
||||||
context.writeString(type.getText())
|
context.writeString(ltype.getText())
|
||||||
|
|
||||||
|
|
||||||
def deserialize(context):
|
def deserialize(context):
|
||||||
|
|
|
@ -8,18 +8,17 @@ except ImportError:
|
||||||
|
|
||||||
class UserId(object):
|
class UserId(object):
|
||||||
|
|
||||||
def __init__(self, id = None):
|
def __init__(self, userid = None):
|
||||||
if id is None:
|
if userid is None:
|
||||||
if not pwd_error:
|
if not pwd_error:
|
||||||
self.id = pwd.getpwuid(os.getuid()).pw_name
|
self.id = pwd.getpwuid(os.getuid()).pw_name
|
||||||
else:
|
else:
|
||||||
self.id = "GenericUsername"
|
self.id = "GenericUsername"
|
||||||
else:
|
else:
|
||||||
self.id = id
|
self.id = userid
|
||||||
|
|
||||||
def getId(self):
|
def getId(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def setId(self, id):
|
def setId(self, userid):
|
||||||
self.id = id
|
self.id = userid
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from awips.dataaccess import IDataRequest
|
from awips.dataaccess import IDataRequest
|
||||||
|
|
||||||
from dynamicserialize.dstypes.com.vividsolutions.jts.geom import Envelope
|
from dynamicserialize.dstypes.com.vividsolutions.jts.geom import Envelope
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||||
|
|
||||||
|
|
|
@ -72,9 +72,11 @@ class DatabaseID(object):
|
||||||
|
|
||||||
def __encodeIdentifier(self):
|
def __encodeIdentifier(self):
|
||||||
if self.dbType is not None:
|
if self.dbType is not None:
|
||||||
self.modelId = self.siteId + "_" + self.format + "_" + self.dbType + "_" + self.modelName
|
self.modelId = self.siteId + "_" + self.format + "_" \
|
||||||
|
+ self.dbType + "_" + self.modelName
|
||||||
else:
|
else:
|
||||||
self.modelId = self.siteId + "_" + self.format + "__" + self.modelName
|
self.modelId = self.siteId + "_" + self.format + "__" \
|
||||||
|
+ self.modelName
|
||||||
|
|
||||||
self.shortModelId = self.modelName
|
self.shortModelId = self.modelName
|
||||||
if self.dbType is not None and self.dbType != "":
|
if self.dbType is not None and self.dbType != "":
|
||||||
|
@ -127,7 +129,7 @@ class DatabaseID(object):
|
||||||
dateStruct = time.gmtime(0)
|
dateStruct = time.gmtime(0)
|
||||||
try:
|
try:
|
||||||
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
|
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
|
||||||
except:
|
except ValueError:
|
||||||
return (False, dateStruct)
|
return (False, dateStruct)
|
||||||
return (True, dateStruct)
|
return (True, dateStruct)
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects i
|
||||||
|
|
||||||
class GridParmInfo(object):
|
class GridParmInfo(object):
|
||||||
|
|
||||||
def __init__(self, id=None, gridLoc=None, gridType="NONE", unit=None,
|
def __init__(self, parmid=None, gridLoc=None, gridType="NONE", unit=None,
|
||||||
descriptiveName="", minValue=0.0, maxValue=0.0, precision=0,
|
descriptiveName="", minValue=0.0, maxValue=0.0, precision=0,
|
||||||
timeIndependentParm=False, timeConstraints=None, rateParm=False):
|
timeIndependentParm=False, timeConstraints=None, rateParm=False):
|
||||||
self.parmID = id
|
self.parmID = parmid
|
||||||
self.gridLoc = gridLoc
|
self.gridLoc = gridLoc
|
||||||
self.gridType = gridType
|
self.gridType = gridType
|
||||||
self.descriptiveName = descriptiveName
|
self.descriptiveName = descriptiveName
|
||||||
|
|
|
@ -20,7 +20,10 @@ class TimeConstraints(object):
|
||||||
self.valid = True
|
self.valid = True
|
||||||
else:
|
else:
|
||||||
if self.isInvalidInterval(repeatInterval, duration, startTime):
|
if self.isInvalidInterval(repeatInterval, duration, startTime):
|
||||||
logging.warning("Bad init values for TimeConstraints: ", self)
|
logging.warning("Bad init values for TimeConstraints: "
|
||||||
|
+ self.duration + ", "
|
||||||
|
+ self.repeatInterval + ", "
|
||||||
|
+ self.startTime)
|
||||||
self.valid = False
|
self.valid = False
|
||||||
duration = 0
|
duration = 0
|
||||||
repeatInterval = 0
|
repeatInterval = 0
|
||||||
|
|
|
@ -150,8 +150,8 @@ class Level(object):
|
||||||
def getId(self):
|
def getId(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def setId(self, id):
|
def setId(self, levelid):
|
||||||
self.id = id
|
self.id = levelid
|
||||||
|
|
||||||
def getMasterLevel(self):
|
def getMasterLevel(self):
|
||||||
return self.masterLevel
|
return self.masterLevel
|
||||||
|
|
|
@ -85,8 +85,8 @@ class MasterLevel(object):
|
||||||
return self.type.decode('utf-8')
|
return self.type.decode('utf-8')
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
def setType(self, type):
|
def setType(self, leveltype):
|
||||||
self.type = type
|
self.type = leveltype
|
||||||
|
|
||||||
def getIdentifier(self):
|
def getIdentifier(self):
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
|
|
|
@ -123,11 +123,11 @@ class RequestConstraint(object):
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
return float(value)
|
return float(value)
|
||||||
except Exception:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
return DataTime(value)
|
return DataTime(value)
|
||||||
except Exception:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,6 @@ class Request(object):
|
||||||
def getType(self):
|
def getType(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
def setType(self, type):
|
def setType(self, requesttype):
|
||||||
self.type = type
|
self.type = requesttype
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.localization.stream import AbstractLocalizationStreamRequest
|
from dynamicserialize.dstypes.com.raytheon.uf.common.localization.stream import AbstractLocalizationStreamRequest
|
||||||
|
|
||||||
|
@ -15,14 +16,14 @@ class LocalizationStreamPutRequest(AbstractLocalizationStreamRequest):
|
||||||
def getId(self):
|
def getId(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def setId(self, id):
|
def setId(self, requestid):
|
||||||
self.id = id
|
self.id = requestid
|
||||||
|
|
||||||
def getBytes(self):
|
def getBytes(self):
|
||||||
return self.bytes
|
return self.bytes
|
||||||
|
|
||||||
def setBytes(self, bytes):
|
def setBytes(self, streambytes):
|
||||||
self.bytes = bytes
|
self.bytes = streambytes
|
||||||
|
|
||||||
def getEnd(self):
|
def getEnd(self):
|
||||||
return self.end
|
return self.end
|
||||||
|
|
|
@ -34,8 +34,8 @@ class CompressedDataRecord(object):
|
||||||
def getType(self):
|
def getType(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
def setType(self, type):
|
def setType(self, recordtype):
|
||||||
self.type = type
|
self.type = recordtype
|
||||||
|
|
||||||
def getCompressedData(self):
|
def getCompressedData(self):
|
||||||
return self.compressedData
|
return self.compressedData
|
||||||
|
|
|
@ -21,8 +21,8 @@ class SiteActivationNotification(object):
|
||||||
def getType(self):
|
def getType(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
def setType(self, type):
|
def setType(self, notificationType):
|
||||||
self.type = type
|
self.type = notificationType
|
||||||
|
|
||||||
def getStatus(self):
|
def getStatus(self):
|
||||||
return self.status
|
return self.status
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
# 06/23/2016 #5696 rjpeter Initial creation.
|
# 06/23/2016 #5696 rjpeter Initial creation.
|
||||||
#
|
#
|
||||||
|
|
||||||
from time import gmtime, strftime
|
|
||||||
from dynamicserialize.dstypes.java.sql import Timestamp
|
from dynamicserialize.dstypes.java.sql import Timestamp
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue