dlpt – Damogran Labs Python Tools

This is just a quick shout-out to our first official Python package on PyPi: dlpt Damogran Labs Python Tools, which was just released!

This library should cover the most everyday use cases that you encounter while writing any Python project. Most of dlpt functions are basically a wrappers around built-in functions, that take care of the most common scenario.

Why?

The easiest way is to write an example.
Lets say I want to copy file on location x to a location y/<subfolder> with the same file name as file on location x.
Now, you might wonder: there is already a builtin shutil.copy, shutil.copyfile and os.makedirs – so, why not just create a folder and copy the file with these functions. And yes, it would work – on a clean environment. What if you want to copy the same file again? Here is the catch. In my experiences, most of the time I found myself wrapping the same lines of code to a different functions, that would handle such scenarios:

  • does destination folder already exist? If not, create it.
  • does file already exist? If it does, remove it before copy.

As you might notice, I claim that most of the time I need to remove existing file before copying new one. If needed, I can explicitly check if file is already existing, but for the most of the time, I just want to copy a file without any fuss. And dlpt.pth.copy_file() does exactly this.

This “example” section could easily be longer than the Python code itself, so let me just say that dlpt library is made in the same way as it explained above for many other code areas: paths, processes, logging, generic list/dictionary comparing, string search operations, time formatting, JSON handlers, …
Basically, stuff that you do most of the time and every time think: “oh, what is that function with weird name?” or “do I really need to take care of every possible scenario one could think of, creating wrapper in every single project?”

Source: https://github.com/damogranlabs/dlpt
PyPi: https://pypi.org/project/dlpt/
Docs: https://dlpt.readthedocs.io/en/latest/

Feel free to comment and contribute!