How to use smmap - 10 common examples

To help you get started, we’ve selected a few smmap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gitpython-developers / smmap / smmap / mman.py View on Github external
self._max_memory_size = max_memory_size
        self._max_handle_count = max_open_handles
        self._memory_size = 0
        self._handle_count = 0

        if window_size < 0:
            coeff = 64
            if is_64_bit():
                coeff = 1024
            # END handle arch
            self._window_size = coeff * self._MB_in_bytes
        # END handle max window size

        if max_memory_size == 0:
            coeff = 1024
            if is_64_bit():
                coeff = 8192
            # END handle arch
            self._max_memory_size = coeff * self._MB_in_bytes
        # END handle max memory size
github h3llrais3r / Auto-Subliminal / lib / gitdb / util.py View on Github external
def sliding_ro_buffer(filepath, flags=0):
    """
    :return: a buffer compatible object which uses our mapped memory manager internally
        ready to read the whole given filepath"""
    return SlidingWindowMapBuffer(mman.make_cursor(filepath), flags=flags)
github gitpython-developers / gitdb / gitdb / util.py View on Github external
def sliding_ro_buffer(filepath, flags=0):
    """
    :return: a buffer compatible object which uses our mapped memory manager internally
        ready to read the whole given filepath"""
    return SlidingWindowMapBuffer(mman.make_cursor(filepath), flags=flags)
github h3llrais3r / Auto-Subliminal / lib / gitdb / util.py View on Github external
import errno

from io import BytesIO

from smmap import (
    StaticWindowMapManager,
    SlidingWindowMapManager,
    SlidingWindowMapBuffer
)

# initialize our global memory manager instance
# Use it to free cached (and unused) resources.
if sys.version_info < (2, 6):
    mman = StaticWindowMapManager()
else:
    mman = SlidingWindowMapManager()
# END handle mman

import hashlib

try:
    from struct import unpack_from
except ImportError:
    from struct import unpack, calcsize
    __calcsize_cache = dict()

    def unpack_from(fmt, data, offset=0):
        try:
            size = __calcsize_cache[fmt]
        except KeyError:
            size = calcsize(fmt)
            __calcsize_cache[fmt] = size
github gitpython-developers / gitdb / gitdb / util.py View on Github external
import mmap
import sys
import time
import errno

from io import BytesIO

from smmap import (
    StaticWindowMapManager,
    SlidingWindowMapManager,
    SlidingWindowMapBuffer
)

# initialize our global memory manager instance
# Use it to free cached (and unused) resources.
mman = SlidingWindowMapManager()
# END handle mman

import hashlib

try:
    from struct import unpack_from
except ImportError:
    from struct import unpack, calcsize
    __calcsize_cache = dict()

    def unpack_from(fmt, data, offset=0):
        try:
            size = __calcsize_cache[fmt]
        except KeyError:
            size = calcsize(fmt)
            __calcsize_cache[fmt] = size
github robmadole / jig / src / jig / gitutils / hooking.py View on Github external
import smmap

from jig.exc import (
    NotGitRepo, PreCommitExists, JigUserDirectoryError,
    GitTemplatesMissing, GitHomeTemplatesExists, GitConfigError,
    InitTemplateDirAlreadySet)
from jig.conf import JIG_DIR_NAME
from jig.gitutils.scripts import RUN_JIG_SCRIPT, AUTO_JIG_INIT_SCRIPT
from jig.gitutils.checks import is_git_repo

# Dependencies to make jig run
JIG_DIR = realpath(join(dirname(__file__), '..'))
GIT_PYTHON_DIR = realpath(join(dirname(git.__file__), '..'))
GITDB_DIR = realpath(join(dirname(gitdb.__file__), '..'))
ASYNC_DIR = realpath(join(dirname(async.__file__), '..'))
SMMAP_DIR = realpath(join(dirname(smmap.__file__), '..'))


def _git_templates():
    """
    Search and return the location of the shared Git templates directory.

    :rtype: string or None
    """
    search_locations = [
        '/usr/share/git-core/templates',
        '/usr/local/share/git-core/templates',
        '/usr/local/git/share/git-core/templates'
    ]

    for possible_location in search_locations:
        if isdir(possible_location):
github robmadole / jig / src / jig / gitutils.py View on Github external
import git
from git.exc import GitCommandError
import gitdb
import async
import smmap

from jig.exc import NotGitRepo, PreCommitExists, GitCloneError
from jig.conf import JIG_DIR_NAME

# Dependencies to make jig run
BE_CAREFUL_DIR = realpath(join(dirname(__file__), '..'))
GIT_PYTHON_DIR = realpath(join(dirname(git.__file__), '..'))
GITDB_DIR = realpath(join(dirname(gitdb.__file__), '..'))
ASYNC_DIR = realpath(join(dirname(async.__file__), '..'))
SMMAP_DIR = realpath(join(dirname(smmap.__file__), '..'))

PRE_COMMIT_HOOK_SCRIPT = \
    dedent("""\
    #!{python_executable}
    from sys import path
    from os.path import dirname, join

    # Make sure that we can find the directory that jig is installed
    path.append('{be_careful_dir}')
    path.append('{git_python_dir}')
    path.append('{gitdb_dir}')
    path.append('{async_dir}')
    path.append('{smmap_dir}')

    from jig.runner import Runner
github h3llrais3r / Auto-Subliminal / lib / gitdb / util.py View on Github external
import sys
import time
import errno

from io import BytesIO

from smmap import (
    StaticWindowMapManager,
    SlidingWindowMapManager,
    SlidingWindowMapBuffer
)

# initialize our global memory manager instance
# Use it to free cached (and unused) resources.
if sys.version_info < (2, 6):
    mman = StaticWindowMapManager()
else:
    mman = SlidingWindowMapManager()
# END handle mman

import hashlib

try:
    from struct import unpack_from
except ImportError:
    from struct import unpack, calcsize
    __calcsize_cache = dict()

    def unpack_from(fmt, data, offset=0):
        try:
            size = __calcsize_cache[fmt]
        except KeyError:
github gitpython-developers / smmap / setup.py View on Github external
from ez_setup import use_setuptools
    use_setuptools()
    from setuptools import setup, find_packages

import smmap

if os.path.exists("README.md"):
    long_description = codecs.open('README.md', "r", "utf-8").read().replace('\r\n', '\n')
else:
    long_description = "See https://github.com/gitpython-developers/smmap"

setup(
    name="smmap",
    version=smmap.__version__,
    description="A pure Python implementation of a sliding window memory map manager",
    author=smmap.__author__,
    author_email=smmap.__contact__,
    url=smmap.__homepage__,
    platforms=["any"],
    license="BSD",
    packages=find_packages(),
    zip_safe=True,
    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
    classifiers=[
        # Picked from
        #    http://pypi.python.org/pypi?:action=list_classifiers
        #"Development Status :: 1 - Planning",
        #"Development Status :: 2 - Pre-Alpha",
        #"Development Status :: 3 - Alpha",
        # "Development Status :: 4 - Beta",
        "Development Status :: 5 - Production/Stable",
        #"Development Status :: 6 - Mature",
github gitpython-developers / smmap / setup.py View on Github external
use_setuptools()
    from setuptools import setup, find_packages

import smmap

if os.path.exists("README.md"):
    long_description = codecs.open('README.md', "r", "utf-8").read().replace('\r\n', '\n')
else:
    long_description = "See https://github.com/gitpython-developers/smmap"

setup(
    name="smmap",
    version=smmap.__version__,
    description="A pure Python implementation of a sliding window memory map manager",
    author=smmap.__author__,
    author_email=smmap.__contact__,
    url=smmap.__homepage__,
    platforms=["any"],
    license="BSD",
    packages=find_packages(),
    zip_safe=True,
    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
    classifiers=[
        # Picked from
        #    http://pypi.python.org/pypi?:action=list_classifiers
        #"Development Status :: 1 - Planning",
        #"Development Status :: 2 - Pre-Alpha",
        #"Development Status :: 3 - Alpha",
        # "Development Status :: 4 - Beta",
        "Development Status :: 5 - Production/Stable",
        #"Development Status :: 6 - Mature",
        #"Development Status :: 7 - Inactive",