Skip to content

Commit

Permalink
Renaming 'objects.py' files to more aptly named 'types.py'. Always im…
Browse files Browse the repository at this point in the history
…porting all types in the adjacent '__init__.py's
  • Loading branch information
constantinius committed Nov 29, 2019
1 parent 327364e commit a6a2459
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 38 deletions.
2 changes: 1 addition & 1 deletion ows/cis/v11.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ows.xml import ElementMaker, NameSpace, NameSpaceMap
from ows.util import isoformat
from ows.swe.v20 import Field, encode_data_record
from ows.gml.objects import (
from ows.gml.types import (
PositionType, AxisType,
Grid, IndexAxis, RegularAxis, IrregularAxis
)
Expand Down
1 change: 1 addition & 0 deletions ows/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .types import *
File renamed without changes.
8 changes: 5 additions & 3 deletions ows/common/v20/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@

from .namespaces import nsmap

from .. import objects
from ..types import GetCapabilitiesRequest


# ------------------------------------------------------------------------------
# GetCapabilities
# ------------------------------------------------------------------------------

class KVPGetCapabilitiesDecoder(kvp.Decoder):
object_class = objects.GetCapabilitiesRequest
object_class = GetCapabilitiesRequest

service = kvp.Parameter('service')
update_sequence = kvp.Parameter('updatesequence', num="?")
sections = kvp.Parameter(type=typelist(lower, ","), num="?", default_factory=list)
Expand All @@ -48,7 +49,8 @@ class KVPGetCapabilitiesDecoder(kvp.Decoder):


class XMLGetCapabilitiesDecoder(xml.Decoder):
object_class = objects.GetCapabilitiesRequest
object_class = GetCapabilitiesRequest

service = xml.Parameter("@service")
sections = xml.Parameter("ows:Sections/ows:Section/text()", num="*", default_factory=list)
update_sequence = xml.Parameter("@updateSequence", num="?")
Expand Down
2 changes: 1 addition & 1 deletion ows/common/v20/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from typing import List

from .namespaces import OWS, ns_xlink
from ..objects import (
from ..types import (
ServiceCapabilities, Operation, Constraint,
WGS84BoundingBox, BoundingBox, Metadata
)
Expand Down
2 changes: 1 addition & 1 deletion ows/gml/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .objects import *
from .types import *
File renamed without changes.
2 changes: 1 addition & 1 deletion ows/gml/v32.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ows.xml import ElementMaker, NameSpace, NameSpaceMap
from ows.util import isoformat
from ows.swe.v20 import Field, encode_data_record
from .objects import Grid, RegularAxis, IrregularAxis, IndexAxis
from .types import Grid, RegularAxis, IrregularAxis, IndexAxis


# namespace declarations
Expand Down
1 change: 1 addition & 0 deletions ows/swe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .types import *
File renamed without changes.
2 changes: 1 addition & 1 deletion ows/swe/v20.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# -------------------------------------------------------------------------------

from ows.xml import ElementMaker, NameSpace, NameSpaceMap, Element
from .objects import Field, DataRecord
from .types import Field, DataRecord

ns_swe = NameSpace("http://www.opengis.net/swe/2.0", "swe")

Expand Down
1 change: 1 addition & 0 deletions ows/wcs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .types import *
6 changes: 3 additions & 3 deletions ows/wcs/objects.py → ows/wcs/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from typing import List, Tuple
from dataclasses import dataclass, field

from ows.common import objects as common
from ows.gml.objects import Grid
from ows.swe.objects import Field
from ows.common import types as common
from ows.gml.types import Grid
from ows.swe.types import Field


@dataclass
Expand Down
1 change: 1 addition & 0 deletions ows/wcs/v20/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .types import *
34 changes: 17 additions & 17 deletions ows/wcs/v20/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
InvalidSubsettingException, InvalidScaleFactorException,
InvalidScaleExtentException,
)
from . import objects
from . import types


# ------------------------------------------------------------------------------
Expand All @@ -46,12 +46,12 @@


class KVPDescribeCoverageDecoder(kvp.Decoder):
object_class = objects.DescribeCoverageRequest
object_class = types.DescribeCoverageRequest
coverage_ids = kvp.Parameter("coverageid", type=typelist(str, ","), num=1)


class XMLDescribeCoverageDecoder(xml.Decoder):
object_class = objects.DescribeCoverageRequest
object_class = types.DescribeCoverageRequest
coverage_ids = xml.Parameter("wcs:CoverageId/text()", num="+")
namespaces = nsmap

Expand All @@ -71,7 +71,7 @@ def xml_decode_describe_coverage(xml):


class GetCoverageBaseDecoder:
object_class = objects.GetCoverageRequest
object_class = types.GetCoverageRequest

def create_object(self, params):
params['scales'] = (
Expand All @@ -83,7 +83,7 @@ def create_object(self, params):
params['output_crs'] = params.pop('outputcrs')
params['range_subset'] = params.pop('rangesubset')

return objects.GetCoverageRequest(**params)
return types.GetCoverageRequest(**params)


# ------------------------------------------------------------------------------
Expand All @@ -107,11 +107,11 @@ def parse_subset_kvp(string):
axis = match.group(1)
try:
if match.group(4) is not None:
return objects.Trim(
return types.Trim(
axis, float(match.group(2)), float(match.group(4))
)
else:
return objects.Slice(axis, float(match.group(2)))
return types.Slice(axis, float(match.group(2)))
except ValueError:
raise InvalidSubsettingException(
"Could not parse input subset string."
Expand All @@ -123,7 +123,7 @@ def parse_range_subset_kvp(string):
for item in string.split(","):
if ":" in item:
start, end = item.split(":")
rangesubset.append(objects.RangeInterval(start, end))
rangesubset.append(types.RangeInterval(start, end))
else:
rangesubset.append(item)

Expand All @@ -141,7 +141,7 @@ def parse_scaleaxis_kvp(string):
except ValueError:
raise InvalidScaleFactorException(match.group(2))

return objects.ScaleAxis(axis, value)
return types.ScaleAxis(axis, value)


def parse_scalesize_kvp(string):
Expand All @@ -155,7 +155,7 @@ def parse_scalesize_kvp(string):
except ValueError:
raise InvalidScaleFactorException(match.group(2))

return objects.ScaleSize(axis, value)
return types.ScaleSize(axis, value)


def parse_scaleextent_kvp(string):
Expand All @@ -173,7 +173,7 @@ def parse_scaleextent_kvp(string):
if low >= high:
raise InvalidScaleExtentException(low, high)

return objects.ScaleExtent(axis, low, high)
return types.ScaleExtent(axis, low, high)


class KVPGetCoverageDecoder(GetCoverageBaseDecoder, kvp.Decoder):
Expand Down Expand Up @@ -203,13 +203,13 @@ def parse_subset_xml(elem):
try:
dimension = elem.findtext(ns_wcs("Dimension"))
if elem.tag == ns_wcs("DimensionTrim"):
return objects.Trim(
return types.Trim(
dimension,
float(elem.findtext(ns_wcs("TrimLow"))),
float(elem.findtext(ns_wcs("TrimHigh")))
)
elif elem.tag == ns_wcs("DimensionSlice"):
return objects.Slice(
return types.Slice(
dimension,
float(elem.findtext(ns_wcs("SlicePoint")))
)
Expand All @@ -224,7 +224,7 @@ def parse_range_subset_xml(elem):
if item.tag == ns_rsub("RangeComponent"):
rangesubset.append(item.text)
elif item.tag == ns_rsub("RangeInterval"):
rangesubset.append(objects.RangeInterval(
rangesubset.append(types.RangeInterval(
item.findtext(ns_rsub("startComponent")),
item.findtext(ns_rsub("endComponent"))
))
Expand All @@ -243,7 +243,7 @@ def parse_scaleaxis_xml(elem):
except ValueError:
InvalidScaleFactorException(raw)

return ScaleAxis(axis, value)
return types.ScaleAxis(axis, value)


def parse_scalesize_xml(elem):
Expand All @@ -254,7 +254,7 @@ def parse_scalesize_xml(elem):
except ValueError:
InvalidScaleFactorException(raw)

return objects.ScaleSize(axis, value)
return types.ScaleSize(axis, value)


def parse_scaleextent_xml(elem):
Expand All @@ -270,7 +270,7 @@ def parse_scaleextent_xml(elem):
if low >= high:
raise InvalidScaleExtentException(low, high)

return objects.ScaleExtent(axis, low, high)
return types.ScaleExtent(axis, low, high)


class XMLGetCoverageDecoder(GetCoverageBaseDecoder, xml.Decoder):
Expand Down
4 changes: 2 additions & 2 deletions ows/wcs/v20/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
from typing import List

from ows.util import Result
from .objects import (
from .types import (
DescribeCoverageRequest, GetCoverageRequest,
Trim, Slice, ScaleSize, ScaleAxis, ScaleExtent
)
from .namespaces import WCS, SCAL, CRS, INT, EOWCS
from ..objects import (
from ..types import (
ServiceCapabilities, CoverageSummary, DatasetSeriesSummary,
CoverageDescription
)
Expand Down
2 changes: 1 addition & 1 deletion ows/wcs/v20/test_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from lxml import etree

from .objects import DescribeCoverageRequest, GetCoverageRequest
from .types import DescribeCoverageRequest, GetCoverageRequest
from .decoders import (
kvp_decode_describe_coverage, xml_decode_describe_coverage,
kvp_decode_get_coverage, xml_decode_get_coverage
Expand Down
10 changes: 5 additions & 5 deletions ows/wcs/v20/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

from lxml import etree

from ows.common.objects import WGS84BoundingBox, BoundingBox, Metadata
from ows.gml.objects import Grid, RegularAxis
from ows.swe.objects import Field
from .objects import (
from ows.common.types import WGS84BoundingBox, BoundingBox, Metadata
from ows.gml.types import Grid, RegularAxis
from ows.swe.types import Field
from .types import (
DescribeCoverageRequest, GetCoverageRequest, Trim, Slice,
ScaleAxis, ScaleExtent, ScaleSize, AxisInterpolation,
)
from ..objects import (
from ..types import (
ServiceCapabilities, CoverageSummary, DatasetSeriesSummary,
CoverageDescription
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ows/wcs/v21/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
encode_envelope, encode_domain_set, encode_range_type
)
from .namespaces import WCS, ns_gml
from ..objects import CoverageDescription
from ..types import CoverageDescription


def xml_encode_coverage_descriptions(coverage_descriptions: List[CoverageDescription], **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion ows/wcs/v21/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from .encoders import xml_encode_coverage_descriptions
from ows.cis.v11 import Grid, Field, RegularAxis, IrregularAxis
from ..objects import CoverageDescription
from ..types import CoverageDescription


print(xml_encode_coverage_descriptions([
Expand Down

0 comments on commit a6a2459

Please sign in to comment.