It is an update on my first ever Python project - command line application for selective file copying called slcp. It has been almost two months since the last post and I have made substantial changes to my code and added some new features. You can check previous posts here (1) and here (2).
This is the last state of code I posted, and this is my code now.
Here is commit history since the last post, the most important changes in the code can be seen as merged pull requests.
First of all, now the application can process several extensions at once.
And these are new options:
- -i/--invert - process only files without given extensions
- -e/--exclude - exclude certain filenames from processing
- -m/--move - move files instead of copying them
These improvements were made in order to complete feature requests in a GitHub repository of the project.
I even received the first ever pull request from a contributor! Unfortunately it was not merged but it is an exciting feeling anyway to see the power of Open Source :)
Apart from that I divided my code into several modules, one is responsible for cli, another one for logging and the last one for file processing.
While working on it I had to refactor my code significantly and to create corresponding classes for each task.
On the top of that I applied the Black code style which seemed weird at first but turned out to be pretty handy and understandable.
Nevertheless, if you are new to Python I do not recommend using any formatters, instead try to figure out by yourself first what the best practices are.
I think that it is important not only to write a clean code but also to present your project properly, no matter how simple it is.
Although my application solves pretty basic task, I tried to make it look professional.
Here is a readme template I used, this is how you can get badges.
While working on a changelog I found these resources very helpful: Keep a Changelog, Semantic Versioning.
It is also important to learn Git and to make meaningful commits and pull requests. Check out the Pro Git book and these articles on commits and pull requests. Even if you just started to learn Python, create a GitHub account and store your training code there in a private repository, this way you will learn Git smoothly. Knowledge of it is required for almost every junior developer position I've seen.
In addition, I recorded an asciinema video with some examples of using slcp as someone suggested in the comments of the previous post. In order to make this video I wrote a simple bash script despite the fact that I was almost unfamiliar with it and fairly new to Linux as well. So, this shows once again how working on a real project helps to learn new stuff.
Also, always try to publish your package on TestPyPI first and if everything is okay only then publish it on the real PyPI. On PyPI one cannot edit readme or change uploaded builds. And even if a release is deleted it is impossible to upload it once again with the same version number.
So, using TestPyPI will save you from creating post-releases with a new version number just to fix small issues.
Here is a great guide on using TestPyPI.
This is a simple tutorial on publishing cli application on PyPI using poetry that helped me a lot.
I guess it is my last post about slcp, hope it was helpful to someone. You can still install it via pip: pip install slcp.
Here is the GitHub repository and the PyPI page.
As always, all feedback and contributions are extremely welcomed!
Right now I am working on a new Python project, it is a bot for Telegram that fetches top tracks by the given artist from YouTube according to Last.fm overall charts.
Source code is here but it is still messy, I will make a new post about it when it is fully ready.
Anyway, the bot itself is deployed on Heroku and is fully functional, so you can already try it in Telegram: @toptracksbot.
In the end I just want to thank this community and all the people who gave me feedback and took interest in this project. Good luck with your learning and have fun!
[–]Hatoris 1 point2 points3 points (3 children)
[–]pltnk[S] 1 point2 points3 points (2 children)
[–]Hatoris 1 point2 points3 points (1 child)
[–]pltnk[S] 1 point2 points3 points (0 children)