Skip to content

Commit 4407056

Browse files
JoeSchiffWyattBlue
authored andcommitted
Convert deprecated cython extension class properties to new syntax part 3
1 parent 92a4750 commit 4407056

File tree

6 files changed

+149
-149
lines changed

6 files changed

+149
-149
lines changed

av/data/stream.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ cdef class DataStream(Stream):
1515
def decode(self, packet=None, count=0):
1616
return []
1717

18-
property name:
19-
def __get__(self):
20-
cdef const lib.AVCodecDescriptor *desc = lib.avcodec_descriptor_get(self.ptr.codecpar.codec_id)
21-
if desc == NULL:
22-
return None
23-
return desc.name
18+
@property
19+
def name(self):
20+
cdef const lib.AVCodecDescriptor *desc = lib.avcodec_descriptor_get(self.ptr.codecpar.codec_id)
21+
if desc == NULL:
22+
return None
23+
return desc.name

av/filter/context.pyx

+16-16
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ cdef class FilterContext:
3333
parent = self.filter.ptr.name if self.filter and self.filter.ptr != NULL else None
3434
return f"<av.FilterContext {name} of {parent!r} at 0x{id(self):x}>"
3535

36-
property name:
37-
def __get__(self):
38-
if self.ptr.name != NULL:
39-
return self.ptr.name
40-
41-
property inputs:
42-
def __get__(self):
43-
if self._inputs is None:
44-
self._inputs = alloc_filter_pads(self.filter, self.ptr.input_pads, True, self)
45-
return self._inputs
46-
47-
property outputs:
48-
def __get__(self):
49-
if self._outputs is None:
50-
self._outputs = alloc_filter_pads(self.filter, self.ptr.output_pads, False, self)
51-
return self._outputs
36+
@property
37+
def name(self):
38+
if self.ptr.name != NULL:
39+
return self.ptr.name
40+
41+
@property
42+
def inputs(self):
43+
if self._inputs is None:
44+
self._inputs = alloc_filter_pads(self.filter, self.ptr.input_pads, True, self)
45+
return self._inputs
46+
47+
@property
48+
def outputs(self):
49+
if self._outputs is None:
50+
self._outputs = alloc_filter_pads(self.filter, self.ptr.output_pads, False, self)
51+
return self._outputs
5252

5353
def init(self, args=None, **kwargs):
5454
if self.inited:

av/filter/filter.pyx

+55-55
Original file line numberDiff line numberDiff line change
@@ -31,61 +31,61 @@ cdef class Filter:
3131
if not self.ptr:
3232
raise ValueError(f"no filter {name}")
3333

34-
property descriptor:
35-
def __get__(self):
36-
if self._descriptor is None:
37-
self._descriptor = wrap_avclass(self.ptr.priv_class)
38-
return self._descriptor
39-
40-
property options:
41-
def __get__(self):
42-
if self.descriptor is None:
43-
return
44-
return self.descriptor.options
45-
46-
property name:
47-
def __get__(self):
48-
return self.ptr.name
49-
50-
property description:
51-
def __get__(self):
52-
return self.ptr.description
53-
54-
property flags:
55-
def __get__(self):
56-
return self.ptr.flags
57-
58-
property dynamic_inputs:
59-
def __get__(self):
60-
return bool(self.ptr.flags & lib.AVFILTER_FLAG_DYNAMIC_INPUTS)
61-
62-
property dynamic_outputs:
63-
def __get__(self):
64-
return bool(self.ptr.flags & lib.AVFILTER_FLAG_DYNAMIC_OUTPUTS)
65-
66-
property timeline_support:
67-
def __get__(self):
68-
return bool(self.ptr.flags & lib.AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC)
69-
70-
property slice_threads:
71-
def __get__(self):
72-
return bool(self.ptr.flags & lib.AVFILTER_FLAG_SLICE_THREADS)
73-
74-
property command_support:
75-
def __get__(self):
76-
return self.ptr.process_command != NULL
77-
78-
property inputs:
79-
def __get__(self):
80-
if self._inputs is None:
81-
self._inputs = alloc_filter_pads(self, self.ptr.inputs, True)
82-
return self._inputs
83-
84-
property outputs:
85-
def __get__(self):
86-
if self._outputs is None:
87-
self._outputs = alloc_filter_pads(self, self.ptr.outputs, False)
88-
return self._outputs
34+
@property
35+
def descriptor(self):
36+
if self._descriptor is None:
37+
self._descriptor = wrap_avclass(self.ptr.priv_class)
38+
return self._descriptor
39+
40+
@property
41+
def options(self):
42+
if self.descriptor is None:
43+
return
44+
return self.descriptor.options
45+
46+
@property
47+
def name(self):
48+
return self.ptr.name
49+
50+
@property
51+
def description(self):
52+
return self.ptr.description
53+
54+
@property
55+
def flags(self):
56+
return self.ptr.flags
57+
58+
@property
59+
def dynamic_inputs(self):
60+
return bool(self.ptr.flags & lib.AVFILTER_FLAG_DYNAMIC_INPUTS)
61+
62+
@property
63+
def dynamic_outputs(self):
64+
return bool(self.ptr.flags & lib.AVFILTER_FLAG_DYNAMIC_OUTPUTS)
65+
66+
@property
67+
def timeline_support(self):
68+
return bool(self.ptr.flags & lib.AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC)
69+
70+
@property
71+
def slice_threads(self):
72+
return bool(self.ptr.flags & lib.AVFILTER_FLAG_SLICE_THREADS)
73+
74+
@property
75+
def command_support(self):
76+
return self.ptr.process_command != NULL
77+
78+
@property
79+
def inputs(self):
80+
if self._inputs is None:
81+
self._inputs = alloc_filter_pads(self, self.ptr.inputs, True)
82+
return self._inputs
83+
84+
@property
85+
def outputs(self):
86+
if self._outputs is None:
87+
self._outputs = alloc_filter_pads(self, self.ptr.outputs, False)
88+
return self._outputs
8989

9090

9191
cdef get_filter_names():

av/filter/link.pyx

+30-30
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ cdef class FilterLink:
1212
if sentinel is not _cinit_sentinel:
1313
raise RuntimeError("cannot instantiate FilterLink")
1414

15-
property input:
16-
def __get__(self):
17-
if self._input:
18-
return self._input
19-
cdef lib.AVFilterContext *cctx = self.ptr.src
20-
cdef unsigned int i
21-
for i in range(cctx.nb_outputs):
22-
if self.ptr == cctx.outputs[i]:
23-
break
24-
else:
25-
raise RuntimeError("could not find link in context")
26-
ctx = self.graph._context_by_ptr[<long>cctx]
27-
self._input = ctx.outputs[i]
15+
@property
16+
def input(self):
17+
if self._input:
2818
return self._input
29-
30-
property output:
31-
def __get__(self):
32-
if self._output:
33-
return self._output
34-
cdef lib.AVFilterContext *cctx = self.ptr.dst
35-
cdef unsigned int i
36-
for i in range(cctx.nb_inputs):
37-
if self.ptr == cctx.inputs[i]:
38-
break
39-
else:
40-
raise RuntimeError("could not find link in context")
41-
try:
42-
ctx = self.graph._context_by_ptr[<long>cctx]
43-
except KeyError:
44-
raise RuntimeError("could not find context in graph", (cctx.name, cctx.filter.name))
45-
self._output = ctx.inputs[i]
19+
cdef lib.AVFilterContext *cctx = self.ptr.src
20+
cdef unsigned int i
21+
for i in range(cctx.nb_outputs):
22+
if self.ptr == cctx.outputs[i]:
23+
break
24+
else:
25+
raise RuntimeError("could not find link in context")
26+
ctx = self.graph._context_by_ptr[<long>cctx]
27+
self._input = ctx.outputs[i]
28+
return self._input
29+
30+
@property
31+
def output(self):
32+
if self._output:
4633
return self._output
34+
cdef lib.AVFilterContext *cctx = self.ptr.dst
35+
cdef unsigned int i
36+
for i in range(cctx.nb_inputs):
37+
if self.ptr == cctx.inputs[i]:
38+
break
39+
else:
40+
raise RuntimeError("could not find link in context")
41+
try:
42+
ctx = self.graph._context_by_ptr[<long>cctx]
43+
except KeyError:
44+
raise RuntimeError("could not find context in graph", (cctx.name, cctx.filter.name))
45+
self._output = ctx.inputs[i]
46+
return self._output
4747

4848

4949
cdef FilterLink wrap_filter_link(Graph graph, lib.AVFilterLink *ptr):

av/filter/pad.pyx

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ cdef class FilterPad:
1515

1616
return f"<av.FilterPad {_filter}.{_io}[{self.index}]: {self.name} ({self.type})>"
1717

18-
property is_output:
19-
def __get__(self):
20-
return not self.is_input
18+
@property
19+
def is_output(self):
20+
return not self.is_input
2121

22-
property name:
23-
def __get__(self):
24-
return lib.avfilter_pad_get_name(self.base_ptr, self.index)
22+
@property
23+
def name(self):
24+
return lib.avfilter_pad_get_name(self.base_ptr, self.index)
2525

2626
@property
2727
def type(self):
@@ -43,22 +43,22 @@ cdef class FilterContextPad(FilterPad):
4343

4444
return f"<av.FilterContextPad {_filter}.{_io}[{self.index}] of {context}: {self.name} ({self.type})>"
4545

46-
property link:
47-
def __get__(self):
48-
if self._link:
49-
return self._link
50-
cdef lib.AVFilterLink **links = self.context.ptr.inputs if self.is_input else self.context.ptr.outputs
51-
cdef lib.AVFilterLink *link = links[self.index]
52-
if not link:
53-
return
54-
self._link = wrap_filter_link(self.context.graph, link)
46+
@property
47+
def link(self):
48+
if self._link:
5549
return self._link
50+
cdef lib.AVFilterLink **links = self.context.ptr.inputs if self.is_input else self.context.ptr.outputs
51+
cdef lib.AVFilterLink *link = links[self.index]
52+
if not link:
53+
return
54+
self._link = wrap_filter_link(self.context.graph, link)
55+
return self._link
5656

57-
property linked:
58-
def __get__(self):
59-
cdef FilterLink link = self.link
60-
if link:
61-
return link.input if self.is_input else link.output
57+
@property
58+
def linked(self):
59+
cdef FilterLink link = self.link
60+
if link:
61+
return link.input if self.is_input else link.output
6262

6363

6464
cdef tuple alloc_filter_pads(Filter filter, const lib.AVFilterPad *ptr, bint is_input, FilterContext context=None):

av/subtitles/subtitle.pyx

+22-22
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ cdef class SubtitleSet:
2020
id(self),
2121
)
2222

23-
property format:
24-
def __get__(self): return self.proxy.struct.format
25-
property start_display_time:
26-
def __get__(self): return self.proxy.struct.start_display_time
27-
property end_display_time:
28-
def __get__(self): return self.proxy.struct.end_display_time
29-
property pts:
30-
def __get__(self): return self.proxy.struct.pts
23+
@property
24+
def format(self): return self.proxy.struct.format
25+
@property
26+
def start_display_time(self): return self.proxy.struct.start_display_time
27+
@property
28+
def end_display_time(self): return self.proxy.struct.end_display_time
29+
@property
30+
def pts(self): return self.proxy.struct.pts
3131

3232
def __len__(self):
3333
return len(self.rects)
@@ -110,16 +110,16 @@ cdef class BitmapSubtitle(Subtitle):
110110
id(self),
111111
)
112112

113-
property x:
114-
def __get__(self): return self.ptr.x
115-
property y:
116-
def __get__(self): return self.ptr.y
117-
property width:
118-
def __get__(self): return self.ptr.w
119-
property height:
120-
def __get__(self): return self.ptr.h
121-
property nb_colors:
122-
def __get__(self): return self.ptr.nb_colors
113+
@property
114+
def x(self): return self.ptr.x
115+
@property
116+
def y(self): return self.ptr.y
117+
@property
118+
def width(self): return self.ptr.w
119+
@property
120+
def height(self): return self.ptr.h
121+
@property
122+
def nb_colors(self): return self.ptr.nb_colors
123123

124124
def __len__(self):
125125
return len(self.planes)
@@ -161,8 +161,8 @@ cdef class TextSubtitle(Subtitle):
161161
id(self),
162162
)
163163

164-
property text:
165-
def __get__(self): return self.ptr.text
164+
@property
165+
def text(self): return self.ptr.text
166166

167167

168168
cdef class AssSubtitle(Subtitle):
@@ -175,5 +175,5 @@ cdef class AssSubtitle(Subtitle):
175175
id(self),
176176
)
177177

178-
property ass:
179-
def __get__(self): return self.ptr.ass
178+
@property
179+
def ass(self): return self.ptr.ass

0 commit comments

Comments
 (0)