Skip to content

Add leading r for literal regexes #1176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dicom-archive/database_config_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def get_subject_ids(db, dicom_value=None, scanner_id=None):

imaging = Imaging(db, False)

phantom_match = re.search('(pha)|(test)', dicom_value, re.IGNORECASE)
candidate_match = re.search('([^_]+)_(\d+)_([^_]+)', dicom_value, re.IGNORECASE)
phantom_match = re.search(r'(pha)|(test)', dicom_value, re.IGNORECASE)
candidate_match = re.search(r'([^_]+)_(\d+)_([^_]+)', dicom_value, re.IGNORECASE)

if phantom_match:
subject_id_dict['isPhantom'] = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _run_dcm2niix_conversion(self):
os.makedirs(nifti_tmp_dir)

converter = self.config_db_obj.get_config("converter")
if not re.search('.*dcm2niix.*', converter, re.IGNORECASE):
if not re.search(r'.*dcm2niix.*', converter, re.IGNORECASE):
message = f"{converter} does not appear to be a dcm2niix binary."
self.log_error_and_exit(message, lib.exitcode.PROJECT_CUSTOMIZATION_FAILURE, is_error="Y", is_verbose="N")

Expand Down
4 changes: 2 additions & 2 deletions python/lib/mri.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def fetch_and_insert_nifti_file(self, nifti_file, derivatives=None):
other_assoc_files['bvec_file'] = assoc_file.path
elif re.search(r'bval$', file_info['extension']):
other_assoc_files['bval_file'] = assoc_file.path
elif re.search('tsv$', file_info['extension']) and file_info['suffix'] == 'events':
elif re.search(r'tsv$', file_info['extension']) and file_info['suffix'] == 'events':
other_assoc_files['task_file'] = assoc_file.path
elif re.search('tsv$', file_info['extension']) and file_info['suffix'] == 'physio':
elif re.search(r'tsv$', file_info['extension']) and file_info['suffix'] == 'physio':
other_assoc_files['physio_file'] = assoc_file.path

# read the json file if it exists
Expand Down
2 changes: 1 addition & 1 deletion python/lib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def assemble_hed_service(data_dir, event_tsv_path, event_json_path):
tokenResponse = requests.get(requestTokenURL)

cookie = tokenResponse.headers['Set-Cookie']
token = re.search('csrf_token" value="(.+?)"', tokenResponse.text).group(1)
token = re.search(r'csrf_token" value="(.+?)"', tokenResponse.text).group(1)

# Define headers for assemble POST request, containing token and cookie
headers = {
Expand Down
2 changes: 1 addition & 1 deletion python/mass_nifti_pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def make_pic(file_id, config_file, force, verbose):
if not nii_file_path:
print('WARNING: no file in the database with FileID = ' + str(file_id))
return
if not re.search('.nii.gz$', nii_file_path):
if not re.search(r'.nii.gz$', nii_file_path):
print('WARNING: wrong file type. File ' + nii_file_path + ' is not a .nii.gz file')
return
if not os.path.exists(data_dir + nii_file_path):
Expand Down
Loading