Skip to content

Commit ccbc3b7

Browse files
committed
Use r’’ syntax to denote regexp patterns
1 parent c1b26e7 commit ccbc3b7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

bagit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def _make_tag_file(bag_info_path, bag_info):
711711
else:
712712
txt = bag_info[h]
713713
# strip CR, LF and CRLF so they don't mess up the tag file
714-
txt = re.sub('\n|\r|(\r\n)', '', txt)
714+
txt = re.sub(r'\n|\r|(\r\n)', '', txt)
715715
f.write("%s: %s\n" % (h, txt))
716716

717717

@@ -755,7 +755,7 @@ def _make_tagmanifest_file(alg, bag_dir):
755755
files = [f for f in listdir(bag_dir) if isfile(join(bag_dir, f))]
756756
checksums = []
757757
for f in files:
758-
if re.match('^tagmanifest-.+\.txt$', f):
758+
if re.match(r'^tagmanifest-.+\.txt$', f):
759759
continue
760760
with open(join(bag_dir, f), 'rb') as fh:
761761
m = _hasher(alg)
@@ -862,8 +862,8 @@ def _encode_filename(s):
862862

863863

864864
def _decode_filename(s):
865-
s = re.sub("%0D", "\r", s, re.IGNORECASE)
866-
s = re.sub("%0A", "\n", s, re.IGNORECASE)
865+
s = re.sub(r"%0D", "\r", s, re.IGNORECASE)
866+
s = re.sub(r"%0A", "\n", s, re.IGNORECASE)
867867
return s
868868

869869

0 commit comments

Comments
 (0)