On 2011-02-14, Richard Heck wrote:

> I committed two simple fixes for configure.py. Here is what 2to3 says 
> about the rest:

> [rgheck@rghquad lib]$ /usr/lib64/python3.1/Tools/scripts/2to3 configure.py
> RefactoringTool: Skipping implicit fixer: buffer
> RefactoringTool: Skipping implicit fixer: idioms
> RefactoringTool: Skipping implicit fixer: set_literal
> RefactoringTool: Skipping implicit fixer: ws_comma
> RefactoringTool: Refactored configure.py
> --- configure.py        (original)
> +++ configure.py        (refactored)
> @@ -996,7 +996,7 @@
>                   prereq_latex = checkForClassExtension(classname)
>               else:
>                   prereq_list = optAll[1:-1].split(',')
> -                prereq_list = map(checkForClassExtension, prereq_list)
> +                prereq_list = list(map(checkForClassExtension, 
> prereq_list))
>                   prereq_latex = ','.join(prereq_list)
>               prereq_docbook = {'true':'', 'false':'docbook'}[bool_docbook]
>               prereq = {'LaTeX':prereq_latex, 
> 'DocBook':prereq_docbook}[classtype]
> @@ -1280,13 +1280,13 @@
>       ## Parse the command line
>       for op in sys.argv[1:]:   # default shell/for list is $*, the options
>           if op in [ '-help', '--help', '-h' ]:
> -            print '''Usage: configure [options]
> +            print('''Usage: configure [options]
>   Options:
>       --help                   show this help lines
>       --keep-temps             keep temporary files (for debug. purposes)
>       --without-latex-config   do not run LaTeX to determine configuration
>       --with-version-suffix=suffix suffix of binary installed files
> -'''
> +''')
>               sys.exit(0)
>           elif op == '--without-latex-config':
>               lyx_check_config = False
> @@ -1295,7 +1295,7 @@
>           elif op[0:22] == '--with-version-suffix=':  # never mind if op 
> is not long enough
>               version_suffix = op[22:]
>           else:
> -            print "Unknown option", op
> +            print("Unknown option", op)
>               sys.exit(1)
>       #
>       # check if we run from the right directory
> RefactoringTool: Files that need to be modified:
> RefactoringTool: configure.py

> So we have two print statements that need fixing, and one call to map(). 
> For map(), I think the change mentioned works in 2.x anyway, right? So 
> that's easy.

Yes.

> What's the minimum Python version we require these days? If 2.6, then we 
> can handle the print stuff by importing print_function from __future__. 

We can easily use

  print("Unknown option " + op)
  
if I got it right and op is a string variable.¹  
This prints the concatenated string without the parentheses in both
Python 2 and 3.

¹ otherwise it would be print("Unknown option " + str(op))


Günter

Reply via email to