Skip to content

Conversation

johnscancella
Copy link
Contributor

Shoudl fix issue #68

Copy link
Member

@acdha acdha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me but I would change the filename processing for clarity

bagit.py Outdated
if re.match(r'^tagmanifest-.+\.txt$', filename):
continue
#remove everything up to the bag_dir directory
p=join(dirName, filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be p = following PEP-8.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

for digest, filename in checksums:
tagmanifest.write('%s %s\n' % (digest, filename))

def _find_tag_files(bag_dir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Python community has increasingly discouraged the convention of using _ prefixes like this, but there's precedent in the other functions in this file. I'd be inclined to remove it.

bagit.py Outdated
tagmanifest.write('%s %s\n' % (digest, filename))

def _find_tag_files(bag_dir):
for dirName, subdirList, fileList in os.walk(bag_dir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP-8 encourages dir_name, etc. I generally prefer to use plural names like subdirectories, filenames, rather than a list suffix but am ±0 on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

bagit.py Outdated
for dirName, subdirList, fileList in os.walk(bag_dir):
if not re.match(r'.*data$', dirName):
for filename in fileList:
if re.match(r'^tagmanifest-.+\.txt$', filename):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using a file regex, this could be faster and potentially easier to read as if filename.startswith('tagmanifest-')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

bagit.py Outdated
continue
#remove everything up to the bag_dir directory
p=join(dirName, filename)
yield p[len(bag_dir)+1:]
Copy link
Member

@acdha acdha Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistically, this should have spaces around operators (len(bag_dir) + 1) following PEP-8.

Logically, if I'm understanding it correctly this could also be written as yield os.path.relpath(p, start=bag_dir)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, didn't know that this existed. Done

test.py Outdated
os.remove(j(tagdir, "tagfile"))
bag = bagit.Bag(self.tmpdir)
self.assertRaises(bagit.BagValidationError, self.validate, bag)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds trailing whitespace, which makes diffs noisier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@acdha acdha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@johnscancella johnscancella merged commit 3375cd7 into LibraryOfCongress:master Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants