GRAYBYTE WORDPRESS FILE MANAGER3475

Server IP : 149.255.58.128 / Your IP : 216.73.216.69
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /lib/python3.9/site-packages/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /lib/python3.9/site-packages//magic.py
# coding: utf-8

'''
Python bindings for libmagic
'''

import ctypes
import threading

from collections import namedtuple

from ctypes import *
from ctypes.util import find_library


def _init():
    """
    Loads the shared library through ctypes and returns a library
    L{ctypes.CDLL} instance
    """
    return ctypes.cdll.LoadLibrary(find_library('magic'))

_libraries = {}
_libraries['magic'] = _init()

# Flag constants for open and setflags
MAGIC_NONE = NONE = 0
MAGIC_DEBUG = DEBUG = 1
MAGIC_SYMLINK = SYMLINK = 2
MAGIC_COMPRESS = COMPRESS = 4
MAGIC_DEVICES = DEVICES = 8
MAGIC_MIME_TYPE = MIME_TYPE = 16
MAGIC_CONTINUE = CONTINUE = 32
MAGIC_CHECK = CHECK = 64
MAGIC_PRESERVE_ATIME = PRESERVE_ATIME = 128
MAGIC_RAW = RAW = 256
MAGIC_ERROR = ERROR = 512
MAGIC_MIME_ENCODING = MIME_ENCODING = 1024
MAGIC_MIME = MIME = 1040  # MIME_TYPE + MIME_ENCODING
MAGIC_APPLE = APPLE = 2048

MAGIC_NO_CHECK_COMPRESS = NO_CHECK_COMPRESS = 4096
MAGIC_NO_CHECK_TAR = NO_CHECK_TAR = 8192
MAGIC_NO_CHECK_SOFT = NO_CHECK_SOFT = 16384
MAGIC_NO_CHECK_APPTYPE = NO_CHECK_APPTYPE = 32768
MAGIC_NO_CHECK_ELF = NO_CHECK_ELF = 65536
MAGIC_NO_CHECK_TEXT = NO_CHECK_TEXT = 131072
MAGIC_NO_CHECK_CDF = NO_CHECK_CDF = 262144
MAGIC_NO_CHECK_TOKENS = NO_CHECK_TOKENS = 1048576
MAGIC_NO_CHECK_ENCODING = NO_CHECK_ENCODING = 2097152

MAGIC_NO_CHECK_BUILTIN = NO_CHECK_BUILTIN = 4173824

FileMagic = namedtuple('FileMagic', ('mime_type', 'encoding', 'name'))


class magic_set(Structure):
    pass
magic_set._fields_ = []
magic_t = POINTER(magic_set)

_open = _libraries['magic'].magic_open
_open.restype = magic_t
_open.argtypes = [c_int]

_close = _libraries['magic'].magic_close
_close.restype = None
_close.argtypes = [magic_t]

_file = _libraries['magic'].magic_file
_file.restype = c_char_p
_file.argtypes = [magic_t, c_char_p]

_descriptor = _libraries['magic'].magic_descriptor
_descriptor.restype = c_char_p
_descriptor.argtypes = [magic_t, c_int]

_buffer = _libraries['magic'].magic_buffer
_buffer.restype = c_char_p
_buffer.argtypes = [magic_t, c_void_p, c_size_t]

_error = _libraries['magic'].magic_error
_error.restype = c_char_p
_error.argtypes = [magic_t]

_setflags = _libraries['magic'].magic_setflags
_setflags.restype = c_int
_setflags.argtypes = [magic_t, c_int]

_load = _libraries['magic'].magic_load
_load.restype = c_int
_load.argtypes = [magic_t, c_char_p]

_compile = _libraries['magic'].magic_compile
_compile.restype = c_int
_compile.argtypes = [magic_t, c_char_p]

_check = _libraries['magic'].magic_check
_check.restype = c_int
_check.argtypes = [magic_t, c_char_p]

_list = _libraries['magic'].magic_list
_list.restype = c_int
_list.argtypes = [magic_t, c_char_p]

_errno = _libraries['magic'].magic_errno
_errno.restype = c_int
_errno.argtypes = [magic_t]


class Magic(object):
    def __init__(self, ms):
        self._magic_t = ms

    def close(self):
        """
        Closes the magic database and deallocates any resources used.
        """
        _close(self._magic_t)

    @staticmethod
    def __tostr(s):
        if s is None:
            return None
        if isinstance(s, str):
            return s
        try:  # keep Python 2 compatibility
            return str(s, 'utf-8')
        except TypeError:
            return str(s)

    @staticmethod
    def __tobytes(b):
        if b is None:
            return None
        if isinstance(b, bytes):
            return b
        try:  # keep Python 2 compatibility
            return bytes(b, 'utf-8')
        except TypeError:
            return bytes(b)

    def file(self, filename):
        """
        Returns a textual description of the contents of the argument passed
        as a filename or None if an error occurred and the MAGIC_ERROR flag
        is set. A call to errno() will return the numeric error code.
        """
        return Magic.__tostr(_file(self._magic_t, Magic.__tobytes(filename)))

    def descriptor(self, fd):
        """
        Returns a textual description of the contents of the argument passed
        as a file descriptor or None if an error occurred and the MAGIC_ERROR
        flag is set. A call to errno() will return the numeric error code.
        """
        return Magic.__tostr(_descriptor(self._magic_t, fd))

    def buffer(self, buf):
        """
        Returns a textual description of the contents of the argument passed
        as a buffer or None if an error occurred and the MAGIC_ERROR flag
        is set. A call to errno() will return the numeric error code.
        """
        return Magic.__tostr(_buffer(self._magic_t, buf, len(buf)))

    def error(self):
        """
        Returns a textual explanation of the last error or None
        if there was no error.
        """
        return Magic.__tostr(_error(self._magic_t))

    def setflags(self, flags):
        """
        Set flags on the magic object which determine how magic checking
        behaves; a bitwise OR of the flags described in libmagic(3), but
        without the MAGIC_ prefix.

        Returns -1 on systems that don't support utime(2) or utimes(2)
        when PRESERVE_ATIME is set.
        """
        return _setflags(self._magic_t, flags)

    def load(self, filename=None):
        """
        Must be called to load entries in the colon separated list of database
        files passed as argument or the default database file if no argument
        before any magic queries can be performed.

        Returns 0 on success and -1 on failure.
        """
        return _load(self._magic_t, Magic.__tobytes(filename))

    def compile(self, dbs):
        """
        Compile entries in the colon separated list of database files
        passed as argument or the default database file if no argument.
        The compiled files created are named from the basename(1) of each file
        argument with ".mgc" appended to it.

        Returns 0 on success and -1 on failure.
        """
        return _compile(self._magic_t, Magic.__tobytes(dbs))

    def check(self, dbs):
        """
        Check the validity of entries in the colon separated list of
        database files passed as argument or the default database file
        if no argument.

        Returns 0 on success and -1 on failure.
        """
        return _check(self._magic_t, Magic.__tobytes(dbs))

    def list(self, dbs):
        """
        Check the validity of entries in the colon separated list of
        database files passed as argument or the default database file
        if no argument.

        Returns 0 on success and -1 on failure.
        """
        return _list(self._magic_t, Magic.__tobytes(dbs))

    def errno(self):
        """
        Returns a numeric error code. If return value is 0, an internal
        magic error occurred. If return value is non-zero, the value is
        an OS error code. Use the errno module or os.strerror() can be used
        to provide detailed error information.
        """
        return _errno(self._magic_t)


def open(flags):
    """
    Returns a magic object on success and None on failure.
    Flags argument as for setflags.
    """
    return Magic(_open(flags))


# Objects used by `detect_from_` functions
class MagicDetect(object):
    def __init__(self):
        self.mime_magic = Magic(_open(MAGIC_MIME))
        self.mime_magic.load()
        self.none_magic = Magic(_open(MAGIC_NONE))
        self.none_magic.load()

    def __del__(self):
        self.mime_magic.close()
        self.none_magic.close()

threadlocal = threading.local()

def _detect_make():
    v = getattr(threadlocal, "magic_instance", None)
    if v is None:
        v = MagicDetect()
        setattr(threadlocal, "magic_instance", v)
    return v

def _create_filemagic(mime_detected, type_detected):
    try:
        mime_type, mime_encoding = mime_detected.split('; ')
    except ValueError:
        raise ValueError(mime_detected)

    return FileMagic(name=type_detected, mime_type=mime_type,
                     encoding=mime_encoding.replace('charset=', ''))


def detect_from_filename(filename):
    '''Detect mime type, encoding and file type from a filename

    Returns a `FileMagic` namedtuple.
    '''
    x = _detect_make()
    return _create_filemagic(x.mime_magic.file(filename),
                             x.none_magic.file(filename))


def detect_from_fobj(fobj):
    '''Detect mime type, encoding and file type from file-like object

    Returns a `FileMagic` namedtuple.
    '''

    file_descriptor = fobj.fileno()
    x = _detect_make()
    return _create_filemagic(x.mime_magic.descriptor(file_descriptor),
                             x.none_magic.descriptor(file_descriptor))


def detect_from_content(byte_content):
    '''Detect mime type, encoding and file type from bytes

    Returns a `FileMagic` namedtuple.
    '''

    x = _detect_make()
    return _create_filemagic(x.mime_magic.buffer(byte_content),
                             x.none_magic.buffer(byte_content))

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
December 12 2024 10:11:36
0 / root
0755
OpenSSL
--
October 13 2023 17:01:36
0 / root
0755
PySocks-1.7.1-py3.9.egg-info
--
October 13 2023 17:01:36
0 / root
0755
__pycache__
--
December 12 2024 10:11:36
0 / root
0755
_distutils_hack
--
December 04 2024 22:44:03
0 / root
0755
chardet
--
October 13 2023 17:01:35
0 / root
0755
chardet-4.0.0.dist-info
--
October 13 2023 17:01:35
0 / root
0755
dateutil
--
February 04 2024 10:27:16
0 / root
0755
distro-1.5.0-py3.9.egg-info
--
October 13 2023 17:01:34
0 / root
0755
dnf
--
December 04 2024 22:44:23
0 / root
0755
dnf-plugins
--
May 14 2025 21:42:23
0 / root
0755
dnfpluginscore
--
December 04 2024 22:44:23
0 / root
0755
dns
--
March 19 2025 22:42:16
0 / root
0755
dnspython-2.6.1-py3.9.egg-info
--
March 19 2025 22:42:16
0 / root
0755
file_magic-0.4.0-py3.9.egg-info
--
May 30 2024 07:43:18
0 / root
0755
firewall
--
February 07 2025 22:43:15
0 / root
0755
gi
--
October 13 2023 17:01:33
0 / root
0755
google
--
February 06 2024 08:17:43
0 / root
0755
html2text
--
March 19 2025 22:42:16
0 / root
0755
html2text-2020.1.16-py3.9.egg-info
--
March 19 2025 22:42:16
0 / root
0755
html5lib
--
February 07 2024 08:30:34
0 / root
0755
html5lib-1.1.dist-info
--
February 07 2024 08:30:34
0 / root
0755
idna
--
June 14 2024 21:42:16
0 / root
0755
idna-2.10-py3.9.egg-info
--
June 14 2024 21:42:16
0 / root
0755
iotop
--
February 05 2024 19:28:44
0 / root
0755
isc
--
February 22 2025 22:42:16
0 / root
0755
nftables
--
December 04 2024 22:44:04
0 / root
0755
nftables-0.1.dist-info
--
December 04 2024 22:44:04
0 / root
0755
pexpect
--
October 13 2023 17:01:36
0 / root
0755
pip
--
February 24 2025 22:47:34
0 / root
0755
pip-21.3.1.dist-info
--
February 24 2025 22:47:34
0 / root
0755
pkg_resources
--
December 04 2024 22:44:03
0 / root
0755
ply
--
October 13 2023 17:01:35
0 / root
0755
ply-3.11-py3.9.egg-info
--
October 13 2023 17:01:35
0 / root
0755
procfs
--
May 30 2024 07:43:18
0 / root
0755
protobuf-3.14.0-py3.9.egg-info
--
February 06 2024 08:17:43
0 / root
0755
ptyprocess
--
October 13 2023 17:01:36
0 / root
0755
pyOpenSSL-21.0.0-py3.9.egg-info
--
October 13 2023 17:01:36
0 / root
0755
pycparser
--
October 13 2023 17:01:35
0 / root
0755
pycparser-2.20-py3.9.egg-info
--
October 13 2023 17:01:35
0 / root
0755
pycriu
--
February 06 2024 08:17:50
0 / root
0755
pygtkcompat
--
October 13 2023 17:01:33
0 / root
0755
pyparsing-2.4.7.dist-info
--
February 05 2024 19:59:43
0 / root
0755
python_dateutil-2.8.1-py3.9.egg-info
--
February 04 2024 10:27:16
0 / root
0755
python_linux_procfs-0.7.3-py3.9.egg-info
--
May 30 2024 07:43:18
0 / root
0755
pyudev
--
October 13 2023 17:01:35
0 / root
0755
pyudev-0.22.0-py3.9.egg-info
--
October 13 2023 17:01:35
0 / root
0755
requests
--
May 30 2024 07:43:18
0 / root
0755
requests-2.25.1.dist-info
--
May 30 2024 07:43:18
0 / root
0755
rhn
--
February 26 2025 11:56:05
0 / root
0755
sepolgen
--
May 30 2024 07:43:41
0 / root
0755
sepolicy
--
May 30 2024 07:43:41
0 / root
0755
sepolicy-3.6-py3.9.egg-info
--
May 30 2024 07:43:41
0 / root
0755
setuptools
--
December 04 2024 22:44:03
0 / root
0755
setuptools-53.0.0.dist-info
--
December 04 2024 22:44:03
0 / root
0755
six-1.15.0.dist-info
--
October 13 2023 17:01:33
0 / root
0755
sos
--
December 05 2024 22:42:22
0 / root
0755
sos-4.7.2-py3.9.egg-info
--
December 05 2024 22:42:22
0 / root
0755
tuned
--
December 04 2024 22:44:57
0 / root
0755
up2date_client
--
March 18 2025 22:42:18
0 / root
0755
urllib3
--
December 04 2024 22:45:20
0 / root
0755
urllib3-1.26.5-py3.9.egg-info
--
December 04 2024 22:45:20
0 / root
0755
webencodings
--
February 07 2024 08:30:34
0 / root
0755
webencodings-0.5.1-py3.9.egg-info
--
February 07 2024 08:30:34
0 / root
0755
crit-0.0.1-py3.9.egg-info
0.226 KB
December 07 2022 08:02:09
0 / root
0644
distro.py
42.605 KB
March 30 2020 20:35:18
0 / root
0644
distutils-precedence.pth
0.148 KB
October 02 2024 19:20:21
0 / root
0644
hwdata.py
7.951 KB
March 23 2018 13:41:48
0 / root
0644
iotop-0.6-py3.9.egg-info
0.34 KB
October 15 2022 09:47:02
0 / root
0644
isc-2.0-py3.9.egg-info
0.261 KB
February 19 2025 16:01:38
0 / root
0644
magic.py
8.731 KB
April 03 2024 11:40:16
0 / root
0644
pciutils-2.3.7-py3.9.egg-info
0.236 KB
December 08 2022 12:41:41
0 / root
0644
pexpect-4.8.0-py3.9.egg-info
2.231 KB
February 14 2022 15:32:11
0 / root
0644
protobuf-3.14.0-py3.9-nspkg.pth
0.526 KB
October 15 2022 12:17:44
0 / root
0644
ptyprocess-0.6.0-py3.9.egg-info
0.258 KB
February 10 2022 23:49:36
0 / root
0644
pyparsing.py
266.958 KB
March 25 2022 18:16:50
0 / root
0644
rhnlib-2.8.6-py3.9.egg-info
0.335 KB
December 07 2022 13:15:24
0 / root
0644
seobject.py
108.671 KB
April 03 2024 15:47:25
0 / root
0644
six.py
33.483 KB
March 24 2022 22:11:54
0 / root
0644
socks.py
30.357 KB
September 20 2019 01:58:31
0 / root
0644
sockshandler.py
3.873 KB
September 20 2019 01:58:31
0 / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF