summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/guessit/files')
-rw-r--r--dev-python/guessit/files/guessit-0.5.4-python3.patch30
-rw-r--r--dev-python/guessit/files/guessit-0.5.4-tests.patch172
2 files changed, 202 insertions, 0 deletions
diff --git a/dev-python/guessit/files/guessit-0.5.4-python3.patch b/dev-python/guessit/files/guessit-0.5.4-python3.patch
new file mode 100644
index 000000000000..954c7154a08a
--- /dev/null
+++ b/dev-python/guessit/files/guessit-0.5.4-python3.patch
@@ -0,0 +1,30 @@
+From 93f4fe97f664c207e769186fe79961bf5a998447 Mon Sep 17 00:00:00 2001
+From: Nicolas Wack <wackou@gmail.com>
+Date: Thu, 25 Apr 2013 16:05:05 +0200
+Subject: [PATCH] Fixed some unicode issues when reading files from disk
+
+---
+ guessit/fileutils.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/guessit/fileutils.py b/guessit/fileutils.py
+index 2fca6b7..dc077e6 100644
+--- a/guessit/fileutils.py
++++ b/guessit/fileutils.py
+@@ -22,6 +22,7 @@
+ from guessit import s, u
+ import os.path
+ import zipfile
++import io
+
+
+ def split_path(path):
+@@ -84,4 +85,4 @@ def load_file_in_same_dir(ref_file, filename):
+ zfile = zipfile.ZipFile(zfilename)
+ return zfile.read('/'.join(path[i + 1:]))
+
+- return u(open(os.path.join(*path)).read())
++ return u(io.open(os.path.join(*path), encoding='utf-8').read())
+--
+1.8.1.6
+
diff --git a/dev-python/guessit/files/guessit-0.5.4-tests.patch b/dev-python/guessit/files/guessit-0.5.4-tests.patch
new file mode 100644
index 000000000000..50d8f579e47e
--- /dev/null
+++ b/dev-python/guessit/files/guessit-0.5.4-tests.patch
@@ -0,0 +1,172 @@
+From 409218bc3d5b62e4f3e37aa57126cd628a34bd21 Mon Sep 17 00:00:00 2001
+From: Nicolas Wack <wackou@gmail.com>
+Date: Fri, 19 Apr 2013 22:08:38 +0200
+Subject: [PATCH] Allow to run tests using "python setup.py test"; fixed
+ autodetect_all test target
+
+---
+ fabfile.py | 1 +
+ setup.py | 3 ++-
+ tests/__init__.py | 0
+ tests/guessittest.py | 19 ++++++++++++-------
+ tests/test_autodetect.py | 2 +-
+ tests/test_autodetect_all.py | 12 ++++++++----
+ 6 files changed, 24 insertions(+), 13 deletions(-)
+ create mode 100644 tests/__init__.py
+
+diff --git a/fabfile.py b/fabfile.py
+index 5b2c9fe..d8c4112 100644
+--- a/fabfile.py
++++ b/fabfile.py
+@@ -25,6 +25,7 @@ def run(self):
+ test_ep = TestTask('episode', 'episodes')
+ test_movie = TestTask('movie', 'movies')
+ test_auto = TestTask('autodetect', 'autodetected files')
++test_auto_all = TestTask('autodetect_all', 'all files using autodetected type')
+ test_lang = TestTask('language', 'languages')
+ test_utils = TestTask('utils', 'utility functions')
+ test_matchtree = TestTask('matchtree', 'MatchTree')
+diff --git a/setup.py b/setup.py
+index deee110..81f907d 100644
+--- a/setup.py
++++ b/setup.py
+@@ -65,7 +65,8 @@
+ include_package_data=True,
+ install_requires = requires,
+ entry_points=entry_points,
+- extras_require = { 'language_detection': ['guess-language>=0.2'] }
++ extras_require = { 'language_detection': ['guess-language>=0.2'] },
++ test_suite = 'tests'
+ )
+
+
+diff --git a/tests/__init__.py b/tests/__init__.py
+new file mode 100644
+index 0000000..e69de29
+diff --git a/tests/guessittest.py b/tests/guessittest.py
+index c56b6ca..cfeaef0 100644
+--- a/tests/guessittest.py
++++ b/tests/guessittest.py
+@@ -21,7 +21,7 @@
+ from __future__ import unicode_literals
+ from guessit import base_text_type, u
+ from guessit.slogging import setupLogging
+-from unittest import *
++from unittest import TestCase, TestLoader, TextTestRunner
+
+ import yaml, logging, sys, os
+ from os.path import *
+@@ -58,20 +58,25 @@ def allTests(testClass):
+
+ class TestGuessit(TestCase):
+
+-
+-
+- def checkMinimumFieldsCorrect(self, filetype, filename, removeType=True):
++ def checkMinimumFieldsCorrect(self, filetype, filename, remove_type=True,
++ exclude_files=None):
+ groundTruth = yaml.load(load_file_in_same_dir(__file__, filename))
+ def guess_func(string):
+ return guess_file_info(string, filetype=filetype)
+
+- return self.checkFields(groundTruth, guess_func, removeType)
++ return self.checkFields(groundTruth, guess_func, remove_type, exclude_files)
+
+- def checkFields(self, groundTruth, guess_func, removeType=True):
++
++ def checkFields(self, groundTruth, guess_func, remove_type=True,
++ exclude_files=None):
+ correct, total = 0, 0
++ exclude_files = exclude_files or []
+
+ for filename, required_fields in groundTruth.items():
+ filename = u(filename)
++ if filename in exclude_files:
++ continue
++
+ log.debug('\n' + '-' * 120)
+ log.info('Guessing information for file: %s' % filename)
+
+@@ -85,7 +90,7 @@ def error(*args):
+ is_incomplete[0] = True
+
+ # no need for these in the unittests
+- if removeType:
++ if remove_type:
+ try:
+ del found['type']
+ except:
+diff --git a/tests/test_autodetect.py b/tests/test_autodetect.py
+index 1e0fd9d..e654afb 100644
+--- a/tests/test_autodetect.py
++++ b/tests/test_autodetect.py
+@@ -25,7 +25,7 @@ class TestAutoDetect(TestGuessit):
+ def testAutoDetect(self):
+ self.checkMinimumFieldsCorrect(filetype='autodetect',
+ filename='autodetect.yaml',
+- removeType=False)
++ remove_type=False)
+
+
+ suite = allTests(TestAutoDetect)
+diff --git a/tests/test_autodetect_all.py b/tests/test_autodetect_all.py
+index 6aa1704..cfd3463 100644
+--- a/tests/test_autodetect_all.py
++++ b/tests/test_autodetect_all.py
+@@ -18,23 +18,27 @@
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #
+
+-
++from __future__ import unicode_literals
+ from guessittest import *
+
++IGNORE_EPISODES = [ 'finale ' ]
++IGNORE_MOVIES = []
+
+ class TestAutoDetectAll(TestGuessit):
+ def testAutoMatcher(self):
+ self.checkMinimumFieldsCorrect(filetype='autodetect',
+ filename='autodetect.yaml',
+- removeType=False)
++ remove_type=False)
+
+ def testAutoMatcherMovies(self):
+ self.checkMinimumFieldsCorrect(filetype='autodetect',
+- filename='movies.yaml')
++ filename='movies.yaml',
++ exclude_files=IGNORE_MOVIES)
+
+ def testAutoMatcherEpisodes(self):
+ self.checkMinimumFieldsCorrect(filetype='autodetect',
+- filename='episodes.yaml')
++ filename='episodes.yaml',
++ exclude_files=IGNORE_EPISODES)
+
+
+ suite = allTests(TestAutoDetectAll)
+--
+1.8.1.6
+
+Added by maksbotan@gentoo.org, to be upstreamed
+
+diff -ur /var/tmp/portage/dev-python/guessit-0.5.4/work/guessit-0.5.4/tests/test_language.py guessit-0.5.4/tests/test_language.py
+--- /var/tmp/portage/dev-python/guessit-0.5.4/work/guessit-0.5.4/tests/test_language.py 2013-02-11 03:49:53.000000000 +0400
++++ guessit-0.5.4/tests/test_language.py 2013-04-25 18:41:22.000000000 +0400
+@@ -20,6 +20,7 @@
+
+ from __future__ import unicode_literals
+ from guessittest import *
++import io
+
+ class TestLanguage(TestGuessit):
+
+@@ -81,7 +82,7 @@
+
+ def test_opensubtitles(self):
+ opensubtitles_langfile = file_in_same_dir(__file__, 'opensubtitles_languages_2012_05_09.txt')
+- langs = [ u(l).strip().split('\t') for l in open(opensubtitles_langfile) ][1:]
++ langs = [ u(l).strip().split('\t') for l in io.open(opensubtitles_langfile, encoding="utf8") ][1:]
+ for lang in langs:
+ # check that we recognize the opensubtitles language code correctly
+ # and that we are able to output this code from a language