[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/gldemo.py demo/papertest.py libpap...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/gldemo.py demo/papertest.py libpap... |
Date: |
Mon, 07 Oct 2002 10:22:25 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/10/07 10:22:25
Modified files:
gfx/demo : gldemo.py papertest.py
gfx/libpaper : papermill.py textures.py
gfx/libutil : myimport.py
Log message:
Don't do much initialization at load time in libpaper modules
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/gldemo.py.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest.py.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/textures.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/myimport.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/gldemo.py
diff -c gzz/gfx/demo/gldemo.py:1.33 gzz/gfx/demo/gldemo.py:1.34
*** gzz/gfx/demo/gldemo.py:1.33 Mon Oct 7 06:15:09 2002
--- gzz/gfx/demo/gldemo.py Mon Oct 7 10:22:25 2002
***************
*** 226,231 ****
--- 226,241 ----
def loadScenes():
print "RELOAD"
+
+ if 0:
+ # Reload gfx.* modules
+ mods = sys.modules.keys()
+ mods.sort()
+ for mod in mods:
+ if mod[:4] == "gfx.":
+ print "Reloading", mod
+ reload(sys.modules[mod])
+
try:
exec open(scenefile) in globals(), globals()
except:
Index: gzz/gfx/demo/papertest.py
diff -c gzz/gfx/demo/papertest.py:1.35 gzz/gfx/demo/papertest.py:1.36
*** gzz/gfx/demo/papertest.py:1.35 Mon Oct 7 08:14:04 2002
--- gzz/gfx/demo/papertest.py Mon Oct 7 10:22:25 2002
***************
*** 25,33 ****
def ignore(s):
return ""
! import gfx.libpaper.papermill
from gfx.libpaper.papermill import ThePaperMill
- reload(gfx.libpaper.papermill)
benchmark = 0
def globalkey(k):
--- 25,36 ----
def ignore(s):
return ""
! import gfx.libutil.myimport
! reload(gfx.libutil.myimport)
! from gfx.libutil.myimport import my_import
!
! my_import("gfx.libpaper.papermill")
from gfx.libpaper.papermill import ThePaperMill
benchmark = 0
def globalkey(k):
Index: gzz/gfx/libpaper/papermill.py
diff -c gzz/gfx/libpaper/papermill.py:1.36 gzz/gfx/libpaper/papermill.py:1.37
*** gzz/gfx/libpaper/papermill.py:1.36 Mon Oct 7 08:43:23 2002
--- gzz/gfx/libpaper/papermill.py Mon Oct 7 10:22:25 2002
***************
*** 1,5 ****
--- 1,7 ----
#initialized = 0
+ import gfx.libutil.myimport
+ reload(gfx.libutil.myimport)
from gfx.libutil.myimport import my_import
my_import("gfx.libpaper.textures")
Index: gzz/gfx/libpaper/textures.py
diff -c gzz/gfx/libpaper/textures.py:1.14 gzz/gfx/libpaper/textures.py:1.15
*** gzz/gfx/libpaper/textures.py:1.14 Mon Oct 7 08:43:23 2002
--- gzz/gfx/libpaper/textures.py Mon Oct 7 10:22:25 2002
***************
*** 17,23 ****
ptextures = {}
-
# XXX: where should this code be? --------------
from gzz.gfx.gl import GL
from gfx.libutil.myimport import get_file_ctime
--- 17,22 ----
***************
*** 69,96 ****
tres = 128
! ptextures["RGB2"] = [
! apply(NamedTexture, i) for i in [
! ("rgbw1", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]]),
! ("rgbw2", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
"seed", "1412"]]),
!
! ("turb", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["turb", "1", "scale", ".3", "freq", "1", "freq2",
"100", "df", "2", "bias", "0"]]),
!
! ("pyramid", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]]),
! ("checkerboard", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type",
"1"]]),
! ("cone", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "2"]]),
! ("checkerboard2", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type",
"3"]]),
! ]]
!
def getPaperTexture(type, gen):
return selectRandom(ptextures[type], gen)
class Textures:
def __init__(self, seed):
rnd = java.util.Random(seed)
hyper = rnd.nextGaussian()*5
--- 68,102 ----
tres = 128
! initialized = 0
! def init():
! global initialized
! initialized = 1
! global ptextures
! ptextures["RGB2"] = [
! apply(NamedTexture, i) for i in [
! ("rgbw1", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["scale", "2.5", "freq", "1", "df", "2", "bias",
"0.5"]]),
! ("rgbw2", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["scale", ".43", "freq", "1", "df", "2", "bias",
"0.5", "seed", "1412"]]),
!
! ("turb", [tres, tres, 0, 3, "RGB", "RGB",
! "fnoise", ["turb", "1", "scale", ".3", "freq", "1",
"freq2", "100", "df", "2", "bias", "0"]]),
!
! ("pyramid", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]]),
! ("checkerboard", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type",
"1"]]),
! ("cone", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "2"]]),
! ("checkerboard2", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type",
"3"]]),
! ]]
!
def getPaperTexture(type, gen):
return selectRandom(ptextures[type], gen)
class Textures:
def __init__(self, seed):
+ if not initialized: init()
+
rnd = java.util.Random(seed)
hyper = rnd.nextGaussian()*5
Index: gzz/gfx/libutil/myimport.py
diff -c gzz/gfx/libutil/myimport.py:1.1 gzz/gfx/libutil/myimport.py:1.2
*** gzz/gfx/libutil/myimport.py:1.1 Mon Oct 7 08:14:05 2002
--- gzz/gfx/libutil/myimport.py Mon Oct 7 10:22:25 2002
***************
*** 1,4 ****
--- 1,5 ----
import sys
+ import inspect
if 0:
# XXX: stat not properly implemented in jython
***************
*** 18,43 ****
if not globals().has_key("import_times"):
import_times = {}
! def my_import(name):
""" Import the named module or reload if already imported
"""
! #XXX: ctime checking commented out because
! #dependecy checking is not implemented
! #ctime = get_module_ctime(name)
if name in sys.modules.keys():
! #if import_times[name] < ctime:
! print "Reloading module", name
! reload(sys.modules[name])
! #else:
! # print "Not reloading unchanged module", name
else:
print "Importing module", name
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
sys.modules[name] = mod
! #import_times[name] = ctime
--- 19,76 ----
if not globals().has_key("import_times"):
import_times = {}
! if not globals().has_key("dependencies"):
! dependencies = {}
!
! def do_reload(name):
! global dependencies, import_times
! ctime = get_module_ctime(name)
!
! if (not import_times.has_key(name)) or (import_times[name] < ctime):
! print "Reloading module", name
! reload(sys.modules[name])
! import_times[name] = ctime
! else:
! #print "Not reloading unchanged module", name
! if dependencies.has_key(name):
! #print "Checking dependencies:"
! deps = dependencies[name].keys()
! deps.sort()
! for dep in deps:
! do_reload(dep)
! #print "Dependencies done\n"
!
! def my_import_dep(name):
""" Import the named module or reload if already imported
+ and the file has changed
"""
! global dependencies, import_times
!
! parentname = inspect.currentframe().f_back.f_locals["__name__"]
! if not dependencies.has_key(parentname):
! dependencies[parentname] = {}
! dependencies[parentname][name] = 1
!
if name in sys.modules.keys():
! do_reload(name)
else:
print "Importing module", name
+ ctime = get_module_ctime(name)
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
sys.modules[name] = mod
+ import_times[name] = ctime
+
! def my_import_simple(name):
! print "Importing module", name
! mod = __import__(name)
! components = name.split('.')
! for comp in components[1:]:
! mod = getattr(mod, comp)
! sys.modules[name] = mod
+ my_import = my_import_dep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx demo/gldemo.py demo/papertest.py libpap...,
Janne V. Kujala <=