function
stringlengths 11
56k
| repo_name
stringlengths 5
60
| features
sequence |
---|---|---|
def get_inputs(self):
return self.distribution.headers or [] | ryfeus/lambda-packs | [
1086,
234,
1086,
13,
1476901359
] |
def find_files(pattern, root):
"""Return all the files matching pattern below root dir."""
for path, _, files in os.walk(root):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename) | ryfeus/lambda-packs | [
1086,
234,
1086,
13,
1476901359
] |
def available():
return tornadoAvailable | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def start():
if WebSocket.available():
WSThread().start() | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def broadcast(data):
for handler in handlers:
handler.write_message(toJS(data)) | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def sendChannel(channel, data):
if not 'channel' in data:
data['channel'] = channel
for handler in channels.get(channel, []):
handler.write_message(toJS(data)) | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def __init__(self):
Thread.__init__(self)
self.name = 'websocket'
self.daemon = True | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def __init__(self, *args, **kw):
super(WSHandler, self).__init__(*args, **kw)
self.channels = set() | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def open(self):
handlers.append(self)
console('websocket', "Opened") | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def on_close(self):
for channel in self.channels:
channels[channel].remove(self)
if len(channels[channel]) == 0:
del channels[channel]
handlers.remove(self)
console('websocket', "Closed") | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def newTask(self, handler, task):
WebSocket.sendChannel("backlog#%d" % task.sprint.id, {'type': 'new'}); #TODO | mrozekma/Sprint | [
3,
1,
3,
58,
1334369567
] |
def test_telemetry_finish(runner, live_mock_server, parse_ctx):
with runner.isolated_filesystem():
run = wandb.init()
run.finish()
ctx_util = parse_ctx(live_mock_server.get_ctx())
telemetry = ctx_util.telemetry
assert telemetry and 2 in telemetry.get("3", []) | wandb/client | [
5607,
445,
5607,
725,
1490334383
] |
def test_telemetry_imports_catboost(runner, live_mock_server, parse_ctx):
with runner.isolated_filesystem():
with mock.patch.dict("sys.modules", {"catboost": mock.Mock()}):
import catboost
run = wandb.init()
run.finish()
ctx_util = parse_ctx(live_mock_server.get_ctx())
telemetry = ctx_util.telemetry
# catboost in both init and finish modules
assert telemetry and 7 in telemetry.get("1", [])
assert telemetry and 7 in telemetry.get("2", []) | wandb/client | [
5607,
445,
5607,
725,
1490334383
] |
def test_telemetry_imports_jax(runner, live_mock_server, parse_ctx):
with runner.isolated_filesystem():
import jax
wandb.init()
wandb.finish()
ctx_util = parse_ctx(live_mock_server.get_ctx())
telemetry = ctx_util.telemetry
# jax in finish modules but not in init modules
assert telemetry and 12 in telemetry.get("1", [])
assert telemetry and 12 in telemetry.get("2", []) | wandb/client | [
5607,
445,
5607,
725,
1490334383
] |
def rectangular_plane_layout(mesh,corner, closed = False,I=1.):
"""
corner: sorted list of four corners (x,y,z)
2--3
| |
1--4
y
|
|--> x
Output:
Js
"""
Jx = np.zeros(mesh.nEx)
Jy = np.zeros(mesh.nEy)
Jz = np.zeros(mesh.nEz)
indy1 = np.logical_and( \
np.logical_and( \
np.logical_and(mesh.gridEy[:,0]>=corner[0,0],mesh.gridEy[:,0]<=corner[1,0]), \
np.logical_and(mesh.gridEy[:,1] >=corner[0,1] , mesh.gridEy[:,1]<=corner[1,1] )),
(mesh.gridEy[:,2] == corner[0,2]
)
)
indx1 = np.logical_and( \
np.logical_and( \
np.logical_and(mesh.gridEx[:,0]>=corner[1,0],mesh.gridEx[:,0]<=corner[2,0]), \
np.logical_and(mesh.gridEx[:,1] >=corner[1,1] , mesh.gridEx[:,1]<=corner[2,1] )),
(mesh.gridEx[:,2] == corner[1,2]
)
)
indy2 = np.logical_and( \
np.logical_and( \
np.logical_and(mesh.gridEy[:,0]>=corner[2,0],mesh.gridEy[:,0]<=corner[3,0]), \
np.logical_and(mesh.gridEy[:,1] <=corner[2,1] , mesh.gridEy[:,1]>=corner[3,1] )),
(mesh.gridEy[:,2] == corner[2,2]
)
)
if closed:
indx2 = np.logical_and( \
np.logical_and( \
np.logical_and(mesh.gridEx[:,0]>=corner[0,0],mesh.gridEx[:,0]<=corner[3,0]), \
np.logical_and(mesh.gridEx[:,1] >=corner[0,1] , mesh.gridEx[:,1]<=corner[3,1] )),
(mesh.gridEx[:,2] == corner[0,2]
)
)
else:
indx2 = []
Jy[indy1] = -I
Jx[indx1] = -I
Jy[indy2] = I
Jx[indx2] = I
J = np.hstack((Jx,Jy,Jz))
J = J*mesh.edge
return J | geoscixyz/em_examples | [
8,
7,
8,
9,
1453777337
] |
def analytic_infinite_wire(obsloc,wireloc,orientation,I=1.):
"""
Compute the response of an infinite wire with orientation 'orientation'
and current I at the obsvervation locations obsloc
Output:
B: magnetic field [Bx,By,Bz]
"""
n,d = obsloc.shape
t,d = wireloc.shape
d = np.sqrt(np.dot(obsloc**2.,np.ones([d,t]))+np.dot(np.ones([n,d]),(wireloc.T)**2.)
- 2.*np.dot(obsloc,wireloc.T))
distr = np.amin(d, axis=1, keepdims = True)
idxmind = d.argmin(axis=1)
r = obsloc - wireloc[idxmind]
orient = np.c_[[orientation for i in range(obsloc.shape[0])]]
B = (mu_0*I)/(2*np.pi*(distr**2.))*np.cross(orientation,r)
return B | geoscixyz/em_examples | [
8,
7,
8,
9,
1453777337
] |
def hexstr(s):
import string
h = string.hexdigits
r = ''
for c in s:
i = ord(c)
r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
return r | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_unknown_hash(self):
try:
hashlib.new('spam spam spam spam spam')
except ValueError:
pass
else:
self.assert_(0 == "hashlib didn't reject bogus hash name") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_hexdigest(self):
for name in self.supported_hash_names:
h = hashlib.new(name)
self.assert_(hexstr(h.digest()) == h.hexdigest()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_large_update(self):
aas = 'a' * 128
bees = 'b' * 127
cees = 'c' * 126 | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def check(self, name, data, digest):
# test the direct constructors
computed = getattr(hashlib, name)(data).hexdigest()
self.assert_(computed == digest)
# test the general new() interface
computed = hashlib.new(name, data).hexdigest()
self.assert_(computed == digest) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_md5_0(self):
self.check('md5', '', 'd41d8cd98f00b204e9800998ecf8427e') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_md5_1(self):
self.check('md5', 'abc', '900150983cd24fb0d6963f7d28e17f72') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_md5_2(self):
self.check('md5', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
'd174ab98d277d9f5a5611c2c9f419d9f') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_md5_huge(self, size):
if size == _4G + 5:
try:
self.check('md5', 'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
except OverflowError:
pass # 32-bit arch | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_md5_uintmax(self, size):
if size == _4G - 1:
try:
self.check('md5', 'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')
except OverflowError:
pass # 32-bit arch | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha1_0(self):
self.check('sha1', "",
"da39a3ee5e6b4b0d3255bfef95601890afd80709") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha1_1(self):
self.check('sha1', "abc",
"a9993e364706816aba3e25717850c26c9cd0d89d") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha1_2(self):
self.check('sha1', "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha1_3(self):
self.check('sha1', "a" * 1000000,
"34aa973cd4c4daa4f61eeb2bdbad27316534016f") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha224_0(self):
self.check('sha224', "",
"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha224_1(self):
self.check('sha224', "abc",
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha224_2(self):
self.check('sha224',
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha224_3(self):
self.check('sha224', "a" * 1000000,
"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha256_0(self):
self.check('sha256', "",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha256_1(self):
self.check('sha256', "abc",
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha256_2(self):
self.check('sha256',
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha256_3(self):
self.check('sha256', "a" * 1000000,
"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha384_0(self):
self.check('sha384', "",
"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da"+
"274edebfe76f65fbd51ad2f14898b95b") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha384_1(self):
self.check('sha384', "abc",
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed"+
"8086072ba1e7cc2358baeca134c825a7") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha384_2(self):
self.check('sha384',
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712"+
"fcc7c71a557e2db966c3e9fa91746039") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha384_3(self):
self.check('sha384', "a" * 1000000,
"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b"+
"07b8b3dc38ecc4ebae97ddd87f3d8985") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha512_0(self):
self.check('sha512', "",
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"+
"47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha512_1(self):
self.check('sha512', "abc",
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"+
"2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha512_2(self):
self.check('sha512',
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"+
"501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_case_sha512_3(self):
self.check('sha512', "a" * 1000000,
"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"+
"de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b") | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_main():
test_support.run_unittest(HashLibTestCase) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_getattr_fallback(mock_record):
"""Verify cursor __getattr__ falls back to AttributeError for unknown cursor + list methods"""
with pytest.raises(AttributeError):
getattr(mock_record['Text List'], 'unknown_method') | Swimlane/sw-python-client | [
25,
26,
25,
2,
1452204955
] |
def test_modification_validation(mock_record):
"""Test calling list methods on cursor respects validation"""
mock_record['Text List'].append('text')
with pytest.raises(ValidationError):
mock_record['Text List'].append(123) | Swimlane/sw-python-client | [
25,
26,
25,
2,
1452204955
] |
def test_list_length_validation(mock_record):
"""List length validation check"""
key = 'Numeric List Range Limit'
mock_record[key] = [5, 6, 7]
with pytest.raises(ValidationError):
mock_record[key].append(8)
with pytest.raises(ValidationError):
mock_record[key] = [] | Swimlane/sw-python-client | [
25,
26,
25,
2,
1452204955
] |
def test_min_max_word_validation(mock_record):
"""Validate against min/max word restrictions"""
key = 'Text List Word Limit'
with pytest.raises(ValidationError):
mock_record[key] = ['word ' * 10]
with pytest.raises(ValidationError):
mock_record[key] = ['word'] | Swimlane/sw-python-client | [
25,
26,
25,
2,
1452204955
] |
def printData(sample):
# os.system('clear')
print("----------------")
print("%f" % (sample.id))
print(sample.channel_data)
print(sample.aux_data)
print("----------------") | OpenBCI/OpenBCI_Python | [
471,
201,
471,
44,
1401812525
] |
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest() | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def __init__(self, key):
self.bs = 32
self.key = hashlib.sha256(key.encode()).digest() | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def decrypt(self, enc):
# enc = base64.b64decode(enc)
iv = enc[:AES.block_size]
cipher = AES.new(self.key, AES.MODE_CBC, iv)
return self._unpad(cipher.decrypt(enc[AES.block_size:])).decode('utf-8') | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def _unpad(s):
return s[:-ord(s[len(s)-1:])] | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def __init__(self, host, key, port=443, max_size=4096):
# Params for all class
self.host = host
self.port = port
self.max_size = max_size - 60
self.AESDriver = AESCipher(key=key)
self.serv_addr = (host, port)
# Class Globals
self.max_packets = 255 # Limitation by QUIC itself.
self._genSeq() # QUIC Sequence is used to know that this is the same sequence,
# and it's a 20 byte long that is kept the same through out the
# session and is transfered hex encoded.
self.delay = 0.1
self.sock = None
if self._createSocket() is 1: # Creating a UDP socket object
sys.exit(1)
self.serv_addr = (self.host, self.port) # Creating socket addr format | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def _createSocket(self):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock = sock
return 0
except socket.error as e:
sys.stderr.write("[!]\tFailed to create a UDP socket.\n%s.\n" % e)
return 1 | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def _getFileContent(self, file_path):
try:
f = open(file_path, 'rb')
data = f.read()
f.close()
sys.stdout.write("[+]\tFile '%s' was loaded for exfiltration.\n" % file_path)
return data
except IOError, e:
sys.stderr.write("[-]\tUnable to read file '%s'.\n%s.\n" % (file_path, e))
return 1 | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def close(self):
time.sleep(0.1)
self.sock.close()
return 0 | ytisf/PyExfil | [
668,
140,
668,
1,
1417115184
] |
def kazoo_client_cache_enable(enable):
"""
You may disable or enable the connection cache using this function.
The connection cache reuses a connection object when the same connection parameters
are encountered that have been used previously. Because of the design of parts of this program
functionality needs to be independent and uncoupled, which means it needs to establish its own
connections.
Connections to Zookeeper are the most time consuming part of most interactions so caching
connections enables much faster running of tests health checks, etc.
"""
global CONNECTION_CACHE_ENABLED
CONNECTION_CACHE_ENABLED = enable | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def kazoo_client_cache_serialize_args(kwargs):
'''
Returns a hashable object from keyword arguments dictionary.
This hashable object can be used as the key in another dictionary. | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def kazoo_client_cache_get(kwargs):
if CONNECTION_CACHE_ENABLED:
return CONNECTION_CACHE.get(kazoo_client_cache_serialize_args(kwargs)) | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def kazoo_client_cache_put(kwargs, client):
global CONNECTION_CACHE
CONNECTION_CACHE[kazoo_client_cache_serialize_args(kwargs)] = client | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def kazoo_clients_connect(clients, timeout=5, continue_on_error=False):
"""
Connect the provided Zookeeper client asynchronously.
This is the fastest way to connect multiple clients while respecting a timeout. | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def kazoo_clients_from_client(kazoo_client):
"""
Construct a series of KazooClient connection objects from a single KazooClient instance | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def get_leader(zk_hosts):
# TODO refactor me to accept KazooClient object.
for host in zk_hosts: | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def get_server_by_id(zk_hosts, server_id):
# TODO refactor me to accept KazooClient object.
if not isinstance(server_id, int):
raise ValueError('server_id must be int, got: %s' % type(server_id)) | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def zk_conn_from_client(kazoo_client):
"""
Make a Zookeeper connection string from a KazooClient instance
"""
hosts = kazoo_client.hosts
chroot = kazoo_client.chroot
return zk_conn_from_hosts(hosts, chroot) | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def zk_conns_from_client(kazoo_client):
"""
Make a Zookeeper connection string per-host from a KazooClient instance
"""
hosts = kazoo_client.hosts
chroot = kazoo_client.chroot
return zk_conns_from_hosts(hosts, chroot) | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def zk_conn_from_hosts(hosts, chroot=None):
"""
Make a Zookeeper connection string from a list of (host,port) tuples.
"""
if chroot and not chroot.startswith('/'):
chroot = '/' + chroot
return ','.join(['%s:%s' % (host,port) for host, port in hosts]) + chroot or '' | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def zk_conns_from_hosts(hosts, chroot=None):
"""
Make a list of Zookeeper connection strings one her host.
"""
if chroot and not chroot.startswith('/'):
chroot = '/' + chroot
return ['%s:%s' % (host,port) + chroot or '' for host, port in hosts] | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def parse_zk_conn(zookeepers):
"""
Parse Zookeeper connection string into a list of fully qualified connection strings.
"""
zk_hosts, root = zookeepers.split('/') if len(zookeepers.split('/')) > 1 else (zookeepers, None)
zk_hosts = zk_hosts.split(',')
root = '/'+root if root else '' | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def parse_zk_hosts(zookeepers, all_hosts=False, leader=False, server_id=None):
"""
Returns [host1, host2, host3] | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def text_type(string, encoding='utf-8'):
"""
Given text, or bytes as input, return text in both python 2/3 | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def netcat(hostname, port, content, timeout=5):
"""
Operate similary to netcat command in linux (nc).
Thread safe implementation
""" | bendemott/solr-zkutil | [
15,
1,
15,
18,
1486525374
] |
def __unicode__(self):
return self.username | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
"""
full_name = self.full_name
return full_name.strip() | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_sex(self):
return self.sex | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_no_messages(self):
number = Message.objects.filter(recipient=self, read=False)
if number.count() > 0:
return number.count()
else:
return None | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_messages_all(self):
msg = Message.objects.filter(recipient=self).order_by('date').reverse()
return msg | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_no_notifs(self):
return self.notifications.unread().count() | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_no_followers(self):
num = Follow.objects.filter(followee=self).count()
return num | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_following(self):
num = Follow.objects.filter(follower=self).values_list('followee')
result = []
for follower in num:
user = CustomUser.objects.get(pk=follower[0])
result.append(user)
return result | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def no_of_rides_shared(self):
return self.vehiclesharing_set.filter(user=self, ended=True).count() | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_no_broadcast(self):
return Broadcast.objects.filter(user=self).count() | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_absolute_url(self):
return "/app/ride/%d/view" % self.pk | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __str__(self):
return self.start + " to " + self.dest | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def get_absolute_url(self):
return "/app/sharing/%d/view" % self.pk | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __str__(self):
return "request from " + self.user.get_full_name() + " on " + self.reg_date.isoformat(' ')[0:16] | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __str__(self):
return self.sender.username + ' to ' + self.recipient.username + ' - ' + self.message[0:20] + '...' | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def send(self, user, recipient, subject, message):
message = Message()
message.sender = user
message.recipient = recipient
message.subject = subject
message.message = message
message.save() | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __unicode__(self):
return str(self.follower) + ' follows ' + str(self.followee) | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def is_follows(self, user_1, user_2):
foll = Follow.objects.filter(user=user_1, follower=user_2)
if foll.exists():
return True
else:
return False | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __str__(self):
return self.user.username | othreecodes/MY-RIDE | [
53,
33,
53,
7,
1468451947
] |
def __init__(self, created_date=None, last_modified_date=None, source=None, put_code=None, department_name=None, role_title=None, start_date=None, end_date=None, organization=None, url=None, external_ids=None, display_index=None, visibility=None, path=None): # noqa: E501
"""EducationSummaryV30 - a model defined in Swagger""" # noqa: E501
self._created_date = None
self._last_modified_date = None
self._source = None
self._put_code = None
self._department_name = None
self._role_title = None
self._start_date = None
self._end_date = None
self._organization = None
self._url = None
self._external_ids = None
self._display_index = None
self._visibility = None
self._path = None
self.discriminator = None
if created_date is not None:
self.created_date = created_date
if last_modified_date is not None:
self.last_modified_date = last_modified_date
if source is not None:
self.source = source
if put_code is not None:
self.put_code = put_code
if department_name is not None:
self.department_name = department_name
if role_title is not None:
self.role_title = role_title
if start_date is not None:
self.start_date = start_date
if end_date is not None:
self.end_date = end_date
if organization is not None:
self.organization = organization
if url is not None:
self.url = url
if external_ids is not None:
self.external_ids = external_ids
if display_index is not None:
self.display_index = display_index
if visibility is not None:
self.visibility = visibility
if path is not None:
self.path = path | Royal-Society-of-New-Zealand/NZ-ORCID-Hub | [
13,
7,
13,
28,
1486087622
] |
def created_date(self):
"""Gets the created_date of this EducationSummaryV30. # noqa: E501
:return: The created_date of this EducationSummaryV30. # noqa: E501
:rtype: CreatedDateV30
"""
return self._created_date | Royal-Society-of-New-Zealand/NZ-ORCID-Hub | [
13,
7,
13,
28,
1486087622
] |
def created_date(self, created_date):
"""Sets the created_date of this EducationSummaryV30.
:param created_date: The created_date of this EducationSummaryV30. # noqa: E501
:type: CreatedDateV30
"""
self._created_date = created_date | Royal-Society-of-New-Zealand/NZ-ORCID-Hub | [
13,
7,
13,
28,
1486087622
] |
def last_modified_date(self):
"""Gets the last_modified_date of this EducationSummaryV30. # noqa: E501
:return: The last_modified_date of this EducationSummaryV30. # noqa: E501
:rtype: LastModifiedDateV30
"""
return self._last_modified_date | Royal-Society-of-New-Zealand/NZ-ORCID-Hub | [
13,
7,
13,
28,
1486087622
] |
def last_modified_date(self, last_modified_date):
"""Sets the last_modified_date of this EducationSummaryV30.
:param last_modified_date: The last_modified_date of this EducationSummaryV30. # noqa: E501
:type: LastModifiedDateV30
"""
self._last_modified_date = last_modified_date | Royal-Society-of-New-Zealand/NZ-ORCID-Hub | [
13,
7,
13,
28,
1486087622
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.