diff options
author | Thomas White <taw@physics.org> | 2017-05-12 15:51:33 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-05-12 15:51:33 +0200 |
commit | 690666e32643302970b1f54bbaa0efe83aac7e86 (patch) | |
tree | cd4e9b32b46160649a1fa4f5c1786b1cbf614356 /scripts/split-by-mask | |
parent | 4227f0b190b08ecc50a49875e86dbb9b14714bdd (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/split-by-mask')
-rwxr-xr-x | scripts/split-by-mask | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/split-by-mask b/scripts/split-by-mask index aede3f43..18b672e4 100755 --- a/scripts/split-by-mask +++ b/scripts/split-by-mask @@ -1,13 +1,13 @@ #!/usr/bin/env python - +# -*- coding: utf-8 -*- # # Split stream according to an external mask # -# Copyright (c) 2014-2016 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-2016 Thomas White <taw@physics.org> +# 2014-2017 Thomas White <taw@physics.org> # import sys @@ -21,7 +21,7 @@ prog = re.compile("^\s+([\d-]+)\s+([\d-]+)\s+([\d-]+)\s+[\d\.\-]+\s+[\d\.\-]+\s+ def process_refln(fline, g, h, mask): match = prog.match(fline) if not match: - print 'Line not understood, WTF? %s' % fline + print('Line not understood, WTF? {}'.format(fline)) return fs = int(round(float(match.group(4)))) ss = int(round(float(match.group(5)))) @@ -48,7 +48,7 @@ op.add_option('', '--mask', action='store', type='string', dest='mask_fn', opt,arg = op.parse_args(sys.argv) if not opt.ifn: - print "You need at least --input" + print("You need at least --input") exit(1) f = open(opt.ifn, 'r') |