Small utils for Python
Project description
utilspy
Small utils for python
Installation
Package Installation from PyPi
$ pip install utilspy-g4
Package Installation from Source Code
The source code is available on GitHub.
Download and install the package:
$ git clone https://github.com/Genzo4/utilspy
$ cd utilspy
$ pip install -r requirements.txt
$ pip install .
Utils
-
add_ext
Add extension to path.
Support Windows and Linux paths.
from utilspy_g4 import add_ext
path = '/test/test.png'
ext = '2'
new_path = add_ext(path, ext) # new_path = '/test/test.2.png'
-
compare_frames
Compare 2 frames.
from utilspy_g4 import compare_frames
is_equal = compare_frames('path_to_frame_1.png', 'path_to_frame_2.png')
-
del_ext
Del extension from path.
Support Windows and Linux paths.
from utilspy_g4 import del_ext
path = '/test/test.png'
new_path = del_ext(path) # new_path = '/test/test'
path = '/test/test.2.png'
new_path = del_ext(path) # new_path = '/test/test.2'
path = '/test/test.2.png'
new_path = del_ext(path, 2) # new_path = '/test/test'
-
templated_remove_files
Remove files by template
from utilspy_g4 import templated_remove_files
templated_remove_files('/tmp/test_*.txt')
-
get_ext
Get extension from path.
Support Windows and Linux paths.
from utilspy_g4 import get_ext
path = '/test/test.png'
ext = get_ext(path) # ext = 'png'
path = '/test/test.jpeg.png'
ext = get_ext(path) # ext = 'png'
path = '/test/test.jpeg.png'
ext = get_ext(path, 2) # ext = 'jpeg'
path = '/test/test.jpeg.png'
ext = get_ext(path, 0) # ext = ''
-
concat_video
Concat 2 video files with same codecs and params. It use ffmpeg. Install ffmpeg and add it to PATH.
from utilspy_g4 import concat_video
concat_video('path_to_video_1.ts', 'path_to_video_2.ts', 'path_to_output_video.ts')
-
int_to_2str
Convert integer to 2 chars string with 0.
from utilspy_g4 import int_to_2str
time = f'{int_to_2str(2)}:{int_to_2str(23)}:{int_to_2str(5)}' # time = '02-23-05'
-
get_files_count
Get files count from template.
Support Windows and Linux paths.
from utilspy_g4 import get_files_count
get_files_count('/tmp/test_*.txt')
utilspy
Небольшие утилитки для Python.
Установка
Установка пакета с PyPi
$ pip install utilspy-g4
Установка пакета из исходного кода
Исходный код размещается на GitHub.
Скачайте его и установите пакет:
$ git clone https://github.com/Genzo4/utilspy
$ cd utilspy
$ pip install -r requirements.txt
$ pip install .
Утилиты
-
add_ext
Добавляет дополнительное расширение файла перед его последним расширением.
Обрабатывает как Windows пути, так и Linux.
from utilspy_g4 import add_ext
path = '/test/test.png'
ext = '2'
newPath = add_ext(path, ext) # newPath = '/test/test.2.png'
-
compare_frames
Сравнение двух кадров (изображений).
from utilspy_g4 import compare_frames
is_equal = compare_frames('path_to_frame_1.png', 'path_to_frame_2.png')
-
del_ext
Удаляет одно или несколько расширений файла
Обрабатывает как Windows пути, так и Linux.
from utilspy_g4 import del_ext
path = '/test/test.png'
new_path = del_ext(path) # newPath = '/test/test'
path = '/test/test.2.png'
new_path = del_ext(path) # newPath = '/test/test.2'
path = '/test/test.2.png'
new_path = del_ext(path, 2) # newPath = '/test/test'
-
templated_remove_files
Удаление файлов по шаблону
Обрабатывает как Windows пути, так и Linux.
from utilspy_g4 import templated_remove_files
templated_remove_files('/tmp/test_*.txt')
-
get_ext
Возвращает расширение файла. Можно указать какое по счёту расширение надо вернуть.
Обрабатывает как Windows пути, так и Linux.
from utilspy_g4 import get_ext
path = '/test/test.png'
ext = get_ext(path) # ext = 'png'
path = '/test/test.jpeg.png'
ext = get_ext(path) # ext = 'png'
path = '/test/test.jpeg.png'
ext = get_ext(path, 2) # ext = 'jpeg'
path = '/test/test.jpeg.png'
ext = get_ext(path, 0) # ext = ''
-
concat_video
Объединение двух видео файлов с одинаковыми кодеками и параметрами в один файл. Используется ffmpeg. Для использования установите ffmpeg и пропишите его в PATH.
from utilspy_g4 import concat_video
concat_video('path_to_video_1.ts', 'path_to_video_2.ts', 'path_to_output_video.ts')
-
int_to_2str
Преобразует число в строку из двух символов. Если число состоит из одной цифры, то спереди добавляется '0'.
from utilspy_g4 import int_to_2str
time = f'{int_to_2str(2)}:{int_to_2str(23)}:{int_to_2str(5)}' # time = '02-23-05'
-
get_files_count
Возвращает количество файлов в папке по шаблону.
Обрабатывает как Windows пути, так и Linux.
from utilspy_g4 import get_files_count
get_files_count('/tmp/test_*.txt')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for utilspy_g4-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92171787f9b112740eeac92118ec705f2686e4a38d1d9b676118bed0b5112a0b |
|
MD5 | 08de4ed32d7a2baa649cd1955d3ed0b7 |
|
BLAKE2b-256 | f249b63ca33c7d41c42301379fcb6f4eca99ffabca3c37c32e5180ba408b749d |