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:
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.
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.
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.
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:
Nr. 3 could become cumbersome and I'm not sure whether there is any real use case for it.
Any opinions?