Commits

Antoni Aloy committed 883c8e8

updated from ensaimeitor

  • Participants
  • Parent commits b59fa08

Comments (0)

Files changed (5)

fakeutils/chomsky.py

     output = chain(*islice(izip(*parts), 0, times))
     return textwrap.fill(' '.join(output), line_length)
 
+if __name__=='__main__':
+	print chomsky(times=10)

fakeutils/core.py

 import datetime
 import re
 import lorem_ipsum
-
+ROOT = os.path.abspath(os.path.dirname(__file__))
 
 def slugify(value):
     """
     value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
     return re.sub('[-\s]+', '-', value)
 
-
-try:
-    from cStringIO import StringIO
-except ImportError:
-    from StringIO import StringIO
-
 log = logging.getLogger(__name__)
 
-dictionary = "/usr/share/dict/catalan"
+dictionary = os.path.join(ROOT, "dict/catalan")
+if not os.path.exists(dictionary):
+    dictionary = "/var/pywww/ensaimeitor/src/fakeutils/dict/catalan"
 
 if os.path.exists(dictionary):
     d = open(dictionary, "r").readlines()
     words = _random_words(num).decode('utf8').encode('utf8')
     return words
 
+def random_unicode_words(num):
+    """Deuevle el número de palabras especificado en unicode"""
+    return _random_words(num).decode('utf8')
+
 def random_slug(num=2):
     slug = random_words(num).replace(" ", "-")
     return ''.join(ch for ch in slug if ch.isalnum() or ch == '-')
     else:
         return simple_url
 
-def random_domain_url(sufix=".com"):
+def random_domain_url(sufix=None):
+    if not sufix:
+        sufix = random.choice(["com", "org", "net", "gov", "eu", 'es','cat'])
     data = (random_slug(),sufix)
-    return "http://%s%s/" % data
+    return "http://%s.%s/" % data
 
 def random_text(max_length):
     text_content = _random_paragraphs(4)