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]
|
||||
elif idra[ii].getName() == "Angles":
|
||||
azdat = idra[ii]
|
||||
dattyp = "radial"
|
||||
# dattyp = "radial"
|
||||
elif idra[ii].getName() == "DependentValues":
|
||||
depVals = idra[ii].getShortData()
|
||||
elif idra[ii].getName() == "Thresholds":
|
||||
|
@ -62,12 +62,12 @@ def get_hdf5_data(idra):
|
|||
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
|
||||
mytime = get_datetime_str(record)
|
||||
dattyp = get_data_type(azdat)
|
||||
|
||||
if format :
|
||||
if headerFormat:
|
||||
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||
dattyp + " " + str(record.getLatitude()) + " " + \
|
||||
str(record.getLongitude()) + " " + \
|
||||
|
@ -75,8 +75,7 @@ def get_header(record, format, xLen, yLen, azdat, description):
|
|||
str(record.getElevationNumber()) + " " + \
|
||||
description + " " + str(record.getTrueElevationAngle()) + " " + \
|
||||
str(record.getVolumeCoveragePattern()) + "\n"
|
||||
#"%.1f"%
|
||||
else :
|
||||
else:
|
||||
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
|
||||
dattyp + " " + description + " " + \
|
||||
str(record.getTrueElevationAngle()) + " " + \
|
||||
|
@ -91,32 +90,32 @@ def encode_thresh_vals(threshVals):
|
|||
nnn = len(threshVals)
|
||||
j = 0
|
||||
msg = ""
|
||||
while j<nnn :
|
||||
while j<nnn:
|
||||
lo = threshVals[j] % 256
|
||||
hi = threshVals[j] / 256
|
||||
msg += " "
|
||||
j += 1
|
||||
if hi < 0 :
|
||||
if lo > 14 :
|
||||
if hi < 0:
|
||||
if lo > 14:
|
||||
msg += "."
|
||||
else :
|
||||
else:
|
||||
msg += spec[lo]
|
||||
continue
|
||||
if hi % 16 >= 8 :
|
||||
if hi % 16 >= 8:
|
||||
msg += ">"
|
||||
elif hi % 8 >= 4 :
|
||||
elif hi % 8 >= 4:
|
||||
msg += "<"
|
||||
if hi % 4 >= 2 :
|
||||
if hi % 4 >= 2:
|
||||
msg += "+"
|
||||
elif hi % 2 >= 1 :
|
||||
elif hi % 2 >= 1:
|
||||
msg += "-"
|
||||
if hi >= 64 :
|
||||
msg += "%.2f"%(lo*0.01)
|
||||
elif hi % 64 >= 32 :
|
||||
msg += "%.2f"%(lo*0.05)
|
||||
elif hi % 32 >= 16 :
|
||||
msg += "%.1f"%(lo*0.1)
|
||||
else :
|
||||
if hi >= 64:
|
||||
msg += "%.2f" % (lo*0.01)
|
||||
elif hi % 64 >= 32:
|
||||
msg += "%.2f" % (lo*0.05)
|
||||
elif hi % 32 >= 16:
|
||||
msg += "%.1f" % (lo*0.1)
|
||||
else:
|
||||
msg += str(lo)
|
||||
msg += "\n"
|
||||
return msg
|
||||
|
@ -126,7 +125,7 @@ def encode_dep_vals(depVals):
|
|||
nnn = len(depVals)
|
||||
j = 0
|
||||
msg = []
|
||||
while j<nnn :
|
||||
while j < nnn:
|
||||
msg.append(str(depVals[j]))
|
||||
j += 1
|
||||
return msg
|
||||
|
@ -136,7 +135,7 @@ def encode_radial(azVals):
|
|||
azValsLen = len(azVals)
|
||||
j = 0
|
||||
msg = []
|
||||
while j<azValsLen :
|
||||
while j < azValsLen:
|
||||
msg.append(azVals[j])
|
||||
j += 1
|
||||
return msg
|
||||
|
|
|
@ -11,14 +11,9 @@
|
|||
# 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 dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||
from shapely.geometry import Point
|
||||
|
||||
|
||||
def getSounding(modelName, weatherElements, levels, samplePoint, timeRange=None):
|
||||
|
|
|
@ -21,6 +21,7 @@ from awips.dataaccess import IGeometryData
|
|||
from awips.dataaccess import PyData
|
||||
import six
|
||||
|
||||
|
||||
class PyGeometryData(IGeometryData, PyData.PyData):
|
||||
|
||||
def __init__(self, geoDataRecord, geometry):
|
||||
|
@ -76,7 +77,7 @@ class PyGeometryData(IGeometryData, PyData.PyData):
|
|||
def getType(self, param):
|
||||
if six.PY2:
|
||||
return self.__dataMap[param][1]
|
||||
type = self.__dataMap[param.encode('utf-8')][1]
|
||||
if type is not None:
|
||||
return type.decode('utf-8')
|
||||
return type
|
||||
datatype = self.__dataMap[param.encode('utf-8')][1]
|
||||
if datatype is not None:
|
||||
return datatype.decode('utf-8')
|
||||
return datatype
|
||||
|
|
|
@ -65,8 +65,8 @@ class IFPClient(object):
|
|||
request.setDbIds(ids)
|
||||
sr = self.__makeRequest(request)
|
||||
ssr.setMessages(sr.getMessages())
|
||||
list = sr.getPayload() if sr.getPayload() is not None else []
|
||||
ssr.setPayload(list)
|
||||
parmlist = sr.getPayload() if sr.getPayload() is not None else []
|
||||
ssr.setPayload(parmlist)
|
||||
return ssr
|
||||
|
||||
def __isHomogenousIterable(self, iterable, classType):
|
||||
|
@ -82,17 +82,18 @@ class IFPClient(object):
|
|||
def getGridInventory(self, parmID):
|
||||
if isinstance(parmID, ParmID):
|
||||
sr = self.__getGridInventory([parmID])
|
||||
list = []
|
||||
inventoryList = []
|
||||
try:
|
||||
list = sr.getPayload()[parmID]
|
||||
inventoryList = sr.getPayload()[parmID]
|
||||
except KeyError:
|
||||
# no-op, we've already default the TimeRange list to empty
|
||||
pass
|
||||
sr.setPayload(list)
|
||||
sr.setPayload(inventoryList)
|
||||
return sr
|
||||
elif self.__isHomogenousIterable(parmID, 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):
|
||||
ssr = ServerResponse()
|
||||
|
|
|
@ -22,15 +22,15 @@ class DynamicSerializationManager:
|
|||
def _deserialize(self, ctx):
|
||||
return ctx.deserializeMessage()
|
||||
|
||||
def deserializeBytes(self, bytes):
|
||||
ctx = self._buildSerializationContext(bytes)
|
||||
def deserializeBytes(self, sbytes):
|
||||
ctx = self._buildSerializationContext(sbytes)
|
||||
ctx.readMessageStart()
|
||||
obj = self._deserialize(ctx)
|
||||
ctx.readMessageEnd()
|
||||
return obj
|
||||
|
||||
def _buildSerializationContext(self, bytes=None):
|
||||
self.transport = TTransport.TMemoryBuffer(bytes)
|
||||
def _buildSerializationContext(self, sbytes=None):
|
||||
self.transport = TTransport.TMemoryBuffer(sbytes)
|
||||
protocol = SelfDescribingBinaryProtocol.SelfDescribingBinaryProtocol(self.transport)
|
||||
return ThriftSerializationContext.ThriftSerializationContext(self, protocol)
|
||||
|
||||
|
|
|
@ -24,10 +24,12 @@ class SerializationException(Exception):
|
|||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def serialize(obj):
|
||||
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||
return dsm.serializeObject(obj)
|
||||
|
||||
def deserialize(bytes):
|
||||
|
||||
def deserialize(objbytes):
|
||||
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 GetGeometryDataResponse
|
||||
|
||||
|
||||
ClassAdapter = 'com.raytheon.uf.common.dataaccess.response.GetGeometryDataResponse'
|
||||
|
||||
|
||||
|
@ -54,7 +53,7 @@ def serialize(context, resp):
|
|||
def deserialize(context):
|
||||
size = context.readI32()
|
||||
wkbs = []
|
||||
for i in range(size):
|
||||
for __ in range(size):
|
||||
wkb = context.readBinary()
|
||||
wkbs.append(wkb)
|
||||
|
||||
|
@ -78,7 +77,7 @@ def deserialize(context):
|
|||
# parameters
|
||||
paramSize = context.readI32()
|
||||
paramMap = {}
|
||||
for k in range(paramSize):
|
||||
for __ in range(paramSize):
|
||||
paramName = context.readString()
|
||||
value = context.readObject()
|
||||
tName = context.readString()
|
||||
|
|
|
@ -17,8 +17,8 @@ ClassAdapter = [
|
|||
]
|
||||
|
||||
|
||||
def serialize(context, type):
|
||||
context.writeString(type.getText())
|
||||
def serialize(context, ltype):
|
||||
context.writeString(ltype.getText())
|
||||
|
||||
|
||||
def deserialize(context):
|
||||
|
|
|
@ -8,18 +8,17 @@ except ImportError:
|
|||
|
||||
class UserId(object):
|
||||
|
||||
def __init__(self, id = None):
|
||||
if id is None:
|
||||
def __init__(self, userid = None):
|
||||
if userid is None:
|
||||
if not pwd_error:
|
||||
self.id = pwd.getpwuid(os.getuid()).pw_name
|
||||
else:
|
||||
self.id = "GenericUsername"
|
||||
else:
|
||||
self.id = id
|
||||
self.id = userid
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def setId(self, id):
|
||||
self.id = id
|
||||
|
||||
def setId(self, userid):
|
||||
self.id = userid
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#
|
||||
|
||||
from awips.dataaccess import IDataRequest
|
||||
|
||||
from dynamicserialize.dstypes.com.vividsolutions.jts.geom import Envelope
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||
|
||||
|
|
|
@ -72,9 +72,11 @@ class DatabaseID(object):
|
|||
|
||||
def __encodeIdentifier(self):
|
||||
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:
|
||||
self.modelId = self.siteId + "_" + self.format + "__" + self.modelName
|
||||
self.modelId = self.siteId + "_" + self.format + "__" \
|
||||
+ self.modelName
|
||||
|
||||
self.shortModelId = self.modelName
|
||||
if self.dbType is not None and self.dbType != "":
|
||||
|
@ -127,7 +129,7 @@ class DatabaseID(object):
|
|||
dateStruct = time.gmtime(0)
|
||||
try:
|
||||
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
|
||||
except:
|
||||
except ValueError:
|
||||
return (False, dateStruct)
|
||||
return (True, dateStruct)
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects i
|
|||
|
||||
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,
|
||||
timeIndependentParm=False, timeConstraints=None, rateParm=False):
|
||||
self.parmID = id
|
||||
self.parmID = parmid
|
||||
self.gridLoc = gridLoc
|
||||
self.gridType = gridType
|
||||
self.descriptiveName = descriptiveName
|
||||
|
|
|
@ -20,7 +20,10 @@ class TimeConstraints(object):
|
|||
self.valid = True
|
||||
else:
|
||||
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
|
||||
duration = 0
|
||||
repeatInterval = 0
|
||||
|
|
|
@ -150,8 +150,8 @@ class Level(object):
|
|||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def setId(self, id):
|
||||
self.id = id
|
||||
def setId(self, levelid):
|
||||
self.id = levelid
|
||||
|
||||
def getMasterLevel(self):
|
||||
return self.masterLevel
|
||||
|
|
|
@ -85,8 +85,8 @@ class MasterLevel(object):
|
|||
return self.type.decode('utf-8')
|
||||
return self.type
|
||||
|
||||
def setType(self, type):
|
||||
self.type = type
|
||||
def setType(self, leveltype):
|
||||
self.type = leveltype
|
||||
|
||||
def getIdentifier(self):
|
||||
if six.PY2:
|
||||
|
|
|
@ -123,11 +123,11 @@ class RequestConstraint(object):
|
|||
'''
|
||||
try:
|
||||
return float(value)
|
||||
except Exception:
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
return DataTime(value)
|
||||
except Exception:
|
||||
except ValueError:
|
||||
pass
|
||||
return value
|
||||
|
||||
|
|
|
@ -36,6 +36,6 @@ class Request(object):
|
|||
def getType(self):
|
||||
return self.type
|
||||
|
||||
def setType(self, type):
|
||||
self.type = type
|
||||
def setType(self, requesttype):
|
||||
self.type = requesttype
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
import uuid
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.localization.stream import AbstractLocalizationStreamRequest
|
||||
|
||||
|
@ -15,14 +16,14 @@ class LocalizationStreamPutRequest(AbstractLocalizationStreamRequest):
|
|||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def setId(self, id):
|
||||
self.id = id
|
||||
def setId(self, requestid):
|
||||
self.id = requestid
|
||||
|
||||
def getBytes(self):
|
||||
return self.bytes
|
||||
|
||||
def setBytes(self, bytes):
|
||||
self.bytes = bytes
|
||||
def setBytes(self, streambytes):
|
||||
self.bytes = streambytes
|
||||
|
||||
def getEnd(self):
|
||||
return self.end
|
||||
|
|
|
@ -34,8 +34,8 @@ class CompressedDataRecord(object):
|
|||
def getType(self):
|
||||
return self.type
|
||||
|
||||
def setType(self, type):
|
||||
self.type = type
|
||||
def setType(self, recordtype):
|
||||
self.type = recordtype
|
||||
|
||||
def getCompressedData(self):
|
||||
return self.compressedData
|
||||
|
|
|
@ -21,8 +21,8 @@ class SiteActivationNotification(object):
|
|||
def getType(self):
|
||||
return self.type
|
||||
|
||||
def setType(self, type):
|
||||
self.type = type
|
||||
def setType(self, notificationType):
|
||||
self.type = notificationType
|
||||
|
||||
def getStatus(self):
|
||||
return self.status
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# 06/23/2016 #5696 rjpeter Initial creation.
|
||||
#
|
||||
|
||||
from time import gmtime, strftime
|
||||
from dynamicserialize.dstypes.java.sql import Timestamp
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue