Exemplo n.º 1
0
 def __init__(self,
              data,
              name=haikunator.haikunate(),
              env=LiterateEnvironment()):
     self.env = env
     self.name = name
     self.env.globals[self.name] = self
     super().__init__(data)
Exemplo n.º 2
0
def _new_haiku():
    name = None
    while not name:
        name = haikunator.haikunate(tokenlength=3, delimiter='')
        if Game.objects.filter(name=name).exists():
            name = None
            continue
    return name
Exemplo n.º 3
0
def _new_haiku():
    name = None
    while not name:
        name = haikunator.haikunate(tokenlength=3, delimiter='')
        if Game.objects.filter(name=name).exists():
            name = None
            continue
    return name
Exemplo n.º 4
0
def new_room(request):
    new_room = None
    while not new_room:
        with transaction.atomic():

            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label, lobby=Lobby.objects.get(label=cache.get('lobbylabel')))
Exemplo n.º 5
0
    def make_name(self):
        """
        Makes a Heroku-style name.

        :return: a Heroku-style haiku name
        """
        while True:
            name = haikunate()
            if name not in self.games:
                return name
Exemplo n.º 6
0
Arquivo: views.py Projeto: vsoch/chat
def new_room(request):
    '''new_room will randomly create a new room, and redirect to it.
    '''
    new_room = None
    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)
    return redirect(chat_room, label=label)
Exemplo n.º 7
0
def new_room(request):
    new_room = None

    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)

    return redirect(room, label=label)
Exemplo n.º 8
0
def new_room(request):
    """
    Randomly create a new room, and redirect to it.
    """
    new_room = None
    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)
    return redirect(chat_room, label=label)
Exemplo n.º 9
0
def new_discussion(request):
    """
    Randomly create a new discussion, and redirect to it.
    """
    new_discussion = None
    while not new_discussion:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Discussion.objects.filter(label=label).exists():
                continue
            new_discussion = Discussion.objects.create(label=label)
    return redirect(discussion_forum, label=label)
Exemplo n.º 10
0
def new_room(request):
    """
    Randomly create a new roomt
    """
    print("new room")
    new_room = None
    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)
    return redirect('chat:chat_room', label=label)
Exemplo n.º 11
0
 def literate(self, line, cell):
     line = line.strip()
     args = IPython.core.magic_arguments.parse_argstring(self.literate, line)
     define_global = True
     if args.name:
         self.env.globals['_current_name'] = args.name
     else:
         define_global = False
         args.name = haikunator.haikunate(delimiter='_',tokenlength=0)
     display = Cell( cell, args.name, self.env )
     if define_global:
         self.env.ip.user_ns[args.name] = display
     if not args.nodisplay:
         return display
Exemplo n.º 12
0
def new_room(request):
    """
    Cree aleatoriamente una nueva sala y redireccione a ella.
    """
    new_room = None

    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)

    return redirect(chat_room, label=label)
Exemplo n.º 13
0
def new_room(request):
    """
    Randomly create a new room, and redirect to it.
    """
    print("start in new_room of view!!!!!!!!!!!!")

    new_room = None
    while not new_room:
        with transaction.atomic():
            label = haikunator.haikunate()
            if Room.objects.filter(label=label).exists():
                continue
            new_room = Room.objects.create(label=label)
    return redirect(chat_room, label=label)
Exemplo n.º 14
0
    def create(self, request, *args, **kwargs):
        new_room = None
        while not new_room:
            with transaction.atomic():
                label = haikunator.haikunate()
                if Room.objects.filter(label=label).exists():
                    continue
                new_room = Room.objects.create(label=label)

        serializer = self.get_serializer(new_room)
        headers = self.get_success_headers(serializer.data)
        return Response(serializer.data,
                        status=status.HTTP_201_CREATED,
                        headers=headers)
Exemplo n.º 15
0
 def literate(self, line, cell):
     line = line.strip()
     args = IPython.core.magic_arguments.parse_argstring(
         self.literate, line)
     define_global = True
     if args.name:
         self.env.globals['_current_name'] = args.name
     else:
         define_global = False
         args.name = haikunator.haikunate(delimiter='_', tokenlength=0)
     display = Cell(cell, args.name, self.env)
     if define_global:
         self.env.ip.user_ns[args.name] = display
     if not args.nodisplay:
         return display
Exemplo n.º 16
0
 def test_onesingleword(self):
     self.assertRegexp(haikunate(delimiter='', tokenlength=0),
                       "((?:[a-z][a-z]+))$")
Exemplo n.º 17
0
 def test_wont_return_same(self):
     self.assertNotEqual(haikunate(), haikunate())
Exemplo n.º 18
0
 def test_9digits_use(self):
     self.assertRegexp(haikunate(tokenlength=9), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{9})$")
Exemplo n.º 19
0
 def test_return_same_with_seed(self):
     seed = 'testseed'
     self.assertEqual(haikunate(seed=seed), haikunate(seed=seed))
Exemplo n.º 20
0
def append_random_haiku(name):
    haiku = haikunator.haikunate(token_length=0, delimiter='')
    return "{}_{}".format(name, haiku)
Exemplo n.º 21
0
def _make_display_name():
    return haikunate(tokenhex=True, tokenlength=6)
Exemplo n.º 22
0
 def test_spacedelimiter_and_notoken(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(delimiter=' ', tokenLength=0), "((?:[a-z][a-z]+))( )((?:[a-z][a-z]+))$")
   else:
     self.assertRegexpMatches(haikunate(delimiter=' ', tokenLength=0), "((?:[a-z][a-z]+))( )((?:[a-z][a-z]+))$")
Exemplo n.º 23
0
 def test_permits_optional_delimiter(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(delimiter='.'), "((?:[a-z][a-z]+))(\\.)((?:[a-z][a-z]+))(\\.)(\\d+)$")
   else:
     self.assertRegexpMatches(haikunate(delimiter='.'), "((?:[a-z][a-z]+))(\\.)((?:[a-z][a-z]+))(\\.)(\\d+)$")
Exemplo n.º 24
0
 def test_drops_token(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(tokenLength=0), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))$")
   else:
     self.assertRegexpMatches(haikunate(tokenLength=0), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))$")
Exemplo n.º 25
0
 def test_9digitsashex_use(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(tokenHex=True, tokenLength=9), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{9})$")
   else:
     self.assertRegexpMatches(haikunate(tokenHex=True, tokenLength=9), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{9})$")
Exemplo n.º 26
0
 def test_hex_use(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(tokenHex=True), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{4})$")
   else:
     self.assertRegexpMatches(haikunate(tokenHex=True), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{4})$")
Exemplo n.º 27
0
 def test_9digitsashex_use(self):
     self.assertRegexp(haikunate(tokenhex=True, tokenlength=9),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{9})$")
Exemplo n.º 28
0
 def test_return_same_with_seed(self):
     seed = 'testseed'
     self.assertEqual(haikunate(seed=seed), haikunate(seed=seed))
Exemplo n.º 29
0
 def test_drops_token(self):
     self.assertRegexp(haikunate(tokenlength=0),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))$")
Exemplo n.º 30
0
 def test_onesingleword(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(delimiter='', tokenLength=0), "((?:[a-z][a-z]+))$")
   else:
     self.assertRegexpMatches(haikunate(delimiter='', tokenLength=0), "((?:[a-z][a-z]+))$")
Exemplo n.º 31
0
def _make_display_name():
    return haikunate(tokenhex=True, tokenlength=6)
Exemplo n.º 32
0
 def test_customchars(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(tokenChars='A'), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(AAAA)$")
   else:
     self.assertRegexpMatches(haikunate(tokenChars='A'), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(AAAA)$")
Exemplo n.º 33
0
 def test_permits_optional_delimiter(self):
     self.assertRegexp(
         haikunate(delimiter='.'),
         "((?:[a-z][a-z]+))(\\.)((?:[a-z][a-z]+))(\\.)(\\d+)$")
Exemplo n.º 34
0
 def test_default_use(self):
     self.assertRegexp(haikunate(), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{4})$")
Exemplo n.º 35
0
 def test_default_use(self):
   if (sys.version_info > (3, 0)):
     self.assertRegex(haikunate(), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{4})$")
   else:
     self.assertRegexpMatches(haikunate(), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{4})$")
Exemplo n.º 36
0
 def test_customchars(self):
     self.assertRegexp(haikunate(tokenchars='A'),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(AAAA)$")
Exemplo n.º 37
0
def get_default_device_name():
	return haikunate(tokenLength=0)
Exemplo n.º 38
0
 def test_9digits_use(self):
     self.assertRegexp(haikunate(tokenlength=9),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{9})$")
Exemplo n.º 39
0
 def test_hex_use(self):
     self.assertRegexp(haikunate(tokenhex=True), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{4})$")
Exemplo n.º 40
0
 def test_permits_optional_delimiter(self):
     self.assertRegexp(haikunate(delimiter='.'), "((?:[a-z][a-z]+))(\\.)((?:[a-z][a-z]+))(\\.)(\\d+)$")
Exemplo n.º 41
0
 def test_9digitsashex_use(self):
     self.assertRegexp(haikunate(tokenhex=True, tokenlength=9), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{9})$")
Exemplo n.º 42
0
 def test_onesingleword(self):
     self.assertRegexp(haikunate(delimiter='', tokenlength=0), "((?:[a-z][a-z]+))$")
Exemplo n.º 43
0
 def test_drops_token(self):
     self.assertRegexp(haikunate(tokenlength=0), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))$")
Exemplo n.º 44
0
 def test_spacedelimiter_and_notoken(self):
     self.assertRegexp(haikunate(delimiter=' ', tokenlength=0),
                       "((?:[a-z][a-z]+))( )((?:[a-z][a-z]+))$")
Exemplo n.º 45
0
 def test_spacedelimiter_and_notoken(self):
     self.assertRegexp(haikunate(delimiter=' ', tokenlength=0), "((?:[a-z][a-z]+))( )((?:[a-z][a-z]+))$")
Exemplo n.º 46
0
 def test_hex_use(self):
     self.assertRegexp(haikunate(tokenhex=True),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(.{4})$")
Exemplo n.º 47
0
 def test_customchars(self):
     self.assertRegexp(haikunate(tokenchars='A'), "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(AAAA)$")
Exemplo n.º 48
0
 def test_default_use(self):
     self.assertRegexp(haikunate(),
                       "((?:[a-z][a-z]+))(-)((?:[a-z][a-z]+))(-)(\\d{4})$")
Exemplo n.º 49
0
 def __init__(self, data, name=haikunator.haikunate(), env=LiterateEnvironment()):
     self.env = env
     self.name = name
     self.env.globals[self.name] = self
     super().__init__(data)
Exemplo n.º 50
0
 def test_wont_return_same(self):
     self.assertNotEqual(haikunate(), haikunate())