aboutsummaryrefslogtreecommitdiff
path: root/scripts/find-pairs
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-05-12 15:51:33 +0200
committerThomas White <taw@physics.org>2017-05-12 15:51:33 +0200
commit690666e32643302970b1f54bbaa0efe83aac7e86 (patch)
treecd4e9b32b46160649a1fa4f5c1786b1cbf614356 /scripts/find-pairs
parent4227f0b190b08ecc50a49875e86dbb9b14714bdd (diff)
Make all Python scripts compatible with Python 2 and 3
It would be nice to upgrade completely to Python 3, but this may create problems at SLAC because psana only supports Python 2 (Python 3 is available, but means that users have to jump through hoops to run a simple CrystFEL script). None of our scripts do anything complicated, so they can all be compatible with both so far. If anyone adds a script which requires a particular version, make sure to specify the version in the first line, consistent with PEP 394.
Diffstat (limited to 'scripts/find-pairs')
-rwxr-xr-xscripts/find-pairs37
1 files changed, 18 insertions, 19 deletions
diff --git a/scripts/find-pairs b/scripts/find-pairs
index 4629767d..8c3b69d0 100755
--- a/scripts/find-pairs
+++ b/scripts/find-pairs
@@ -1,14 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
#
# Find pairs of observations from the same pattern
#
-# Copyright © 2014 Deutsches Elektronen-Synchrotron DESY,
-# a research centre of the Helmholtz Association.
+# Copyright © 2014-2017 Deutsches Elektronen-Synchrotron DESY,
+# a research centre of the Helmholtz Association.
#
# Author:
-# 2014 Thomas White <taw@physics.org>
+# 2014-2017 Thomas White <taw@physics.org>
#
import re as regexp
@@ -41,33 +40,33 @@ def find_405(f):
f = open(fn1, 'r')
flines = find_405(f)
-print len(flines),"measurements in",fn1
+print("{} measurements in {}".format(len(flines),fn1))
g = open(fn2, 'r')
glines = find_405(g)
-print len(glines),"measurements in",fn2
+print("{} measurements in {}".format(len(glines),fn2))
-print "\nThe common measurements:\n"
+print("\nThe common measurements:\n")
for fn in flines.keys():
if fn in glines:
- print fn
- print flines[fn].rstrip("\r\n")
- print glines[fn]
- print
+ print(fn)
+ print(flines[fn].rstrip("\r\n"))
+ print(glines[fn])
+ print()
del flines[fn]
del glines[fn]
-print "\nThe measurements only in",fn1,":\n"
+print("\nThe measurements only in {}:\n".format(fn1))
for fn in flines.keys():
- print fn
- print flines[fn].rstrip("\r\n")
- print
+ print(fn)
+ print(flines[fn].rstrip("\r\n"))
+ print()
-print "\nThe measurements only in",fn2,":\n"
+print("\nThe measurements only in {}:\n".format(fn2))
for fn in glines.keys():
- print fn
- print glines[fn].rstrip("\r\n")
- print
+ print(fn)
+ print(glines[fn].rstrip("\r\n"))
+ print("")