On 2019-04-29 20:12:28 -0000, Grant Edwards wrote: > On 2019-04-29, DL Neil <[email protected]> wrote: > > Are you aware of a library/utility which will generate and maintain the > > file names of multiple generations of a file? > > Well, the FILES-11 filesystem on VAX/VMS did that automatically, but > that's probably not too helpful. Though I guess Python is actually > available for OpenVMS, and the porting of OpenVMS to AMD64 (aka > x86-64) is progressing: https://www.vmssoftware.com/updates_port.html
Until this is finished you could use something like this:
#!/usr/bin/python3
import os
def open11(file, mode, **kwargs):
if "w" in mode:
try:
oldfile = os.readlink(file)
basename, version = oldfile.split(";")
except FileNotFoundError:
basename = os.path.basename(file)
version = 0
newfile = basename + ";" + str(int(version) + 1)
os.unlink(file)
os.symlink(newfile, file)
return open(file, mode, **kwargs)
if __name__ == "__main__":
with open11("foo", "w") as f:
f.write("test1")
with open11("foo", "w") as f:
f.write("test2")
with open11("foo", "w") as f:
f.write("test3")
:-)
(WARNING: I haven't really tested this)
hp
PS: I like Chris' suggestion to just use git. But it's IMHO only
practical if you plan to keep old versions for ever.
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | [email protected] | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
