prompt large_stringlengths 72 9.34k | completion large_stringlengths 0 7.61k |
|---|---|
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
<|fim_middle|>
def clear(r1, r2, c1, c2):
for i in range(r1, r2):
... | for i in range(r1, r2):
for j in range(c1, c2):
if 0 <= i < m and 0 <= j < n:
if g[i][j] == None:
s[i][j] = 0
elif i == 0 or j == 0:
s[i][j] = 1
elif g[i-1][j] != g[i][j] and g[i][j-1] != g[i][j] and \
... |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | for i in range(r1, r2):
for j in range(c1, c2):
if 0 <= i < m and 0 <= j < n:
g[i][j] = None |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | if g[i][j] == None:
s[i][j] = 0
elif i == 0 or j == 0:
s[i][j] = 1
elif g[i-1][j] != g[i][j] and g[i][j-1] != g[i][j] and \
g[i-1][j-1] == g[i][j]:
s[i][j] = 1 + min(s[i-1][j], s[i][j-1], ... |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | s[i][j] = 0 |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | s[i][j] = 1 |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | s[i][j] = 1 + min(s[i-1][j], s[i][j-1], s[i-1][j-1]) |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | s[i][j] = 1 |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | g[i][j] = None |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | b.append((-x, r, c))
clear(r+x+1, r+1, c+x+1, c+1)
process(r+x+1, r-x+1, c+x+1, c-x+1) |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def <|fim_middle|>(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
... | process |
<|file_name|>C.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
#
# Problem: Making Chess Boards
# Language: Python
# Author: KirarinSnow
# Usage: python thisfile.py <input.in >output.out
from heapq import *
def process(r1, r2, c1, c2):
for i in range(r1, r2):
for j in range(c1, c2):
if 0 <... | clear |
<|file_name|>weekend.py<|end_file_name|><|fim▁begin|>from datetime import datetime
from grazyna.utils import register
@register(cmd='weekend')
def weekend(bot):
"""
Answer to timeless question - are we at .weekend, yet?
"""
current_date = datetime.now()
day = current_date.weekday()
nick = bot.... | str_day = datetime.strftime(current_date, "%A")
answer = "%s - dopiero %s, musisz jeszcze poczekać..." % (nick, str_day) |
<|file_name|>weekend.py<|end_file_name|><|fim▁begin|>from datetime import datetime
from grazyna.utils import register
@register(cmd='weekend')
def weekend(bot):
<|fim_middle|>
<|fim▁end|> | """
Answer to timeless question - are we at .weekend, yet?
"""
current_date = datetime.now()
day = current_date.weekday()
nick = bot.user.nick
if day in (5, 6):
answer = "Oczywiście %s - jest weekend. Omawiamy tylko lajtowe tematy, ok?" % nick
else:
str_day = datetime.str... |
<|file_name|>weekend.py<|end_file_name|><|fim▁begin|>from datetime import datetime
from grazyna.utils import register
@register(cmd='weekend')
def weekend(bot):
"""
Answer to timeless question - are we at .weekend, yet?
"""
current_date = datetime.now()
day = current_date.weekday()
nick = bot.... | answer = "Oczywiście %s - jest weekend. Omawiamy tylko lajtowe tematy, ok?" % nick
|
<|file_name|>weekend.py<|end_file_name|><|fim▁begin|>from datetime import datetime
from grazyna.utils import register
@register(cmd='weekend')
def weekend(bot):
"""
Answer to timeless question - are we at .weekend, yet?
"""
current_date = datetime.now()
day = current_date.weekday()
nick = bot.... | tr_day = datetime.strftime(current_date, "%A")
answer = "%s - dopiero %s, musisz jeszcze poczekać..." % (nick, str_day)
|
<|file_name|>weekend.py<|end_file_name|><|fim▁begin|>from datetime import datetime
from grazyna.utils import register
@register(cmd='weekend')
def <|fim_middle|>(bot):
"""
Answer to timeless question - are we at .weekend, yet?
"""
current_date = datetime.now()
day = current_date.weekday()
nick... | weekend |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | print "Done look for results in testPanelResults.txt" |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | split_name_list = name.split("/")
for i in range(0, len(split_name_list)):
split_name_list[i] = split_name_list[i].strip()
return split_name_list |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | if "'" in name:
return "$$" + name + "$$"
else:
return "'" + name + "'" |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | return "$$" + name + "$$" |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | return "'" + name + "'" |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | test_description = esc_char(test_names[row] + "(" + type[row] + ")")
test_panel_results.write("nextval( 'panel_item_seq' ) , (select id from panel where name = '" + panel[row] + "')")
test_panel_results.write(" , (select id from test where description = " + test_description + ") , nu... |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | get_split_names |
<|file_name|>testPanel.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
panel_file = open('panels.txt','r')
name_file = open('testName.txt','r')
sample_type_file = open("sampleType.txt")
test_panel_results = open("output/testPanelResults.txt", 'w')
panel = []
type = []
test_names = []
def... | esc_char |
<|file_name|>test_docs.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
Money doctests as unittest Suite
"""
# RADAR: Python2
from __future__ import absolute_import
import doctest
import unittest
# RADAR: Python2
import money.six
FILES = (
'../../README.rst',
)
def load_tests(loader, tests, pattern):... | |
<|file_name|>test_docs.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
Money doctests as unittest Suite
"""
# RADAR: Python2
from __future__ import absolute_import
import doctest
import unittest
# RADAR: Python2
import money.six
FILES = (
'../../README.rst',
)
def load_tests(loader, tests, pattern):... | if money.six.PY2:
# Doc tests are Python 3.x
return unittest.TestSuite()
return doctest.DocFileSuite(*FILES) |
<|file_name|>test_docs.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
Money doctests as unittest Suite
"""
# RADAR: Python2
from __future__ import absolute_import
import doctest
import unittest
# RADAR: Python2
import money.six
FILES = (
'../../README.rst',
)
def load_tests(loader, tests, pattern):... | return unittest.TestSuite() |
<|file_name|>test_docs.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
Money doctests as unittest Suite
"""
# RADAR: Python2
from __future__ import absolute_import
import doctest
import unittest
# RADAR: Python2
import money.six
FILES = (
'../../README.rst',
)
def <|fim_middle|>(loader, tests, patte... | load_tests |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Tests for the wrapper around the libbind ns_msg struct"""
def test000Exists(self):
"""Check that the ns_msg type object exists cleanly in the module"""
assert(libbind.ns_msg.__class__ is type)
def testInstantiate(self):
"""Check that the ns_msg type accepts the correct arguments"""
# Too few
self... |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Check that the ns_msg type object exists cleanly in the module"""
assert(libbind.ns_msg.__class__ is type) |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Check that the ns_msg type accepts the correct arguments"""
# Too few
self.assertRaises(TypeError, libbind.ns_msg)
# Too many
self.assertRaises(TypeError, libbind.ns_msg, 'one', 'two') |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Test whether the ns_msg type can handle bad data"""
rng = testutils.rng
for testNum in range(0, 50):
packetLength = random.randrange(20, 80)
packetVal = rng.read(packetLength)
self.assertRaises(TypeError, libbind.ns_msg, packetVal) |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Test whether ns_msg initialization parses valid NS queries"""
packetData = file("data/www.company.example-query").read()
n = libbind.ns_msg(packetData)
assert(type(n) is libbind.ns_msg) |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | """Test whether ns_msg initialization parses valid NS queries"""
packetData = file("data/www.company.example-response").read()
n = libbind.ns_msg(packetData)
assert(type(n) is libbind.ns_msg) |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | s = unittest.TestSuite()
s.addTest( unittest.makeSuite(ns_msgTestCase, 'test') )
return s |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | unittest.main() |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | test000Exists |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | testInstantiate |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | testNoticeInvalid |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | testParseValidQuery |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | testParseValidResponse |
<|file_name|>testlibbind_ns_msg.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
#
# testlibbind_ns_msg.py - Unit tests for the libbind ns_msg wrapper
#
# This file is part of Strangle.
#
# Strangle is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | suite |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | context.update(
SETTINGS=settings,
now=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | secs, msecs = divmod(msecs, 1000)
mins, secs = divmod(secs, 60)
hours, mins = divmod(mins, 60)
if hours:
return '%dh%dm%ds' % (hours, mins, secs)
elif mins:
return '%dm%ds' % (mins, secs)
elif secs:
return '%ds%dms' % (secs, msecs)
else:
return '%.2fms' % msec... |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | template = env.get_template(template_name)
context.update(
SETTINGS=settings,
now=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
version='.'.join(map(str, __VERSION__)))
return template.render(**context) |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | return '%dh%dm%ds' % (hours, mins, secs) |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | return '%dm%ds' % (mins, secs) |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | return '%ds%dms' % (secs, msecs) |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | return '%.2fms' % msecs |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | friendly_time |
<|file_name|>template.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""Template shortcut & filters"""
import os
import datetime
from jinja2 import Environment, FileSystemLoader
from uwsgi_sloth.settings import ROOT
from uwsgi_sloth import settings, __VERSION__
template_path = os.path.join(ROOT, 'templates')... | render_template |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | } |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
<|fim_middle|>
class Pa... | username_or_email = forms.CharField()
error_messages = {
'not_found': _("Sorry, this user doesn't exist."),
}
def __init__(self, *args, **kwargs):
self.case_sensitive = kwargs.pop('case_sensitive', True)
search_fields = kwargs.pop('search_fields', ('username', 'email'))
... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.case_sensitive = kwargs.pop('case_sensitive', True)
search_fields = kwargs.pop('search_fields', ('username', 'email'))
super(PasswordRecoveryForm, self).__init__(*args, **kwargs)
message = ("No other fields than email are supported "
"by default")
if len(... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | username = self.cleaned_data['username_or_email']
cleaner = getattr(self, 'get_user_by_%s' % self.label_key)
self.cleaned_data['user'] = cleaner(username)
return username |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | key = 'username__%sexact' % ('' if self.case_sensitive else 'i')
User = get_user_model()
try:
user = User._default_manager.get(**{key: username})
except User.DoesNotExist:
raise forms.ValidationError(self.error_messages['not_found'],
... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | validate_email(email)
key = 'email__%sexact' % ('' if self.case_sensitive else 'i')
User = get_user_model()
try:
user = User._default_manager.get(**{key: email})
except User.DoesNotExist:
raise forms.ValidationError(self.error_messages['not_found'],
... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | key = '__%sexact'
key = key % '' if self.case_sensitive else key % 'i'
f = lambda field: Q(**{field + key: username})
filters = f('username') | f('email')
User = get_user_model()
try:
user = User._default_manager.get(filters)
except User.DoesNotExist:
... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | password1 = forms.CharField(
label=_('New password'),
widget=forms.PasswordInput,
)
password2 = forms.CharField(
label=_('New password (confirm)'),
widget=forms.PasswordInput,
)
error_messages = {
'password_mismatch': _("The two passwords didn't match."),
... |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.user = kwargs.pop('user')
super(PasswordResetForm, self).__init__(*args, **kwargs) |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | password1 = self.cleaned_data.get('password1', '')
password2 = self.cleaned_data['password2']
if not password1 == password2:
raise forms.ValidationError(
self.error_messages['password_mismatch'],
code='password_mismatch')
return password2 |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.user.set_password(self.cleaned_data['password1'])
if commit:
get_user_model()._default_manager.filter(pk=self.user.pk).update(
password=self.user.password,
)
return self.user |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | raise ValueError(message) |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | raise ValueError(message) |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.label_key = 'email' |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.label_key = search_fields[0] |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | self.label_key = 'both' |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | raise forms.ValidationError(
self.error_messages['password_mismatch'],
code='password_mismatch') |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | get_user_model()._default_manager.filter(pk=self.user.pk).update(
password=self.user.password,
) |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | __init__ |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | clean_username_or_email |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | get_user_by_username |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | get_user_by_email |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | get_user_by_both |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | __init__ |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | clean_password2 |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms
from django.core.validators import validate_email
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from .utils import get_user_model
class PasswordRecoveryForm(forms.Form):
username_or_email = forms.... | save |
<|file_name|>example_grid_time.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
"""
Grid time
=============
"""
from datetime import timedelta
import numpy as np
from opendrift.readers import reader_global_landmask
from opendrift.readers import reader_netCDF_CF_generic
from opendrift.models.oceandrift import Ocea... | lons = lons.ravel() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | if stat == "mean":
return data.mean()
if stat == "variance":
return data.var() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return re.match("q[0-9][0-9]?$", stat) |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | if stat in ["mean", "variance", "min", "max", "q100"]:
return stat
elif is_quantile(stat):
return stat
else:
raise argparse.ArgumentTypeError(
"Invalid statistic {0}".format(stat)) |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | parser = argparse.ArgumentParser()
parser.add_argument("data",
type=argparse.FileType("r"),
help="data file to be summarized."
"Should have columns seed, "\
"set, and metrics columns.")
parser.add_argu... |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | if stat == "mean":
return data.mean()
if stat == "variance":
return data.var()
if is_quantile(stat):
quantile = float(stat[1:]) / 100.0
if quantile == 0.0:
return data.min()
return data.quantile(quantile)
if stat == "max" or stat == "q100":
ret... |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | results = []
if group is None:
group = ["Set"]
togroupby = copy.copy(group)
ii = 0
if deltas is None:
togroupby = group
else:
while ii < len(group) and ii < len(deltas):
colname = "grid_{0}".format(group[ii])
gridnumbers = numpy.floor(data[group[ii... |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | fn = "_".join([result[0], os.path.basename(infn)])
fn = re.sub("\.hv$", "", fn)
fn = os.path.join(outputdir, fn)
print "writing {0}".format(fn)
result[1].to_csv(fn, sep=" ", index=True) |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | args = get_args()
data = pandas.read_table(args.data, sep=" ")
parameters = pandas.read_table(
args.parameters, sep=" ",
names=["name","low","high"],
header=None)
param_names = parameters["name"].values
para... |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return stat |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return stat |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | raise argparse.ArgumentTypeError(
"Invalid statistic {0}".format(stat)) |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return data.mean() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return data.var() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | quantile = float(stat[1:]) / 100.0
if quantile == 0.0:
return data.min()
return data.quantile(quantile) |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return data.min() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return data.max() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | return data.min() |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | group = ["Set"] |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | togroupby = group |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | while ii < len(group) and ii < len(deltas):
colname = "grid_{0}".format(group[ii])
gridnumbers = numpy.floor(data[group[ii]].apply(
lambda val: val / deltas[ii]))
data[colname] = gridnumbers.apply(
lambda val: val * delt... |
<|file_name|>statistics.py<|end_file_name|><|fim▁begin|>"""
Copyright (C) 2013 Matthew Woodruff
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your opti... | deltas = args.deltas |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.