yta-video-frame-time 0.0.12__tar.gz → 0.0.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of yta-video-frame-time might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yta-video-frame-time
3
- Version: 0.0.12
3
+ Version: 0.0.16
4
4
  Summary: Youtube Autonomous Video Frame Time Module
5
5
  License-File: LICENSE
6
6
  Author: danialcala94
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yta-video-frame-time"
3
- version = "0.0.12"
3
+ version = "0.0.16"
4
4
  description = "Youtube Autonomous Video Frame Time Module"
5
5
  authors = [
6
6
  {name = "danialcala94",email = "danielalcalavalera@gmail.com"}
@@ -17,6 +17,7 @@ packages = [{include = "yta_video_frame_time", from = "src"}]
17
17
 
18
18
  [tool.poetry.group.dev.dependencies]
19
19
  pytest = "^8.3.5"
20
+ yta_testing = ">=0.0.1"
20
21
 
21
22
  [build-system]
22
23
  requires = ["poetry-core>=2.0.0,<3.0.0"]
@@ -0,0 +1,99 @@
1
+ """
2
+ TODO: I think this module should not be here, or maybe
3
+ yes, but I need this decorator.
4
+ """
5
+ from functools import wraps
6
+
7
+
8
+ def parameter_to_time_interval(
9
+ param_name: str
10
+ ):
11
+ """
12
+ Force the parameter with the given `param_name` to
13
+ be a `TimeInterval` instance.
14
+
15
+ Values accepted:
16
+ - `TimeInterval` instance
17
+ - `tuple[float, float]` that will be `(start, end)`
18
+ """
19
+ def decorator(
20
+ func
21
+ ):
22
+ @wraps(func)
23
+ def wrapper(
24
+ *args,
25
+ **kwargs
26
+ ):
27
+ from inspect import signature
28
+ from yta_validation import PythonValidator
29
+ from yta_video_frame_time.interval import TimeInterval
30
+
31
+ sig = signature(func)
32
+ bound = sig.bind(*args, **kwargs)
33
+ bound.apply_defaults()
34
+
35
+ value = bound.arguments[param_name]
36
+
37
+ if PythonValidator.is_instance_of(value, TimeInterval):
38
+ pass
39
+ elif (
40
+ PythonValidator.is_tuple(value) and
41
+ len(value) == 2
42
+ ):
43
+ value = TimeInterval(*value)
44
+ bound.arguments[param_name] = value
45
+ else:
46
+ raise Exception(f'The "{param_name}" parameter must be a TimeInterval or a tuple[float, float].')
47
+
48
+ return func(*bound.args, **bound.kwargs)
49
+
50
+ return wrapper
51
+
52
+ return decorator
53
+
54
+ # TODO: Remove when we have everything unified
55
+ def parameter_to_new_time_interval(
56
+ param_name: str
57
+ ):
58
+ """
59
+ Force the parameter with the given `param_name` to
60
+ be a `NewTimeInterval` instance.
61
+
62
+ Values accepted:
63
+ - `NewTimeInterval` instance
64
+ - `tuple[float, float]` that will be `(start, end)`
65
+ """
66
+ def decorator(
67
+ func
68
+ ):
69
+ @wraps(func)
70
+ def wrapper(
71
+ *args,
72
+ **kwargs
73
+ ):
74
+ from inspect import signature
75
+ from yta_validation import PythonValidator
76
+ from yta_video_frame_time.interval import NewTimeInterval
77
+
78
+ sig = signature(func)
79
+ bound = sig.bind(*args, **kwargs)
80
+ bound.apply_defaults()
81
+
82
+ value = bound.arguments[param_name]
83
+
84
+ if PythonValidator.is_instance_of(value, NewTimeInterval):
85
+ pass
86
+ elif (
87
+ PythonValidator.is_tuple(value) and
88
+ len(value) == 2
89
+ ):
90
+ value = NewTimeInterval(*value)
91
+ bound.arguments[param_name] = value
92
+ else:
93
+ raise Exception(f'The "{param_name}" parameter must be a NewTimeInterval or a tuple[float, float].')
94
+
95
+ return func(*bound.args, **bound.kwargs)
96
+
97
+ return wrapper
98
+
99
+ return decorator