> object_path = "%s/%s" % (now, DB_PATH.rsplit("/", maxsplit=1)[-1] + ".gz") > AttributeError: 'PosixPath' object has no attribute 'rsplit'
Sorry, I'd meant to imply in the review that string manipulation generally shouldn't be used for path handling now that pathlib.Path is part of the stdlib, i.e. my example was more meant to suggest that all the path handling in the script should be replaced with pathlib.Path stuff rather than trying to mix'n'match strings and Path objects. Generally I find pathlib much nicer to work with than trying to mash strings around with all sorts of methods, but pathlib really only works well if the replacement is wholesale. So, feel free to ignore that bit of my review if you want to stick with string manipulation for now. It may well be preferable than a re-write of all the path handling! Just to sell you on the idea of pathlib a bit though (for future use). This: DB_PATH.rsplit('/', maxsplit=1)[-1] + '.gz' becomes the much more obvious: DB_PATH.with_name(DB_PATH.name + '.gz') Path.with_name just replaces the final component of the path. There's also Path.with_suffix (https://docs.python.org/3.11/library/pathlib.html#pathlib.PurePath.with_suffix) but that would replace any extension whereas we want to add an extra extension here. The date prefix is a little trickier. I'd probably be tempted to use an f-string there: now = dt.datetime.now() object_path = ( Path(f'{now:%Y/%m/%d/%H_%M_%S}') / DB_PATH.with_name(DB_PATH.name + '.gz')) Anyway, as mentioned, feel free to ignore those bits -- but I'd recommend having a read through the pathlib docs at some point -- it's a lovely addition to the stdlib! -- https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/460043 Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:sqlite-db-backup into autopkgtest-cloud:master. -- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp