Thanks for the nice introduction to the subprocess module. Have you looked at the pathlib module? It provides an object-oriented way to interact with the filesystem. For example, instead of parsing the stdout from ls, you can get the directory contents using pathlib:
You can also use it to move the draft to the destination.
iflen(fileList)==1:...src=fileList[0]# already a Path objectdst=Path(“./_posts”,getTodaysDate()+“-“+src.name)src.rename(dst)
So pathlib can replace all the file system subprocess calls here! (But you’d still need subprocess for the git calls, of course. There are libraries for that, but nothing in the standard library.)
A Python developer with a knack for math. TKD black belt, ask me about 2013.
Applied Math Alum @SMU, but I can tell you all about commutative rings too.
https://www.pbk.org/
Thanks for the nice introduction to the subprocess module. Have you looked at the pathlib module? It provides an object-oriented way to interact with the filesystem. For example, instead of parsing the stdout from
ls
, you can get the directory contents using pathlib:You can also use it to move the draft to the destination.
So pathlib can replace all the file system subprocess calls here! (But you’d still need subprocess for the git calls, of course. There are libraries for that, but nothing in the standard library.)
It’s part of Python 3 and available on pypi for Python 2.
I should be the one thanking you, this is so cool!