aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/command
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/command')
-rw-r--r--libbe/command/__init__.py2
-rw-r--r--libbe/command/assign.py2
-rw-r--r--libbe/command/base.py22
-rw-r--r--libbe/command/comment.py2
-rw-r--r--libbe/command/commit.py6
-rw-r--r--libbe/command/depend.py37
-rw-r--r--libbe/command/diff.py6
-rw-r--r--libbe/command/due.py4
-rw-r--r--libbe/command/help.py6
-rw-r--r--libbe/command/html.py14
-rw-r--r--libbe/command/import_xml.py156
-rw-r--r--libbe/command/init.py7
-rw-r--r--libbe/command/list.py19
-rw-r--r--libbe/command/merge.py4
-rw-r--r--libbe/command/new.py2
-rw-r--r--libbe/command/remove.py4
-rw-r--r--libbe/command/serve_commands.py12
-rw-r--r--libbe/command/set.py7
-rw-r--r--libbe/command/severity.py2
-rw-r--r--libbe/command/show.py13
-rw-r--r--libbe/command/status.py2
-rw-r--r--libbe/command/subscribe.py8
-rw-r--r--libbe/command/tag.py8
-rw-r--r--libbe/command/target.py12
-rw-r--r--libbe/command/util.py10
25 files changed, 180 insertions, 187 deletions
diff --git a/libbe/command/__init__.py b/libbe/command/__init__.py
index f1c74d5..18d12a5 100644
--- a/libbe/command/__init__.py
+++ b/libbe/command/__init__.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License along with
# Bugs Everywhere. If not, see <http://www.gnu.org/licenses/>.
-import base
+from . import base
UserError = base.UserError
UsageError = base.UsageError
diff --git a/libbe/command/assign.py b/libbe/command/assign.py
index edc8ed1..4cadc11 100644
--- a/libbe/command/assign.py
+++ b/libbe/command/assign.py
@@ -27,7 +27,7 @@ import libbe.command.util
class Assign (libbe.command.Command):
- u"""Assign an individual or group to fix a bug
+ """Assign an individual or group to fix a bug
>>> import sys
>>> import libbe.bugdir
diff --git a/libbe/command/base.py b/libbe/command/base.py
index f019450..efba1b2 100644
--- a/libbe/command/base.py
+++ b/libbe/command/base.py
@@ -21,9 +21,9 @@
import codecs
import optparse
import os.path
-import StringIO
+import io
import sys
-import urlparse
+import urllib.parse
import libbe
import libbe.storage
@@ -84,8 +84,8 @@ def get_command(command_name):
try:
cmd = libbe.util.plugin.import_by_name(
'libbe.command.%s' % command_name.replace("-", "_"))
- except ImportError, e:
- raise UnknownCommand(command_name, message=unicode(e))
+ except ImportError as e:
+ raise UnknownCommand(command_name, message=str(e))
return cmd
def get_command_class(module=None, command_name=None):
@@ -104,7 +104,7 @@ def get_command_class(module=None, command_name=None):
try:
cname = command_name.capitalize().replace('-', '_')
cmd = getattr(module, cname)
- except ImportError, e:
+ except ImportError as e:
raise UnknownCommand(command_name)
return cmd
@@ -320,9 +320,9 @@ class Command (object):
if 'user-id' in options:
self._user_id = options.pop('user-id')
if len(options) > 0:
- raise UserError, 'Invalid option passed to command %s:\n %s' \
+ raise UserError('Invalid option passed to command %s:\n %s' \
% (self.name, '\n '.join(['%s: %s' % (k,v)
- for k,v in options.items()]))
+ for k,v in list(options.items())])))
in_optional_args = False
for i,arg in enumerate(self.args):
if arg.repeatable == True:
@@ -352,7 +352,7 @@ class Command (object):
'command': self.name,
'parameters': kwargs,
}, context=0)
- url = urlparse.urljoin(self.server, 'run')
+ url = urllib.parse.urljoin(self.server, 'run')
page,final_url,info = libbe.util.http.get_post_url(
url=url, get=False, data=data, agent=self.user_agent)
self.stdout.write(page)
@@ -491,14 +491,14 @@ class StringInputOutput (InputOutput):
u'goodbye\\n'
"""
def __init__(self):
- stdin = StringIO.StringIO()
+ stdin = io.StringIO()
stdin.encoding = 'utf-8'
- stdout = StringIO.StringIO()
+ stdout = io.StringIO()
stdout.encoding = 'utf-8'
InputOutput.__init__(self, stdin, stdout)
def set_stdin(self, stdin_string):
- self.stdin = StringIO.StringIO(stdin_string)
+ self.stdin = io.StringIO(stdin_string)
def get_stdout(self):
ret = self.stdout.getvalue()
diff --git a/libbe/command/comment.py b/libbe/command/comment.py
index 302445c..e110c81 100644
--- a/libbe/command/comment.py
+++ b/libbe/command/comment.py
@@ -138,7 +138,7 @@ class Comment (libbe.command.Command):
estr = 'Please enter your comment above\n\n%s\n\n> %s\n' \
% (header, '\n> '.join(parent_body.splitlines()))
body = libbe.ui.util.editor.editor_string(estr)
- except libbe.ui.util.editor.CantFindEditor, e:
+ except libbe.ui.util.editor.CantFindEditor as e:
raise libbe.command.UserError(
'No comment supplied, and EDITOR not specified.')
if body is None:
diff --git a/libbe/command/commit.py b/libbe/command/commit.py
index 453311f..077980d 100644
--- a/libbe/command/commit.py
+++ b/libbe/command/commit.py
@@ -93,9 +93,9 @@ class Commit (libbe.command.Command):
try:
revision = storage.commit(summary, body=body,
allow_empty=params['allow-empty'])
- print >> self.stdout, 'Committed %s' % revision
- except libbe.storage.EmptyCommit, e:
- print >> self.stdout, e
+ print('Committed %s' % revision, file=self.stdout)
+ except libbe.storage.EmptyCommit as e:
+ print(e, file=self.stdout)
return 1
def _long_help(self):
diff --git a/libbe/command/depend.py b/libbe/command/depend.py
index 0040cf3..4cb0efd 100644
--- a/libbe/command/depend.py
+++ b/libbe/command/depend.py
@@ -211,10 +211,9 @@ class Depend (libbe.command.Command):
bugdirs, repair_broken_links=True)
assert len(broken) == 0, broken
if len(fixed) > 0:
- print >> self.stdout, 'Fixed the following links:'
- print >> self.stdout, \
- '\n'.join(['%s |-- %s' % (blockee.id.user(), blocker.id.user())
- for blockee,blocker in fixed])
+ print('Fixed the following links:', file=self.stdout)
+ print('\n'.join(['%s |-- %s' % (blockee.id.user(), blocker.id.user())
+ for blockee,blocker in fixed]), file=self.stdout)
return 0
status = parse_status(params['status'])
severity = parse_severity(params['severity'])
@@ -227,19 +226,19 @@ class Depend (libbe.command.Command):
if params['tree-depth'] != None:
dtree = DependencyTree(bugdirs, bugA, params['tree-depth'], filter)
if len(dtree.blocked_by_tree()) > 0:
- print >> self.stdout, '%s blocked by:' % bugA.id.user()
+ print('%s blocked by:' % bugA.id.user(), file=self.stdout)
for depth,node in dtree.blocked_by_tree().thread():
if depth == 0: continue
- print >> self.stdout, (
+ print((
'%s%s'
- % (' '*(depth), self.bug_string(node.bug, params)))
+ % (' '*(depth), self.bug_string(node.bug, params))), file=self.stdout)
if len(dtree.blocks_tree()) > 0:
- print >> self.stdout, '%s blocks:' % bugA.id.user()
+ print('%s blocks:' % bugA.id.user(), file=self.stdout)
for depth,node in dtree.blocks_tree().thread():
if depth == 0: continue
- print >> self.stdout, (
+ print((
'%s%s'
- % (' '*(depth), self.bug_string(node.bug, params)))
+ % (' '*(depth), self.bug_string(node.bug, params))), file=self.stdout)
return 0
if params['blocking-bug-id'] != None:
@@ -254,16 +253,14 @@ class Depend (libbe.command.Command):
blocked_by = get_blocked_by(bugdirs, bugA)
if len(blocked_by) > 0:
- print >> self.stdout, '%s blocked by:' % bugA.id.user()
- print >> self.stdout, \
- '\n'.join([self.bug_string(_bug, params)
- for _bug in blocked_by])
+ print('%s blocked by:' % bugA.id.user(), file=self.stdout)
+ print('\n'.join([self.bug_string(_bug, params)
+ for _bug in blocked_by]), file=self.stdout)
blocks = get_blocks(bugdirs, bugA)
if len(blocks) > 0:
- print >> self.stdout, '%s blocks:' % bugA.id.user()
- print >> self.stdout, \
- '\n'.join([self.bug_string(_bug, params)
- for _bug in blocks])
+ print('%s blocks:' % bugA.id.user(), file=self.stdout)
+ print('\n'.join([self.bug_string(_bug, params)
+ for _bug in blocks]), file=self.stdout)
return 0
def bug_string(self, _bug, params):
@@ -410,13 +407,13 @@ def check_dependencies(bugdirs, repair_broken_links=False):
[]
>>> bugdir.cleanup()
"""
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
if bugdir.storage is not None:
bugdir.load_all_bugs()
good_links = []
fixed_links = []
broken_links = []
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
for bug in bugdir:
for blocker in get_blocked_by(bugdirs, bug):
blocks = get_blocks(bugdirs, blocker)
diff --git a/libbe/command/diff.py b/libbe/command/diff.py
index 1368654..d8aea37 100644
--- a/libbe/command/diff.py
+++ b/libbe/command/diff.py
@@ -89,7 +89,7 @@ class Diff (libbe.command.Command):
try:
subscriptions = libbe.diff.subscriptions_from_string(
params['subscribe'])
- except ValueError, e:
+ except ValueError as e:
raise libbe.command.UserError(e.msg)
bugdirs = self._get_bugdirs()
for uuid,bugdir in sorted(bugdirs.items()):
@@ -124,11 +124,11 @@ class Diff (libbe.command.Command):
bugs = tree.child_by_path('/bugs')
for bug_type in bugs:
uuids.extend([bug.name for bug in bug_type])
- print >> self.stdout, '\n'.join(uuids)
+ print('\n'.join(uuids), file=self.stdout)
else :
rep = tree.report_string()
if rep != None:
- print >> self.stdout, rep
+ print(rep, file=self.stdout)
return 0
def _long_help(self):
diff --git a/libbe/command/due.py b/libbe/command/due.py
index b2a281f..ddf111a 100644
--- a/libbe/command/due.py
+++ b/libbe/command/due.py
@@ -68,9 +68,9 @@ class Due (libbe.command.Command):
if params['due'] == None:
due_time = get_due(bug)
if due_time is None:
- print >> self.stdout, 'No due date assigned.'
+ print('No due date assigned.', file=self.stdout)
else:
- print >> self.stdout, libbe.util.utility.time_to_str(due_time)
+ print(libbe.util.utility.time_to_str(due_time), file=self.stdout)
else:
if params['due'] == 'none':
remove_due(bug)
diff --git a/libbe/command/help.py b/libbe/command/help.py
index 3af7769..981ea1a 100644
--- a/libbe/command/help.py
+++ b/libbe/command/help.py
@@ -95,15 +95,15 @@ class Help (libbe.command.Command):
def _run(self, **params):
if params['topic'] == None:
if hasattr(self.ui, 'help'):
- print >> self.stdout, self.ui.help().rstrip('\n')
+ print(self.ui.help().rstrip('\n'), file=self.stdout)
elif params['topic'] in libbe.command.commands(command_names=True):
module = libbe.command.get_command(params['topic'])
Class = libbe.command.get_command_class(module,params['topic'])
c = Class(ui=self.ui)
self.ui.setup_command(c)
- print >> self.stdout, c.help().rstrip('\n')
+ print(c.help().rstrip('\n'), file=self.stdout)
elif params['topic'] in TOPICS:
- print >> self.stdout, TOPICS[params['topic']].rstrip('\n')
+ print(TOPICS[params['topic']].rstrip('\n'), file=self.stdout)
else:
raise libbe.command.UserError(
'"%s" is neither a command nor topic' % params['topic'])
diff --git a/libbe/command/html.py b/libbe/command/html.py
index 3dfeb75..df87450 100644
--- a/libbe/command/html.py
+++ b/libbe/command/html.py
@@ -23,7 +23,7 @@
import codecs
import email.utils
-import htmlentitydefs
+import html.entities
import itertools
import os
import os.path
@@ -97,7 +97,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
filter_ = self._filters.get(bug_type, self._filters['active'])
bugs = list(itertools.chain(*list(
[bug for bug in bugdir if filter_(bug)]
- for bugdir in self.bugdirs.values())))
+ for bugdir in list(self.bugdirs.values()))))
bugs.sort()
if self.logger:
self.logger.log(
@@ -187,13 +187,13 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
if time.time() > self._refresh:
if self.logger:
self.logger.log(self.log_level, 'refresh bugdirs')
- for bugdir in self.bugdirs.values():
+ for bugdir in list(self.bugdirs.values()):
bugdir.load_all_bugs()
self._refresh = time.time() + 60
def _truncated_bugdir_id(self, bugdir):
return libbe.util.id._truncate(
- bugdir.uuid, self.bugdirs.keys(),
+ bugdir.uuid, list(self.bugdirs.keys()),
min_length=self.min_id_length)
def _truncated_bug_id(self, bug):
@@ -255,7 +255,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
p = libbe.util.id.parse_user(bugdirs, long_id)
except (libbe.util.id.MultipleIDMatches,
libbe.util.id.NoIDMatches,
- libbe.util.id.InvalidIDStructure), e:
+ libbe.util.id.InvalidIDStructure) as e:
return '#%s#' % long_id # re-wrap failures
if p['type'] == 'bugdir':
return '#%s#' % long_id
@@ -881,7 +881,7 @@ will exit after the dump without serving anything over the wire.
def _write_default_template(self, template_dict, out_dir):
out_dir = self._make_dir(out_dir)
- for filename,text in template_dict.iteritems():
+ for filename,text in template_dict.items():
self._write_file(text, [out_dir, filename])
def _write_static_pages(self, app, out_dir):
@@ -904,7 +904,7 @@ will exit after the dump without serving anything over the wire.
for url_,path_ in url_mappings:
content = content.replace(url_, path_)
self._write_file(content=content, path_array=[out_dir, path])
- for bugdir in app.bugdirs.values():
+ for bugdir in list(app.bugdirs.values()):
for bug in bugdir:
bug_dir_url = app.bug_dir(bug=bug)
segments = bug_dir_url.split('/')
diff --git a/libbe/command/import_xml.py b/libbe/command/import_xml.py
index fbf456b..8699e70 100644
--- a/libbe/command/import_xml.py
+++ b/libbe/command/import_xml.py
@@ -37,7 +37,7 @@ import libbe.util.utility
if libbe.TESTING == True:
import doctest
- import StringIO
+ import io
import unittest
import libbe.bugdir
@@ -474,147 +474,147 @@ if libbe.TESTING == True:
self.bugdir.flush_reload()
def testCleanBugdir(self):
uuids = list(self.bugdir.uuids())
- self.failUnless(uuids == ['b'], uuids)
+ self.assertTrue(uuids == ['b'], uuids)
def testNotAddOnly(self):
bugB = self.bugdir.bug_from_uuid('b')
self._execute(self.xml, {}, ['-'])
uuids = list(self.bugdir.uuids())
- self.failUnless(uuids == ['b'], uuids)
+ self.assertTrue(uuids == ['b'], uuids)
bugB = self.bugdir.bug_from_uuid('b')
- self.failUnless(bugB.uuid == 'b', bugB.uuid)
- self.failUnless(bugB.creator == 'John', bugB.creator)
- self.failUnless(bugB.status == 'fixed', bugB.status)
- self.failUnless(bugB.summary == 'a test bug', bugB.summary)
+ self.assertTrue(bugB.uuid == 'b', bugB.uuid)
+ self.assertTrue(bugB.creator == 'John', bugB.creator)
+ self.assertTrue(bugB.status == 'fixed', bugB.status)
+ self.assertTrue(bugB.summary == 'a test bug', bugB.summary)
estrs = ["don't forget your towel",
'helps with space travel',
'watch out for flying dolphins']
- self.failUnless(bugB.extra_strings == estrs, bugB.extra_strings)
+ self.assertTrue(bugB.extra_strings == estrs, bugB.extra_strings)
comments = list(bugB.comments())
- self.failUnless(len(comments) == 3,
+ self.assertTrue(len(comments) == 3,
['%s (%s, %s)' % (c.uuid, c.alt_id, c.body)
for c in comments])
c1 = bugB.comment_from_uuid('c1')
comments.remove(c1)
- self.failUnless(c1.uuid == 'c1', c1.uuid)
- self.failUnless(c1.alt_id == None, c1.alt_id)
- self.failUnless(c1.author == 'Jane', c1.author)
- self.failUnless(c1.body == 'So long\n', c1.body)
+ self.assertTrue(c1.uuid == 'c1', c1.uuid)
+ self.assertTrue(c1.alt_id == None, c1.alt_id)
+ self.assertTrue(c1.author == 'Jane', c1.author)
+ self.assertTrue(c1.body == 'So long\n', c1.body)
c2 = bugB.comment_from_uuid('c2')
comments.remove(c2)
- self.failUnless(c2.uuid == 'c2', c2.uuid)
- self.failUnless(c2.alt_id == None, c2.alt_id)
- self.failUnless(c2.author == 'Jess', c2.author)
- self.failUnless(c2.body == 'World\n', c2.body)
+ self.assertTrue(c2.uuid == 'c2', c2.uuid)
+ self.assertTrue(c2.alt_id == None, c2.alt_id)
+ self.assertTrue(c2.author == 'Jess', c2.author)
+ self.assertTrue(c2.body == 'World\n', c2.body)
c4 = comments[0]
- self.failUnless(len(c4.uuid) == 36, c4.uuid)
- self.failUnless(c4.alt_id == 'c3', c4.alt_id)
- self.failUnless(c4.author == 'Jed', c4.author)
- self.failUnless(c4.body == 'And thanks\n', c4.body)
+ self.assertTrue(len(c4.uuid) == 36, c4.uuid)
+ self.assertTrue(c4.alt_id == 'c3', c4.alt_id)
+ self.assertTrue(c4.author == 'Jed', c4.author)
+ self.assertTrue(c4.body == 'And thanks\n', c4.body)
def testAddOnly(self):
bugB = self.bugdir.bug_from_uuid('b')
initial_bugB_summary = bugB.summary
self._execute(self.xml, {'add-only':True}, ['-'])
uuids = list(self.bugdir.uuids())
- self.failUnless(uuids == ['b'], uuids)
+ self.assertTrue(uuids == ['b'], uuids)
bugB = self.bugdir.bug_from_uuid('b')
- self.failUnless(bugB.uuid == 'b', bugB.uuid)
- self.failUnless(bugB.creator == 'John', bugB.creator)
- self.failUnless(bugB.status == 'open', bugB.status)
- self.failUnless(bugB.summary == initial_bugB_summary, bugB.summary)
+ self.assertTrue(bugB.uuid == 'b', bugB.uuid)
+ self.assertTrue(bugB.creator == 'John', bugB.creator)
+ self.assertTrue(bugB.status == 'open', bugB.status)
+ self.assertTrue(bugB.summary == initial_bugB_summary, bugB.summary)
estrs = ["don't forget your towel",
'helps with space travel']
- self.failUnless(bugB.extra_strings == estrs, bugB.extra_strings)
+ self.assertTrue(bugB.extra_strings == estrs, bugB.extra_strings)
comments = list(bugB.comments())
- self.failUnless(len(comments) == 3,
+ self.assertTrue(len(comments) == 3,
['%s (%s)' % (c.uuid, c.alt_id) for c in comments])
c1 = bugB.comment_from_uuid('c1')
comments.remove(c1)
- self.failUnless(c1.uuid == 'c1', c1.uuid)
- self.failUnless(c1.alt_id == None, c1.alt_id)
- self.failUnless(c1.author == 'Jane', c1.author)
- self.failUnless(c1.body == 'Hello\n', c1.body)
+ self.assertTrue(c1.uuid == 'c1', c1.uuid)
+ self.assertTrue(c1.alt_id == None, c1.alt_id)
+ self.assertTrue(c1.author == 'Jane', c1.author)
+ self.assertTrue(c1.body == 'Hello\n', c1.body)
c2 = bugB.comment_from_uuid('c2')
comments.remove(c2)
- self.failUnless(c2.uuid == 'c2', c2.uuid)
- self.failUnless(c2.alt_id == None, c2.alt_id)
- self.failUnless(c2.author == 'Jess', c2.author)
- self.failUnless(c2.body == 'World\n', c2.body)
+ self.assertTrue(c2.uuid == 'c2', c2.uuid)
+ self.assertTrue(c2.alt_id == None, c2.alt_id)
+ self.assertTrue(c2.author == 'Jess', c2.author)
+ self.assertTrue(c2.body == 'World\n', c2.body)
c4 = comments[0]
- self.failUnless(len(c4.uuid) == 36, c4.uuid)
- self.failUnless(c4.alt_id == 'c3', c4.alt_id)
- self.failUnless(c4.author == 'Jed', c4.author)
- self.failUnless(c4.body == 'And thanks\n', c4.body)
+ self.assertTrue(len(c4.uuid) == 36, c4.uuid)
+ self.assertTrue(c4.alt_id == 'c3', c4.alt_id)
+ self.assertTrue(c4.author == 'Jed', c4.author)
+ self.assertTrue(c4.body == 'And thanks\n', c4.body)
def testRootCommentsNotAddOnly(self):
bugB = self.bugdir.bug_from_uuid('b')
initial_bugB_summary = bugB.summary
self._execute(self.root_comment_xml, {'root':'/b'}, ['-'])
uuids = list(self.bugdir.uuids())
uuids = list(self.bugdir.uuids())
- self.failUnless(uuids == ['b'], uuids)
+ self.assertTrue(uuids == ['b'], uuids)
bugB = self.bugdir.bug_from_uuid('b')
- self.failUnless(bugB.uuid == 'b', bugB.uuid)
- self.failUnless(bugB.creator == 'John', bugB.creator)
- self.failUnless(bugB.status == 'open', bugB.status)
- self.failUnless(bugB.summary == initial_bugB_summary, bugB.summary)
+ self.assertTrue(bugB.uuid == 'b', bugB.uuid)
+ self.assertTrue(bugB.creator == 'John', bugB.creator)
+ self.assertTrue(bugB.status == 'open', bugB.status)
+ self.assertTrue(bugB.summary == initial_bugB_summary, bugB.summary)
estrs = ["don't forget your towel",
'helps with space travel']
- self.failUnless(bugB.extra_strings == estrs, bugB.extra_strings)
+ self.assertTrue(bugB.extra_strings == estrs, bugB.extra_strings)
comments = list(bugB.comments())
- self.failUnless(len(comments) == 3,
+ self.assertTrue(len(comments) == 3,
['%s (%s, %s)' % (c.uuid, c.alt_id, c.body)
for c in comments])
c1 = bugB.comment_from_uuid('c1')
comments.remove(c1)
- self.failUnless(c1.uuid == 'c1', c1.uuid)
- self.failUnless(c1.alt_id == None, c1.alt_id)
- self.failUnless(c1.author == 'Jane', c1.author)
- self.failUnless(c1.body == 'So long\n', c1.body)
+ self.assertTrue(c1.uuid == 'c1', c1.uuid)
+ self.assertTrue(c1.alt_id == None, c1.alt_id)
+ self.assertTrue(c1.author == 'Jane', c1.author)
+ self.assertTrue(c1.body == 'So long\n', c1.body)
c2 = bugB.comment_from_uuid('c2')
comments.remove(c2)
- self.failUnless(c2.uuid == 'c2', c2.uuid)
- self.failUnless(c2.alt_id == None, c2.alt_id)
- self.failUnless(c2.author == 'Jess', c2.author)
- self.failUnless(c2.body == 'World\n', c2.body)
+ self.assertTrue(c2.uuid == 'c2', c2.uuid)
+ self.assertTrue(c2.alt_id == None, c2.alt_id)
+ self.assertTrue(c2.author == 'Jess', c2.author)
+ self.assertTrue(c2.body == 'World\n', c2.body)
c4 = comments[0]
- self.failUnless(len(c4.uuid) == 36, c4.uuid)
- self.failUnless(c4.alt_id == 'c3', c4.alt_id)
- self.failUnless(c4.author == 'Jed', c4.author)
- self.failUnless(c4.body == 'And thanks\n', c4.body)
+ self.assertTrue(len(c4.uuid) == 36, c4.uuid)
+ self.assertTrue(c4.alt_id == 'c3', c4.alt_id)
+ self.assertTrue(c4.author == 'Jed', c4.author)
+ self.assertTrue(c4.body == 'And thanks\n', c4.body)
def testRootCommentsAddOnly(self):
bugB = self.bugdir.bug_from_uuid('b')
initial_bugB_summary = bugB.summary
self._execute(self.root_comment_xml,
{'root':'/b', 'add-only':True}, ['-'])
uuids = list(self.bugdir.uuids())
- self.failUnless(uuids == ['b'], uuids)
+ self.assertTrue(uuids == ['b'], uuids)
bugB = self.bugdir.bug_from_uuid('b')
- self.failUnless(bugB.uuid == 'b', bugB.uuid)
- self.failUnless(bugB.creator == 'John', bugB.creator)
- self.failUnless(bugB.status == 'open', bugB.status)
- self.failUnless(bugB.summary == initial_bugB_summary, bugB.summary)
+ self.assertTrue(bugB.uuid == 'b', bugB.uuid)
+ self.assertTrue(bugB.creator == 'John', bugB.creator)
+ self.assertTrue(bugB.status == 'open', bugB.status)
+ self.assertTrue(bugB.summary == initial_bugB_summary, bugB.summary)
estrs = ["don't forget your towel",
'helps with space travel']
- self.failUnless(bugB.extra_strings == estrs, bugB.extra_strings)
+ self.assertTrue(bugB.extra_strings == estrs, bugB.extra_strings)
comments = list(bugB.comments())
- self.failUnless(len(comments) == 3,
+ self.assertTrue(len(comments) == 3,
['%s (%s)' % (c.uuid, c.alt_id) for c in comments])
c1 = bugB.comment_from_uuid('c1')
comments.remove(c1)
- self.failUnless(c1.uuid == 'c1', c1.uuid)
- self.failUnless(c1.alt_id == None, c1.alt_id)
- self.failUnless(c1.author == 'Jane', c1.author)
- self.failUnless(c1.body == 'Hello\n', c1.body)
+ self.assertTrue(c1.uuid == 'c1', c1.uuid)
+ self.assertTrue(c1.alt_id == None, c1.alt_id)
+ self.assertTrue(c1.author == 'Jane', c1.author)
+ self.assertTrue(c1.body == 'Hello\n', c1.body)
c2 = bugB.comment_from_uuid('c2')
comments.remove(c2)
- self.failUnless(c2.uuid == 'c2', c2.uuid)
- self.failUnless(c2.alt_id == None, c2.alt_id)
- self.failUnless(c2.author == 'Jess', c2.author)
- self.failUnless(c2.body == 'World\n', c2.body)
+ self.assertTrue(c2.uuid == 'c2', c2.uuid)
+ self.assertTrue(c2.alt_id == None, c2.alt_id)
+ self.assertTrue(c2.author == 'Jess', c2.author)
+ self.assertTrue(c2.body == 'World\n', c2.body)
c4 = comments[0]
- self.failUnless(len(c4.uuid) == 36, c4.uuid)
- self.failUnless(c4.alt_id == 'c3', c4.alt_id)
- self.failUnless(c4.author == 'Jed', c4.author)
- self.failUnless(c4.body == 'And thanks\n', c4.body)
+ self.assertTrue(len(c4.uuid) == 36, c4.uuid)
+ self.assertTrue(c4.alt_id == 'c3', c4.alt_id)
+ self.assertTrue(c4.author == 'Jed', c4.author)
+ self.assertTrue(c4.body == 'And thanks\n', c4.body)
unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()])
diff --git a/libbe/command/init.py b/libbe/command/init.py
index b4b3456..8640ae4 100644
--- a/libbe/command/init.py
+++ b/libbe/command/init.py
@@ -99,11 +99,10 @@ class Init (libbe.command.Command):
bd = libbe.bugdir.BugDir(storage, from_storage=False)
self.ui.storage_callbacks.set_bugdirs({bd.uuid: bd})
if bd.storage.name is not 'None':
- print >> self.stdout, \
- 'Using %s for revision control.' % storage.name
+ print('Using %s for revision control.' % storage.name, file=self.stdout)
else:
- print >> self.stdout, 'No revision control detected.'
- print >> self.stdout, 'BE repository initialized.'
+ print('No revision control detected.', file=self.stdout)
+ print('BE repository initialized.', file=self.stdout)
def _long_help(self):
return """
diff --git a/libbe/command/list.py b/libbe/command/list.py
index 4bb9c7b..6d4fcd8 100644
--- a/libbe/command/list.py
+++ b/libbe/command/list.py
@@ -135,11 +135,11 @@ class List (libbe.command.Command):
extra_strings_regexps=extra_strings_regexps)
bugs = list(itertools.chain(*list(
[bugdir.bug_from_uuid(uuid) for uuid in bugdir.uuids()]
- for bugdir in bugdirs.values())))
- bugs = [b for b in bugs if filter(bugdirs, b) == True]
+ for bugdir in list(bugdirs.values()))))
+ bugs = [b for b in bugs if list(filter(bugdirs, b)) == True]
self.result = bugs
if len(bugs) == 0 and params['xml'] == False:
- print >> self.stdout, 'No matching bugs found'
+ print('No matching bugs found', file=self.stdout)
# sort bugs
bugs = self._sort_bugs(bugs, cmp_list)
@@ -147,7 +147,7 @@ class List (libbe.command.Command):
# print list of bugs
if params['ids'] == True:
for bug in bugs:
- print >> self.stdout, bug.id.user()
+ print(bug.id.user(), file=self.stdout)
else:
self._list_bugs(bugs, show_tags=params['tags'], xml=params['xml'])
storage.writeable = writeable
@@ -194,13 +194,12 @@ class List (libbe.command.Command):
def _list_bugs(self, bugs, show_tags=False, xml=False):
if xml == True:
- print >> self.stdout, \
- '<?xml version="1.0" encoding="%s" ?>' % self.stdout.encoding
- print >> self.stdout, '<be-xml>'
+ print('<?xml version="1.0" encoding="%s" ?>' % self.stdout.encoding, file=self.stdout)
+ print('<be-xml>', file=self.stdout)
if len(bugs) > 0:
for bug in bugs:
if xml == True:
- print >> self.stdout, bug.xml(show_comments=True)
+ print(bug.xml(show_comments=True), file=self.stdout)
else:
bug_string = bug.string(shortlist=True)
if show_tags == True:
@@ -210,9 +209,9 @@ class List (libbe.command.Command):
% (attrs,
','.join(libbe.command.tag.get_tags(bug)),
summary))
- print >> self.stdout, bug_string
+ print(bug_string, file=self.stdout)
if xml == True:
- print >> self.stdout, '</be-xml>'
+ print('</be-xml>', file=self.stdout)
def _long_help(self):
return """
diff --git a/libbe/command/merge.py b/libbe/command/merge.py
index 2d52492..85fbb60 100644
--- a/libbe/command/merge.py
+++ b/libbe/command/merge.py
@@ -182,8 +182,8 @@ class Merge (libbe.command.Command):
mergeA.add_reply(comment, allow_time_inversion=True)
bugB.new_comment('Merged into bug #%s#' % bugA.id.long_user())
bugB.status = 'closed'
- print >> self.stdout, 'Merged bugs #%s# and #%s#' \
- % (bugA.id.user(), bugB.id.user())
+ print('Merged bugs #%s# and #%s#' \
+ % (bugA.id.user(), bugB.id.user()), file=self.stdout)
return 0
def _long_help(self):
diff --git a/libbe/command/new.py b/libbe/command/new.py
index 33ede50..b9a3147 100644
--- a/libbe/command/new.py
+++ b/libbe/command/new.py
@@ -120,7 +120,7 @@ class New (libbe.command.Command):
if params['bugdir']:
bugdir = bugdirs[params['bugdir']]
elif len(bugdirs) == 1:
- bugdir = bugdirs.values()[0]
+ bugdir = list(bugdirs.values())[0]
else:
raise libbe.command.UserError(
'Ambiguous bugdir {}'.format(sorted(bugdirs.values())))
diff --git a/libbe/command/remove.py b/libbe/command/remove.py
index 08eb4d1..2ca2699 100644
--- a/libbe/command/remove.py
+++ b/libbe/command/remove.py
@@ -71,9 +71,9 @@ class Remove (libbe.command.Command):
user_ids.append(bug.id.user())
bugdir.remove_bug(bug)
if len(user_ids) == 1:
- print >> self.stdout, 'Removed bug %s' % user_ids[0]
+ print('Removed bug %s' % user_ids[0], file=self.stdout)
else:
- print >> self.stdout, 'Removed bugs %s' % ', '.join(user_ids)
+ print('Removed bugs %s' % ', '.join(user_ids), file=self.stdout)
return 0
def _long_help(self):
diff --git a/libbe/command/serve_commands.py b/libbe/command/serve_commands.py
index d380a8d..dbdb76b 100644
--- a/libbe/command/serve_commands.py
+++ b/libbe/command/serve_commands.py
@@ -27,7 +27,7 @@ import logging
import os.path
import posixpath
import re
-import urllib
+import urllib.request, urllib.parse, urllib.error
import wsgiref.simple_server
import libbe
@@ -40,7 +40,7 @@ import libbe.version
if libbe.TESTING:
import copy
import doctest
- import StringIO
+ import io
import sys
import unittest
import wsgiref.validate
@@ -90,7 +90,7 @@ class ServerApp (libbe.util.wsgi.WSGI_AppObject,
parameters = data.get('parameters', {})
try:
Class = libbe.command.get_command_class(command_name=name)
- except libbe.command.UnknownCommand, e:
+ except libbe.command.UnknownCommand as e:
raise libbe.util.wsgi.HandlerError(
libbe.util.http.HTTP_USER_ERROR, 'UnknownCommand {}'.format(e))
command = Class(ui=self.ui)
@@ -197,12 +197,12 @@ if libbe.TESTING:
'parameters': params,
}, context=0)
self.getURL(self.app, '/run', method='POST', data=data)
- self.failUnless(self.status.startswith('200 '), self.status)
- self.failUnless(
+ self.assertTrue(self.status.startswith('200 '), self.status)
+ self.assertTrue(
('Content-Type', 'application/octet-stream'
) in self.response_headers,
self.response_headers)
- self.failUnless(self.exc_info == None, self.exc_info)
+ self.assertTrue(self.exc_info == None, self.exc_info)
# TODO: integration tests on ServeCommands?
unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
diff --git a/libbe/command/set.py b/libbe/command/set.py
index 859a731..9ec7e2c 100644
--- a/libbe/command/set.py
+++ b/libbe/command/set.py
@@ -79,7 +79,7 @@ class Set (libbe.command.Command):
if params['bugdir']:
bugdir = bugdirs[params['bugdir']]
elif len(bugdirs) == 1:
- bugdir = bugdirs.values()[0]
+ bugdir = list(bugdirs.values())[0]
else:
raise libbe.command.UserError(
'Ambiguous bugdir {}'.format(sorted(bugdirs.values())))
@@ -87,8 +87,7 @@ class Set (libbe.command.Command):
keys = bugdir.settings_properties
keys.sort()
for key in keys:
- print >> self.stdout, \
- '%16s: %s' % (key, _value_string(bugdir, key))
+ print('%16s: %s' % (key, _value_string(bugdir, key)), file=self.stdout)
return 0
if params['setting'] not in bugdir.settings_properties:
msg = 'Invalid setting %s\n' % params['setting']
@@ -96,7 +95,7 @@ class Set (libbe.command.Command):
msg += '\n '.join(bugdir.settings_properties)
raise libbe.command.UserError(msg)
if params['value'] == None:
- print _value_string(bugdir, params['setting'])
+ print(_value_string(bugdir, params['setting']))
else:
if params['value'] == 'none':
params['value'] = EMPTY
diff --git a/libbe/command/severity.py b/libbe/command/severity.py
index 302d523..b97643e 100644
--- a/libbe/command/severity.py
+++ b/libbe/command/severity.py
@@ -74,7 +74,7 @@ class Severity (libbe.command.Command):
if bug.severity != params['severity']:
try:
bug.severity = params['severity']
- except ValueError, e:
+ except ValueError as e:
if e.name != 'severity':
raise e
raise libbe.command.UserError(
diff --git a/libbe/command/show.py b/libbe/command/show.py
index 3b61cc5..c08fd1f 100644
--- a/libbe/command/show.py
+++ b/libbe/command/show.py
@@ -112,10 +112,9 @@ class Show (libbe.command.Command):
% params['id'][0])
sys.__stdout__.write(comment.body)
return 0
- print >> self.stdout, \
- output(bugdirs, params['id'], encoding=self.stdout.encoding,
+ print(output(bugdirs, params['id'], encoding=self.stdout.encoding,
as_xml=params['xml'],
- with_comments=not params['no-comments'])
+ with_comments=not params['no-comments']), file=self.stdout)
return 0
def _long_help(self):
@@ -147,7 +146,7 @@ def _sort_ids(bugdirs, ids, with_comments=True):
root_comments[p['bug']] = [p['comment']]
else:
root_comments[p['bug']].append(p['comment'])
- for bugname in root_comments.keys():
+ for bugname in list(root_comments.keys()):
assert bugname not in bugs, \
'specifically requested both #/%s/%s# and #/%s#' \
% (bugname, root_comments[bugname][0], bugname)
@@ -169,7 +168,7 @@ def _xml_footer():
def output(bugdirs, ids, encoding, as_xml=True, with_comments=True):
if ids == None or len(ids) == 0:
ids = []
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
bugdir.load_all_bugs()
ids.extend([bug.id.user() for bug in bugdir])
uuids,root_comments = _sort_ids(bugdirs, ids, with_comments)
@@ -187,14 +186,14 @@ def output(bugdirs, ids, encoding, as_xml=True, with_comments=True):
if spaces_left > 0:
spaces_left -= 1
lines.append('') # add a blank line between bugs/comments
- for bugname,comments in root_comments.items():
+ for bugname,comments in list(root_comments.items()):
bug = libbe.command.util.bug_from_uuid(bugdirs, bugname)
if as_xml:
lines.extend([' <bug>', ' <uuid>%s</uuid>' % bug.uuid])
for commname in comments:
try:
comment = bug.comment_root.comment_from_uuid(commname)
- except KeyError, e:
+ except KeyError as e:
raise libbe.command.UserError(e.message)
if as_xml:
lines.append(comment.xml(indent=4))
diff --git a/libbe/command/status.py b/libbe/command/status.py
index 96448df..b5dbf2e 100644
--- a/libbe/command/status.py
+++ b/libbe/command/status.py
@@ -75,7 +75,7 @@ class Status (libbe.command.Command):
if bug.status != params['status']:
try:
bug.status = params['status']
- except ValueError, e:
+ except ValueError as e:
if e.name != 'status':
raise e
raise libbe.command.UserError(
diff --git a/libbe/command/subscribe.py b/libbe/command/subscribe.py
index 5884a9a..8541970 100644
--- a/libbe/command/subscribe.py
+++ b/libbe/command/subscribe.py
@@ -143,7 +143,7 @@ class Subscribe (libbe.command.Command):
types = params['types'].split(',')
if len(params['id']) == 0:
- params['id'] = bugdirs.keys()
+ params['id'] = list(bugdirs.keys())
for _id in params['id']:
p = libbe.util.id.parse_user(bugdirs, _id)
if p['type'] == 'bugdir':
@@ -173,7 +173,7 @@ class Subscribe (libbe.command.Command):
if params['list-all'] == True:
subscriptions = []
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
bugdir.load_all_bugs()
subscriptions.extend(
get_bugdir_subscribers(bugdir, servers[0]))
@@ -184,8 +184,8 @@ class Subscribe (libbe.command.Command):
subscriptions.append(estr[len(TAG):])
if len(subscriptions) > 0:
- print >> self.stdout, 'Subscriptions for %s:' % entity_name
- print >> self.stdout, '\n'.join(subscriptions)
+ print('Subscriptions for %s:' % entity_name, file=self.stdout)
+ print('\n'.join(subscriptions), file=self.stdout)
if params['list-all'] == True or params['list'] == True:
storage.writeable = writeable
return 0
diff --git a/libbe/command/tag.py b/libbe/command/tag.py
index 94030b8..3b11e99 100644
--- a/libbe/command/tag.py
+++ b/libbe/command/tag.py
@@ -112,10 +112,10 @@ class Tag (libbe.command.Command):
bugdirs = self._get_bugdirs()
if params['list'] == True:
tags = list(itertools.chain(*
- [get_all_tags(bugdir) for bugdir in bugdirs.values()]))
+ [get_all_tags(bugdir) for bugdir in list(bugdirs.values())]))
tags.sort()
if len(tags) > 0:
- print >> self.stdout, '\n'.join(tags)
+ print('\n'.join(tags), file=self.stdout)
return 0
bugdir,bug,comment = (
@@ -136,8 +136,8 @@ class Tag (libbe.command.Command):
tags.append(estr[len(TAG_TAG):])
if len(tags) > 0:
- print "Tags for %s:" % bug.id.user()
- print '\n'.join(tags)
+ print("Tags for %s:" % bug.id.user())
+ print('\n'.join(tags))
return 0
def _long_help(self):
diff --git a/libbe/command/target.py b/libbe/command/target.py
index 9f76303..0886fbf 100644
--- a/libbe/command/target.py
+++ b/libbe/command/target.py
@@ -101,15 +101,15 @@ class Target (libbe.command.Command):
if params['bugdir']:
bugdir = bugdirs[params['bugdir']]
elif len(bugdirs) == 1:
- bugdir = bugdirs.values()[0]
+ bugdir = list(bugdirs.values())[0]
else:
raise libbe.command.UserError(
'Ambiguous bugdir {}'.format(sorted(bugdirs.values())))
bug = bug_from_target_summary(bugdirs, bugdir, params['target'])
if bug == None:
- print >> self.stdout, 'No target assigned.'
+ print('No target assigned.', file=self.stdout)
else:
- print >> self.stdout, bug.id.long_user()
+ print(bug.id.long_user(), file=self.stdout)
return 0
bugdir,bug,comment = (
libbe.command.util.bugdir_bug_comment_from_user_id(
@@ -117,9 +117,9 @@ class Target (libbe.command.Command):
if params['target'] == None:
target = bug_target(bugdirs, bug)
if target == None:
- print >> self.stdout, 'No target assigned.'
+ print('No target assigned.', file=self.stdout)
else:
- print >> self.stdout, target.summary
+ print(target.summary, file=self.stdout)
else:
if params['target'] == 'none':
target = remove_target(bugdirs, bug)
@@ -204,7 +204,7 @@ def add_target(bugdirs, bugdir, bug, summary):
def targets(bugdirs):
"""Generate all possible target bug summaries."""
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
bugdir.load_all_bugs()
for bug in bugdir:
if bug.severity == 'target':
diff --git a/libbe/command/util.py b/libbe/command/util.py
index 9f76ad8..49f3490 100644
--- a/libbe/command/util.py
+++ b/libbe/command/util.py
@@ -61,7 +61,7 @@ def complete_severity(command, argument, fragment=None):
def assignees(bugdirs):
ret = set()
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
bugdir.load_all_bugs()
ret.update(set([bug.assigned for bug in bugdir
if bug.assigned != None]))
@@ -77,7 +77,7 @@ def complete_extra_strings(command, argument, fragment=None):
def complete_bugdir_id(command, argument, fragment=None):
bugdirs = command._get_bugdirs()
- return bugdirs.keys()
+ return list(bugdirs.keys())
def complete_bug_id(command, argument, fragment=None):
return complete_bug_comment_id(command, argument, fragment,
@@ -96,11 +96,11 @@ def complete_bug_comment_id(command, argument, fragment=None,
root,residual = (fragment, None)
if not root.endswith('/'):
root += '/'
- except libbe.util.id.InvalidIDStructure, e:
+ except libbe.util.id.InvalidIDStructure as e:
return []
except libbe.util.id.NoIDMatches:
return []
- except libbe.util.id.MultipleIDMatches, e:
+ except libbe.util.id.MultipleIDMatches as e:
if e.common == None:
# choose among bugdirs
return e.matches
@@ -226,7 +226,7 @@ def bugdir_bug_comment_from_user_id(bugdirs, id):
def bug_from_uuid(bugdirs, uuid):
error = None
- for bugdir in bugdirs.values():
+ for bugdir in list(bugdirs.values()):
try:
bug = bugdir.bug_from_uuid(uuid)
except libbe.bugdir.NoBugMatches as e: