Skip to content

Commit adafefa

Browse files
committed
BF: make strings using \ into r"" to address warnings
1 parent 38e889c commit adafefa

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

heudiconv/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def add_taskname_to_infofile(infofiles):
895895
for infofile in infofiles:
896896
meta_info = load_json(infofile)
897897
try:
898-
meta_info['TaskName'] = (re.search('(?<=_task-)\w+',
898+
meta_info['TaskName'] = (re.search(r'(?<=_task-)\w+',
899899
op.basename(infofile))
900900
.group(0).split('_')[0])
901901
except AttributeError:

heudiconv/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Ensure they are cleaned up upon exit
2323
atexit.register(tempdirs.cleanup)
2424

25-
_VCS_REGEX = '%s\.(?:git|gitattributes|svn|bzr|hg)(?:%s|$)' % (op.sep, op.sep)
25+
_VCS_REGEX = r'%s\.(?:git|gitattributes|svn|bzr|hg)(?:%s|$)' % (op.sep, op.sep)
2626

2727

2828
@docstring_parameter(_VCS_REGEX)
@@ -161,7 +161,7 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
161161
for f in files_opt:
162162
if op.isdir(f):
163163
files += sorted(find_files(
164-
'.*', topdir=f, exclude_vcs=True, exclude="/\.datalad/"))
164+
'.*', topdir=f, exclude_vcs=True, exclude=r"/\.datalad/"))
165165
else:
166166
files.append(f)
167167

heudiconv/tests/test_heuristics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_scans_keys_reproin(tmpdir, invocation):
124124
if i != 0:
125125
assert(os.path.exists(pjoin(dirname(scans_keys[0]), row[0])))
126126
assert(re.match(
127-
'^[\d]{4}-[\d]{2}-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}.[\d]{6}$',
127+
r'^[\d]{4}-[\d]{2}-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}.[\d]{6}$',
128128
row[1]))
129129

130130

heudiconv/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,20 @@ def json_dumps_pretty(j, indent=2, sort_keys=True):
259259
'[\n ]+("?[-+.0-9e]+"?,?) *\n(?= *"?[-+.0-9e]+"?)', r' \1',
260260
js, flags=re.MULTILINE)
261261
# uniform no spaces before ]
262-
js_ = re.sub(" *\]", "]", js_)
262+
js_ = re.sub(r" *\]", "]", js_)
263263
# uniform spacing before numbers
264264
# But that thing could screw up dates within strings which would have 2 spaces
265265
# in a date like Mar 3 2017, so we do negative lookahead to avoid changing
266266
# in those cases
267267
#import pdb; pdb.set_trace()
268268
js_ = re.sub(
269-
'(?<!\w{3})' # negative lookbehind for the month
270-
' *("?[-+.0-9e]+"?)'
271-
'(?! [123]\d{3})' # negative lookahead for a year
272-
'(?P<space> ?)[ \n]*',
269+
r'(?<!\w{3})' # negative lookbehind for the month
270+
r' *("?[-+.0-9e]+"?)'
271+
r'(?! [123]\d{3})' # negative lookahead for a year
272+
r'(?P<space> ?)[ \n]*',
273273
r' \1\g<space>', js_)
274274
# no spaces after [
275-
js_ = re.sub('\[ ', '[', js_)
275+
js_ = re.sub(r'\[ ', '[', js_)
276276
# the load from the original dump and reload from tuned up
277277
# version should result in identical values since no value
278278
# must be changed, just formatting.

0 commit comments

Comments
 (0)