def prompt_layer_selection(self, node, layers):
        """Ask user what to do when an old node is contained in more than one layer.
        Possible answers are:
            * use default layer (default answer if pressing enter)
            * choose layer
            * discard node
        """
        valid = {
            "default": "default",
            "def": "default",
            "discard": "discard",
            "dis": "discard",
        }
        question = """Cannot automatically determine layer for node "%s" because there \
are %d layers available in that area, what do you want to do?\n\n""" % (node.name, len(layers))

        available_layers = ""
        for layer in layers:
            available_layers += "%d (%s)\n" % (layer.id, layer.name)
            valid[str(layer.id)] = layer.id

        prompt = """\
choose (enter the number of) one of the following layers:
%s
"default"    use default layer (if no default layer specified in settings node will be discarded)
"discard"    discard node

(default action is to use default layer)\n\n""" % available_layers

        sys.stdout.write(question + prompt)

        while True:
            if self.options.get('noinput') is True:
                answer = 'default'
                break

            answer = raw_input().lower()
            if answer == '':
                answer = "default"

            if answer in valid:
                answer = valid[answer]
                break
            else:
                sys.stdout.write("Please respond with one of the valid answers\n")

        sys.stdout.write("\n")
        return answer
def prompt_layer_selection ( self , node , layers ) : valid = { "default" : "default" , "def" : "default" , "discard" : "discard" , "dis" : "discard" , } question = """Cannot automatically determine layer for node "%s" because there \
are %d layers available in that area, what do you want to do?\n\n""" % ( node . name , len ( layers ) ) available_layers = "" for layer in layers : available_layers += "%d (%s)\n" % ( layer . id , layer . name ) valid [ str ( layer . id ) ] = layer . id prompt = """\
choose (enter the number of) one of the following layers:
%s
"default"    use default layer (if no default layer specified in settings node will be discarded)
"discard"    discard node
(default action is to use default layer)\n\n""" % available_layers sys . stdout . write ( question + prompt ) while True : if self . options . get ( 'noinput' ) is True : answer = 'default' break answer = raw_input ( ) . lower ( ) if answer == '' : answer = "default" if answer in valid : answer = valid [ answer ] break else : sys . stdout . write ( "Please respond with one of the valid answers\n" ) sys . stdout . write ( "\n" ) return answer
Ask user what to do when an old node is contained in more than one layer.
        Possible answers are:
            * use default layer (default answer if pressing enter)
            * choose layer
            * discard node