Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make python3 compatible #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions meeting
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python

from __future__ import print_function
#
# A simple tool to manage the discuss meetings.
#
Expand Down Expand Up @@ -45,10 +45,10 @@ def list_meetings():
meetings = [ "%s [%s]" % ( entry['displayname'], ", ".join(entry['names']) )
for entry in rcfile.entries.values() if entry['hostname'] == server ]
meetings.sort()
print "--- Meetings on %s ---" % server
print("--- Meetings on %s ---" % server)
for meeting in meetings:
print "* %s" % meeting
print ""
print("* %s" % meeting)
print("")

def get_meeting(name):
rcfile = discuss.RCFile()
Expand All @@ -66,10 +66,10 @@ def list_acl():
acl = meeting.get_acl()
acl.sort(key = lambda acl: acl[0])

print "%s Principal" % acl_flags
print "%s ---------" % ("-" * len(acl_flags))
print("%s Principal" % acl_flags)
print("%s ---------" % ("-" * len(acl_flags)))
for principal, modes in acl:
print "%s %s" % (modes, principal)
print("%s %s" % (modes, principal))

def set_acl():
meeting = get_meeting(args.meeting)
Expand All @@ -96,7 +96,7 @@ def complete():

meetings = [entry['displayname'] for entry in rcfile.entries.values() if entry['displayname'].startswith(args.prefix)]
meetings.sort()
print " ".join( meetings )
print(" ".join( meetings ))

def parse_args():
global args
Expand Down
5 changes: 3 additions & 2 deletions ndsc
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ def format_transaction_row(trn, width):

def truncate_column(text, maxlen):
if len(text) <= maxlen:
return pad(text, maxlen)
return str(pad(text, maxlen))
else:
return text[0:maxlen-1] + '…'
# python 2 can't concatenate unicode and str-containing-unicode
return str(text[0:maxlen-1]) + '…'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure I understand what's going on here. Looking at the code and the comment, it seems like '...' is str-containing-unicode for python2, and text[0:maxlen-1] is unicode, so we have to force it to string in order to get the concatenation to work? (This also has the side effect of making truncate_column() always return a str.) But how would text[0:maxlen-1] end up being unicode?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text[0:maxlen-1] is unicode because of the changes I made to python-discuss. In python3 the str does nothing, and in python2 I believe it was a str before I changed anything in python-discuss, so I don't think making it always return a str changes anything.


number_column = pad(str(trn.number), number_column_len, True)
sender_column = truncate_column(trn.signature, sender_column_len)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python

from distutils.core import setup
from setuptools import setup

setup(name='discuss-ng',
version='1.1.1',
version='1.2',
description='User interface front-end to the discuss network forum system',
author='Victor Vasiliev',
scripts=['meeting', 'ndsc']
Expand Down