From d296a17f844dff38fc67a7769c0a891b94dda912 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 11 Jun 2011 12:39:43 +0200 Subject: namegen.py: some documentation --- namegen.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/namegen.py b/namegen.py index e04a3e5..0898d06 100755 --- a/namegen.py +++ b/namegen.py @@ -34,13 +34,40 @@ OPTIONS -n , --number= Generate names (0 to generate no name). -c , --context= - Use characters of context in the stats. + Use characters of context in the stats (ignored when loading + existing stats). -h, --help Show an help message. LICENSE ------- +Copyright (c) 2011, Elena Grandi, Diego Roversi +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + """ import json @@ -75,16 +102,16 @@ class Stats: self._increment_stats(name[i-self.context:i],name[i]) def load_stats(self,fp): - """Load stats from a yaml in a string or file-like object""" + """Load stats from json in a file-like object.""" self.stats = json.load(fp) self.context = max([len(k) for k in self.stats.keys()]) def save_stats(self,fp): - """Save stats in yaml to a file-like object""" + """Save stats in json to a file-like object.""" json.dump(self.stats,fp) def generate_name(self): - """Generate a name following the stats""" + """Generate a name.""" name = '' c = '' while c != '\n': -- cgit v1.2.3