[vlc-devel] commit: python-ctypes: fix pylint/pyflakes warnings (Olivier Aubert )
git version control
git at videolan.org
Fri Sep 11 12:09:22 CEST 2009
vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Thu Sep 10 17:13:15 2009 +0200| [4043a1ce053976cf14d6147f8f41d0830d11c5c8] | committer: Olivier Aubert
python-ctypes: fix pylint/pyflakes warnings
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4043a1ce053976cf14d6147f8f41d0830d11c5c8
---
bindings/python-ctypes/Makefile | 4 ++
bindings/python-ctypes/footer.py | 54 ++++++++++++++++-------------------
bindings/python-ctypes/generate.py | 7 +++-
bindings/python-ctypes/header.py | 7 ++--
bindings/python-ctypes/override.py | 2 +-
5 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/bindings/python-ctypes/Makefile b/bindings/python-ctypes/Makefile
index 3c10756..d18f1c9 100644
--- a/bindings/python-ctypes/Makefile
+++ b/bindings/python-ctypes/Makefile
@@ -11,5 +11,9 @@ doc: $(MODULE_NAME)
test: $(MODULE_NAME)
python test.py
+check: $(MODULE_NAME)
+ -pyflakes $<
+ -pylint $<
+
clean:
-$(RM) $(MODULE_NAME)
diff --git a/bindings/python-ctypes/footer.py b/bindings/python-ctypes/footer.py
index f0e3008..e95f36f 100644
--- a/bindings/python-ctypes/footer.py
+++ b/bindings/python-ctypes/footer.py
@@ -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()
+ media=player.get_media()
+ print "State:", player.get_state()
+ print "Media:", media.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:", player.get_time(), "/", media.get_duration()
+ print "Position:", player.get_position()
+ print "FPS:", player.get_fps()
+ print "Rate:", player.get_rate()
+ print "Video size: (%d, %d)" % (player.video_get_width(), player.video_get_height())
except Exception:
pass
def forward():
"""Go forward 1s"""
- p.set_time(p.get_time() + 1000)
+ player.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)))
+ player.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)))
+ player.set_time(player.get_time() - long(1000 / (player.get_fps() or 25)))
def backward():
"""Go backward 1s"""
- p.set_time(p.get_time() - 1000)
+ player.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': player.toggle_fullscreen,
+ ' ': player.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)
+ player.set_position(v)
diff --git a/bindings/python-ctypes/generate.py b/bindings/python-ctypes/generate.py
index f1fdf05..b00fa9f 100755
--- a/bindings/python-ctypes/generate.py
+++ b/bindings/python-ctypes/generate.py
@@ -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])
diff --git a/bindings/python-ctypes/header.py b/bindings/python-ctypes/header.py
index 7cd29c1..4fc7193 100755
--- a/bindings/python-ctypes/header.py
+++ b/bindings/python-ctypes/header.py
@@ -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
diff --git a/bindings/python-ctypes/override.py b/bindings/python-ctypes/override.py
index 1a39684..2813ac1 100644
--- a/bindings/python-ctypes/override.py
+++ b/bindings/python-ctypes/override.py
@@ -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()
More information about the vlc-devel
mailing list