Say I want to delete 'Core.dll'
after 'git pull'
, so I write a hook.
import os
dir = os.path.dirname(__file__)
try:
os.remove(os.path.abspath(dir+os.sep+".."+os.sep+".."+os.sep+"Assets"+os.sep+"Plugins"+os.sep+"Core.dll"))
except OSError:
pass
Say the hook path is 'E:\client\.git\hooks'
, the file I want to delete is in 'E:\client\Assets\Plugins\Core.dll'.
I think my way is very silly, is there any elegant way to get the relative path?
Using pathlib
:
from pathlib import Path
(Path(__file__).absolute().parent.parent.parent/'Assets'/'Plugins'/'Core.dll').unlink()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With