Skip to content

Fix issue 68 #69

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 4 commits into from
Oct 5, 2016
Merged

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

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

@@ -784,6 +784,15 @@ def _make_tagmanifest_file(alg, bag_dir):
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.

@@ -784,6 +784,15 @@ def _make_tagmanifest_file(alg, bag_dir):
for digest, filename in checksums:
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

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

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

@@ -267,6 +267,37 @@ def test_validate_optional_tagfile(self):
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