#! /usr/bin/env python
#
# This queries the tags a user has applied to an entity and submits a changed
# list of tags to the MusicBrainz server.
#
# Usage:
#    python tag.py
#
# $Id$
#
import sys
import logging
import musicbrainz2.webservice as mbws
from musicbrainz2.model import Tag
from musicbrainz2.utils import extractUuid

MB_HOST = 'test.musicbrainz.org'

logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)


# Get the username and password
print 'Username: ',
username = sys.stdin.readline().strip()
print 'Password: ',
password = sys.stdin.readline().strip()

# Ask for an entity type to tag.
print 'Entity type to tag (artist, release, track or label): ',
entity = sys.stdin.readline().strip()

# Ask for a MBID to tag.
print 'Enter a MBID: ',
id_ = sys.stdin.readline().strip()
mbid = extractUuid(id_)

# Set the authentication for the webservice.
service = mbws.WebService(host=MB_HOST, username=username, password=password)

# Create a new Query object which will provide
# us an interface to the MusicBrainz web service.
query = mbws.Query(service)

# Read and print the current tags for the given MBID
tags = query.getUserTags(entity, mbid)
print
print 'Current tags: '
print ', '.join([tag.value for tag in tags])

# Ask the user for new tags and submit them
print 'Enter new tags: '
tag_str = sys.stdin.readline().strip()
new_tags = [Tag(tag) for tag in tag_str.split(',')]
query.submitUserTags('artist', mbid, new_tags)

print 'Tags applied'

@@ -179,16 +179,31 @@
  $Id$%0A#%0A
+import getpass%0A
 import s
@@ -492,87 +492,42 @@
 ord%0A
-print 'Username: ',%0Ausername = sys.stdin.readline().strip()%0Aprint 'Password: ',
+username = raw_input('Username: ')
 %0Apas
@@ -538,35 +538,36 @@
 d = 
-sys.stdin.readline().strip(
+getpass.getpass('Password: '
 )%0A%0A#
@@ -594,30 +594,43 @@
 ype to tag.%0A
-print 
+entity = raw_input(
 'Entity type
@@ -677,131 +677,68 @@
 ): '
-,%0Aentity = sys.stdin.readline().strip()%0A%0A# Ask for a MBID to tag.%0Aprint 'Enter a MBID: ',%0Aid_ = sys.stdin.readline().strip(
+)%0A%0A# Ask for a MBID to tag.%0Aid_ = raw_input('Enter a MBID: '
 )%0Amb
@@ -1225,70 +1225,46 @@
 hem%0A
-print 'Enter new tags: '%0Atag_str = sys.stdin.readline().strip(
+tag_str = raw_input('Enter new tags: '
 )%0Ane
@@ -1338,16 +1338,14 @@
 ags(
-'artist'
+entity
 , mb

Use raw_input and getpass rather than reading directly from stdin