diff -Nru genetic-wallpapers-1.0/debian/changelog genetic-wallpapers-1.1/debian/changelog --- genetic-wallpapers-1.0/debian/changelog 2010-12-19 07:36:23.000000000 +0000 +++ genetic-wallpapers-1.1/debian/changelog 2010-12-19 07:34:41.000000000 +0000 @@ -1,5 +1,17 @@ -genetic-wallpapers (1.0-1ubuntu3) lucid; urgency=low +genetic-wallpapers (1.1-1ubuntu1) lucid; urgency=low - * First working submission + * Automatic PPA Build for lucid - -- Martin Owens (DoctorMO) Fri, 17 Dec 2010 19:04:40 -0500 + -- Martin Owens (DoctorMO) Sun, 19 Dec 2010 02:34:41 -0500 + +genetic-wallpapers (1.1-1ubuntu0) UNRELEASED; urgency=low + + * Automatic PPA Build + + -- Martin Owens (DoctorMO) Sun, 19 Dec 2010 02:34:41 -0500 + +genetic-wallpapers (1.0-1ubuntu1) unstable; urgency=low + + * First action + + -- Martin Owens (DoctorMO) Fri, 17 Dec 2010 00:38:50 -0500 diff -Nru genetic-wallpapers-1.0/debian/control genetic-wallpapers-1.1/debian/control --- genetic-wallpapers-1.0/debian/control 2010-12-19 07:36:23.000000000 +0000 +++ genetic-wallpapers-1.1/debian/control 2010-12-19 07:34:41.000000000 +0000 @@ -1,11 +1,12 @@ Source: genetic-wallpapers Section: python Priority: optional -Maintainer: Luke Faraone +Maintainer: Martin Owens +XSBC-Original-Maintainer: Martin Owens Uploaders: Martin Owens Build-Depends: debhelper (>= 7), python-support, python Build-Depends-Indep: python-distutils-extra -Standards-Version: 3.8.4 +Standards-Version: 3.9.1 XS-Python-Version: >= 2.5 Homepage: https://launchpad.net/~doctormo diff -Nru genetic-wallpapers-1.0/debian/source/format genetic-wallpapers-1.1/debian/source/format --- genetic-wallpapers-1.0/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ genetic-wallpapers-1.1/debian/source/format 2010-12-19 07:36:23.000000000 +0000 @@ -0,0 +1 @@ +3.0 (native) diff -Nru genetic-wallpapers-1.0/GeneticWallpapers/genetic.py genetic-wallpapers-1.1/GeneticWallpapers/genetic.py --- genetic-wallpapers-1.0/GeneticWallpapers/genetic.py 2010-12-17 03:18:13.000000000 +0000 +++ genetic-wallpapers-1.1/GeneticWallpapers/genetic.py 2010-12-19 06:53:13.000000000 +0000 @@ -35,6 +35,11 @@ MUTATION = 0.02 # 2% of (max - min) MIGRATION = 0.2 # 20% of target +def Elements(nodeList): + """Create itorator for elements only""" + for node in nodeList: + if node.nodeType == 1: + yield node class SvgFileNotFound(IOError): pass @@ -46,7 +51,7 @@ """Reprisent a genetic wallpaper svg""" def __init__(self, filename, plots=None): self.filename = filename - self.plot = self.load_todays_plot(plots) + (self.plot, self.weight) = self.todays_plot(plots) self.shapes = None if not os.path.exists(filename): @@ -58,7 +63,7 @@ for group in self.xmldom.getElementsByTagName("g"): if group.getAttribute("id") == 'gen': - self.shapes = group.childNodes + self.shapes = Elements(group.childNodes) break if not self.shapes: raise SvgParseError("No generative groups in svg: %s." % filename) @@ -83,37 +88,40 @@ """Return the plot for the loaded svg file""" result = [] for shape in self.shapes: - if shape.nodeType == 1: - tram = shape.getAttribute('transform') - kind = tram.split('(')[0] - matrix = tram.split('(')[-1].split(')')[0].split(",") - if kind == 'translate': - matrix = [ '1', '0', '0', '1', matrix[0], matrix[1] ] - result.append(matrix) + name = shape.getAttribute('id') + result.append([name] + self.get_transform_matrix(shape)) return result + def get_transform_matrix(self, shape): + """Returns a transformation matrix, corrects for translates""" + attribute = shape.getAttribute('transform') + kind = attribute.split('(')[0] + matrix = attribute.split('(')[-1].split(')')[0].split(",") + if kind == 'translate': + # Force translate into a matrix transform + matrix = [ '1', '0', '0', '1', matrix[0], matrix[1] ] + elif len(matrix) != 6: + # Used to catch errors + matrix = [ '1', '0', '0', '1', '0', '0' ] + return matrix + + def nudge_all_shapes(self): """Go through all shapes and nudge them all""" - x = 0 for shape in self.shapes: - if shape.nodeType == 1: - locat = None - weight = None - if self.plot and len(self.plot) > x: - locat = self.plot[x].split(',') - weight = self.plot[-1] - self.nudge_shape(shape, locat, weight) - x += 1 + self.nudge_shape(shape) - def nudge_shape(self, shape, evil_plot=None, weight=None): + def nudge_shape(self, shape): """Nudge a single shape via it's transform""" - tram = shape.getAttribute('transform').split('(')[-1].split(')')[0] - matrix = tram.split(",") + name = shape.getAttribute('id') or '' + plot = self.plot.get(name, None) + matrix = self.get_transform_matrix(shape) + for x in range(0, len(matrix)): - if evil_plot and len(evil_plot) >= x: - matrix[x] = self.migrate(matrix[x], float(evil_plot[x]), weight) + if plot: + matrix[x] = self.migrate(matrix[x], float(plot[x]), self.weight) else: matrix[x] = self.mutate(matrix[x], MINIMUM[x], MAXIMUM[x]) tr = ",".join(matrix) @@ -122,6 +130,7 @@ def mutate(self, element, emin, emax): """Mutate makes the shapes move randomly""" + print "Mutating..." if emin and emax: element = float(element) amount = (float(random.randint(int(emin*100), @@ -137,6 +146,7 @@ def migrate(self, element, target, weight=MIGRATION): """Migrate makes the shapes move towards predefined points""" + print "Migrating..." element = float(element) diff = target - element if weight > 0 and weight <= 1: @@ -144,10 +154,10 @@ return str(element) - def load_todays_plot(self, filename): + def todays_plot(self, filename): """Downloads a configuration file for convergence""" if not (filename and os.path.exists(filename)): - return None + return ({}, None) fhs = open(filename, "r") for line in fhs.readlines(): cus = line.strip().split('|') @@ -159,7 +169,17 @@ step_day = date.today() - start print "Plotting Day %s (%s)" % (str(step_day.days), str(1.0 / (steps - step_day.days))) if step_day.days < steps: - return cus[1:] + [ 1.0 / (steps - step_day.days) ] + weight = 1.0 / (steps - step_day.days) + return (self.decode_plots(cus[1:]), weight) fhs.close() + return ({}, None) + def decode_plots(self, plots): + """Return a hash/dict of plots and the objects they apply to""" + result = {} + for plot in plots: + items = plot.split(',') + result[items[0]] = items[1:] + return result + diff -Nru genetic-wallpapers-1.0/GeneticWallpapers/__init__.py genetic-wallpapers-1.1/GeneticWallpapers/__init__.py --- genetic-wallpapers-1.0/GeneticWallpapers/__init__.py 2010-12-17 06:12:42.000000000 +0000 +++ genetic-wallpapers-1.1/GeneticWallpapers/__init__.py 2010-12-19 07:10:14.000000000 +0000 @@ -24,7 +24,7 @@ from fnmatch import fnmatch __package__ = 'genetic-wallpapers' -__version__ = '1.0' +__version__ = '1.1' GLOBAL_FILES = '/usr/share/genetic-wallpapers/' LOCAL_FILES = os.path.expanduser('~/.config/genetic-wallpapers/') diff -Nru genetic-wallpapers-1.0/PKG-INFO genetic-wallpapers-1.1/PKG-INFO --- genetic-wallpapers-1.0/PKG-INFO 2010-12-17 06:25:09.000000000 +0000 +++ genetic-wallpapers-1.1/PKG-INFO 2010-12-19 07:34:41.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: genetic-wallpapers -Version: 1.0 +Version: 1.1 Summary: Provide scripts for genetic svg wallpapers using genetic plotting and randomness Home-page: https://code.launchpad.net/~doctormo/ Author: Martin Owens