Esempio n. 1
0
    def __init__(self, base_url: str):
        logger.debug('Adding s3 to urllib supported protocols for urljoin')
        uses_netloc.append('s3')
        uses_relative.append('s3')

        self.base_url = base_url.rstrip('/') + '/'

        self.mcf = {
            'mcf': {
                'version': '1.0'
            },
            'metadata': {
                'language': LANGUAGE,
                'charset': 'utf8',
                'parentidentifier': 'TBD'
            },
            'spatial': {
                'datatype': 'grid',
                'geomtype': 'solid'
            },
            'identification': {
                'charset': 'utf8',
                'language': 'missing',
                'keywords': {},
                'status': 'onGoing',
                'maintenancefrequency': 'continual'
            },
            'content_info': {
                'type': 'image',
                'dimensions': []
            },
            'contact': {
                'pointOfContact': {},
                'distributor': {}
            },
            'distribution': {}
        }
Esempio n. 2
0
                 warnings=[
                     'ERROR: No anchor #missing for internal URI reference'
                 ])

    assert_links('''
            <body style="width: 100px; transform: translateY(100px)">
            <a href="#lipsum" id="lipsum" style="display: block; height: 20px;
                transform: rotate(90deg) scale(2)">
        ''', [[('internal', 'lipsum', (30, 10, 40, 200))]], [{
        'lipsum': (70, 10)
    }], [[('internal', (0, 70, 10), (30, 10, 40, 200))]],
                 round=True)


# Make relative URL references work with our custom URL scheme.
uses_relative.append('weasyprint-custom')


@assert_no_logs
def test_url_fetcher():
    with open(resource_filename('pattern.png'), 'rb') as pattern_fd:
        pattern_png = pattern_fd.read()

    def fetcher(url):
        if url == 'weasyprint-custom:foo/%C3%A9_%e9_pattern':
            return dict(string=pattern_png, mime_type='image/png')
        elif url == 'weasyprint-custom:foo/bar.css':
            return dict(string='body { background: url(é_%e9_pattern)',
                        mime_type='text/css')
        else:
            return default_url_fetcher(url)
Esempio n. 3
0
            'ERROR: No anchor #missing for internal URI reference'])

    assert_links(
        '''
            <body style="width: 100px; transform: translateY(100px)">
            <a href="#lipsum" id="lipsum" style="display: block; height: 20px;
                transform: rotate(90deg) scale(2)">
        ''',
        [[('internal', 'lipsum', (30, 10, 40, 200))]],
        [{'lipsum': (70, 10)}],
        [([('internal', 'lipsum', (30, 10, 40, 200))], [('lipsum', 70, 10)])],
        round=True)


# Make relative URL references work with our custom URL scheme.
uses_relative.append('weasyprint-custom')


@assert_no_logs
def test_url_fetcher():
    filename = resource_filename('pattern.png')
    with open(filename, 'rb') as pattern_fd:
        pattern_png = pattern_fd.read()

    def fetcher(url):
        if url == 'weasyprint-custom:foo/%C3%A9_%e9_pattern':
            return dict(string=pattern_png, mime_type='image/png')
        elif url == 'weasyprint-custom:foo/bar.css':
            return dict(string='body { background: url(é_%e9_pattern)',
                        mime_type='text/css')
        else:
Esempio n. 4
0
import vim
from urllib.parse import urljoin, uses_relative, uses_netloc
uses_relative.append('gemini')
uses_netloc.append('gemini')


def resolve(path, base=None):
    if base is None:
        base = vim.eval('@%')
        base = vim.current.buffer.vars.get('netfind_basehref', base)
    return urljoin(base, path)
Esempio n. 5
0
from openmtc_onem2m.exc import CSEError
from openmtc_onem2m.model import AnnounceableResource, get_onem2m_type, \
    CSEBase, RemoteCSE

from openmtc_onem2m.transport import OneM2MRequest, MetaInformation, \
    OneM2MOperation
from openmtc_server.Plugin import Plugin
from copy import deepcopy
from openmtc_server.util.async_ import async_all
from re import sub
from urllib.parse import urlparse
# url join with coap compatibility
from urllib.parse import urljoin, uses_relative, uses_netloc

uses_relative.append('coap')
uses_netloc.append('coap')

AnncResult = namedtuple('AnncResult', ['cse_uri', 'res_con'])


class AnnouncementHandler(Plugin):
    # method constants
    _CREATE = 'create'
    _UPDATE = 'update'
    _DELETE = 'delete'

    def __init__(self, api, config, *args, **kw):
        super(AnnouncementHandler, self).__init__(api, config, *args, **kw)
        self._announcements = {}
        self._cse_base = urlparse(self.config['global']['cse_base']).path