Esempio n. 1
0
import os
import re
import six
import sys
from requests import Request, codes, exceptions
from requests.compat import urljoin
from praw.decorators import restrict_access
from praw.errors import (ClientException, HTTPException, Forbidden, NotFound,
                         InvalidSubreddit, OAuthException,
                         OAuthInsufficientScope, OAuthInvalidToken,
                         RedirectException)
from warnings import warn
try:
    from OpenSSL import __version__ as _opensslversion
    _opensslversionlist = [int(minor) if minor.isdigit() else minor
                           for minor in _opensslversion.split('.')]
except ImportError:
    _opensslversionlist = [0, 15]

MIN_PNG_SIZE = 67
MIN_JPEG_SIZE = 128
MAX_IMAGE_SIZE = 512000
JPEG_HEADER = b'\xff\xd8\xff'
PNG_HEADER = b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a'
RE_REDIRECT = re.compile('(rand(om|nsfw))|about/sticky')


def _get_redditor_listing(subpath=''):
    """Return function to generate Redditor listings."""
    def _listing(self, sort='new', time='all', *args, **kwargs):
        """Return a get_content generator for some RedditContentObject type.
Esempio n. 2
0
import os
import re
import six
import sys
from requests import Request, codes, exceptions
from requests.compat import urljoin
from .decorators import restrict_access
from .errors import (ClientException, HTTPException, Forbidden, NotFound,
                     InvalidSubreddit, OAuthException,
                     OAuthInsufficientScope, OAuthInvalidToken,
                     RedirectException)
from warnings import warn
try:
    from OpenSSL import __version__ as _opensslversion
    _opensslversionlist = [int(minor) if minor.isdigit() else minor
                           for minor in _opensslversion.split('.')]
except ImportError:
    _opensslversionlist = [0, 15]

MIN_PNG_SIZE = 67
MIN_JPEG_SIZE = 128
MAX_IMAGE_SIZE = 512000
JPEG_HEADER = b'\xff\xd8\xff'
PNG_HEADER = b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a'
RE_REDIRECT = re.compile('(rand(om|nsfw))|about/sticky')


def _get_redditor_listing(subpath=''):
    """Return function to generate Redditor listings."""
    def _listing(self, sort='new', time='all', *args, **kwargs):
        """Return a get_content generator for some RedditContentObject type.