rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "Child wrote: ", n
def write_to_parent(self, message): #time.sleep(1) n = os.write(self.int_w, message) # print "Child wrote: ", n
if request is None: debug("[+] Invalid Exit") exit(1)
def parse_request(self, data): arr = data.split('\r\n') request = None
self.controller.queue_action(cherrypy.engine.start, False)
self.controller.queue_action(cherrypy.engine.start)
def start(self): """Start the webserver. """ self.controller.queue_action(cherrypy.engine.start, False) return True
xxt = SubElement(xx, "association", element=e, tag=t)
xxt = SubElement(xx, "association", element=e) xxt.attrib["tag"] = t
def _serialize_external_tagging(self, xpackage): xx = SubElement(xpackage, "external-tag-associations") pairs = self.package._backend.iter_external_tagging(self.package._id) for e, t in pairs: xxt = SubElement(xx, "association", element=e, tag=t) if len(xx) == 0: xpackage.remove(xx)
return self.element_constraint.content_parsed.get("mimetype", None) or "*/*"
return (self.element_constraint and self.element_constraint.content_parsed.get("mimetype", None)) or "*/*"
def _get_mimetype(self): return self.element_constraint.content_parsed.get("mimetype", None) or "*/*"
elif "content.xml" in z.nameslit():
elif "content.xml" in z.namelist():
def claims_for_parse(cls, file_): """Is this parser likely to parse that file-like object?
return o._backend.count_lists((o._id,), item=item, position=position,
return o._backend.count_lists((o._id,), item=item, pos=position,
def count_user_lists(self, item=None, position=None): o = self._owner return o._backend.count_lists((o._id,), item=item, position=position, meta=[(CAMSYS_TYPE, None, None)])
return o._backend.count_lists((o._id,), item=item, position=position,
return o._backend.count_lists((o._id,), item=item, pos=position,
def count_schemas(self, item=None, position=None): o = self._owner return o._backend.count_lists((o._id,), item=item, position=position, meta=[(CAMSYS_TYPE, "schema", False)])
adj.value = adj.upper - .1
adj.value = adj.upper - adj.page_size
def clicked_callback(self, columnbrowser, node): if columnbrowser is None: # We selected the rootcolumn. Delete the next ones cb=self.rootcolumn.next while cb is not None: cb.widget.destroy() cb=cb.next self.rootcolumn.next=None elif columnbrowser.next is None: t=type(node.element) clazz=CLASS2COLUMN.get(t, ModelColum...
for sprite in sprites: if isinstance(sprite, Sprite): return self.has_internal(sprite) try: for spr in sprite: if not self.has(spr):
if sprites: for sprite in sprites: if isinstance(sprite, Sprite): if not self.has_internal(sprite):
def has(self, *sprites): """ask if group has a sprite or sprites
return True except (TypeError, AttributeError): if hasattr(sprite, '_spritegroup'): for spr in sprite.sprites(): if not self.has_internal(spr): return False return True
def has(self, *sprites): """ask if group has a sprite or sprites
return self.has_internal(sprite)
try: for spr in sprite: if not self.has(spr): return False except (TypeError, AttributeError): if hasattr(sprite, '_spritegroup'): for spr in sprite.sprites(): if not self.has_internal(spr): return False else: if not self.has_internal(sprite): return False return True else: return False
def has(self, *sprites): """ask if group has a sprite or sprites
def test_collide_mask(self):
def test_collide_mask__opaque(self):
def test_collide_mask(self): # make some fully opaque sprites that will collide with masks. self.s1.image.fill((255,255,255,255)) self.s2.image.fill((255,255,255,255)) self.s3.image.fill((255,255,255,255))
def test_collide_mask(self):
def test_collide_mask__transparent(self):
def test_collide_mask(self): # make some sprites that are fully transparent, so they won't collide. self.s1.image.fill((255,255,255,0)) self.s2.image.fill((255,255,255,0)) self.s3.image.fill((255,255,255,0))
self.s3.rect.move_ip(105, 105)
def test_spritecollideany__without_collided_callback(self):
arg_emsg = 'Sound takes either 1 positional or 1 keywork argument'
arg_emsg = 'Sound takes either 1 positional or 1 keyword argument' try: mixer.Sound() except TypeError: self.assert_(str(geterror()) == arg_emsg) else: self.fail("no exception")
def get_bytes(snd): return snd.get_buffer().raw
FFMPEGDependency('AVFORMAT', 'avformat.h', 'libavformat.a', ['avformat'], ['/include/libavformat', '/include/ffmpeg']), FFMPEGDependency('SWSCALE', 'swscale.h', 'libswscale.a', ['swscale'], ['/include/libswscale', '/include/ffmpeg']),
FFMPEGDependency('AVFORMAT', 'libavformat/avformat.h', 'libavformat.a', ['avformat'], ['/include', '/include/ffmpeg']), FFMPEGDependency('SWSCALE', 'libswscale/swscale.h', 'libswscale.a', ['swscale'], ['/include', '/include/ffmpeg']),
def main(): print ('\nHunting dependencies...') DEPS = [ DependencyProg('SDL', 'SDL_CONFIG', 'sdl-config', '1.2', ['sdl']), Dependency('FONT', 'SDL_ttf.h', 'libSDL_ttf.so', ['SDL_ttf']), Dependency('IMAGE', 'SDL_image.h', 'libSDL_image.so', ['SDL_image']), Dependency('MIXER', 'SDL_mixer.h', 'libSDL_mixer.so', ['SDL_mix...
default_msys_prefix = '/usr/local'
default_prefix_mp = '/usr/local'
def geterror(): return sys.exc_info()[1]
self.dlls = []
self.libs = []
def __init__(self, name, shell_script): self.name = name self.path = '' self.paths = [] self.dlls = [] self.shell_script = shell_script
% (default_msys_prefix,))
% (default_prefix_mp,))
def command_line(): """Process the command line and return the options""" usage = ("usage: %prog [options] --all\n" " %prog [options] [args]\n" "\n" "Build the Pygame dependencies. The args, if given, are\n" "libraries to include or exclude.\n" "\n" "At startup this program may prompt for missing information.\n"...
msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix)
msys_root_wp = msys.msys_root prefix_wp = options.prefix if not prefix_wp: prefix_wp = environ.get('PREFIX', '') if prefix_wp: prefix_mp = msys.windows_to_msys(prefix_wp)
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
prefix = default_msys_prefix environ['PREFIX'] = prefix path = environ['PATH'] environ['PATH'] = "%s:%s/bin" % (path, prefix)
prefix_mp = default_prefix_mp prefix_wp = msys.msys_to_windows(prefix_mp) environ['PREFIX'] = prefix_mp
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
lib_path = prefix + '/lib' msvcr71_path = ''
lib_mp = prefix_mp + '/lib' msvcr71_mp = ''
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
msvcr71_path = lib_path + '/msvcr71' environ['DBMSVCR71'] = msvcr71_path
msvcr71_mp = lib_mp + '/msvcr71' environ['DBMSVCR71'] = msvcr71_mp
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
as_linker_lib_path(lib_path), as_linker_lib_path(msvcr71_path),
as_linker_lib_path(lib_mp), as_linker_lib_path(msvcr71_mp),
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
include_path = prefix + '/include' environ['CPATH'] = merge_strings(include_path, environ.get('CPATH', ''),
include_wp = prefix_wp + '/include' environ['CPATH'] = merge_strings(include_wp, environ.get('CPATH', ''),
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if not prefix: prefix = environ.get('PREFIX', '') if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['...
CFLAGS_MIKMOD=-c -DWIN32 -DDRV_DS -DDRV_WIN -DHAVE_FCNTL_H -DHAVE_MALLOC_H -DHAVE_LIMITS_H $(CFLAGS) COMPILE=$(CC) $(CFLAGS_MIKMOD) -I../include -I.. -I../win32
CPPFLAGS_MIKMOD=-c -DWIN32 -DDRV_DS -DDRV_WIN -DHAVE_FCNTL_H -DHAVE_MALLOC_H -DHAVE_LIMITS_H $(CPPFLAGS) COMPILE=$(CC) $(CPPFLAGS_MIKMOD) -I../include -I.. -I../win32 $(CFLAGS)
sed 's/^# ifdef _MSC_VER$/# if defined _MSC_VER || defined __MINGW32__/' \ "$BDTMP" >"$BDHDR"
cd "$BDWD" if [ x$BDCONF == x1 ]; then
export PATH="$PREFIX/bin:$PATH" cd "$BDWD" if [ x$BDCONF == x1 ]; then
cat > portmidi.def << 'THE_END'
--prefix="$PREFIX" --host-cflags="$CFLAGS" \ --host-ldflags="$LDFLAGS" --enable-runtime-cpudetect
--disable-pthreads --prefix="$PREFIX" \ --enable-runtime-cpudetect
cat > portmidi.def << 'THE_END'
-e "s~\\\\(_POSIX_C_SOURCE=\\\\)200112~\\\\1199209~g" \
cat > portmidi.def << 'THE_END'
self.assertEqual(self.v1.yx, (self.v1.y, self.v1.x)) self.assertEqual(self.v1.xxyyxy, (self.v1.x, self.v1.x, self.v1.y, self.v1.y, self.v1.x, self.v1.y))
self.assertEqual(self.v1.yxz, (self.v1.y, self.v1.x, self.v1.z)) self.assertEqual(self.v1.xxyyzzxyz, (self.v1.x, self.v1.x, self.v1.y, self.v1.y, self.v1.z, self.v1.z, self.v1.x, self.v1.y, self.v1.z))
def testSwizzle(self): self.assertEquals(hasattr(pygame.math, "enable_swizzling"), True) self.assertEquals(hasattr(pygame.math, "disable_swizzling"), True) # swizzling disabled by default self.assertRaises(AttributeError, lambda : self.v1.yx) pygame.math.enable_swizzling() self.assertEqual(self.v1.yx, (self.v1.y, self...
sed -e "s~\\\\(-std=\\\\)c99~\\\\1=gnu99~g" \ -e "s~\\\\(_POSIX_C_SOURCE=\\\\)200112~\\\\1=199209~g" \
sed -e "s~\\\\(-std=\\\\)c99~\\\\1gnu99~g" \ -e "s~\\\\(_POSIX_C_SOURCE=\\\\)200112~\\\\1199209~g" \
cat > portmidi.def << 'THE_END'
strip --strip-all "$PREFIX/bin/avformat-52.dll strip --strip-all "$PREFIX/bin/swscale-0.dll strip --strip-all "$PREFIX/bin/avcodec-52.dll strip --strip-all "$PREFIX/bin/avutil-50.dll
strip --strip-all "$PREFIX/bin/avformat-52.dll" strip --strip-all "$PREFIX/bin/swscale-0.dll" strip --strip-all "$PREFIX/bin/avcodec-52.dll" strip --strip-all "$PREFIX/bin/avutil-50.dll"
cat > portmidi.def << 'THE_END'
return '/%s%s' % (drive[0], tail.replace(os.sep, '/'))
tail = tail.replace(os.sep, '/') tail = tail.replace(' ', '\\ ') return '/%s%s' % (drive[0], tail)
def windows_to_msys(self, path): """Return an MSYS translation of an absolute Windows path""" msys_root = self.msys_root mingw_root = self.mingw_root path_lower = path.lower() if path_lower.startswith(msys_root.lower()): return '/usr' + path[len(msys_root):].replace(os.sep, '/') if mingw_root is not None and path_lowe...
The Unix path separator is uses as it survives the distutils setup
The Unix path separator is used as it survives the distutils setup
def msys_to_windows(self, path): """Return a Windows translation of an MSYS path The Unix path separator is uses as it survives the distutils setup file read process. Raises a ValueError if the path cannot be translated. """
from win32file import ReadFile, WriteFile, TerminateProcess
from win32file import ReadFile, WriteFile
def PeekNamedPipe(handle, desired_bytes): c_avail = DWORD() c_message = DWORD() if desired_bytes > 0: c_read = DWORD() buffer = ctypes.create_string_buffer(desired_bytes+1) success = ctypes.windll.kernel32.PeekNamedPipe(handle, buffer, desired_bytes, ctypes.byref(c_read), ctypes.byref(c_avail), ctypes.byref(c_message))...
size = font.get_size(text, ptsize=24) rend = font.render_raw(text, ptsize=24) self.assertTrue(isinstance(rend, tuple)) self.assertEqual(len(rend), 2) r, s = rend self.assertTrue(isinstance(r, bytes_)) self.assertTrue(isinstance(s, tuple)) self.assertTrue(len(s), 2) w, h = s self.assertTrue(isinstance(w, int)) self.asse...
def test_freetype_Font_render_raw(self): font = self._TEST_FONTS['sans'] text = "abc" # size = font.get_size(text, ptsize=24) # rend = font.render_raw(text, ptsize=24) # self.assertTrue(isinstance(rend, tuple)) # self.assertEqual(len(rend), 2) # r, s = rend # self.assertTrue(isinstance(r, bytes_)) # self.assertTrue(i...
self.assertEqual(w, 0) self.assertEqual(h, font.height) self.assertEqual(len(r), 0) rend = font.render_raw('render_raw', ptsize=24)
def test_freetype_Font_render_raw(self): font = self._TEST_FONTS['sans'] text = "abc" # size = font.get_size(text, ptsize=24) # rend = font.render_raw(text, ptsize=24) # self.assertTrue(isinstance(rend, tuple)) # self.assertEqual(len(rend), 2) # r, s = rend # self.assertTrue(isinstance(r, bytes_)) # self.assertTrue(i...
def __init__(self, name, wildcards, dlls, shell_script):
def __init__(self, name, wildcards, libs, shell_script):
def __init__(self, name, wildcards, dlls, shell_script): self.name = name self.wildcards = wildcards self.shell_script = shell_script self.dlls = dlls
self.dlls = dlls
self.libs = libs
def __init__(self, name, wildcards, dlls, shell_script): self.name = name self.wildcards = wildcards self.shell_script = shell_script self.dlls = dlls
include_path = '/'.join((prefix, 'include'))
include_path = prefix + '/include'
def set_environment_variables(msys, options): """Set the environment variables used by the scripts""" environ = msys.environ msys_root = msys.msys_root prefix = options.prefix if prefix: prefix = msys.windows_to_msys(prefix) else: prefix = default_msys_prefix environ['PREFIX'] = prefix environ['BDCONF'] = as_flag(opti...
name = d.name dlls = d.dlls for dll in dlls: dll_path = os.path.join(bin_dir, dll) try: mod_time = os.path.getmtime(dll_path) except: msg = "No DLL"
for lib in d.libs: if lib.endswith('.dll'): lib_path = os.path.join(bin_dir, lib) try: mod_time = os.path.getmtime(lib_path) except: msg = "No DLL" else: if mod_time >= start_time: msg = "Installed new DLL %s" % (lib_path,) else: msg = "-- (old DLL %s)" % (lib_path,) elif lib.endswith('.a'): lib_path = os.path.join(lib...
def summary(dependencies, msys, start_time, chosen_deps): """Display a summary report of new, existing and missing DLLs""" import datetime print_("\n\n=== Summary ===") if start_time is not None: print_(" Elapse time:", datetime.timedelta(seconds=time.time()-start_time)) print_() for dep in chosen_deps: if dep.path ...
if mod_time >= start_time: msg = "Installed new DLL %s" % dll_path else: msg = "-- (old DLL %s)" % dll_path print_(" %-10s: %s" % (name, msg))
msg = "Internal error: unknown library type %s" % (lib,) print_(" %-10s: %s" % (d.name, msg))
def summary(dependencies, msys, start_time, chosen_deps): """Display a summary report of new, existing and missing DLLs""" import datetime print_("\n\n=== Summary ===") if start_time is not None: print_(" Elapse time:", datetime.timedelta(seconds=time.time()-start_time)) print_() for dep in chosen_deps: if dep.path ...
make clean -fMakefile.mingw
make clean -fMakefile.mingw prefix="$PREFIX"
def main(dependencies, msvcr71_preparation, msys_preparation): """Build the dependencies according to the command line options.""" options, args = command_line() if options.arg_help: print_("These are the Pygame library dependencies:") for dep in dependencies: print_(" ", dep.name) return 0 try: chosen_deps = choose_d...
Dependency('FLAC', ['flac-[1-9].*'], [], """
Dependency('FLAC', ['flac-[1-9].*'], ['libFLAC.a'], """
def main(dependencies, msvcr71_preparation, msys_preparation): """Build the dependencies according to the command line options.""" options, args = command_line() if options.arg_help: print_("These are the Pygame library dependencies:") for dep in dependencies: print_(" ", dep.name) return 0 try: chosen_deps = choose_d...
PREFIX="$PREFIX" LDFLAGS="$LDFLAGS"
--disable-libtool-lock --prefix="$PREFIX" LDFLAGS="$LDFLAGS"
sed 's/^# ifdef _MSC_VER$/# if defined _MSC_VER || defined __MINGW32__/' \ "$BDTMP" >"$BDHDR"
\tcp -f --target-directory=$(prefix)/bin $< \tcp -f --target-directory=$(prefix)/lib $(pmlib) \tcp -f --target-directory=$(prefix)/lib $(pmimplib) \tcp -f --target-directory=$(prefix)/include $(reqhdr)
\tcp -f --target-directory=$(PREFIX)/bin $< \tcp -f --target-directory=$(PREFIX)/lib $(pmlib) \tcp -f --target-directory=$(PREFIX)/lib $(pmimplib) \tcp -f --target-directory=$(PREFIX)/include $(reqhdr)
\tg++ -shared -static-libgcc $(LDFLAGS) -def $(def) $(pmlib) $(LIBS) -o $@
make install prefix="$PREFIX"
make install PREFIX="$PREFIX"
cat > portmidi.def << 'THE_END'
size_utf16 = font.get_size(as_unicode(r'\uD80C\uDCA7'), ptsize=24, surrogates=True) self.assertEqual(size_utf16[0], size_utf32[0])
def test_size(s): self.assertTrue(isinstance(s, tuple)) self.assertEqual(len(s), 2) self.assertTrue(isinstance(s[0], int)) self.assertTrue(isinstance(s[1], int))
None, as_unicode(r'\uD80C'), color, ptsize=24, surrogates=True)
None, as_unicode(r'\uD80C'), color, ptsize=24)
def test_freetype_Font_render(self):
None, as_unicode(r'\uDCA7'), color, ptsize=24, surrogates=True)
None, as_unicode(r'\uDCA7'), color, ptsize=24)
def test_freetype_Font_render(self):
None, as_unicode(r'\uFEFF'), color, ptsize=24, surrogates=True)
None, as_unicode(r'\uFEFF'), color, ptsize=24)
def test_freetype_Font_render(self):
None, as_unicode(r'\uFFFE'), color, ptsize=24, surrogates=True) rend1 = font.render(None, as_unicode(r'\uD80C\uDCA7'), color, ptsize=24, surrogates=True) rend2 = font.render(None, as_unicode(r'\U000130A7'), color, ptsize=24)
None, as_unicode(r'\uFFFE'), color, ptsize=24) rend1 = font.render(None, as_unicode(r'\uD80C\uDCA7'), color, ptsize=24) rend2 = font.render(None, as_unicode(r'\U000130A7'), color, ptsize=24)
def test_freetype_Font_render(self):
color, ptsize=24)
color, ptsize=24, surrogates=False)
def test_freetype_Font_render(self):
self.assertNotEqual(True, self.ag.has([])
self.assertNotEqual(True, self.ag.has([]))
def test_has( self ): " See if AbstractGroup.has() works as expected. "
self.assertRaises(UnicodeEncodeError, font.render, None, as_unicode(r'\uD80C'), color, ptsize=24) self.assertRaises(UnicodeEncodeError, font.render, None, as_unicode(r'\uDCA7'), color, ptsize=24) self.assertRaises(UnicodeEncodeError, font.render, None, as_unicode(r'\uFEFF'), color, ptsize=24) self.assertRaises(UnicodeE...
rend1 = font.render(None, as_unicode(r'\uD800\uDC00'), color, ptsize=24) rend1 = font.render(None, as_unicode(r'\uDBFF\uDFFF'), color, ptsize=24)
def test_freetype_Font_render(self):
size = font.get_size(text, ptsize=24) rend = font.render_raw(text, ptsize=24) self.assertTrue(isinstance(rend, tuple)) self.assertEqual(len(rend), 2) r, s = rend self.assertTrue(isinstance(r, bytes_)) self.assertTrue(isinstance(s, tuple)) self.assertTrue(len(s), 2) self.assertTrue(isinstance(s[0], int)) self.assertTrue...
r, (w, h) = font.render_raw('', ptsize=24)
def test_freetype_Font_render_raw(self): font = self._TEST_FONTS['sans'] text = "abc" size = font.get_size(text, ptsize=24) rend = font.render_raw(text, ptsize=24) self.assertTrue(isinstance(rend, tuple)) self.assertEqual(len(rend), 2) r, s = rend self.assertTrue(isinstance(r, bytes_)) self.assertTrue(isinstance(s, t...
Return a list of all the Groups that contain this Sprite.
Returns a list of all the Groups that contain this Sprite.
def groups(self): """list of Groups that contain this Sprite Sprite.groups(): return group_list
if set to 1, it is repainted and then set to 0 again if set to 2 then it is always dirty ( repainted each frame, flag is not reset) 0 means that it is not dirty and therefor not repainted again
If set to 1, it is repainted and then set to 0 again. If set to 2, it is always dirty (repainted each frame; flag is not reset). If set to 0, it is not dirty and therefore not repainted again.
def __repr__(self): return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
its the special_flags argument of blit, blendmodes
It's the special_flags argument of Surface.blit; see the blendmodes in the Surface.blit documentation
def __repr__(self): return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
source rect to use, remember that it is relative to topleft (0,0) of self.image
This is the source rect to use. Remember that it is relative to the top left corner (0, 0) of self.image.
def __repr__(self): return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
normally 1, if set to 0 it will not be repainted (you must set it dirty too to be erased from screen)
Normally this is 1. If set to 0, it will not be repainted. (If you change visible to 1, you must set dirty to 1 for it to be erased from the screen.)
def __repr__(self): return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
(READONLY value, it is read when adding it to the LayeredUpdates, for details see doc of LayeredUpdates) """
A READ ONLY value, it is read when adding it to the LayeredUpdates group. For details see documentation of sprite.LayeredUpdates. """
def __repr__(self): return "<%s sprite(in %d groups)>" % (self.__class__.__name__, len(self.__g))
visible = property(lambda self: self._get_visible(),\ lambda self, value:self._set_visible(value), \ doc="you can make this sprite disappear without removing it from the group,\n"+ "values 0 for invisible and 1 for visible")
visible = property(lambda self: self._get_visible(), lambda self, value: self._set_visible(value), doc="you can make this sprite disappear without " "removing it from the group,\n" "assign 0 for invisible and 1 for visible")
def _get_visible(self): """returns the visible value of that sprite""" return self._visible
return "<%s DirtySprite(in %d groups)>" % (self.__class__.__name__, len(self.groups()))
return "<%s DirtySprite(in %d groups)>" % \ (self.__class__.__name__, len(self.groups()))
def __repr__(self): return "<%s DirtySprite(in %d groups)>" % (self.__class__.__name__, len(self.groups()))
del(self.spritedict[sprite])
del self.spritedict[sprite]
def remove_internal(self, sprite): r = self.spritedict[sprite] if r is not 0: self.lostsprites.append(r) del(self.spritedict[sprite])
A simple container for Sprite objects. This class can be inherited to create containers with more specific behaviors. The constructor takes any
A simple container for Sprite objects. This class can be subclassed to create containers with more specific behaviors. The constructor takes any
def __repr__(self): return "<%s(%d sprites)>" % (self.__class__.__name__, len(self))
The Sprites in the Group are not ordered, so drawing and iterating the Sprites is in no particular order. """
The Sprites in the Group are not ordered, so the Sprites are drawn and iterated over in no particular order. """
def __repr__(self): return "<%s(%d sprites)>" % (self.__class__.__name__, len(self))
This class is derived from pygame.sprite.Group(). It has an extended draw()
This class is derived from pygame.sprite.Group(). It has an enhanced draw
def __init__(self, *sprites): AbstractGroup.__init__(self) self.add(*sprites)
"""LayeredUpdates Group handles layers, that draws like OrderedUpdates.
"""LayeredUpdates Group handles layers, which are drawn like OrderedUpdates
def remove_internal(self, sprite): RenderUpdates.remove_internal(self, sprite) self._spritelist.remove(sprite)
"""
"""initialize an instance of LayeredUpdates with the given attributes
def __init__(self, *sprites, **kwargs): """ You can set the default layer through kwargs using 'default_layer' and an integer for the layer. The default layer is 0. If the sprite you add has an attribute layer then that layer will be used. If the **kwarg contains 'layer' then the sprites passed will be added to that l...
If the sprite you add has an attribute layer then that layer will be used. If the **kwarg contains 'layer' then the sprites passed will be added to that layer (overriding the sprite.layer attribute). If neither sprite has attribute layer nor kwarg then the default layer is used to add the sprites.
If the sprite you add has an attribute layer, then that layer will be used. If **kwarg contains 'layer', then the passed sprites will be added to that layer (overriding the sprite.layer attribute). If neither the sprite nor **kwarg has a 'layer', then the default layer is used to add the sprites.
def __init__(self, *sprites, **kwargs): """ You can set the default layer through kwargs using 'default_layer' and an integer for the layer. The default layer is 0. If the sprite you add has an attribute layer then that layer will be used. If the **kwarg contains 'layer' then the sprites passed will be added to that l...
while(low<=high): mid = low + (high-low)//2 if(sprites_layers[sprites[mid]]<=layer): low = mid+1
while low <= high: mid = low + (high - low) // 2 if sprites_layers[sprites[mid]] <= layer: low = mid + 1
def add_internal(self, sprite, layer=None): """ Do not use this method directly. It is used by the group to add a sprite internally. """ self.spritedict[sprite] = Rect(0, 0, 0, 0) # add a old rect if layer is None: try: layer = sprite._layer except AttributeError: layer = self._default_layer self._spritelayers[sprit...
while(mid<leng and sprites_layers[sprites[mid]]<=layer):
while mid < leng and sprites_layers[sprites[mid]] <= layer:
def add_internal(self, sprite, layer=None): """ Do not use this method directly. It is used by the group to add a sprite internally. """ self.spritedict[sprite] = Rect(0, 0, 0, 0) # add a old rect if layer is None: try: layer = sprite._layer except AttributeError: layer = self._default_layer self._spritelayers[sprit...
If the sprite(s) have an attribute layer then that is used for the layer. If kwargs contains 'layer' then the sprite(s) will be added to that argument (overriding the sprite layer attribute). If neither is passed then the sprite(s) will be added to the default layer. """
If the sprite you add has an attribute layer, then that layer will be used. If **kwarg contains 'layer', then the passed sprites will be added to that layer (overriding the sprite.layer attribute). If neither the sprite nor **kwarg has a 'layer', then the default layer is used to add the sprites. """
def add(self, *sprites, **kwargs): """add a sprite or sequence of sprites to a group LayeredUpdates.add(*sprites, **kwargs): return None
"""returns a ordered list of sprites (first back, last top).
"""return a ordered list of sprites (first back, last top).
def sprites(self): """returns a ordered list of sprites (first back, last top). LayeredUpdates.sprites(): return sprites """ return list(self._spritelist)
"""draw all sprites in the right order onto the passed surface.
"""draw all sprites in the right order onto the passed surface
def draw(self, surface): """draw all sprites in the right order onto the passed surface. LayeredUpdates.draw(surface): return Rect_list """ spritedict = self.spritedict surface_blit = surface.blit dirty = self.lostsprites self.lostsprites = [] dirty_append = dirty.append for spr in self.sprites(): rec = spritedict[spr]...
"""returns a list with all sprites at that position.
"""return a list with all sprites at that position
def get_sprites_at(self, pos): """returns a list with all sprites at that position. LayeredUpdates.get_sprites_at(pos): return colliding_sprites
Bottom sprites first, top last. """
Bottom sprites are listed first; the top ones are listed last. """
def get_sprites_at(self, pos): """returns a list with all sprites at that position. LayeredUpdates.get_sprites_at(pos): return colliding_sprites
"""returns the sprite at the index idx from the groups sprites
"""return the sprite at the index idx from the groups sprites
def get_sprite(self, idx): """returns the sprite at the index idx from the groups sprites LayeredUpdates.get_sprite(idx): return sprite
"""removes all sprites from a layer and returns them as a list
"""remove all sprites from a layer and return them as a list
def remove_sprites_of_layer(self, layer_nr): """removes all sprites from a layer and returns them as a list LayeredUpdates.remove_sprites_of_layer(layer_nr): return sprites """ sprites = self.get_sprites_from_layer(layer_nr) self.remove(sprites) return sprites
"""returns a list of layers defined (unique), sorted from botton up.
"""return a list of unique defined layers defined.
def layers(self): """returns a list of layers defined (unique), sorted from botton up. LayeredUpdates.layers(): return layers """ layers = set() for layer in self._spritelayers.values(): layers.add(layer) return list(layers)
"""changes the layer of the sprite
"""change the layer of the sprite
def change_layer(self, sprite, new_layer): """changes the layer of the sprite LayeredUpdates.change_layer(sprite, new_layer): return None
sprite must have been added to the renderer. It is not checked.
The sprite must have been added to the renderer already. This is not checked.
def change_layer(self, sprite, new_layer): """changes the layer of the sprite LayeredUpdates.change_layer(sprite, new_layer): return None
while(low<=high): mid = low + (high-low)//2 if(sprites_layers[sprites[mid]]<=new_layer): low = mid+1
while low <= high: mid = low + (high - low) // 2 if sprites_layers[sprites[mid]] <= new_layer: low = mid + 1
def change_layer(self, sprite, new_layer): """changes the layer of the sprite LayeredUpdates.change_layer(sprite, new_layer): return None
while(mid<leng and sprites_layers[sprites[mid]]<=new_layer):
while mid < leng and sprites_layers[sprites[mid]] <= new_layer:
def change_layer(self, sprite, new_layer): """changes the layer of the sprite LayeredUpdates.change_layer(sprite, new_layer): return None
""" Returns the layer that sprite is currently in. If the sprite is not found then it will return the default layer.
"""return the layer that sprite is currently in If the sprite is not found, then it will return the default layer.
def get_layer_of_sprite(self, sprite): """ Returns the layer that sprite is currently in. If the sprite is not found then it will return the default layer. """ return self._spritelayers.get(sprite, self._default_layer)
"""returns the top layer
"""return the top layer
def get_top_layer(self): """returns the top layer LayeredUpdates.get_top_layer(): return layer """ return self._spritelayers[self._spritelist[-1]]
"""returns the bottom layer
"""return the bottom layer
def get_bottom_layer(self): """returns the bottom layer LayeredUpdates.get_bottom_layer(): return layer """ return self._spritelayers[self._spritelist[0]]
"""brings the sprite to front layer
"""bring the sprite to front layer
def move_to_front(self, sprite): """brings the sprite to front layer LayeredUpdates.move_to_front(sprite): return None
Brings the sprite to front, changing sprite layer to topmost layer (added at the end of that layer).
Brings the sprite to front by changing the sprite layer to the top-most layer. The sprite is added at the end of the list of sprites in that top-most layer.
def move_to_front(self, sprite): """brings the sprite to front layer LayeredUpdates.move_to_front(sprite): return None
"""moves the sprite to the bottom layer
"""move the sprite to the bottom layer
def move_to_back(self, sprite): """moves the sprite to the bottom layer LayeredUpdates.move_to_back(sprite): return None
Moves the sprite to the bottom layer, moving it behind all other layers and adding one additional layer. """ self.change_layer(sprite, self.get_bottom_layer()-1)
Moves the sprite to the bottom layer by moving it to a new layer below the current bottom layer. """ self.change_layer(sprite, self.get_bottom_layer() - 1)
def move_to_back(self, sprite): """moves the sprite to the bottom layer LayeredUpdates.move_to_back(sprite): return None
"""returns the topmost sprite
"""return the topmost sprite
def get_top_sprite(self): """returns the topmost sprite LayeredUpdates.get_top_sprite(): return Sprite """ return self._spritelist[-1]
"""returns all sprites from a layer, ordered by how they where added
"""return all sprites from a layer ordered as they where added
def get_sprites_from_layer(self, layer): """returns all sprites from a layer, ordered by how they where added LayeredUpdates.get_sprites_from_layer(layer): return sprites
Returns all sprites from a layer, ordered by how they where added. It uses linear search and the sprites are not removed from layer.
Returns all sprites from a layer. The sprites are ordered in the sequence that they where added. (The sprites are not removed from the layer.
def get_sprites_from_layer(self, layer): """returns all sprites from a layer, ordered by how they where added LayeredUpdates.get_sprites_from_layer(layer): return sprites
"""switches the sprites from layer1 to layer2
"""switch the sprites from layer1_nr to layer2_nr
def switch_layer(self, layer1_nr, layer2_nr): """switches the sprites from layer1 to layer2 LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None
The layers number must exist, it is not checked.
The layers number must exist. This method does not check for the existence of the given layers.
def switch_layer(self, layer1_nr, layer2_nr): """switches the sprites from layer1 to layer2 LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None
"""LayeredDirty Group is for DirtySprites. Subclasses LayeredUpdates.
"""LayeredDirty Group is for DirtySprites; subclasses LayeredUpdates
def switch_layer(self, layer1_nr, layer2_nr): """switches the sprites from layer1 to layer2 LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None
It uses the dirty flag technique and is therefore faster than the pygame.sprite.RenderUpdates if you have many static sprites. It also switches automatically between dirty rect update and full screen drawing, so you do no have to worry what would be faster. Same as for the pygame.sprite.Group. You can specify some ad...
It uses the dirty flag technique and is therefore faster than pygame.sprite.RenderUpdates if you have many static sprites. It also switches automatically between dirty rect updating and full screen drawing, so you do no have to worry which would be faster. As with the pygame.sprite.Group, you can specify some additio...
def switch_layer(self, layer1_nr, layer2_nr): """switches the sprites from layer1 to layer2 LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None