From 47390d33899ce0869e5ede1086f195b89e66f601 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Mon, 22 Dec 2008 20:32:49 -0500 Subject: [PATCH] Fewer backslash continuations, in favor of parens. --- httpserver.py | 29 +++++++++++++++-------------- plugins/admin/admin.py | 26 +++++++++++++------------- plugins/music/music.py | 8 ++++---- plugins/photo/photo.py | 8 ++++---- plugins/video/video.py | 10 +++++----- plugins/webvideo/webvideo.py | 6 +++--- 6 files changed, 44 insertions(+), 43 deletions(-) diff --git a/httpserver.py b/httpserver.py index 9e8da9b..5e2eab0 100644 --- a/httpserver.py +++ b/httpserver.py @@ -82,8 +82,9 @@ class TivoHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): command = query['Command'][0] # If we are looking at the root container - if command == "QueryContainer" and \ - (not query.has_key('Container') or query['Container'][0] == '/'): + if (command == "QueryContainer" and + (not query.has_key('Container') or + query['Container'][0] == '/')): self.root_container() return @@ -134,23 +135,23 @@ class TivoHTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): t.admin = '' for section, settings in config.getShares(): if 'type' in settings and settings['type'] == 'admin': - t.admin += 'pyTivo Web Configuration
' + \ - 'pyTivo ToGo
' + t.admin += ('pyTivo Web Configuration
' + + 'pyTivo ToGo
') if t.admin == '': - t.admin = '
No Admin plugin installed in pyTivo.conf' + \ - '
If you wish to use the admin plugin add the ' + \ - 'following lines to pyTivo.conf

' + \ - '[Admin]
type=admin' + t.admin = ('
No Admin plugin installed in pyTivo.conf' + + '
If you wish to use the admin plugin add the ' + + 'following lines to pyTivo.conf

' + + '[Admin]
type=admin') t.shares = 'Video shares:
' for section, settings in config.getShares(): if settings.get('type') == 'video': - t.shares += '' + section + \ - '
' + t.shares += ('' + section + + '
') self.wfile.write(t) diff --git a/plugins/admin/admin.py b/plugins/admin/admin.py index 020a21d..9467576 100644 --- a/plugins/admin/admin.py +++ b/plugins/admin/admin.py @@ -221,9 +221,9 @@ class Admin(Plugin): if 'TiVo' in query: tivoIP = query['TiVo'][0] - theurl = 'https://' + tivoIP + \ - '/TiVoConnect?Command=QueryContainer&ItemCount=' + \ - str(shows_per_page) + '&Container=/NowPlaying' + theurl = ('https://' + tivoIP + + '/TiVoConnect?Command=QueryContainer&ItemCount=' + + str(shows_per_page) + '&Container=/NowPlaying') if 'Folder' in query: folder += str(query['Folder'][0]) theurl += '/' + folder @@ -252,8 +252,8 @@ class Admin(Plugin): t = Template(REDIRECT_TEMPLATE) t.container = cname t.time = '20' - t.url = '/TiVoConnect?Command=NPL&Container=' + \ - quote(cname) + t.url = ('/TiVoConnect?Command=NPL&Container=' + + quote(cname)) t.text = UNABLE % (tivoIP, quote(cname)) handler.wfile.write(t) return @@ -433,8 +433,8 @@ class Admin(Plugin): t = Template(REDIRECT_TEMPLATE) command = query['Redirect'][0] t.time = '3' - t.url = '/TiVoConnect?Command=' + command + '&Container=' + \ - quote(cname) + '&TiVo=' + tivoIP + t.url = ('/TiVoConnect?Command=' + command + '&Container=' + + quote(cname) + '&TiVo=' + tivoIP) t.text = TRANS_INIT % (command, quote(cname), tivoIP) handler.wfile.write(t) else: @@ -443,8 +443,8 @@ class Admin(Plugin): t = Template(REDIRECT_TEMPLATE) command = query['Redirect'][0] t.time = '10' - t.url = '/TiVoConnect?Command=' + command + '&Container=' + \ - quote(cname) + '&TiVo=' + tivoIP + t.url = ('/TiVoConnect?Command=' + command + '&Container=' + + quote(cname) + '&TiVo=' + tivoIP) t.text = MISSING % (command, quote(cname), tivoIP) handler.wfile.write(t) @@ -463,8 +463,8 @@ class Admin(Plugin): handler.end_headers() t = Template(REDIRECT_TEMPLATE) t.time = '3' - t.url = '/TiVoConnect?Command=' + command + '&Container=' + \ - quote(cname) + '&TiVo=' + tivoIP + t.url = ('/TiVoConnect?Command=' + command + '&Container=' + + quote(cname) + '&TiVo=' + tivoIP) t.text = TRANS_STOP % (command, quote(cname), tivoIP) handler.wfile.write(t) @@ -489,7 +489,7 @@ class Admin(Plugin): t = Template(REDIRECT_TEMPLATE) t.container = cname t.time = '2' - t.url = '/TiVoConnect?last_page=NPL&Command=Reset&Container=' + \ - quote(cname) + t.url = ('/TiVoConnect?last_page=NPL&Command=Reset&Container=' + + quote(cname)) t.text = SETTINGS2 % quote(cname) handler.wfile.write(t) diff --git a/plugins/music/music.py b/plugins/music/music.py index 6e2b378..2e81dd8 100644 --- a/plugins/music/music.py +++ b/plugins/music/music.py @@ -112,8 +112,8 @@ class Music(Plugin): unquote(path)[len(name) + 2:]) fname = unicode(fname, 'utf-8') - needs_transcode = os.path.splitext(fname)[1].lower() in TRANSCODE \ - or seek or duration + needs_transcode = (os.path.splitext(fname)[1].lower() in TRANSCODE + or seek or duration) handler.send_response(200) handler.send_header('Content-Type', 'audio/mpeg') @@ -249,8 +249,8 @@ class Music(Plugin): cname = subcname.split('/')[0] local_base_path = self.get_local_base_path(handler, query) - if not handler.server.containers.has_key(cname) or \ - not self.get_local_path(handler, query): + if (not handler.server.containers.has_key(cname) or + not self.get_local_path(handler, query)): handler.send_response(404) handler.end_headers() return diff --git a/plugins/photo/photo.py b/plugins/photo/photo.py index 6fe4bea..acc9ca6 100644 --- a/plugins/photo/photo.py +++ b/plugins/photo/photo.py @@ -167,8 +167,8 @@ class Photo(Plugin): if attrs and not 'odate' in attrs: date = exif_date(exif) if date: - year, month, day, hour, minute, second = \ - (int(x) for x in date.groups()) + year, month, day, hour, minute, second = (int(x) + for x in date.groups()) if year: odate = time.mktime((year, month, day, hour, minute, second, -1, -1, -1)) @@ -265,8 +265,8 @@ class Photo(Plugin): subcname = query['Container'][0] cname = subcname.split('/')[0] local_base_path = self.get_local_base_path(handler, query) - if not handler.server.containers.has_key(cname) or \ - not self.get_local_path(handler, query): + if (not handler.server.containers.has_key(cname) or + not self.get_local_path(handler, query)): handler.send_error(404) return diff --git a/plugins/video/video.py b/plugins/video/video.py index 6727622..8e1b572 100644 --- a/plugins/video/video.py +++ b/plugins/video/video.py @@ -200,9 +200,9 @@ class Video(Plugin): sec = duration_delta.seconds % 60 hours = min / 60 min = min % 60 - metadata['iso_duration'] = 'P' + str(duration_delta.days) + \ - 'DT' + str(hours) + 'H' + str(min) + \ - 'M' + str(sec) + 'S' + metadata['iso_duration'] = ('P' + str(duration_delta.days) + + 'DT' + str(hours) + 'H' + str(min) + + 'M' + str(sec) + 'S') return metadata def QueryContainer(self, handler, query): @@ -210,8 +210,8 @@ class Video(Plugin): subcname = query['Container'][0] cname = subcname.split('/')[0] - if not handler.server.containers.has_key(cname) or \ - not self.get_local_path(handler, query): + if (not handler.server.containers.has_key(cname) or + not self.get_local_path(handler, query)): handler.send_response(404) handler.end_headers() return diff --git a/plugins/webvideo/webvideo.py b/plugins/webvideo/webvideo.py index 501aa50..8aa5f67 100644 --- a/plugins/webvideo/webvideo.py +++ b/plugins/webvideo/webvideo.py @@ -141,9 +141,9 @@ class WebVideo(Video): ip = s.getsockname()[0] port = config.getPort() - data['url'] = 'http://%s:%s' % (ip, port) + \ - urllib.quote('/%s/%s' % (share_name, - os.path.split(file_name)[-1])) + data['url'] = ('http://%s:%s' % (ip, port) + + urllib.quote('/%s/%s' % (share_name, + os.path.split(file_name)[-1]))) data['duration'] = file_info['duration'] / 1000 data['size'] = file_info['size'] -- 2.11.4.GIT