Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
4043a1ce
Commit
4043a1ce
authored
Sep 10, 2009
by
Olivier Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python-ctypes: fix pylint/pyflakes warnings
parent
f6cfac86
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
35 deletions
+39
-35
bindings/python-ctypes/Makefile
bindings/python-ctypes/Makefile
+4
-0
bindings/python-ctypes/footer.py
bindings/python-ctypes/footer.py
+25
-29
bindings/python-ctypes/generate.py
bindings/python-ctypes/generate.py
+5
-2
bindings/python-ctypes/header.py
bindings/python-ctypes/header.py
+4
-3
bindings/python-ctypes/override.py
bindings/python-ctypes/override.py
+1
-1
No files found.
bindings/python-ctypes/Makefile
View file @
4043a1ce
...
...
@@ -11,5 +11,9 @@ doc: $(MODULE_NAME)
test
:
$(MODULE_NAME)
python test.py
check
:
$(MODULE_NAME)
-
pyflakes
$<
-
pylint
$<
clean
:
-
$(RM)
$(MODULE_NAME)
bindings/python-ctypes/footer.py
View file @
4043a1ce
...
...
@@ -44,7 +44,6 @@ def debug_callback(event, data):
print
"Data"
,
data
if
__name__
==
'__main__'
:
import
sys
try
:
from
msvcrt
import
getch
except
ImportError
:
...
...
@@ -66,47 +65,44 @@ if __name__ == '__main__':
sys
.
exit
(
0
)
if
sys
.
argv
[
1
:]:
if
sys
.
platform
==
'win32'
and
plugin_path
is
not
None
:
i
=
Instance
(
'--plugin-path'
,
plugin_path
)
else
:
i
=
Instance
()
m
=
i
.
media_new
(
sys
.
argv
[
1
])
p
=
i
.
media_player_new
()
p
.
set_media
(
m
)
p
.
play
()
e
=
p
.
event_manager
()
e
.
event_attach
(
EventType
.
MediaPlayerEndReached
,
end_callback
,
None
)
instance
=
Instance
()
media
=
instance
.
media_new
(
sys
.
argv
[
1
])
player
=
instance
.
media_player_new
()
player
.
set_media
(
media
)
player
.
play
()
event_manager
=
player
.
event_manager
()
event_manager
.
event_attach
(
EventType
.
MediaPlayerEndReached
,
end_callback
,
None
)
def
print_info
():
"""Print information about the media."""
m
=
p
.
get_media
()
print
"State:"
,
p
.
get_state
()
print
"Media:"
,
m
.
get_mrl
()
m
edia
=
player
.
get_media
()
print
"State:"
,
p
layer
.
get_state
()
print
"Media:"
,
m
edia
.
get_mrl
()
try
:
print
"Current time:"
,
p
.
get_time
(),
"/"
,
m
.
get_duration
()
print
"Position:"
,
p
.
get_position
()
print
"FPS:"
,
p
.
get_fps
()
print
"Rate:"
,
p
.
get_rate
()
print
"Video size: (%d, %d)"
%
(
p
.
video_get_width
(),
p
.
video_get_height
())
print
"Current time:"
,
p
layer
.
get_time
(),
"/"
,
media
.
get_duration
()
print
"Position:"
,
p
layer
.
get_position
()
print
"FPS:"
,
p
layer
.
get_fps
()
print
"Rate:"
,
p
layer
.
get_rate
()
print
"Video size: (%d, %d)"
%
(
p
layer
.
video_get_width
(),
player
.
video_get_height
())
except
Exception
:
pass
def
forward
():
"""Go forward 1s"""
p
.
set_time
(
p
.
get_time
()
+
1000
)
p
layer
.
set_time
(
player
.
get_time
()
+
1000
)
def
one_frame_forward
():
"""Go forward one frame"""
p
.
set_time
(
p
.
get_time
()
+
long
(
1000
/
(
p
.
get_fps
()
or
25
)))
p
layer
.
set_time
(
player
.
get_time
()
+
long
(
1000
/
(
player
.
get_fps
()
or
25
)))
def
one_frame_backward
():
"""Go backward one frame"""
p
.
set_time
(
p
.
get_time
()
-
long
(
1000
/
(
p
.
get_fps
()
or
25
)))
p
layer
.
set_time
(
player
.
get_time
()
-
long
(
1000
/
(
player
.
get_fps
()
or
25
)))
def
backward
():
"""Go backward 1s"""
p
.
set_time
(
p
.
get_time
()
-
1000
)
p
layer
.
set_time
(
player
.
get_time
()
-
1000
)
def
print_help
():
"""Print help
...
...
@@ -116,20 +112,20 @@ if __name__ == '__main__':
print
" %s: %s"
%
(
k
,
(
m
.
__doc__
or
m
.
__name__
).
splitlines
()[
0
])
print
" 1-9: go to the given fraction of the movie"
def
quit
():
def
quit
_app
():
"""Exit."""
sys
.
exit
(
0
)
keybindings
=
{
'f'
:
p
.
toggle_fullscreen
,
' '
:
p
.
pause
,
'f'
:
p
layer
.
toggle_fullscreen
,
' '
:
p
layer
.
pause
,
'+'
:
forward
,
'-'
:
backward
,
'.'
:
one_frame_forward
,
','
:
one_frame_backward
,
'?'
:
print_help
,
'i'
:
print_info
,
'q'
:
quit
,
'q'
:
quit
_app
,
}
print
"Press q to quit, ? to get help."
...
...
@@ -142,6 +138,6 @@ if __name__ == '__main__':
elif
o
>=
49
and
o
<=
57
:
# Numeric value. Jump to a fraction of the movie.
v
=
0.1
*
(
o
-
48
)
p
.
set_position
(
v
)
p
layer
.
set_position
(
v
)
bindings/python-ctypes/generate.py
View file @
4043a1ce
...
...
@@ -604,7 +604,8 @@ class PythonGenerator(object):
if classname in docstring:
self.output('
"""%s
\
n
"""' % docstring[classname])
self.output("""
if not '
def
__new__
' in overrides.get(classname, ''):
self.output("""
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
...
...
@@ -616,13 +617,15 @@ class PythonGenerator(object):
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
""")
self.output("""
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
""" % {'
name
': classname}
)
"""
)
if classname in overrides:
self.output(overrides[classname])
...
...
bindings/python-ctypes/header.py
View file @
4043a1ce
...
...
@@ -103,7 +103,7 @@ class ListPOINTER(object):
self
.
etype
=
etype
def
from_param
(
self
,
param
):
if
isinstance
(
param
,
(
list
,
tuple
)):
if
isinstance
(
param
,
(
list
,
tuple
)):
return
(
self
.
etype
*
len
(
param
))(
*
param
)
class
LibVLCException
(
Exception
):
...
...
@@ -170,6 +170,7 @@ class LogMessage(ctypes.Structure):
]
def
__init__
(
self
):
super
(
LogMessage
,
self
).
__init__
()
self
.
size
=
ctypes
.
sizeof
(
self
)
def
__str__
(
self
):
...
...
@@ -187,6 +188,7 @@ class MediaControlPosition(ctypes.Structure):
# class with an int as parameter will create the appropriate
# default position (absolute position, media time, with the
# int as value).
super
(
MediaControlPosition
,
self
).
__init__
()
self
.
value
=
value
if
origin
is
None
:
origin
=
PositionOrigin
.
AbsolutePosition
...
...
@@ -205,8 +207,7 @@ class MediaControlPosition(ctypes.Structure):
@
staticmethod
def
from_param
(
arg
):
if
isinstance
(
arg
,
(
int
,
long
)):
p
=
MediaControlPosition
(
arg
)
return
p
return
MediaControlPosition
(
arg
)
else
:
return
arg
...
...
bindings/python-ctypes/override.py
View file @
4043a1ce
...
...
@@ -144,7 +144,7 @@ class MediaControl:
@param end: the end position
"""
if
not
isinstance
(
begin
,
MediaControlPosition
):
begin
=
self
.
value2position
(
pos
)
begin
=
self
.
value2position
(
begin
)
if
not
isinstance
(
end
,
MediaControlPosition
):
end
=
self
.
value2position
(
end
)
e
=
MediaControlException
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment