Your swiss knife to perform fast and easy pythonic stuff HAL | Handy Algorithmic Library
Table of Contents
The problem
Say you want to
- edit the tags of all the songs in a folder
- plot 2D/3D or even 4D points
- fetch the RSS feed of a YouTube channel
- generate tests code for a module
If you want to do this stuff in a fast and easy way, this library is for you
Examples
Edit songs tags
Classic way
import os
from mutagen.mp3 import MP3
my_folder = "path to folder containing songs"
for root, dirs, files in os.walk(my_folder):
for file in files:
audio = MP3(file)
audio["artist"] = "An example"
audio.save()
pyhal
Using from hal.files.models.system import ls_recurse
from hal.files.models.audio import MP3Song
my_folder = "path to folder containing songs"
for file in ls_recurse(my_folder):
MP3Song(file).set_artist("An example")
Plot data
Classic way
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(1., 100.)
y = np.sin(x)
plt.plot(x, y)
plt.show()
pyhal
Using import numpy as np
from hal.charts.plotter import Plot2d
Plot2d().plot(np.sin, 1, 100, 100)
Get YouTube RSS feed of channel
Classic way
No easy way that I know of
pyhal
Using from hal.internet.services.youtube import YoutubeChannel
video_url = "my awesome video of an awesome channel"
channel_feed = YoutubeChannel.get_feed_url_from_video(video_url)
# or if you know the name
channel_name = "my awesome channel"
channel_feed = YoutubeChannel(channel_name).get_feed_url()
Generate module tests code
Classic way
No easy way that I know of
pyhal
Using from hal.tests.gen import TestWriter
src = "path to module source folder"
out = "path to output folder"
w = TestWriter(src)
w.write_tests(out)
Install
Different ways, all equals
pipenv
via $ pipenv install .
$ make install
pip
via $ pip3 install PyHal
$ make pip-install
fast install
-
make fast-init
just copies source files to distitribution files ... run it only if you're sure about dependencies
Usage and documentation
Browse the online documentation here](https://pyhal.readthedocs.io/en/latest/)
or make your own by make docs
Contributing and feedback
- open an issue
- fork this repository
- create your feature branch (
git checkout -b my-new-feature
) - commit your changes (
git commit -am 'Added my new feature'
) - publish the branch (
git push origin my-new-feature
) - open a PR
Suggestions and improvements are welcome!
Authors
Stefano Fogarollo |