ahankinson / pybagit

Python library for manipulating bagit files.
http://ahankinson.github.io/pybagit
Other
20 stars 8 forks source link

Allow creation of a bag if the directory already exists. #12

Open RKrahl opened 8 years ago

RKrahl commented 8 years ago

Resolve #7.

This is a minimal version of a possible implementation. For the moment, it only adds a "create" flag to the constructor, as discussed in the issue, and ignores OSErrors from mkdir if the directory already exists in _create_bag(). It does not check whether any of the meta files (bagit.txt, ...) in the bag directory already exist and boldly overwrites them. Thanks to the constructor flag, it does not change the behavior of pybagit, unless explicitly requested.

I think, there are three possible ways to proceed from here:

  1. Take the PR as it is now. It does the job and fits at least for my use case. I care only for using already existing data, but not for meta files. This works now.
  2. Check if any meta file exists in the bag directory and throw an error if this is the case. This would prevent overwriting existing files.
  3. If any meta file exists, read it and adapt the newly created bag accordingly rather then writing this file.

Nr. 3 could become cumbersome and I'm not sure whether there is any real use case for it.

Any opinions?

RKrahl commented 8 years ago

Ping!

Could you have a look at the PR and comment on which variant you would prefer?