From 9cb50de271f33014f3975efd87d234cf73857909 Mon Sep 17 00:00:00 2001 From: Bipin <87369440+bipinkrish@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:48:55 +0530 Subject: [PATCH] Py 3.8 support (#88) * start * add removesuffix func (#3) --- .github/workflows/python.yaml | 2 +- src/python/pose_format/bin/directory.py | 15 ++++++++++----- src/python/pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 8658793..9ee3ea8 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9"] + python-version: ["3.8"] steps: - uses: actions/checkout@v3 diff --git a/src/python/pose_format/bin/directory.py b/src/python/pose_format/bin/directory.py index 7dcd968..7bb9bb2 100644 --- a/src/python/pose_format/bin/directory.py +++ b/src/python/pose_format/bin/directory.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - import argparse import os @@ -7,14 +5,21 @@ from tqdm import tqdm +def removesuffix(text: str, suffix: str): + if text.endswith(suffix): + return text[:-len(suffix)] + else: + return text + + def find_missing_pose_files(directory: str): all_files = os.listdir(directory) mp4_files = [f for f in all_files if f.endswith(".mp4")] - pose_files = {f.removesuffix(".pose") for f in all_files if f.endswith(".pose")} + pose_files = {removesuffix(f, ".pose") for f in all_files if f.endswith(".pose")} missing_pose_files = [] for mp4_file in mp4_files: - base_name = mp4_file.removesuffix(".mp4") + base_name = removesuffix(mp4_file, ".mp4") if base_name not in pose_files: missing_pose_files.append(os.path.join(directory, mp4_file)) @@ -34,5 +39,5 @@ def main(): missing_pose_files = find_missing_pose_files(args.directory) for mp4_path in tqdm(missing_pose_files): - pose_file_name = mp4_path.removesuffix(".mp4") + ".pose" + pose_file_name = removesuffix(mp4_path, ".mp4") + ".pose" pose_video(mp4_path, pose_file_name, 'mediapipe') diff --git a/src/python/pyproject.toml b/src/python/pyproject.toml index 02db4b3..c9c58a0 100644 --- a/src/python/pyproject.toml +++ b/src/python/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ "scipy", "tqdm" ] -requires-python = ">= 3.9" +requires-python = ">= 3.8" [project.optional-dependencies] dev = [