summaryrefslogtreecommitdiff
path: root/namegen.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2011-06-11 12:39:43 +0200
committerElena ``of Valhalla'' Grandi <elena.valhalla@gmail.com>2011-06-11 12:39:43 +0200
commitd296a17f844dff38fc67a7769c0a891b94dda912 (patch)
tree805989e59e5ef7b5717fb154ab642809e01438a9 /namegen.py
parentdcc2ce311d7298350a9a3d0460042ebccce7211d (diff)
namegen.py: some documentation
Diffstat (limited to 'namegen.py')
-rwxr-xr-xnamegen.py35
1 files 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 <n>, --number=<n>
Generate <n> names (0 to generate no name).
-c <n>, --context=<n>
- Use <n> characters of context in the stats.
+ Use <n> 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 <organization> 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':