Skip to content

Fix issue 68 - #69

Merged
johnscancella merged 4 commits into
LibraryOfCongress:masterfrom
johnscancella:fix_issue_68
Oct 5, 2016
Merged

Fix issue 68#69
johnscancella merged 4 commits into
LibraryOfCongress:masterfrom
johnscancella:fix_issue_68

Conversation

@johnscancella

Copy link
Copy Markdown
Contributor

Shoudl fix issue #68

@acdhaacdha left a comment

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

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

def _find_tag_files(bag_dir):

Copy link
Copy Markdown
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.

Comment threadbagit.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
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threadbagit.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
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

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

@acdhaacdhaSep 23, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

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

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

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

@acdhaacdha left a comment

Copy link
Copy Markdown
Member

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:masterOct 5, 2016
Sign up for freeto 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

@johnscancella@acdha