prompt large_stringlengths 72 9.34k | completion large_stringlengths 0 7.61k |
|---|---|
<|file_name|>test_cpe_sorter.py<|end_file_name|><|fim▁begin|>import unittest
from matching.cpe_sorter import *
unsorted_cpes = [{'wfn': {'version': '4.0', 'target_sw': 'android_marshmallow'},
'uri_binding': 'cpe:/a:string_value_with\:double_points:internet_explorer:4.0:beta:~~~android_marshmallow~~'... | test_sort_cpes_by_operating_system_android |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []<|fim▁hole|>
def collect(frame):
global frames
frames.append(frame)
ca... | |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
<|fim_middle|>
cam.sigNewFrame.connect(collect)
... | global frames
frames.append(frame) |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
global frames
frames.append(frame)
cam.sigNewFra... | if len(frames) == 0:
QtCore.QTimer.singleShot(100, measure)
return
global run
if run:
global frames
frame = frames[-1]
frames = []
img = frame.data()
w,h = img.shape
img = img[2*w/5:3*w/5, 2*h/5:3*h/5]
w,h = img.shape
f... |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
global frames
frames.append(frame)
cam.sigNewFra... | QtCore.QTimer.singleShot(100, measure)
return |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
global frames
frames.append(frame)
cam.sigNewFra... | global frames
frame = frames[-1]
frames = []
img = frame.data()
w,h = img.shape
img = img[2*w/5:3*w/5, 2*h/5:3*h/5]
w,h = img.shape
fit = imageAnalysis.fitGaussian2D(img, [100, w/2., h/2., w/4., 0])
# convert sigma to full width at 1/e
... |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
global frames
frames.append(frame)
cam.sigNewFra... | global frames
frames = [] |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def <|fim_middle|>(frame):
global frames
frames.append(frame)
cam.si... | collect |
<|file_name|>beamProfiler.py<|end_file_name|><|fim▁begin|>from PyQt4 import QtCore
import acq4.Manager
import acq4.util.imageAnalysis as imageAnalysis
run = True
man = acq4.Manager.getManager()
cam = man.getDevice('Camera')
frames = []
def collect(frame):
global frames
frames.append(frame)
cam.sigNewFra... | measure |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
<|fim▁hole|> def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub_once():
holder... | class MessageHolder(object):
|
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
<|fim_middle|>
def test_multi_pubsub_once():
holder1 = MessageHolder()
holder2 = MessageHolder()
holder3 = MessageHolder()
sub1 = jps.Subscriber('test_utils1', holder1)
s... | def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
<|fim_middle|>
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub_once... | self._saved_msg = [] |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
<|fim_middle|>
def get_msg(self):
return self._saved_msg
def test_multi_pubsub_once():
... | self._saved_msg.append(msg) |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
<|fim_middle|>
def test_multi_pubsub_once()... | return self._saved_msg |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | holder1 = MessageHolder()
holder2 = MessageHolder()
holder3 = MessageHolder()
sub1 = jps.Subscriber('test_utils1', holder1)
sub2 = jps.Subscriber('test_utils2', holder2)
sub3 = jps.Subscriber('test_utils3', holder3)
pub = jps.utils.JsonMultiplePublisher()
time.sleep(0.1)
pub.publish(... |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | msg = '{"aa": 1, "bb": ["hoge", "hogi"], "cc": {"cc1" : 50}}'
converted = jps.utils.to_obj(msg)
assert converted.aa == 1
assert converted.bb[0] == 'hoge'
assert converted.bb[1] == 'hogi'
assert len(converted.bb) == 2
assert converted.cc.cc1 == 50
# todo: do
# json = converted.to_js... |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | msg = '["hoge", "hogi", {"atr1": "val2", "atr2": 1.0}]'
bb = jps.utils.to_obj(msg)
assert len(bb) == 2
assert bb[0] == 'hoge'
assert bb[1] == 'hogi'
assert bb[2].atr1 == 'val2'
assert bb[2].atr2 == 1.0 |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | msg = '[{"hoge": 1}, {"hogi": 2}]'
bb = jps.utils.to_obj(msg)
assert len(bb) == 2
assert bb[0].hoge == 1
assert bb[1].hogi == 2 |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | msg = '{"aa": 1, "cc": 3, "bb": 2}'
converted = jps.utils.to_obj(msg)
assert converted.aa == 1
assert converted.bb == 2
assert converted.cc == 3
# works only super simple case
json1 = converted.to_json()
assert json1 == msg |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def <|fim_middle|>(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_... | __init__ |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def <|fim_middle|>(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_... | __call__ |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def <|fim_middle|>(self):
return self._saved_msg
def test_multi... | get_msg |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def <|fim_middle|>():... | test_multi_pubsub_once |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | test_to_obj |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | test_to_obj_list |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | test_to_obj_list |
<|file_name|>test_utils.py<|end_file_name|><|fim▁begin|>import jps
import json
import time
class MessageHolder(object):
def __init__(self):
self._saved_msg = []
def __call__(self, msg):
self._saved_msg.append(msg)
def get_msg(self):
return self._saved_msg
def test_multi_pubsub... | test_to_obj_simple |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | self.wh.do_proxy.assert_called_with('<socket>') |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | def setUp(self):
super(NovaProxyRequestHandlerBaseTestCase, self).setUp()
self.wh = websocketproxy.NovaProxyRequestHandlerBase()
self.wh.socket = mock.MagicMock()
self.wh.msg = mock.MagicMock()
self.wh.do_proxy = mock.MagicMock()
self.wh.headers = mock.MagicMock()
... |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | super(NovaProxyRequestHandlerBaseTestCase, self).setUp()
self.wh = websocketproxy.NovaProxyRequestHandlerBase()
self.wh.socket = mock.MagicMock()
self.wh.msg = mock.MagicMock()
self.wh.do_proxy = mock.MagicMock()
self.wh.headers = mock.MagicMock() |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = {
'host': 'node1',
'port': '10000'
}
self.wh.socket.return_value = '<socket>'
self.wh.path = "ws://127.0.0.1/?token=123-456-789"
self.wh.new_websocket_client()
check_token.assert_called_with(mock.ANY, token="123-456-789... |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = False
self.wh.path = "ws://127.0.0.1/?token=XXX"
self.assertRaises(exception.InvalidToken,
self.wh.new_websocket_client)
check_token.assert_called_with(mock.ANY, token="XXX") |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = {
'host': 'node1',
'port': '10000'
}
self.wh.socket.return_value = '<socket>'
self.wh.path = "http://127.0.0.1/"
self.wh.headers.getheader.return_value = "token=123-456-789"
self.wh.new_websocket_client()
check_... |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = False
self.wh.path = "http://127.0.0.1/"
self.wh.headers.getheader.return_value = "token=XXX"
self.assertRaises(exception.InvalidToken,
self.wh.new_websocket_client)
check_token.assert_called_with(mock.ANY, token="XXX") |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = {
'host': 'node1',
'port': '10000',
'internal_access_path': 'vmid'
}
tsock = mock.MagicMock()
tsock.recv.return_value = "HTTP/1.1 200 OK\r\n\r\n"
self.wh.socket.return_value = tsock
self.wh.path = "ws://127.... |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | check_token.return_value = {
'host': 'node1',
'port': '10000',
'internal_access_path': 'xxx'
}
tsock = mock.MagicMock()
tsock.recv.return_value = "HTTP/1.1 500 Internal Server Error\r\n\r\n"
self.wh.socket.return_value = tsock
self.wh... |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | setUp |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client_token_invalid |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client_novnc |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client_novnc_token_invalid |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client_internal_access_path |
<|file_name|>test_websocketproxy.py<|end_file_name|><|fim▁begin|># All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LIC... | test_new_websocket_client_internal_access_path_err |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[... | |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
<|fim_middle|>
_reader = reader.Token_reader("\t",1)
_redu... | v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[1])>=int(v2[1]) else y
return r |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[... | for line in sys.stdin:
key, value = _reader.read_all(line)
K,V = _reducer.reduce(key,value)
if K:
print '{}\t{}'.format(V.split(',')[0],V.split(',')[1])
V = _reducer.out.split(',')
print '{}\t{}'.format(V[0],V[1]) |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[... | print '{}\t{}'.format(V.split(',')[0],V.split(',')[1]) |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[... | for line in sys.stdin:
key, value = _reader.read_all(line)
K,V = _reducer.reduce(key,value)
if K:
print '{}\t{}'.format(K,V)
print '{}\t{}'.format(key,V) |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def reduction(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if int(v1[... | print '{}\t{}'.format(K,V) |
<|file_name|>reducer.py<|end_file_name|><|fim▁begin|>#! /usr/bin/python
import sys
sys.path.append('../')
from toolbox.hreaders import token_readers as reader
from toolbox.hreducers import list_reducer as reducer
SOLO_FACTURA = False
def <|fim_middle|>(x,y):
v1 = x.split(',')
v2 = y.split(',')
r = x if in... | reduction |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | mapped_seq = list()
|
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
<|fim_middle|>
<|fim▁end|> | def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.assertEqual(15 , total)
def test_iterating_with_next(self):
stages = iter(['alpha','beta','gamma'])
try:
self.assertEqual('alpha', ne... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
<|fim_middle|>
def test_iterating_with_next(self):
stages = iter(['alpha','beta','gamma'])
... | it = iter(range(1,6))
total = 0
for num in it:
total += num
self.assertEqual(15 , total) |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | stages = iter(['alpha','beta','gamma'])
try:
self.assertEqual('alpha', next(stages))
next(stages)
self.assertEqual('gamma', next(stages))
next(stages)
except StopIteration as ex:
err_msg = 'Ran out of iterations'
self.assertRe... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return item + 10 |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | seq = [1, 2, 3]
mapped_seq = list()
mapping = map(self.add_ten, seq)
self.assertNotEqual(list, mapping.__class__)
self.assertEqual(map, mapping.__class__)
# In Python 3 built in iterator funcs return iterable view objects
# instead of lists
for item in ... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | def is_even(item):
return (item % 2) == 0
seq = [1, 2, 3, 4, 5, 6]
even_numbers = list()
for item in filter(is_even, seq):
even_numbers.append(item)
self.assertEqual([2,4,6], even_numbers) |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return (item % 2) == 0 |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | def is_big_name(item):
return len(item) > 4
names = ["Jim", "Bill", "Clarence", "Doug", "Eli"]
name = None
iterator = filter(is_big_name, names)
try:
name = next(iterator)
except StopIteration:
msg = 'Ran out of big names'
se... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return len(item) > 4 |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return accum + item |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return accum * item |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | import functools
# As of Python 3 reduce() has been demoted from a builtin function
# to the functools module.
result = functools.reduce(self.add, [2, 3, 4])
self.assertEqual(int, result.__class__)
# Reduce() syntax is same as Python 2
self.assertEqual(9, result... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | for num in range(1,5):
pass
self.assertEqual(4, num) |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | result = map(self.add_ten, range(1,4))
self.assertEqual([11, 12, 13], list(result))
try:
file = open("example_file.txt")
try:
def make_upcase(line):
return line.strip().upper()
upcase_lines = map(make_upcase, file.read... |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | return line.strip().upper() |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def <|fim_middle|>(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.assertEqual(15... | test_iterators_are_a_type |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_iterating_with_next |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | add_ten |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_map_transforms_elements_of_a_list |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_filter_selects_certain_items_from_a_list |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | is_even |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_just_return_first_item_found |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | is_big_name |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | add |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | multiply |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_reduce_will_blow_your_mind |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_use_pass_for_iterations_with_no_body |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | test_all_iteration_methods_work_on_any_sequence_not_just_lists |
<|file_name|>about_iteration.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutIteration(Koan):
def test_iterators_are_a_type(self):
it = iter(range(1,6))
total = 0
for num in it:
total += num
self.ass... | make_upcase |
<|file_name|>kartograph-script.py<|end_file_name|><|fim▁begin|>#!C:\Users\SeanSaito\Dev\aviato\flask\Scripts\python.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'kartograph.py==0.6.8','console_scripts','kartograph'
__requires__ = 'kartograph.py==0.6.8'
import sys<|fim▁hole|>if __name__ == '__main__':
sys.exit(
load_ent... | from pkg_resources import load_entry_point
|
<|file_name|>kartograph-script.py<|end_file_name|><|fim▁begin|>#!C:\Users\SeanSaito\Dev\aviato\flask\Scripts\python.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'kartograph.py==0.6.8','console_scripts','kartograph'
__requires__ = 'kartograph.py==0.6.8'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__... | sys.exit(
load_entry_point('kartograph.py==0.6.8', 'console_scripts', 'kartograph')()
) |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | is_staff = False
def get_short_name(self):
return self.name |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | is_staff = False
def get_short_name(self):
return self.name
def get_full_name(self):
return self.nickname
USERNAME_FIELD = 'username'
username = models.CharField('用户名', unique=True, max_length=64, editable=False, null=False, blank=False)
password = models.CharField('密码', max_l... |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | return self.name |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | return self.nickname |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | ample_user'
app_label = 'example_app'
verbose_name = verbose_name_plural = "用户"
|
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | get_short_name |
<|file_name|>models.py<|end_file_name|><|fim▁begin|># encoding: utf-8
from __future__ import absolute_import, unicode_literals
from apiview.model import AbstractUserMixin, BaseModel
from django.contrib.auth.base_user import AbstractBaseUser
from django.db import models
class User(AbstractUserMixin, BaseModel, Abstra... | get_full_name |
<|file_name|>manage.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "corponovo.settings")<|fim▁hole|> try:
from django.core.management import execute_from_command_line
except ImportError:
# ... | |
<|file_name|>manage.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
<|fim_middle|>
<|fim▁end|> | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "corponovo.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking oth... |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... |
class clv_insured(models.Model): |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | code = map(int, str(code_seq))
code_len = len(code)
while len(code) < 14:
code.insert(0, 0)
while len(code) < 16:
n = sum([(len(code) + 1 - i) * v for i, v in enumerate(code)]) % 11
if n > 1:
f = 11 - n
else:
f = 0
code.append(f)
code_s... |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | _inherit = 'clv_insured'
code = fields.Char('Insured Code', size=64, select=1, required=False, readonly=False, default='/',
help='Use "/" to get an automatic new Insured Code.')
@api.model
def create(self, vals):
if not 'code' in vals or ('code' in vals and vals['cod... |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | if not 'code' in vals or ('code' in vals and vals['code'] == '/'):
code_seq = self.pool.get('ir.sequence').get(self._cr, self._uid, 'clv_insured.code')
vals['code'] = format_code(code_seq)
return super(clv_insured, self).create(vals) |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | if 'code' in vals and vals['code'] == '/':
code_seq = self.pool.get('ir.sequence').get(self._cr, self._uid, 'clv_insured.code')
vals['code'] = format_code(code_seq)
return super(clv_insured, self).write(vals) |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | default = dict(default or {})
default.update({'code': '/',})
return super(clv_insured, self).copy(default) |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | f = 11 - n |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | f = 0 |
<|file_name|>clv_insured_seq.py<|end_file_name|><|fim▁begin|># -*- encoding: utf-8 -*-
################################################################################
# #
# Copyright (C) 2013-Today Carlos Eduardo Vercelino - CLVsol ... | code_form = code_str[18 - code_len:21] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.