# Path: newsreap/Utils.py
# def strsize_to_bytes(strsize):
#     """
#     This function returns the byte size equivalent (as an integer) that best
#     represents the string passed in.  the string passed in is intended to be
#     in the format as:
#         value <unit>
# 
#         example: 4TB, 3GB, 10MB, 25KB, etc
# 
#     """
#     if isinstance(strsize, int):
#         # Nothing further to do
#         return strsize
# 
#     try:
#         strsize_re = re.match(
#             r'\s*(?P<size>(0|[1-9][0-9]*)(\.(0+|[1-9][0-9]*))?)\s*'
#             r'((?P<unit>.)(?P<type>[bB])?)?\s*',
#             strsize,
#         )
#     except TypeError:
#         return None
# 
#     if not strsize_re:
#         # Not good
#         return None
# 
#     size = int(strsize_re.group('size'))
#     unit = strsize_re.group('unit')
#     use_bytes = strsize_re.group('type') != 'b'
# 
#     if not unit:
#         return size
# 
#     # convert unit to uppercase
#     unit = unit.upper()
# 
#     if use_bytes:
#         if unit == 'B':
#             # We're going to assume bytes and return now
#             return size
# 
#         elif unit == 'K':
#             # We're dealing with Kilobytes
#             return size * 1024
# 
#         elif unit == 'M':
#             # We're dealing with Megabytes
#             return size * 1048576
# 
#         elif unit == 'G':
#             # We're dealing with Gigabytes
#             return size * 1073741824
# 
#         elif unit == 'T':
#             # We're dealing with Terabytes
#             return size * 1073741824 * 1024
# 
#     # In Bits
#     if unit == 'K':
#         # We're dealing with Kilobytes
#         return size * 1e3
# 
#     elif unit == 'M':
#         # We're dealing with Megabytes
#         return size * 1e6
# 
#     elif unit == 'G':
#         # We're dealing with Gigabytes
#         return size * 1e9
# 
#     elif unit == 'T':
#         # We're dealing with Terabytes
#         return size * 1e12
# 
#     # Unsupported Type
#     return None
# 
# Path: newsreap/NNTPSimpleFilter.py
# class NNTPSimpleFilter(NNTPFilterBase):
#     """
#     A simple filter that extends the FilterBase. This filter applies
#     some basic filters we can search against.
#     """
# 
#     def __init__(self):
#         """
#         Initialize Simple Filter
#         """
#         super(NNTPSimpleFilter, self).__init__()
# 
#         self._blacklist = {
#             '.*': [{
#                 FilterDirectives.DESCRIPTION: "Dangerous file types.",
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(exe|sc(f|r)|vb(e|s)?|pif|application|gadget|ms(c|h|i|p)|hta' +\
#                     '|jar|bat|c(md|om|pl)|jse?|ws(f|c|h)?|lnk|inf|reg|' +\
#                     'psc?(1|2)(xml)?|ms(h(1|2)(xml)?|1|2|))[\s"\'].*',
#                 re.IGNORECASE),
#             }],
#         }
# 
#         self._scorelist = {
#             'alt.bin.*' : [{
#                 FilterDirectives.DESCRIPTION: "Video Content",
#                 FilterDirectives.SCORE: 25,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(avi|m(p(4|eg|g)|kv|ov)|asf|ogg|iso|rm)(\.[0-9]{3})?[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Image Content",
#                 FilterDirectives.SCORE: 15,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(jpe?g|png|bmp|gif)[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Compressed Content",
#                 FilterDirectives.SCORE: 25,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(r(ar|[0-9]{2})|7z|z(ip|[0-9]{2})|tgz|tar\.gz)(\.[0-9]{3})?[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Recovery Content",
#                 FilterDirectives.SCORE: 10,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(par2?)[\s"\'].*',
#                 re.IGNORECASE),
#             }],
#         }


import sys
import gevent.monkey
import pytz
from os.path import abspath
from os.path import dirname
from datetime import datetime
from copy import deepcopy as copy
    from tests.TestBase import TestBase
    from tests.TestBase import TestBase
from newsreap.Utils import strsize_to_bytes
from newsreap.NNTPSimpleFilter import NNTPSimpleFilter
# -*- coding: utf-8 -*-
#
# A base testing class/library to test the Filters
#
# Copyright (C) 2015-2016 Chris Caron <lead2gold@gmail.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.

if 'threading' in sys.modules:
    #  gevent patching since pytests import
    #  the sys library before we do.
    del sys.modules['threading']

gevent.monkey.patch_all()


try:


# Path: newsreap/Utils.py
# def strsize_to_bytes(strsize):
#     """
#     This function returns the byte size equivalent (as an integer) that best
#     represents the string passed in.  the string passed in is intended to be
#     in the format as:
#         value <unit>
# 
#         example: 4TB, 3GB, 10MB, 25KB, etc
# 
#     """
#     if isinstance(strsize, int):
#         # Nothing further to do
#         return strsize
# 
#     try:
#         strsize_re = re.match(
#             r'\s*(?P<size>(0|[1-9][0-9]*)(\.(0+|[1-9][0-9]*))?)\s*'
#             r'((?P<unit>.)(?P<type>[bB])?)?\s*',
#             strsize,
#         )
#     except TypeError:
#         return None
# 
#     if not strsize_re:
#         # Not good
#         return None
# 
#     size = int(strsize_re.group('size'))
#     unit = strsize_re.group('unit')
#     use_bytes = strsize_re.group('type') != 'b'
# 
#     if not unit:
#         return size
# 
#     # convert unit to uppercase
#     unit = unit.upper()
# 
#     if use_bytes:
#         if unit == 'B':
#             # We're going to assume bytes and return now
#             return size
# 
#         elif unit == 'K':
#             # We're dealing with Kilobytes
#             return size * 1024
# 
#         elif unit == 'M':
#             # We're dealing with Megabytes
#             return size * 1048576
# 
#         elif unit == 'G':
#             # We're dealing with Gigabytes
#             return size * 1073741824
# 
#         elif unit == 'T':
#             # We're dealing with Terabytes
#             return size * 1073741824 * 1024
# 
#     # In Bits
#     if unit == 'K':
#         # We're dealing with Kilobytes
#         return size * 1e3
# 
#     elif unit == 'M':
#         # We're dealing with Megabytes
#         return size * 1e6
# 
#     elif unit == 'G':
#         # We're dealing with Gigabytes
#         return size * 1e9
# 
#     elif unit == 'T':
#         # We're dealing with Terabytes
#         return size * 1e12
# 
#     # Unsupported Type
#     return None
# 
# Path: newsreap/NNTPSimpleFilter.py
# class NNTPSimpleFilter(NNTPFilterBase):
#     """
#     A simple filter that extends the FilterBase. This filter applies
#     some basic filters we can search against.
#     """
# 
#     def __init__(self):
#         """
#         Initialize Simple Filter
#         """
#         super(NNTPSimpleFilter, self).__init__()
# 
#         self._blacklist = {
#             '.*': [{
#                 FilterDirectives.DESCRIPTION: "Dangerous file types.",
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(exe|sc(f|r)|vb(e|s)?|pif|application|gadget|ms(c|h|i|p)|hta' +\
#                     '|jar|bat|c(md|om|pl)|jse?|ws(f|c|h)?|lnk|inf|reg|' +\
#                     'psc?(1|2)(xml)?|ms(h(1|2)(xml)?|1|2|))[\s"\'].*',
#                 re.IGNORECASE),
#             }],
#         }
# 
#         self._scorelist = {
#             'alt.bin.*' : [{
#                 FilterDirectives.DESCRIPTION: "Video Content",
#                 FilterDirectives.SCORE: 25,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(avi|m(p(4|eg|g)|kv|ov)|asf|ogg|iso|rm)(\.[0-9]{3})?[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Image Content",
#                 FilterDirectives.SCORE: 15,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(jpe?g|png|bmp|gif)[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Compressed Content",
#                 FilterDirectives.SCORE: 25,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(r(ar|[0-9]{2})|7z|z(ip|[0-9]{2})|tgz|tar\.gz)(\.[0-9]{3})?[\s"\'].*',
#                 re.IGNORECASE),
#             },{
#                 FilterDirectives.DESCRIPTION: "Recovery Content",
#                 FilterDirectives.SCORE: 10,
#                 FilterDirectives.SUBJECT_MATCHES_REGEX: re.compile(
#                     '.*\.(par2?)[\s"\'].*',
#                 re.IGNORECASE),
#             }],
#         }


# Path: tests/NNTPSimpleFilter_Test.py
import sys
import gevent.monkey
import pytz
from os.path import abspath
from os.path import dirname
from datetime import datetime
from copy import deepcopy as copy
    from tests.TestBase import TestBase
    from tests.TestBase import TestBase
from newsreap.Utils import strsize_to_bytes
from newsreap.NNTPSimpleFilter import NNTPSimpleFilter

# -*- coding: utf-8 -*-
#
# A base testing class/library to test the Filters
#
# Copyright (C) 2015-2016 Chris Caron <lead2gold@gmail.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.

if 'threading' in sys.modules:
    #  gevent patching since pytests import
    #  the sys library before we do.
    del sys.modules['threading']

gevent.monkey.patch_all()


try:


except ImportError: