class A(object):
def __ge__(self, other):
return True
def __le__(self, other):
return True
print(continue_link.encode().decode('utf-8', 'ignore'))
class Login(TemplateView):
template_name = 'core/home.html'
def post(self, request, *args, **kwargs):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is None:
try:
possible_user = Person.objects.get(phone=username)
user = auth.authenticate(username=possible_user.user.username, password=password)
except Person.DoesNotExist:
user = None
if user is not None:
if user.is_active:
auth.login(request, user)
return redirect(request.GET.get('next') or request.META.get('HTTP_REFERER') or reverse('home'))
else:
messages.add_message(request, messages.ERROR, 'Пользователь не активен')
else:
messages.add_message(request, messages.ERROR, 'Пользователь не найден')
return redirect(reverse('home'))
class CinemaForm(forms.ModelForm):
class Meta:
model = Cinema
fields = ('theater_name', 'theater_address', 'cinema_timetable', 'cinema_name')
password=password
class Retry(object):
"""
Retries function with exponential delay if it's releasing exception.
"""
def __init__(self, tries, exceptions=None, delay=1, exponent=1.5):
self.tries = tries
if exceptions:
self.exceptions = tuple(exceptions)
else:
self.exceptions = (Exception,)
self.delay = delay
self.exponent = exponent
def __call__(self, f):
def fn(*args, **kwargs):
exception = None
for i in range(self.tries):
try:
return f(*args, **kwargs)
except self.exceptions as e:
delay = self.delay * self.exponent ** i
if i + 1 == self.tries:
raise exception
sleep(delay)
exception = e
raise exception
return fn
@Retry(3)
def f():
...
docs = [[] for i in range(1)]
document = []
for line in open(mypath + '\\' + files[0]).readlines():
for word in line.split():
w = preprocessing(word, stop_words_list)
if w:
document.append(w)