Skip to main content

Small utils for Python

Project description

Language

utilspy

PyPI PyPI - License PyPI - Python Version

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

  • addExt

Add extension to path.

Support Windows and Linux paths.

from utilspy_g4 import addExt

path = '/test/test.png'
ext = '2'
newPath = addExt(path, ext)     # newPath = '/test/test.2.png'
  • compareFrames

Compare 2 frames.

from utilspy_g4 import compareFrames

is_equal = compareFrames('path_to_frame_1.png', 'path_to_frame_2.png')
  • delExt

Del extension from path.

Support Windows and Linux paths.

from utilspy_g4 import delExt

path = '/test/test.png'
newPath = delExt(path)     # newPath = '/test/test'

path = '/test/test.2.png'
newPath = delExt(path)     # newPath = '/test/test.2'

path = '/test/test.2.png'
newPath = delExt(path, 2)     # newPath = '/test/test'
  • templatedRemoveFiles

Remove files by template

from utilspy_g4 import templatedRemoveFiles

templatedRemoveFiles('/tmp/test_*.txt')
  • getExt

Get extension from path.

Support Windows and Linux paths.

from utilspy_g4 import getExt

path = '/test/test.png'
ext = getExt(path)     # ext = 'png'

path = '/test/test.jpeg.png'
ext = getExt(path)     # ext = 'png'

path = '/test/test.jpeg.png'
ext = getExt(path, 2)     # ext = 'jpeg'

path = '/test/test.jpeg.png'
ext = getExt(path, 0)     # ext = ''
  • concatVideo

Concat 2 video files with same codecs and params. It use ffmpeg. Install ffmpeg and add it to PATH.

from utilspy_g4 import concatVideo

concatVideo('path_to_video_1.ts', 'path_to_video_2.ts', 'path_to_output_video.ts')
  • intTo2str

Convert integer to 2 chars string with 0.

from utilspy_g4 import intTo2str

time = f'{intTo2str(2)}:{intTo2str(23)}:{intTo2str(5)}' # time = '02-23-05'
  • getFilesCount

Get files count from template.

Support Windows and Linux paths.

from utilspy_g4 import getFilesCount

getFilesCount('/tmp/test_*.txt')

Changelog


Language

utilspy

PyPI PyPI - License PyPI - Python Version

Небольшие утилитки для Python.


Установка

Установка пакета с PyPi

$ pip install utilspy-g4

Установка пакета из исходного кода

Исходный код размещается на GitHub.
Скачайте его и установите пакет:

$ git clone https://github.com/Genzo4/utilspy
$ cd utilspy
$ pip install -r requirements.txt
$ pip install .

Утилиты

  • addExt

Добавляет дополнительное расширение файла перед его последним расширением.

Обрабатывает как Windows пути, так и Linux.

from utilspy_g4 import addExt

path = '/test/test.png'
ext = '2'
newPath = addExt(path, ext)     # newPath = '/test/test.2.png'
  • compareFrames

Сравнение двух кадров (изображений).

from utilspy_g4 import compareFrames

is_equal = compareFrames('path_to_frame_1.png', 'path_to_frame_2.png')
  • delExt

Удаляет одно или несколько расширений файла

Обрабатывает как Windows пути, так и Linux.

from utilspy_g4 import delExt

path = '/test/test.png'
newPath = delExt(path)     # newPath = '/test/test'

path = '/test/test.2.png'
newPath = delExt(path)     # newPath = '/test/test.2'

path = '/test/test.2.png'
newPath = delExt(path, 2)     # newPath = '/test/test'
  • templatedRemoveFiles

Удаление файлов по шаблону

Обрабатывает как Windows пути, так и Linux.

from utilspy_g4 import templatedRemoveFiles

templatedRemoveFiles('/tmp/test_*.txt')
  • getExt

Возвращает расширение файла. Можно указать какое по счёту расширение надо вернуть.

Обрабатывает как Windows пути, так и Linux.

from utilspy_g4 import getExt

path = '/test/test.png'
ext = getExt(path)     # ext = 'png'

path = '/test/test.jpeg.png'
ext = getExt(path)     # ext = 'png'

path = '/test/test.jpeg.png'
ext = getExt(path, 2)     # ext = 'jpeg'

path = '/test/test.jpeg.png'
ext = getExt(path, 0)     # ext = ''
  • concatVideo

Объединение двух видео файлов с одинаковыми кодеками и параметрами в один файл. Используется ffmpeg. Для использования установите ffmpeg и пропишите его в PATH.

from utilspy_g4 import concatVideo

concatVideo('path_to_video_1.ts', 'path_to_video_2.ts', 'path_to_output_video.ts')
  • intTo2str

Преобразует число в строку из двух символов. Если число состоит из одной цифры, то спереди добавляется '0'.

from utilspy_g4 import intTo2str

time = f'{intTo2str(2)}:{intTo2str(23)}:{intTo2str(5)}' # time = '02-23-05'
  • getFilesCount

Возвращает количество файлов в папке по шаблону.

Обрабатывает как Windows пути, так и Linux.

from utilspy_g4 import getFilesCount

getFilesCount('/tmp/test_*.txt')

Changelog

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utilspy_g4-1.6.0.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

utilspy_g4-1.6.0-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page