1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
|
Author: Alastair McKinstry <mckinstry@debian.org>
Description: Make the python code python2-3 agnostic.
Last-Updated:2015-05-02
Forwarded: no
Index: adios-1.13.1/utils/skel/bin/skel_extract.py
===================================================================
--- adios-1.13.1.orig/utils/skel/bin/skel_extract.py
+++ adios-1.13.1/utils/skel/bin/skel_extract.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import xml.dom.minidom
import sys
@@ -46,7 +47,7 @@ def extract (skel_output, dest, select,
# check the selected fields
for field in selected_fields:
if not field in keys:
- print 'Invalid selection, field ' + field
+ print('Invalid selection, field ' + field)
return
#Print the header
@@ -153,13 +154,13 @@ def extract_R (skel_output, select, rank
def parse_iteration (filename):
#assume filename ends with .xml
if not filename.endswith (".xml"):
- print "Warning: filename does not meet expectations, should end with .xml"
+ print("Warning: filename does not meet expectations, should end with .xml")
filename = filename [:-4]
iteration = filename.rsplit ("_", 1)[1]
- print iteration
+ print(iteration)
return iteration
Index: adios-1.13.1/utils/skel/lib/skelconf.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skelconf.py
+++ adios-1.13.1/utils/skel/lib/skelconf.py
@@ -1,5 +1,5 @@
+from __future__ import absolute_import, division, print_function, unicode_literals
import xml.dom.minidom
-
import skel_settings
import skel_have_adios_timing
@@ -10,7 +10,7 @@ class skelConfig:
nodes = doc.childNodes
if (nodes.length != 1):
- print 'malformed param file, should contain only a single skel-config element'
+ print('malformed param file, should contain only a single skel-config element')
raise SystemExit
self.config_node = nodes[0]
Index: adios-1.13.1/utils/gpp/ad_config.py
===================================================================
--- adios-1.13.1.orig/utils/gpp/ad_config.py
+++ adios-1.13.1/utils/gpp/ad_config.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import, division, print_function, unicode_literals
import xml.dom.minidom
import type_mapper
@@ -182,7 +183,7 @@ class var:
return None
else:
# place the dimensions in a list and remove the time-index if it is there.
- dims = filter (lambda x : x != self.time_index, self.var_node.getAttribute ('dimensions').split(',') )
+ dims = [x for x in self.var_node.getAttribute ('dimensions').split(',') if x != self.time_index]
cleandims = []
#print(' get_dimensions of var '+self.get_fullpath())
for d in dims:
Index: adios-1.13.1/utils/skel/lib/adios.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/adios.py
+++ adios-1.13.1/utils/skel/lib/adios.py
@@ -1,5 +1,5 @@
+from __future__ import print_function
import xml.dom.minidom
-
import typeMapper
class adiosConfig:
@@ -12,7 +12,7 @@ class adiosConfig:
doc = xml.dom.minidom.parse (config_file_name)
nodes = doc.childNodes
if (nodes.length != 1):
- print 'malformed adios config file, should contain only a single adios-config element'
+ print('malformed adios config file, should contain only a single adios-config element')
raise SystemExit
self.config_node = nodes[0]
@@ -47,7 +47,7 @@ class adiosConfig:
def get_buffer (self):
#return the buffer info
- print 'implement get_buffer'
+ print('implement get_buffer')
def get_host_language (self):
return self.host_language
@@ -157,7 +157,7 @@ class var:
return None
else:
# place the dimensions in a list and remove the time-index if it is there.
- dims = filter (lambda x : x != self.time_index, self.var_node.getAttribute ('dimensions').split(',') )
+ dims = [x for x in self.var_node.getAttribute ('dimensions').split(',') if x != self.time_index]
cleandims = []
for d in dims:
Index: adios-1.13.1/utils/skel/lib/argparse.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/argparse.py
+++ adios-1.13.1/utils/skel/lib/argparse.py
@@ -81,7 +81,6 @@ __all__ = [
'ZERO_OR_MORE',
]
-
import copy as _copy
import os as _os
import re as _re
Index: adios-1.13.1/utils/skel/lib/skel_install.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_install.py
+++ adios-1.13.1/utils/skel/lib/skel_install.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+from __future__ import absolute_import, division, print_function, unicode_literals
import skel_settings
def main(argv=None):
Index: adios-1.13.1/utils/skel/lib/skel_makefile.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_makefile.py
+++ adios-1.13.1/utils/skel/lib/skel_makefile.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+# from __future__ import absolute_import, division, print_function, unicode_literals
+from __future__ import print_function, unicode_literals
import argparse
import os
import sys
@@ -38,7 +40,7 @@ def generate_makefiles_with_args (parent
try:
config = adios.adiosConfig (args.project + '_skel.xml')
except (IOError):
- print "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first."
+ print ("XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first.")
return 1
@@ -49,8 +51,8 @@ def generate_makefiles_with_args (parent
try:
params = skelconf.skelConfig (args.project + '_params.xml')
except (IOError):
- print "Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,"
- print "then check that " + args.project + "_params.xml exists."
+ print("Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,")
+ print("then check that " + args.project + "_params.xml exists.")
return
generate_makefiles (params, config)
@@ -201,10 +203,10 @@ def main(argv=None):
lang = config.get_host_language ()
if 'c' == lang or 'C' == lang:
- print 'generating C flavored Makefile'
+ print('generating C flavored Makefile')
generate_makefiles_c (params)
else:
- print 'generating fortran flavored Makefile'
+ print('generating fortran flavored Makefile')
generate_makefiles_fortran (params)
Index: adios-1.13.1/utils/skel/lib/skel_params.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_params.py
+++ adios-1.13.1/utils/skel/lib/skel_params.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import absolute_import, division, print_function, unicode_literals
import sys
import os
import argparse
@@ -31,11 +32,11 @@ def pparse_command_line (parent_parser):
def generate_param_file_with_args (parent_parser):
args = pparse_command_line (parent_parser)
-
+
try:
config = adios.adiosConfig (args.project + '_skel.xml')
except (IOError):
- print "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first."
+ print("XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first.")
return 1
@@ -43,13 +44,13 @@ def generate_param_file_with_args (paren
# Only proceed if outfilename does not already exist, or if -f was used
if os.path.exists (outfilename) and not args.force:
- print "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename
+ print( "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename)
return 999
try:
config = adios.adiosConfig (args.project + '_skel.xml')
except (IOError):
- print "Error reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first."
+ print( "Error reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first.")
return 1
generate_param_file (args.project, outfilename, config, args.group, args.bpls)
@@ -60,7 +61,7 @@ def generate_param_file (app, outfile, c
param_file = open (outfile, 'w')
if bplsfile is not None:
- print "Using bpls data in %s" % bplsfile
+ print("Using bpls data in %s" % bplsfile)
bpdata = skel_bpls.bpls (open (bplsfile, 'r') )
#Write the file header
@@ -164,7 +165,7 @@ def main(argv=None):
# Only proceed if outfilename does not already exist.
if os.path.exists (outfilename):
- print "%s exists, aborting. Delete the file or use '-f' to overwrite."
+ print("%s exists, aborting. Delete the file or use '-f' to overwrite.")
return 999
generate_param_file (args.project, outfilename, config, args.group)
Index: adios-1.13.1/utils/skel/lib/skel_settings.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_settings.py
+++ adios-1.13.1/utils/skel/lib/skel_settings.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+from __future__ import absolute_import, division, print_function
import sys
import os.path
import shutil
@@ -20,8 +20,8 @@ class skel_settings:
continue
split_line = line.split('=')
if not len (split_line) == 2:
- print 'Malformed configuration line: ' + line
- print 'Ignoring'
+ print('Malformed configuration line: ' + line)
+ print('Ignoring')
continue
self.settings_dict[split_line[0]] = split_line[1]
Index: adios-1.13.1/utils/skel/lib/skel_source.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_source.py
+++ adios-1.13.1/utils/skel/lib/skel_source.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import absolute_import, division, print_function, unicode_literals
import sys
import os
import argparse
@@ -84,25 +85,25 @@ def generate_c_write (outfile, config, p
# same program var (as is done by genarray)
c_file.write ('\n\n// Scalar declarations')
declarations = set()
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
declarations.add (adios.cFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
c_file.write (d)
# Now the initializations
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
c_file.write (adios.cFormatter.get_initialization (v, params.get_group (g.get_name() ) ) )
c_file.write ('\n\n// Array declarations')
declarations = set()
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
declarations.add (adios.cFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
c_file.write ('\n' + d)
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
c_file.write (adios.cFormatter.get_initialization (v, params.get_group (g.get_name() ) ) )
if measure.use_sleep_before_open():
@@ -220,7 +221,7 @@ def generate_c_write (outfile, config, p
# free the array memory
c_file.write ('\n\n// Free the arrays')
frees = set()
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
frees.add ('\nfree (' + v.get_gwrite() + ');')
for f in frees:
@@ -297,7 +298,7 @@ def generate_fortran_write (outfile, con
# same program var (as is done by genarray)
f_file.write ('\n\n! Scalar declarations')
declarations = set()
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
declarations.add (adios.fortranFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
@@ -305,7 +306,7 @@ def generate_fortran_write (outfile, con
f_file.write ('\n\n! Array declarations')
declarations = set()
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
declarations.add (adios.fortranFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
@@ -335,13 +336,13 @@ def generate_fortran_write (outfile, con
# For now, just do the numerical values first, then come back and do the more
# complicated ones. This won't cover something like a depends on b, b depends on c,
# but it will work for the moment
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
#split at the spaces, just print the ones where the third element is a number
init_str = adios.fortranFormatter.get_initialization (v, params.get_group (g.get_name() ) )
if init_str.split (None, 2)[2].isdigit():
f_file.write (init_str)
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
#split at the spaces, just print the ones where the third element is a number
init_str = adios.fortranFormatter.get_initialization (v, params.get_group (g.get_name() ) )
if not init_str.split (None, 2)[2].isdigit():
@@ -350,7 +351,7 @@ def generate_fortran_write (outfile, con
f_file.write ('\n\n! Initialize the arrays')
# And the vector initializations
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
f_file.write (adios.fortranFormatter.get_initialization (v, params.get_group (g.get_name() ) ) )
@@ -535,7 +536,7 @@ def generate_c_read_all (outfile, config
# same program var (as is done by genarray)
c_file.write ('\n\n// Scalar declarations')
declarations = set()
- for v in filter (lambda x : x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if x.is_scalar()]:
declarations.add (adios.cFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
@@ -543,7 +544,7 @@ def generate_c_read_all (outfile, config
c_file.write ('\n\n// Array declarations')
declarations = set()
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
declarations.add (adios.cFormatter.get_declaration (v, params.get_group (g.get_name() ) ) )
for d in declarations:
@@ -620,7 +621,7 @@ def generate_c_read_all (outfile, config
# free the array memory
c_file.write ('\n\n// Free the arrays')
frees = set()
- for v in filter (lambda x : not x.is_scalar(), g.get_vars() ):
+ for v in [x for x in g.get_vars() if not x.is_scalar()]:
frees.add ('\nfree (' + v.get_gwrite() + ');')
for f in frees:
@@ -683,7 +684,7 @@ def create_source_from_yaml (args, confi
# Only proceed if outfilename does not already exist, or if -f was used
if os.path.exists (outfilename) and not args.force:
- print "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename
+ print( "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename)
return 999
skel_file = open (outfilename, 'w')
@@ -707,7 +708,7 @@ def create_sources_with_args (parent_par
try:
config = adios.adiosConfig (args.project + '_skel.xml')
except (IOError):
- print "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first."
+ print( "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first.")
return 1
@@ -715,7 +716,7 @@ def create_sources_with_args (parent_par
create_source_from_yaml(args, config)
else:
if args.noxml:
- print "NOXML generation only supported with yaml input. Generating XML based code."
+ print( "NOXML generation only supported with yaml input. Generating XML based code.")
create_source_from_xml (args, config)
@@ -724,8 +725,8 @@ def create_source_from_xml (args, config
try:
params = skelconf.skelConfig (args.project + '_params.xml')
except (IOError):
- print "Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,"
- print "then check that " + args.project + "_params.xml exists."
+ print( "Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,")
+ print("then check that " + args.project + "_params.xml exists.")
return
# Determine the target language
Index: adios-1.13.1/utils/skel/lib/skel_submit.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_submit.py
+++ adios-1.13.1/utils/skel/lib/skel_submit.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import os
@@ -123,7 +123,7 @@ def generate_submit_scripts_from_yaml (a
# Only proceed if outfilename does not already exist, or if -f was used
if os.path.exists (outfilename) and not args.force:
- print "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename
+ print( "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename)
return 999
skel_file = open (outfilename, 'w')
@@ -154,7 +154,7 @@ def generate_submit_scripts_with_args (p
try:
config = adios.adiosConfig (args.project + '_skel.xml')
except (IOError):
- print "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first."
+ print( "XXError reading " + args.project + "_skel.xml. Try running skel xml " + args.project + " first.")
return 1
@@ -164,8 +164,8 @@ def generate_submit_scripts_with_args (p
try:
params = skelconf.skelConfig (args.project + '_params.xml')
except (IOError):
- print "Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,"
- print "then check that " + args.project + "_params.xml exists."
+ print("Error reading " + args.project + "_params.xml. Try running skel params " + args.project + " first,")
+ print("then check that " + args.project + "_params.xml exists.")
return 1
generate_submit_scripts_from_xml (params)
Index: adios-1.13.1/utils/skel/lib/skel_xml.py
===================================================================
--- adios-1.13.1.orig/utils/skel/lib/skel_xml.py
+++ adios-1.13.1/utils/skel/lib/skel_xml.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import os
import xml.dom.minidom
@@ -68,7 +69,7 @@ def create_from_yaml (project,args):
# Only proceed if outfilename does not already exist, or if -f was used
if os.path.exists (outfilename) and not args.force:
- print "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename
+ print( "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename)
return 999
skel_file = open (outfilename, 'w')
@@ -91,7 +92,7 @@ def create_from_xml (project, args):
# Only proceed if outfilename does not already exist, or if -f was used
if os.path.exists (outfilename) and not args.force:
- print "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename
+ print( "%s exists, aborting. Delete the file or use -f to overwrite." % outfilename)
return 999
skel_file = open (outfilename, 'w')
Index: adios-1.13.1/wrappers/numpy/tests/test_adios_mpi.py
===================================================================
--- adios-1.13.1.orig/wrappers/numpy/tests/test_adios_mpi.py
+++ adios-1.13.1/wrappers/numpy/tests/test_adios_mpi.py
@@ -4,7 +4,7 @@ Example:
$ mpiexec -n 4 python ./test_adios_mpi.py
"""
-
+from __future__ import print_function
import adios_mpi as ad
import numpy as np
from mpi4py import MPI
|