# Path: pydov/util/hooks.py
# class Hooks(list):
#     """Runtime representation of registered pydov hooks, i.e. a list of
#     instances of AbstractReadHook and/or AbstractInjectHook."""
# 
#     def get_read_hooks(self):
#         """Get the registered read hooks (i.e. hooks that are subclasses of
#         AbstractReadHook), in the order they are defined in the list.
# 
#         Returns
#         -------
#         tuple of AbstractReadHook
#             A tuple with the registered read hooks.
# 
#         """
#         return (h for h in self if isinstance(h, AbstractReadHook))
# 
#     def get_inject_hooks(self):
#         """Get the registered inject hooks (i.e. hooks that are subclasses of
#         AbstractInjectHook), in the order they are defined in the list.
# 
#         Returns
#         -------
#         tuple of AbstractInjectHook
#             A tuple with the registered inject hooks.
# 
#         """
#         return (h for h in self if isinstance(h, AbstractInjectHook))
# 
# Path: pydov/util/owsutil.py
# def __get_namespaces():
# def __get_remote_fc(fc_url):
# def __get_remote_describefeaturetype(describefeaturetype_url):
# def get_remote_metadata(contentmetadata):
# def get_csw_base_url(contentmetadata):
# def get_featurecatalogue_uuid(md_metadata):
# def get_remote_featurecatalogue(csw_url, fc_uuid):
# def get_namespace(wfs, layer):
# def set_geometry_column(location, geometry_column):
# def wfs_build_getfeature_request(typename, geometry_column=None, location=None,
#                                  filter=None, sort_by=None, propertyname=None,
#                                  max_features=None, version='1.1.0'):
# def wfs_get_feature(baseurl, get_feature_request):
# def get_url(url):
# 
# Path: pydov/util/caching.py
# class GzipTextFileCache(AbstractFileCache):
#     """Class for GZipped text caching of downloaded XML files from DOV."""
# 
#     def _get_filepath(self, datatype, key):
#         return os.path.join(self.cachedir, datatype, key + '.xml.gz')
# 
#     def _get_type_key_from_path(self, path):
#         key = os.path.basename(path).rstrip('.xml.gz')
#         datatype = os.path.dirname(path).split()[-1]
#         return datatype, key
# 
#     def _save(self, datatype, key, content):
#         filepath = self._get_filepath(datatype, key)
#         folder = os.path.dirname(filepath)
# 
#         if not os.path.exists(folder):
#             os.makedirs(folder)
# 
#         with gzip.open(filepath, 'wb') as f:
#             f.write(content)
# 
#     def _load(self, datatype, key):
#         filepath = self._get_filepath(datatype, key)
#         with gzip.open(filepath, 'rb') as f:
#             return f.read().decode('utf-8')
# 
# class PlainTextFileCache(AbstractFileCache):
#     """Class for plain text caching of downloaded XML files from DOV."""
# 
#     def _get_filepath(self, datatype, key):
#         return os.path.join(self.cachedir, datatype, key + '.xml')
# 
#     def _get_type_key_from_path(self, path):
#         key = os.path.basename(path).rstrip('.xml')
#         datatype = os.path.dirname(path).split()[-1]
#         return datatype, key
# 
#     def _save(self, datatype, key, content):
#         filepath = self._get_filepath(datatype, key)
#         folder = os.path.dirname(filepath)
# 
#         if not os.path.exists(folder):
#             os.makedirs(folder)
# 
#         with open(filepath, 'w', encoding='utf-8') as f:
#             f.write(content.decode('utf-8'))
# 
#     def _load(self, datatype, key):
#         filepath = self._get_filepath(datatype, key)
#         with open(filepath, 'r', encoding='utf-8') as f:
#             return f.read()
# 
# Path: pydov/util/dovutil.py
# def build_dov_url(path):
#     """Build the DOV url consisting of the fixed DOV base url, appended with
#     the given path.
# 
#     Returns
#     -------
#     str
#         The absolute DOV url.
# 
#     """
#     if 'PYDOV_BASE_URL' in os.environ:
#         base_url = os.environ['PYDOV_BASE_URL']
#     else:
#         base_url = 'https://www.dov.vlaanderen.be/'
# 
#     return base_url + path.lstrip('/')


import datetime
import glob
import os
import tempfile
import owslib
import pytest
import pydov
from _pytest.monkeypatch import MonkeyPatch
from owslib.etree import etree
from owslib.feature.schema import _construct_schema, _get_elements
from owslib.iso import MD_Metadata
from owslib.util import ResponseWrapper, findall
from owslib.wfs import WebFeatureService
from pydov import Hooks
from pydov.util import owsutil
from pydov.util.caching import GzipTextFileCache, PlainTextFileCache
from pydov.util.dovutil import build_dov_url
        return data

    monkeymodule.setattr(pydov.util.owsutil, '__get_remote_fc',
                         __get_remote_fc)


@pytest.fixture(scope='module')
def mp_remote_describefeaturetype(monkeymodule, request):
    """Monkeypatch the call to a remote DescribeFeatureType.

    This monkeypatch requires a module variable
    ``location_wfs_describefeaturetype`` with the path to the
    wfs_describefeaturetype file on disk.

    Parameters
    ----------
    monkeymodule : pytest.fixture
        PyTest monkeypatch fixture with module scope.
    request : pytest.fixtue
        PyTest fixture providing request context.

    """
    def __get_remote_describefeaturetype(*args, **kwargs):
        file_path = getattr(request.module, "location_wfs_describefeaturetype")
        with open(file_path, 'r') as f:
            data = f.read()
            if not isinstance(data, bytes):
                data = data.encode('utf-8')
        return data


# Path: pydov/util/hooks.py
# class Hooks(list):
#     """Runtime representation of registered pydov hooks, i.e. a list of
#     instances of AbstractReadHook and/or AbstractInjectHook."""
# 
#     def get_read_hooks(self):
#         """Get the registered read hooks (i.e. hooks that are subclasses of
#         AbstractReadHook), in the order they are defined in the list.
# 
#         Returns
#         -------
#         tuple of AbstractReadHook
#             A tuple with the registered read hooks.
# 
#         """
#         return (h for h in self if isinstance(h, AbstractReadHook))
# 
#     def get_inject_hooks(self):
#         """Get the registered inject hooks (i.e. hooks that are subclasses of
#         AbstractInjectHook), in the order they are defined in the list.
# 
#         Returns
#         -------
#         tuple of AbstractInjectHook
#             A tuple with the registered inject hooks.
# 
#         """
#         return (h for h in self if isinstance(h, AbstractInjectHook))
# 
# Path: pydov/util/owsutil.py
# def __get_namespaces():
# def __get_remote_fc(fc_url):
# def __get_remote_describefeaturetype(describefeaturetype_url):
# def get_remote_metadata(contentmetadata):
# def get_csw_base_url(contentmetadata):
# def get_featurecatalogue_uuid(md_metadata):
# def get_remote_featurecatalogue(csw_url, fc_uuid):
# def get_namespace(wfs, layer):
# def set_geometry_column(location, geometry_column):
# def wfs_build_getfeature_request(typename, geometry_column=None, location=None,
#                                  filter=None, sort_by=None, propertyname=None,
#                                  max_features=None, version='1.1.0'):
# def wfs_get_feature(baseurl, get_feature_request):
# def get_url(url):
# 
# Path: pydov/util/caching.py
# class GzipTextFileCache(AbstractFileCache):
#     """Class for GZipped text caching of downloaded XML files from DOV."""
# 
#     def _get_filepath(self, datatype, key):
#         return os.path.join(self.cachedir, datatype, key + '.xml.gz')
# 
#     def _get_type_key_from_path(self, path):
#         key = os.path.basename(path).rstrip('.xml.gz')
#         datatype = os.path.dirname(path).split()[-1]
#         return datatype, key
# 
#     def _save(self, datatype, key, content):
#         filepath = self._get_filepath(datatype, key)
#         folder = os.path.dirname(filepath)
# 
#         if not os.path.exists(folder):
#             os.makedirs(folder)
# 
#         with gzip.open(filepath, 'wb') as f:
#             f.write(content)
# 
#     def _load(self, datatype, key):
#         filepath = self._get_filepath(datatype, key)
#         with gzip.open(filepath, 'rb') as f:
#             return f.read().decode('utf-8')
# 
# class PlainTextFileCache(AbstractFileCache):
#     """Class for plain text caching of downloaded XML files from DOV."""
# 
#     def _get_filepath(self, datatype, key):
#         return os.path.join(self.cachedir, datatype, key + '.xml')
# 
#     def _get_type_key_from_path(self, path):
#         key = os.path.basename(path).rstrip('.xml')
#         datatype = os.path.dirname(path).split()[-1]
#         return datatype, key
# 
#     def _save(self, datatype, key, content):
#         filepath = self._get_filepath(datatype, key)
#         folder = os.path.dirname(filepath)
# 
#         if not os.path.exists(folder):
#             os.makedirs(folder)
# 
#         with open(filepath, 'w', encoding='utf-8') as f:
#             f.write(content.decode('utf-8'))
# 
#     def _load(self, datatype, key):
#         filepath = self._get_filepath(datatype, key)
#         with open(filepath, 'r', encoding='utf-8') as f:
#             return f.read()
# 
# Path: pydov/util/dovutil.py
# def build_dov_url(path):
#     """Build the DOV url consisting of the fixed DOV base url, appended with
#     the given path.
# 
#     Returns
#     -------
#     str
#         The absolute DOV url.
# 
#     """
#     if 'PYDOV_BASE_URL' in os.environ:
#         base_url = os.environ['PYDOV_BASE_URL']
#     else:
#         base_url = 'https://www.dov.vlaanderen.be/'
# 
#     return base_url + path.lstrip('/')


# Path: tests/conftest.py
import datetime
import glob
import os
import tempfile
import owslib
import pytest
import pydov
from _pytest.monkeypatch import MonkeyPatch
from owslib.etree import etree
from owslib.feature.schema import _construct_schema, _get_elements
from owslib.iso import MD_Metadata
from owslib.util import ResponseWrapper, findall
from owslib.wfs import WebFeatureService
from pydov import Hooks
from pydov.util import owsutil
from pydov.util.caching import GzipTextFileCache, PlainTextFileCache
from pydov.util.dovutil import build_dov_url

        return data

    monkeymodule.setattr(pydov.util.owsutil, '__get_remote_fc',
                         __get_remote_fc)


@pytest.fixture(scope='module')
def mp_remote_describefeaturetype(monkeymodule, request):
    """Monkeypatch the call to a remote DescribeFeatureType.

    This monkeypatch requires a module variable
    ``location_wfs_describefeaturetype`` with the path to the
    wfs_describefeaturetype file on disk.

    Parameters
    ----------
    monkeymodule : pytest.fixture
        PyTest monkeypatch fixture with module scope.
    request : pytest.fixtue
        PyTest fixture providing request context.

    """
    def __get_remote_describefeaturetype(*args, **kwargs):
        file_path = getattr(request.module, "location_wfs_describefeaturetype")
        with open(file_path, 'r') as f:
            data = f.read()
            if not isinstance(data, bytes):
                data = data.encode('utf-8')
        return data


    monkeymodule.setattr(pydov.util.owsutil,