Skip to content

Commit

Permalink
Ask for confirmation when "(Moderated)" is misplaced in a newsgroup d…
Browse files Browse the repository at this point in the history
…escription.
  • Loading branch information
Julien-Elie committed Dec 6, 2008
1 parent 10c71e9 commit dd754ed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
4 changes: 2 additions & 2 deletions signcontrol.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ID = "control-hierarchy@my.news.server.com"
# The e-mail from which you send your control articles.
MAIL = "control-hierarchy@my.news.server.com"

# The host which appears in the Message-ID of articles generated.
# The host which appears in the message-ID of articles generated.
HOST = "my.news.server.com"

# An existing group of your hierarchy (where checkgroups control articles
Expand All @@ -29,7 +29,7 @@ ADMIN_GROUP = "my.hierarchy.admin"
# to MIME-encode it (for instance: "=?ISO-8859-15?Q?Julien_=C9LIE?=").
NAME = "Control"

# The scope of your hierarchy according to USEPRO.
# The scope of your hierarchy according to RFC 5537 (USEPRO).
# For instance: "fr" (for fr.*), "de !de.alt" (for de.* excepting de.alt.*)
# or "de.alt" (for de.alt.*).
CHECKGROUPS_SCOPE = "my.hierarchy"
Expand Down
38 changes: 31 additions & 7 deletions signcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Script to help in managing Usenet hierarchies. It generates control
# articles and handles PGP keys (generation and management).
#
# signcontrol.py -- v. 1.2.0 -- 2008/11/17.
# signcontrol.py -- v. 1.2.1 -- 2008/12/07.
# Written and maintained by Julien ÉLIE.
# The source code is free to use, distribute, modify and study.
#
Expand All @@ -17,6 +17,9 @@
#
# History:
#
# v. 1.2.1: 2008/12/07 -- ask for confirmation when "(Moderated)" is misplaced
# in a newsgroup description.
#
# v. 1.2.0: 2008/11/17 -- support for USEPRO: checkgroups scope, checkgroups
# serial numbers and accurate Content-Type: headers.
#
Expand Down Expand Up @@ -298,8 +301,8 @@ def generate_newgroup(groups, config, group=None, moderated=None, description=No
if raw_input('Is ' + group + ' a moderated newsgroup? (y/n) ' ) == 'y':
moderated = True
print
print 'There is no need to add " (Moderated)" at the end of the description.'
print 'It will be automatically added.'
print 'There is no need to add " (Moderated)" at the very end of the description.'
print 'It will be automatically added, if not already present.'
print
else:
moderated = False
Expand All @@ -308,16 +311,37 @@ def generate_newgroup(groups, config, group=None, moderated=None, description=No
print 'The description should start with a capital and end in a period.'
description = raw_input("Description of " + group + ": ")
if len(description) > 56:
description = None
print_error('The description is too long. Please shorten it.')
print_error('The description is too long. You should shorten it.')
if raw_input('Do you want to continue despite this recommendation? (y/n) ') != 'y':
description = None
continue

moderated_count = description.count('(Moderated)')
if moderated_count > 0:
if not moderated:
if description.endswith(' (Moderated)'):
description = None
print_error('The description must not end with " (Moderated)".')
continue
else:
print_error('The description must not contain "(Moderated)".')
if raw_input('Do you want to continue despite this recommendation? (y/n) ') != 'y':
description = None
continue
elif moderated_count > 1 or not description.endswith(' (Moderated)'):
print_error('The description must not contain "(Moderated)".')
if raw_input('Do you want to continue despite this recommendation? (y/n) ') != 'y':
description = None
continue

print
print 'Here is the information about the newsgroup:'
print 'Name: ' + group
description = description.replace(' (Moderated)', '')

if moderated:
print 'Status: moderated'
description += ' (Moderated)'
if not description.endswith(' (Moderated)'):
description += ' (Moderated)'
else:
print 'Status: unmoderated'
print 'Description: ' + description
Expand Down

0 comments on commit dd754ed

Please sign in to comment.