projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '14640-api-wb-activejob-upgrade'
[arvados.git]
/
crunch_scripts
/
crunchutil
/
subst.py
diff --git
a/crunch_scripts/crunchutil/subst.py
b/crunch_scripts/crunchutil/subst.py
index 06ef6c1198ffad07d888040794a42dce08e8af16..53def97f9648872e69634b29d701944f3cf59639 100644
(file)
--- a/
crunch_scripts/crunchutil/subst.py
+++ b/
crunch_scripts/crunchutil/subst.py
@@
-1,7
+1,14
@@
-import os
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
import glob
import glob
+import os
+import re
import stat
import stat
+BACKSLASH_ESCAPE_RE = re.compile(r'\\(.)')
+
class SubstitutionError(Exception):
pass
class SubstitutionError(Exception):
pass
@@
-60,7
+67,7
@@
def sub_basename(v):
def sub_glob(v):
l = glob.glob(v)
if len(l) == 0:
def sub_glob(v):
l = glob.glob(v)
if len(l) == 0:
- raise SubstitutionError("$(glob {}) no match fo
nu
d".format(v))
+ raise SubstitutionError("$(glob {}) no match fo
un
d".format(v))
else:
return l[0]
else:
return l[0]
@@
-73,7
+80,7
@@
def do_substitution(p, c, subs=default_subs):
while True:
m = search(c)
if m is None:
while True:
m = search(c)
if m is None:
- return
c
+ return
BACKSLASH_ESCAPE_RE.sub(r'\1', c)
v = do_substitution(p, c[m[0]+2 : m[1]])
var = True
v = do_substitution(p, c[m[0]+2 : m[1]])
var = True