~sir-rainbow/+junk/scribes-on-win

« back to all changes in this revision

Viewing changes to SCRIBES/SaveSystem/NameGenerator.py

  • Committer: Marco Nembrini
  • Date: 2009-11-13 14:04:03 UTC
  • mfrom: (508.1.1 scribes)
  • Revision ID: sir.rainbow@gmail.com-20091113140403-wcr7jkglos4txyzq
corrected bug 480179

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from string import punctuation
2
 
STRIP_CHARACTERS = punctuation + " \n"
 
1
from string import punctuation, whitespace
 
2
STRIP_CHARACTERS = punctuation + whitespace
3
3
RESERVED_CHARACTERS = ["/", "\\", "?", "%", "*", ":", "|", '"', "<", ">", ".", "&", ",", "\t"]
4
4
NUMBER_OF_WORDS = 10
 
5
NUMBER_OF_CHARACTERS = 80
5
6
 
6
7
class Generator(object):
7
8
 
38
39
                        invalid_characters = [character for character in line if character in RESERVED_CHARACTERS]
39
40
                        for character in invalid_characters: line = line.replace(character, " ")
40
41
                        # Select first ten words and remove extras spaces to get filename
41
 
                        filename = " ".join(line.split()[:NUMBER_OF_WORDS]).strip()
 
42
                        filename = " ".join(line.split()[:NUMBER_OF_WORDS]).strip()[:NUMBER_OF_CHARACTERS].strip()
42
43
                except IndexError:
43
44
                        filename = ""
44
45
                finally: