From b7dbd8762560b9f43113a8bf6c319e107de86778 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 10 Jun 2015 06:32:13 +0800 Subject: [PATCH] Change py2 octal literals into the new py2/3 syntax --- CHANGES.md | 1 + SickBeard.py | 2 +- sickbeard/naming.py | 2 +- tests/compatibility_tests.py | 5 ++++- tests/name_parser_tests.py | 4 ++-- tests/tv_tests.py | 16 ++++++++-------- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cdf25cc..ab10384 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,6 +34,7 @@ * Add py2/3 regression testing for exception clauses * Change py2 exception clauses to py2/3 compatible clauses * Change py2 print statements to py2/3 compatible functions +* Change py2 octal literals into the new py2/3 syntax * Change Kodi notifier to use requests as opposed to urllib * Change to consolidate scene exceptions and name cache code diff --git a/SickBeard.py b/SickBeard.py index 6584756..99d2b01 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -243,7 +243,7 @@ class SickGear(object): # Make sure that we can create the data dir if not os.access(sickbeard.DATA_DIR, os.F_OK): try: - os.makedirs(sickbeard.DATA_DIR, 0744) + os.makedirs(sickbeard.DATA_DIR, 0o744) except os.error: sys.exit(u'Unable to create data directory: %s Exiting.' % sickbeard.DATA_DIR) diff --git a/sickbeard/naming.py b/sickbeard/naming.py index e5818a6..55d72b8 100644 --- a/sickbeard/naming.py +++ b/sickbeard/naming.py @@ -51,7 +51,7 @@ class TVShow(): def __init__(self): self.name = "Show Name" self.genre = "Comedy" - self.indexerid = 00001 + self.indexerid = 1 self.air_by_date = 0 self.sports = 0 self.anime = 0 diff --git a/tests/compatibility_tests.py b/tests/compatibility_tests.py index 9c80ab3..dd18d84 100644 --- a/tests/compatibility_tests.py +++ b/tests/compatibility_tests.py @@ -16,7 +16,10 @@ class CompatibilityTests(unittest.TestCase): pyfiles.append(os.path.join(path,'SickBeard.py')) - output = subprocess.Popen('2to3 -f except -f print -p %s' % ' '.join(pyfiles), shell=True, stdout=subprocess.PIPE, + output = subprocess.Popen('2to3' + ' -f except' + ' -f numliterals' + ' %s' % ' '.join(pyfiles), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] if output: print('Changes to be made for Python 2/3 compatibility as follows:') diff --git a/tests/name_parser_tests.py b/tests/name_parser_tests.py index 81498d4..447ccec 100644 --- a/tests/name_parser_tests.py +++ b/tests/name_parser_tests.py @@ -127,8 +127,8 @@ simple_test_cases = { '[HorribleSubs] D Gray-Man - 312 (480p) [F501C9BE]': parser.ParseResult(None, 'D Gray-Man', None, [], '480p', 'HorribleSubs', None, [312]), '[SGKK] Tengen Toppa Gurren Lagann - 45-46 (720p h264) [F501C9BE]': parser.ParseResult(None, 'Tengen Toppa Gurren Lagann', None, [], '720p h264', 'SGKK', None, [45, 46]), '[Stratos-Subs]_Infinite_Stratos_-_12_(1280x720_H.264_AAC)_[379759DB]': parser.ParseResult(None, 'Infinite Stratos', None, [], '1280x720_H.264_AAC', 'Stratos-Subs', None, [12]), - '[ShinBunBu-Subs] Bleach - 02-03 (CX 1280x720 x264 AAC)': parser.ParseResult(None, 'Bleach', None, [], 'CX 1280x720 x264 AAC', 'ShinBunBu-Subs', None, [02, 03]), - '[Doki] Hanasaku Iroha - 03 (848x480 h264 AAC) [CB1AA73B]': parser.ParseResult(None, 'Hanasaku Iroha', None, [], '848x480 h264 AAC', 'Doki', None, [03]), + '[ShinBunBu-Subs] Bleach - 02-03 (CX 1280x720 x264 AAC)': parser.ParseResult(None, 'Bleach', None, [], 'CX 1280x720 x264 AAC', 'ShinBunBu-Subs', None, [2, 3]), + '[Doki] Hanasaku Iroha - 03 (848x480 h264 AAC) [CB1AA73B]': parser.ParseResult(None, 'Hanasaku Iroha', None, [], '848x480 h264 AAC', 'Doki', None, [3]), '[UTW]_Fractal_-_01_[h264-720p][96D3F1BF]': parser.ParseResult(None, 'Fractal', None, [], 'h264-720p', 'UTW', None, [1]), '[a-s]_inuyasha_-_028_rs2_[BFDDF9F2]': parser.ParseResult(None, 'inuyasha', None, [], 'BFDDF9F2', 'a-s', None, [28]), '[HorribleSubs] Fairy Tail S2 - 37 [1080p]': parser.ParseResult(None,'Fairy Tail S2', None, [], '1080p', 'HorribleSubs', None, [37]), diff --git a/tests/tv_tests.py b/tests/tv_tests.py index 458764a..8e5622b 100644 --- a/tests/tv_tests.py +++ b/tests/tv_tests.py @@ -31,11 +31,11 @@ class TVShowTests(test.SickbeardTestDBCase): sickbeard.showList = [] def test_init_indexerid(self): - show = TVShow(1, 0001, "en") - self.assertEqual(show.indexerid, 0001) + show = TVShow(1, 1, "en") + self.assertEqual(show.indexerid, 1) def test_change_indexerid(self): - show = TVShow(1, 0001, "en") + show = TVShow(1, 1, "en") show.name = "show name" show.tvrname = "show name" show.network = "cbs" @@ -48,14 +48,14 @@ class TVShowTests(test.SickbeardTestDBCase): show.saveToDB() show.loadFromDB(skipNFO=True) - show.indexerid = 0002 + show.indexerid = 2 show.saveToDB() show.loadFromDB(skipNFO=True) - self.assertEqual(show.indexerid, 0002) + self.assertEqual(show.indexerid, 2) def test_set_name(self): - show = TVShow(1, 0001, "en") + show = TVShow(1, 1, "en") show.name = "newName" show.saveToDB() show.loadFromDB(skipNFO=True) @@ -69,7 +69,7 @@ class TVEpisodeTests(test.SickbeardTestDBCase): sickbeard.showList = [] def test_init_empty_db(self): - show = TVShow(1, 0001, "en") + show = TVShow(1, 1, "en") ep = TVEpisode(show, 1, 1) ep.name = "asdasdasdajkaj" ep.saveToDB() @@ -84,7 +84,7 @@ class TVTests(test.SickbeardTestDBCase): sickbeard.showList = [] def test_getEpisode(self): - show = TVShow(1, 0001, "en") + show = TVShow(1, 1, "en") show.name = "show name" show.tvrname = "show name" show.network = "cbs"