Commit a4e2de46 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 1.1.1+dfsg

parent 1a96dd5b
*******************************************
*** This is SABnzbd 1.0.3 ***
*** This is SABnzbd 1.1.1 ***
*******************************************
SABnzbd is an open-source cross-platform binary newsreader.
It simplifies the process of downloading from Usenet dramatically,
......@@ -10,33 +10,22 @@ SABnzbd also has a fully customizable user interface,
and offers a complete API for third-party applications to hook into.
There is an extensive Wiki on the use of SABnzbd.
http://wiki.sabnzbd.org/
https://sabnzbd.org/wiki/
IMPORTANT INFORMATION about release 1.0.0:
http://wiki.sabnzbd.org/introducing-1-0-0
https://sabnzbd.org/wiki/introducing-1-0
Please also read the file "ISSUES.txt"
The organization of the download queue is different from 0.7.x (and older).
1.0.0 will not finish downloading an existing queue.
Also, your sabnzbd.ini file will be upgraded, making it
incompatible with older releases.
*******************************************
*** Upgrading from 0.7.x or 0.6.x ***
*** Upgrading from 0.7.x and below ***
*******************************************
Empty your current queue
Stop SABnzbd.
Install new version
Start SABnzbd.
*******************************************
*** Upgrading from 0.5.x ***
*******************************************
Stop SABnzbd.
Uninstall current version, keeping the data.
Install new version
Start SABnzbd.
The organization of the download queue is different from 0.7.x (and older).
1.0.0 will not finish downloading an existing queue.
Also, your sabnzbd.ini file will be upgraded, making it
incompatible with older releases.
SABnzbd 1.0.3
SABnzbd 1.1.1
-------------------------------------------------------------------------------
0) LICENSE
-------------------------------------------------------------------------------
......@@ -55,17 +54,14 @@ You need to have Python installed plus some non-standard Python modules
and a few tools.
Unix/Linux/OSX
Python-2.6 or 2.7 http://www.python.org
OSX Leopard/SnowLeopard
Python 2.6 http://www.activestate.com
Python-2.7 http://www.python.org (2.7.9+ recommended)
OSX Lion/MountainLion
OSX Mavericks or newer
Apple Python 2.7 Included in OSX (default)
Windows
Python-2.7.latest http://www.python.com
Most versions will work: 2.7.10 recommended
Most versions will work: 2.7.10+ recommended
PyWin32 use "pip install pypiwin32"
Essential modules
......@@ -74,7 +70,7 @@ Essential modules
unrar >= 5.00+ http://www.rarlab.com/rar_add.htm
Optional modules
unzip >= 5.52 http://www.info-zip.org/
unzip >= 6.00 http://www.info-zip.org/
7zip >= 9.20 http://www.7zip.org/
yenc module >= 0.3 http://sabnzbd.sourceforge.net/yenc-0.3.tar.gz
http://sabnzbd.sourceforge.net/yenc-0.3-w32fixed.zip (Win32-only)
......@@ -92,7 +88,7 @@ Optional modules Unix/Linux/OSX
If not, you cannot use the NotifyOSD feature.
Embedded modules (preferably use the included version)
CherryPy-3.8.0 with patches http://www.cherrypy.org
CherryPy-6.0.2 with patches http://www.cherrypy.org
Unpack the ZIP-file containing the SABnzbd sources to any folder of your liking.
......@@ -129,7 +125,7 @@ may help you solve problems easier.
-------------------------------------------------------------------------------
Visit the WIKI site:
http://wiki.sabnzbd.org/
https://sabnzbd.org/wiki/
-------------------------------------------------------------------------------
......@@ -138,4 +134,4 @@ Visit the WIKI site:
Several parts of SABnzbd were built by other people, illustrating the
wonderful world of Free Open Source Software.
See the licenses folder of the main program and of the skin folders.
See the licenses folder of the main program and of the skin folders.
\ No newline at end of file
......@@ -12,7 +12,7 @@
Windows-only:
If you keep having trouble with par2 multicore you can disable it
in Config->Switches.
This will force the use of the old and tried, but slower par2-classic program.
This will force the use of the old and tried, but slower par2cmdline program.
- A bug in Windows 7 may cause severe memory leaks when you use SABnzbd in
combination with some virus scanners and firewalls.
......@@ -24,13 +24,13 @@
For these the server blocking method is not very favourable.
There is an INI-only option that will limit blocks to 1 minute.
no_penalties = 1
See: http://wiki.sabnzbd.org/configure-special-1-0
See: https://sabnzbd.org/wiki/configuration/1.0/special
- Some third-party utilties try to probe SABnzbd API in such a way that you will
often see warnings about unauthenticated access.
If you are sure these probes are harmless, you can suppress the warnings by
setting the option "api_warnings" to 0.
See: http://wiki.sabnzbd.org/configure-special-1-0
See: https://sabnzbd.org/wiki/configuration/1.0/special
- On OSX you may encounter downloaded files with foreign characters.
The par2 repair may fail when the files were created on a Windows system.
......@@ -41,7 +41,7 @@
You will see this only when downloaded files contain accented characters.
You need to fix it yourself by running the convmv utility (available for most Linux platforms).
Possible the file system override setting 'fsys_type' might be solve things:
See: http://wiki.sabnzbd.org/configure-special-1-0
See: https://sabnzbd.org/wiki/configuration/1.0/special
- The "Watched Folder" sometimes fails to delete the NZB files it has
processed. This happens when other software still accesses these files.
......@@ -81,4 +81,4 @@
- Squeeze Linux
There is a "special" option that will allow you to select an alternative library.
use_pickle = 1
See: http://wiki.sabnzbd.org/configure-special-1-0
See: https://sabnzbd.org/wiki/configuration/1.0/special
Metadata-Version: 1.0
Name: SABnzbd
Version: 1.0.3
Summary: SABnzbd-1.0.3
Version: 1.1.1
Summary: SABnzbd-1.1.1
Home-page: http://sabnzbd.org
Author: The SABnzbd Team
Author-email: team@sabnzbd.org
......
Release Notes - SABnzbd 1.0.3
Release Notes - SABnzbd 1.1.1
===============================
## Bugfixes in 1.0.3
- Fix jobs hanging at 99% or 100%
- Support X-DNZB-PASSWORD header for inders that use this
- Prevent fatal "too many connections" issue
- Show checksum errors reported by unrar
- Windows: fix coupling of NZB files to SABnzbd, when the name contains non-US-ASCII characters
## Bugfixes in 1.0.2
- Fix hangups at 100% when QuickCheck is off and "all-pars" is on
- Fix handling of "too many connections" for some Usenet servers
## What's new in 1.0.1
- Prevent creating orphan items in "incomplete" when deleting downloading jobs.
- Forced item with missing articles caused overflow into paused jobs
- Do QuickCheck even on files that would be removed by the Cleanup-list (problematic for RAR files).
- Fix "Download all par2 files" behavior
- Treat ambiguous numeric values as number of minutes for custom pause time.
- Accept MIME records that have only LF line endings (error in some third-party utilities)
- Fix PushOver support.
- Fix breaking Glitter bug with large script_log
- Fix issues with deleting jobs via the API
- Fix issue where Sonarr could not read using the History-API
- Increase default cache to 450M
- The pre-queue script can now return an accept value of 2, meaning immediate failure. (Useful for Sonarr.)
- Add start script for portable Windows installations
## What's new in 1.0.0
- Full Unicode support with Chinese and Russian translations
- New default UI: Glitter
- Server priorities instead of primary/backup ==> REVIEW YOUR SERVER SETTINGS!
- Newsserver IPv6 load balancing aka Happy Eyeballs / RFC 6555
- Duplicate detection for series
- More filters in RSS
- 7zip support
- Option to save repair time by downloading all par2 files
- Support for long paths in Windows (above 260)
- Improved security for external access
- Lots of small improvements and bug fixes
- Redesign of notifications classes
- More notification services supported
- Diagnostic dashboard tab for "Status" page
- Bonjour/ZeroConfig support
## Remarks
- SABnzbd's webserver now doesn't listen to IPv6 addresses by default.
- Use Config->Special->ipv6_hosting if you want this enabled.
- "localhost" will be replaced with "127.0.0.1", check any browser bookmark and third-party tool
- Classic skin has been removed
- Support extra parameters for par2 on other platforms than Windows
- Option to verify HTTPS connections (default off)
- Auto-negotiates best Usenet ssl protocol (override possible)
- When upgrading from 0.7.x, a backup server will get priority 1
## What's new in 1.1.1
## Buf fixes
- 8th parameter for user-script wasn't passed correctly.
- Fix broken HTTPS port binding
- Only allow binding to IPv6 when ipv6_hosting enabled
- Allow also "vol01-03.par" on top of "vol01+03.par"
- Glitter didn't allow removal of a set job-password
- Unicode failed downloads were seen as orphaned jobs
- QuickCheck would fail unicode files
- Clean-up all par2 of a set
- Fix retry_all API-call
- Make sure we show results when less than 1 page
- Fixed email notifications to smtp2go.com (and possibly others)
- Replaced par2-classic with par2cmdline (will fix some verification hangups)
- Fix problem with Config pages on mobile browsers
- Updated INSTALL.txt
- Button to regenerate a self-signed HTTPS certificate (to update to modern standards)
- Restored download speed for Unix (and some other) systems
- Fixed yEnc crash that occurred on some Windows systems
- Small UI fixes
## About
......@@ -66,8 +34,8 @@ Release Notes - SABnzbd 1.0.3
(c) Copyright 2007-2016 by "The SABnzbd-team" \<team@sabnzbd.org\>
### IMPORTANT INFORMATION about release 1.0.0
<http://wiki.sabnzbd.org/introducing-1-0-0>
### IMPORTANT INFORMATION about release 1.0.0+
<https://sabnzbd.org/wiki/introducing-1-0>
### Known problems and solutions
- Read the file "ISSUES.txt"
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import sys
if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
print "Sorry, requires Python 2.6 or 2.7."
if sys.version_info[:2] < (2, 7) or sys.version_info[:2] >= (3, 0):
print "Sorry, requires Python 2.7."
sys.exit(1)
# Make sure UTF-8 is default 8bit encoding
......@@ -27,7 +27,7 @@ try:
sys.setdefaultencoding('utf-8')
except:
print 'Sorry, you MUST add the SABnzbd folder to the PYTHONPATH environment variable'
print 'or find another way to force Python to use UTF-8 for string encoding.'
print 'or find another way to force Python to use UTF-8 for text encoding.'
sys.exit(1)
import logging
......@@ -52,8 +52,8 @@ except:
sys.exit(1)
import cherrypy
if [int(n) for n in cherrypy.__version__.split('.')] < [3, 8, 0]:
print 'Sorry, requires Python module Cherrypy 3.8.0+ (use the included version)'
if [int(n) for n in cherrypy.__version__.split('.')] < [6, 0, 2]:
print 'Sorry, requires Python module Cherrypy 6.0.2+ (use the included version)'
sys.exit(1)
from cherrypy import _cpserver
......@@ -98,26 +98,13 @@ import sabnzbd.config as config
import sabnzbd.cfg
import sabnzbd.downloader
from sabnzbd.encoding import unicoder, deunicode
import sabnzbd.growler as growler
import sabnzbd.notifier as notifier
import sabnzbd.zconfig
from threading import Thread
LOG_FLAG = False # Global for this module, signaling loglevel change
_first_log = True
def FORCELOG(txt):
global _first_log
if _first_log:
os.remove('d:/temp/debug.txt')
_first_log = False
ff = open('d:/temp/debug.txt', 'a+')
ff.write(txt)
ff.write('\n')
ff.close()
try:
import win32api
......@@ -493,7 +480,7 @@ def print_modules():
logging.error(T('par2 binary... NOT found!'))
if sabnzbd.newsunpack.PAR2C_COMMAND:
logging.info("par2-classic binary... found (%s)", sabnzbd.newsunpack.PAR2C_COMMAND)
logging.info("par2cmdline binary... found (%s)", sabnzbd.newsunpack.PAR2C_COMMAND)
if sabnzbd.newsunpack.RAR_COMMAND:
logging.info("UNRAR binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND)
......@@ -504,14 +491,12 @@ def print_modules():
if sabnzbd.newsunpack.ZIP_COMMAND:
logging.info("unzip binary... found (%s)", sabnzbd.newsunpack.ZIP_COMMAND)
else:
if sabnzbd.cfg.enable_unzip():
logging.warning(T('unzip binary... NOT found!'))
logging.info(T('unzip binary... NOT found!'))
if sabnzbd.newsunpack.SEVEN_COMMAND:
logging.info("7za binary... found (%s)", sabnzbd.newsunpack.SEVEN_COMMAND)
else:
if sabnzbd.cfg.enable_7zip():
logging.info(T('7za binary... NOT found!'))
logging.info(T('7za binary... NOT found!'))
if not sabnzbd.WIN32:
if sabnzbd.newsunpack.NICE_COMMAND:
......@@ -548,7 +533,8 @@ def all_localhosts():
ips = []
for item in info:
item = item[4][0]
if item not in ips:
# Only return IPv6 when enabled
if item not in ips and ('::1' not in item or sabnzbd.cfg.ipv6_hosting()):
ips.append(item)
return ips
......@@ -691,7 +677,7 @@ def get_webhost(cherryhost, cherryport, https_port):
if cherryport == https_port and sabnzbd.cfg.enable_https():
sabnzbd.cfg.enable_https.set(False)
# TODO: Should have a translated message, but that's not available yet
# Should have a translated message, but that's not available yet
logging.error(T('HTTP and HTTPS ports cannot be the same'))
return cherryhost, cherryport, browserhost, https_port
......@@ -700,14 +686,13 @@ def get_webhost(cherryhost, cherryport, https_port):
def attach_server(host, port, cert=None, key=None, chain=None):
""" Define and attach server, optionally HTTPS """
if sabnzbd.cfg.ipv6_hosting() or '::1' not in host:
http_server = _cpwsgi_server.CPWSGIServer()
http_server = cherrypy._cpserver.Server()
http_server.bind_addr = (host, port)
if cert and key:
http_server.ssl_certificate = cert
http_server.ssl_private_key = key
http_server.ssl_certificate_chain = chain
adapter = _cpserver.ServerAdapter(cherrypy.engine, http_server, http_server.bind_addr)
adapter.subscribe()
http_server.subscribe()
def is_sabnzbd_running(url, timeout=None):
......@@ -943,7 +928,7 @@ def main():
autobrowser = bool(int(arg))
except:
autobrowser = True
elif opt in ('--autorestarted'):
elif opt in ('--autorestarted', ):
autorestarted = True
elif opt in ('-c', '--clean'):
clean_up = True
......@@ -1003,7 +988,7 @@ def main():
osx_console = True
elif opt in ('--ipv6_hosting',):
ipv6_hosting = arg
sabnzbd.MY_FULLNAME = os.path.normpath(os.path.abspath(sabnzbd.MY_FULLNAME))
sabnzbd.MY_NAME = os.path.basename(sabnzbd.MY_FULLNAME)
sabnzbd.DIR_PROG = os.path.dirname(sabnzbd.MY_FULLNAME)
......@@ -1125,14 +1110,15 @@ def main():
else:
if not url:
url = 'https://%s:%s/sabnzbd/api?' % (browserhost, port)
if new_instance or not check_for_sabnzbd(url, upload_nzbs, autobrowser):
newport = find_free_port(browserhost, port)
if newport > 0:
sabnzbd.cfg.https_port.set(newport)
if https_port:
https_port = newport
else:
http_port = newport
if not sabnzbd.cfg.fixed_ports():
if new_instance or not check_for_sabnzbd(url, upload_nzbs, autobrowser):
newport = find_free_port(browserhost, port)
if newport > 0:
sabnzbd.cfg.https_port.set(newport)
if https_port:
https_port = newport
else:
http_port = newport
except:
Bail_Out(browserhost, cherryport, '49')
......@@ -1145,11 +1131,12 @@ def main():
else:
if not url:
url = 'http://%s:%s/sabnzbd/api?' % (browserhost, cherryport)
if new_instance or not check_for_sabnzbd(url, upload_nzbs, autobrowser):
port = find_free_port(browserhost, cherryport)
if port > 0:
sabnzbd.cfg.cherryport.set(port)
cherryport = port
if not sabnzbd.cfg.fixed_ports():
if new_instance or not check_for_sabnzbd(url, upload_nzbs, autobrowser):
port = find_free_port(browserhost, cherryport)
if port > 0:
sabnzbd.cfg.cherryport.set(port)
cherryport = port
except:
Bail_Out(browserhost, cherryport, '49')
......@@ -1343,8 +1330,6 @@ def main():
sabnzbd.WEB_COLOR2 = CheckColor(sabnzbd.cfg.web_color2(), web_dir2)
sabnzbd.cfg.web_color2.set(sabnzbd.WEB_COLOR2)
logging.debug('Unwanted extensions are ... %s', sabnzbd.cfg.unwanted_extensions())
if fork and not sabnzbd.WIN32:
daemonize()
......@@ -1415,7 +1400,7 @@ def main():
hosts[1] = '::1'
# The Windows binary requires numeric localhost as primary address
if multilocal and cherryhost == 'localhost':
if cherryhost == 'localhost':
cherryhost = hosts[0]
if enable_https:
......@@ -1561,7 +1546,7 @@ def main():
if sabnzbd.FOUNDATION:
import sabnzbd.osxmenu
sabnzbd.osxmenu.notify("SAB_Launched", None)
growler.send_notification('SABnzbd%s' % growler.hostname(),
notifier.send_notification('SABnzbd%s' % notifier.hostname(),
T('SABnzbd %s started') % sabnzbd.__version__, 'startup')
# Now's the time to check for a new version
check_latest_version()
......@@ -1610,11 +1595,11 @@ def main():
if sabnzbd.LAST_WARNING:
msg = sabnzbd.LAST_WARNING
sabnzbd.LAST_WARNING = None
sabnzbd.growler.send_notification(T('Warning'), msg, 'warning')
sabnzbd.notifier.send_notification(T('Warning'), msg, 'warning')
if sabnzbd.LAST_ERROR:
msg = sabnzbd.LAST_ERROR
sabnzbd.LAST_ERROR = None
sabnzbd.growler.send_notification(T('Error'), msg, 'error')
sabnzbd.notifier.send_notification(T('Error'), msg, 'error')
if sabnzbd.WIN_SERVICE:
rc = win32event.WaitForMultipleObjects((sabnzbd.WIN_SERVICE.hWaitStop,
......@@ -1622,7 +1607,7 @@ def main():
if rc == win32event.WAIT_OBJECT_0:
if mail:
mail.send('stop')
sabnzbd.save_state(flag=True)
sabnzbd.save_state()
logging.info('Leaving SABnzbd')
sabnzbd.SABSTOP = True
return
......@@ -1684,7 +1669,7 @@ def main():
sys.argv = re_argv
os.chdir(org_dir)
if sabnzbd.DARWIN:
# TODO: when executing from sources on osx, after a restart, process is detached from console
# When executing from sources on osx, after a restart, process is detached from console
# If OSX frozen restart of app instead of embedded python
if getattr(sys, 'frozen', None) == 'macosx_app':
# [[NSProcessInfo processInfo] processIdentifier]]
......@@ -1731,7 +1716,7 @@ def main():
# Failing AppHelper libary!
os._exit(0)
else:
growler.send_notification('SABnzbd', T('SABnzbd shutdown finished'), 'startup')
notifier.send_notification('SABnzbd', T('SABnzbd shutdown finished'), 'startup')
os._exit(0)
......
Copyright (c) 2004-2015, CherryPy Team (team@cherrypy.org)
Copyright (c) 2004-2016, CherryPy Team (team@cherrypy.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......
From 0f6da83f5acff3fc9c4eda2d3111849ef1429711 Mon Sep 17 00:00:00 2001
From: shypike <shypike@sabnzbd.org>
Date: Thu, 23 Jul 2015 18:16:27 +0200
Subject: [PATCH] Patch CherryPy to support 301 redirection.
Needed to support the broken Bonjour/ZeroConfig protocol that
only allows an HTTP address to set, even for a HTTPS-only server.
---
cherrypy/wsgiserver/wsgiserver2.py | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/cherrypy/wsgiserver/wsgiserver2.py b/cherrypy/wsgiserver/wsgiserver2.py
index c0896d3..9367f7b 100644
--- a/cherrypy/wsgiserver/wsgiserver2.py
+++ b/cherrypy/wsgiserver/wsgiserver2.py
@@ -75,7 +75,7 @@ __all__ = ['HTTPRequest', 'HTTPConnection', 'HTTPServer',
'WorkerThread', 'ThreadPool', 'SSLAdapter',
'CherryPyWSGIServer',
'Gateway', 'WSGIGateway', 'WSGIGateway_10', 'WSGIGateway_u0',
- 'WSGIPathInfoDispatcher', 'get_ssl_adapter_class']
+ 'WSGIPathInfoDispatcher', 'get_ssl_adapter_class', 'redirect_url']
import os
try:
@@ -97,6 +97,7 @@ except ImportError:
import StringIO
DEFAULT_BUFFER_SIZE = -1
+REDIRECT_URL = None # Application can write its HTTP-->HTTPS redirection URL here
class FauxSocket(object):
@@ -167,6 +168,12 @@ quoted_slash = re.compile(ntob("(?i)%2F"))
import errno
+def redirect_url(url=None):
+ global REDIRECT_URL
+ if url and '%s' in url:
+ REDIRECT_URL = url
+ return REDIRECT_URL
+
def plat_specific_errors(*errnames):
"""Return error numbers for all errors in errnames on this platform.
@@ -881,6 +888,9 @@ class HTTPRequest(object):
"Content-Length: %s\r\n" % len(msg),
"Content-Type: text/plain\r\n"]
+ if status[:3] in ("301",):
+ buf.append("Location: %s" % msg)
+
if status[:3] in ("413", "414"):
# Request Entity Too Large / Request-URI Too Long
self.close_connection = True
@@ -1394,10 +1404,13 @@ class HTTPConnection(object):
# Unwrap our wfile
self.wfile = CP_fileobject(
self.socket._sock, "wb", self.wbufsize)
- req.simple_response(
- "400 Bad Request",
- "The client sent a plain HTTP request, but "
- "this server only speaks HTTPS on this port.")
+ if REDIRECT_URL:
+ req.simple_response("301 Moved Permanently", REDIRECT_URL % self.remote_addr)
+ else:
+ req.simple_response(
+ "400 Bad Request",
+ "The client sent a plain HTTP request, but "
+ "this server only speaks HTTPS on this port.")
self.linger = True
except Exception:
e = sys.exc_info()[1]
--
1.9.5 (Apple Git-50.3)
CherryPy 3.8.0 Official distribution: https://pypi.python.org/packages/source/C/CherryPy/CherryPy-3.8.0.tar.gz
CherryPy 6.0.2 Official distribution: https://pypi.python.org/packages/source/C/CherryPy/CherryPy-6.0.2.tar.gz
The folders 'tutorial', 'test' and 'scaffold' have been removed.
This file has been added.
A patch is required to enable proper Bonjour/Zeroconfig support.
This diff is collapsed.
......@@ -7,7 +7,7 @@ preferring a newer idiom, sometimes an older one, and sometimes a custom one.
In particular, Python 2 uses str and '' for byte strings, while Python 3
uses str and '' for unicode strings. We will call each of these the 'native
string' type for each version. Because of this major difference, this module
provides new 'bytestr', 'unicodestr', and 'nativestr' attributes, as well as
provides
two functions: 'ntob', which translates native strings (of type 'str') into
byte strings regardless of Python version, and 'ntou', which translates native
strings to unicode strings. This also provides a 'BytesIO' name for dealing
......@@ -20,11 +20,9 @@ import re
import sys
import threading
if sys.version_info >= (3, 0):
py3k = True
bytestr = bytes
unicodestr = str
nativestr = unicodestr
import six
if six.PY3:
basestring = (bytes, str)
def ntob(n, encoding='ISO-8859-1'):
......@@ -49,16 +47,8 @@ if sys.version_info >= (3, 0):
if isinstance(n, bytes):
return n.decode(encoding)
return n
# type("")
from io import StringIO
# bytes:
from io import BytesIO as BytesIO
else:
# Python 2
py3k = False
bytestr = str
unicodestr = unicode
nativestr = bytestr
basestring = basestring
def ntob(n, encoding='ISO-8859-1'):
......@@ -96,25 +86,12 @@ else:
if isinstance(n, unicode):
return n.encode(encoding)
return n
try:
# type("")
from cStringIO import StringIO
except ImportError:
# type("")
from StringIO import StringIO
# bytes:
BytesIO = StringIO
def assert_native(n):
if not isinstance(n, nativestr):
if not isinstance(n, str):
raise TypeError("n must be a native str (got %s)" % type(n).__name__)
try:
set = set
except NameError:
from sets import Set as set
try:
# Python 3.1+
from base64 import decodebytes as _base64_decodebytes
......@@ -127,27 +104,16 @@ except ImportError:
def base64_decode(n, encoding='ISO-8859-1'):
"""Return the native string base64-decoded (as a native string)."""
if isinstance(n, unicodestr):
if isinstance(n, six.text_type):
b = n.encode(encoding)
else:
b = n
b = _base64_decodebytes(b)
if nativestr is unicodestr:
if str is six.text_type:
return b.decode(encoding)
else:
return b
try:
# Python 2.5+
from hashlib import md5
except ImportError:
from md5 import new as md5