uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7d9c3ef0a1b36616ae1b3e49 | train | class | class ps_literal(ps_object):
def __str__(self):
return '/' + self.value
| class ps_literal(ps_object):
| def __str__(self):
return '/' + self.value
| :
psstring = psstring + str(self.value[i])
return psstring + '}'
class ps_name(ps_object):
literal = 0
def __str__(self):
if self.literal:
return '/' + self.value
else:
return self.value
class ps_literal(ps_object):
| 64 | 64 | 19 | 6 | 57 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_literal | ps_literal | 52 | 54 | 52 | 52 | 8ea7f33fe64eae7c5dd2cdd1cd41b9798acf9b6d | bigcode/the-stack | train |
c1278f0b0c1d41125c5481c4 | train | class | class ps_boolean(ps_object):
def __str__(self):
if self.value:
return 'true'
else:
return 'false'
| class ps_boolean(ps_object):
| def __str__(self):
if self.value:
return 'true'
else:
return 'false'
| def __init__(self):
self.value = 'procmark'
self.type = self.__class__.__name__[3:] + "type"
class ps_null(ps_object):
def __init__(self):
self.type = self.__class__.__name__[3:] + "type"
class ps_boolean(ps_object):
| 64 | 64 | 30 | 6 | 58 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_boolean | ps_boolean | 186 | 191 | 186 | 186 | f85e942191f10d8817df2eba76450ca4293b2571 | bigcode/the-stack | train |
173548964caec81415c92d88 | train | class | class ps_file(ps_object):
pass
| class ps_file(ps_object):
| pass
| + 'dup/FontName get exch definefont pop\nmark currentfile closefile\n' + \
8 * (64 * '0' + '\n') + 'cleartomark' + '\n'
def __repr__(self):
return '<font>'
class ps_file(ps_object):
| 63 | 64 | 8 | 6 | 57 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_file | ps_file | 156 | 157 | 156 | 156 | 53fad08fb7923cf63f2c768acc9dadc782f89b8b | bigcode/the-stack | train |
0b2ca61f8ba814862fe83fb5 | train | class | class ps_mark(ps_object):
def __init__(self):
self.value = 'mark'
self.type = self.__class__.__name__[3:] + "type"
| class ps_mark(ps_object):
| def __init__(self):
self.value = 'mark'
self.type = self.__class__.__name__[3:] + "type"
| if access:
access = access + ' '
psstring = psstring + "/%s %s %sdef\n" % (str(key), str(value), access)
return psstring + 'end '
def __repr__(self):
return "<dict>"
class ps_mark(ps_object):
| 63 | 64 | 35 | 6 | 57 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_mark | ps_mark | 172 | 175 | 172 | 172 | d0a9952e2ce1cb8e19e88e4887c10582dbf0a671 | bigcode/the-stack | train |
1ef19e32c4130e0cc02304da | train | class | class ps_object(object):
literal = 1
access = 0
value = None
def __init__(self, value):
self.value = value
self.type = self.__class__.__name__[3:] + "type"
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__[3:], repr(self.value))
| class ps_object(object):
| literal = 1
access = 0
value = None
def __init__(self, value):
self.value = value
self.type = self.__class__.__name__[3:] + "type"
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__[3:], repr(self.value))
| from fontTools.misc.py23 import *
_accessstrings = {0: "", 1: "readonly", 2: "executeonly", 3: "noaccess"}
class ps_object(object):
| 40 | 64 | 79 | 5 | 35 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_object | ps_object | 6 | 17 | 6 | 7 | 63be89871be1a0e1f1dd5060d902961a3b11161a | bigcode/the-stack | train |
f23e2ef4cf2ea14d0c9f496a | train | class | class PSOperators(object):
def ps_def(self):
obj = self.pop()
name = self.pop()
self.dictstack[-1][name.value] = obj
def ps_bind(self):
proc = self.pop('proceduretype')
self.proc_bind(proc)
self.push(proc)
def proc_bind(self, proc):
for i in range(len(proc.value)):
item = proc.value[i]
if item... | class PSOperators(object):
| def ps_def(self):
obj = self.pop()
name = self.pop()
self.dictstack[-1][name.value] = obj
def ps_bind(self):
proc = self.pop('proceduretype')
self.proc_bind(proc)
self.push(proc)
def proc_bind(self, proc):
for i in range(len(proc.value)):
item = proc.value[i]
if item.type == 'proceduretype':
... | if access:
access = access + ' '
psstring = psstring + "/%s %s %sdef\n" % (str(key), str(value), access)
return psstring + 'end '
def __repr__(self):
return "<dict>"
class ps_mark(ps_object):
def __init__(self):
self.value = 'mark'
self.type = self.__class__.__name__[3:] + "type"
class ps_procmark(p... | 256 | 256 | 2,349 | 5 | 251 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | PSOperators | PSOperators | 206 | 535 | 206 | 207 | 20dc4b89fc0fd937ac3bd38ebdb53c62f530e8f2 | bigcode/the-stack | train |
cb312069bd7cf80e082f56a6 | train | class | class ps_string(ps_object):
def __str__(self):
return "(%s)" % repr(self.value)[1:-1]
| class ps_string(ps_object):
| def __str__(self):
return "(%s)" % repr(self.value)[1:-1]
| class ps_null(ps_object):
def __init__(self):
self.type = self.__class__.__name__[3:] + "type"
class ps_boolean(ps_object):
def __str__(self):
if self.value:
return 'true'
else:
return 'false'
class ps_string(ps_object):
| 64 | 64 | 27 | 6 | 58 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_string | ps_string | 193 | 195 | 193 | 193 | 32b70a40e8dee50d28b3cfddbf0f6578db940f31 | bigcode/the-stack | train |
a2bb40495162aea509a30a10 | train | class | class ps_dict(ps_object):
def __str__(self):
psstring = "%d dict dup begin\n" % len(self.value)
items = sorted(self.value.items())
for key, value in items:
access = _accessstrings[value.access]
if access:
access = access + ' '
psstring = psstring + "/%s %s %sdef\n" % (str(key), str(value), access)
... | class ps_dict(ps_object):
| def __str__(self):
psstring = "%d dict dup begin\n" % len(self.value)
items = sorted(self.value.items())
for key, value in items:
access = _accessstrings[value.access]
if access:
access = access + ' '
psstring = psstring + "/%s %s %sdef\n" % (str(key), str(value), access)
return psstring + 'end '
... | definefont pop\nmark currentfile closefile\n' + \
8 * (64 * '0' + '\n') + 'cleartomark' + '\n'
def __repr__(self):
return '<font>'
class ps_file(ps_object):
pass
class ps_dict(ps_object):
| 64 | 64 | 112 | 6 | 57 | anntzer/fonttools | Lib/fontTools/misc/psOperators.py | Python | ps_dict | ps_dict | 159 | 170 | 159 | 159 | e7cab0d06b7710f5dad5ab7d3c54d9066e1724bd | bigcode/the-stack | train |
47aef8b5a19d08315612e1c5 | train | class | class ChinaTriggerTest(BaseScapyTest):
"""
This test is a OONI based implementation of the C tool written
by Philipp Winter to engage chinese probes in active scanning.
Example of running it:
./bin/ooniprobe chinatrigger -d 127.0.0.1 -p 8080
"""
name = "chinatrigger"
usageOptions = Usa... | class ChinaTriggerTest(BaseScapyTest):
| """
This test is a OONI based implementation of the C tool written
by Philipp Winter to engage chinese probes in active scanning.
Example of running it:
./bin/ooniprobe chinatrigger -d 127.0.0.1 -p 8080
"""
name = "chinatrigger"
usageOptions = UsageOptions
requiredOptions = ['dst',... | import random
import string
import struct
import time
from twisted.python import usage
from ooni.templates.scapyt import BaseScapyTest
class UsageOptions(usage.Options):
optParameters = [['dst', 'd', None, 'Specify the target address'],
['port', 'p', None, 'Specify the target port']
... | 82 | 256 | 1,049 | 9 | 73 | meejah/ooni-probe | nettests/experimental/chinatrigger.py | Python | ChinaTriggerTest | ChinaTriggerTest | 14 | 107 | 14 | 14 | fb5ef2f6a923124e4e4b84dc8b9cbafed3386c55 | bigcode/the-stack | train |
5f7e06f147102b32a0f1b9b9 | train | class | class UsageOptions(usage.Options):
optParameters = [['dst', 'd', None, 'Specify the target address'],
['port', 'p', None, 'Specify the target port']
]
| class UsageOptions(usage.Options):
| optParameters = [['dst', 'd', None, 'Specify the target address'],
['port', 'p', None, 'Specify the target port']
]
| import random
import string
import struct
import time
from twisted.python import usage
from ooni.templates.scapyt import BaseScapyTest
class UsageOptions(usage.Options):
| 38 | 64 | 42 | 7 | 30 | meejah/ooni-probe | nettests/experimental/chinatrigger.py | Python | UsageOptions | UsageOptions | 9 | 12 | 9 | 9 | 06bbc96ab255c23473fd0069be4407a2c5458dd2 | bigcode/the-stack | train |
f8c74473c6b35e5526dad136 | train | class | class WalletStateManager:
constants: ConsensusConstants
config: Dict
tx_store: WalletTransactionStore
puzzle_store: WalletPuzzleStore
user_store: WalletUserStore
action_store: WalletActionStore
basic_store: KeyValStore
start_index: int
# Makes sure only one asyncio thread is changi... | class WalletStateManager:
| constants: ConsensusConstants
config: Dict
tx_store: WalletTransactionStore
puzzle_store: WalletPuzzleStore
user_store: WalletUserStore
action_store: WalletActionStore
basic_store: KeyValStore
start_index: int
# Makes sure only one asyncio thread is changing the blockchain state at... | Wallet
from hddcoin.wallet.wallet_action import WalletAction
from hddcoin.wallet.wallet_action_store import WalletActionStore
from hddcoin.wallet.wallet_block_store import WalletBlockStore
from hddcoin.wallet.wallet_blockchain import WalletBlockchain
from hddcoin.wallet.wallet_coin_record import WalletCoinRecord
from ... | 256 | 256 | 10,226 | 5 | 251 | JakubSido/hddcoin-blockchain | hddcoin/wallet/wallet_state_manager.py | Python | WalletStateManager | WalletStateManager | 73 | 1,264 | 73 | 73 | 376de76eb10c7b3cd9a47f13711cae4b9f45eebe | bigcode/the-stack | train |
96ec6d33893f587527503a73 | train | function | def get_balance_from_coin_records(coin_records: Set[WalletCoinRecord]) -> uint128:
amount: uint128 = uint128(0)
for record in coin_records:
amount = uint128(amount + record.coin.amount)
return uint128(amount)
| def get_balance_from_coin_records(coin_records: Set[WalletCoinRecord]) -> uint128:
| amount: uint128 = uint128(0)
for record in coin_records:
amount = uint128(amount + record.coin.amount)
return uint128(amount)
| _transaction_store import WalletTransactionStore
from hddcoin.wallet.wallet_user_store import WalletUserStore
from hddcoin.server.server import HDDcoinServer
from hddcoin.wallet.did_wallet.did_wallet import DIDWallet
def get_balance_from_coin_records(coin_records: Set[WalletCoinRecord]) -> uint128:
| 64 | 64 | 55 | 20 | 43 | JakubSido/hddcoin-blockchain | hddcoin/wallet/wallet_state_manager.py | Python | get_balance_from_coin_records | get_balance_from_coin_records | 66 | 70 | 66 | 66 | 125578882e8481287fc444bb48ef3fc2a471bda8 | bigcode/the-stack | train |
358af36584e217225ab4f800 | train | function | def server(address):
sock = listen(address)
yield serve(sock, handler)
| def server(address):
| sock = listen(address)
yield serve(sock, handler)
| import print_function
from microio import *
from utils import *
def handler(stream, addr):
try:
while True:
data = yield stream.read_bytes(1024, partial=True)
yield stream.write(data)
except IOError:
pass
finally:
stream.close()
def server(address):
| 64 | 64 | 17 | 4 | 60 | ethframe/microio | examples/echo.py | Python | server | server | 18 | 20 | 18 | 18 | c000d445431ffa2f49d1a45376962bc83f7272ff | bigcode/the-stack | train |
d4d2b401cb5e51e251014415 | train | function | def handler(stream, addr):
try:
while True:
data = yield stream.read_bytes(1024, partial=True)
yield stream.write(data)
except IOError:
pass
finally:
stream.close()
| def handler(stream, addr):
| try:
while True:
data = yield stream.read_bytes(1024, partial=True)
yield stream.write(data)
except IOError:
pass
finally:
stream.close()
| from __future__ import print_function
from microio import *
from utils import *
def handler(stream, addr):
| 23 | 64 | 47 | 6 | 17 | ethframe/microio | examples/echo.py | Python | handler | handler | 7 | 15 | 7 | 7 | adf5b4379cc47b9987a776d6f30daefa3ffa5fa2 | bigcode/the-stack | train |
ff5e2fdf1f9229389b1e7531 | train | function | def main():
try:
loop(server(('127.0.0.1', 25000)))
except KeyboardInterrupt:
pass
| def main():
| try:
loop(server(('127.0.0.1', 25000)))
except KeyboardInterrupt:
pass
| , addr):
try:
while True:
data = yield stream.read_bytes(1024, partial=True)
yield stream.write(data)
except IOError:
pass
finally:
stream.close()
def server(address):
sock = listen(address)
yield serve(sock, handler)
def main():
| 64 | 64 | 30 | 3 | 61 | ethframe/microio | examples/echo.py | Python | main | main | 23 | 27 | 23 | 23 | 203376ea39de431f3a7b0fae761772677469583b | bigcode/the-stack | train |
acc3b5ad47dda00ef9138fd2 | train | class | class TestConvertPandas(object):
numpy = 1 # nosetests attribute, use nosetests -a 'not numpy' to skip test
@classmethod
def setupClass(cls):
try:
import pandas as pd
except ImportError:
raise SkipTest('Pandas not available.')
def __init__(self):
global... | class TestConvertPandas(object):
| numpy = 1 # nosetests attribute, use nosetests -a 'not numpy' to skip test
@classmethod
def setupClass(cls):
try:
import pandas as pd
except ImportError:
raise SkipTest('Pandas not available.')
def __init__(self):
global pd
import pandas as pd
... | from nose import SkipTest
from nose.tools import assert_raises
import networkx as nx
from networkx.testing import assert_nodes_equal, assert_edges_equal, assert_graphs_equal
class TestConvertPandas(object):
| 45 | 256 | 2,090 | 7 | 37 | dtrckd/networkx | networkx/tests/test_convert_pandas.py | Python | TestConvertPandas | TestConvertPandas | 8 | 147 | 8 | 8 | 8e38848c93963973d0b1dfa0081649108ce03ad0 | bigcode/the-stack | train |
5f6d7c0626d2712c5bff9321 | train | function | def measure_bias(frame):
"""
Return a DataFrame that measures biases in a semantic space, on four
data sets:
- Gender
- Fine-grained ethnicity
- Coarse-grained ethnicity
- Religious beliefs
"""
gender_binary_axis = normalize_vec(
get_category_axis(frame, FEMALE_WORDS) - get_... | def measure_bias(frame):
| """
Return a DataFrame that measures biases in a semantic space, on four
data sets:
- Gender
- Fine-grained ethnicity
- Coarse-grained ethnicity
- Religious beliefs
"""
gender_binary_axis = normalize_vec(
get_category_axis(frame, FEMALE_WORDS) - get_category_axis(frame, MALE... | ))
centered2 = l2_normalize_rows(subtract_mean_vector(frame2))
grid = centered1.dot(centered2.T)
for i in range(grid.shape[1]):
col_bias = np.max(grid.iloc[:, i]) - np.mean(grid.iloc[:, i])
if verbose:
most_biased = np.argmax(grid.iloc[:, i])
comparison = centered2.i... | 174 | 174 | 580 | 5 | 169 | tesYolan/conceptnet5 | conceptnet5/vectors/evaluation/bias.py | Python | measure_bias | measure_bias | 188 | 243 | 188 | 188 | 348f74f20c0f350b37ff3c7ed8c15fb08d88c337 | bigcode/the-stack | train |
f2abe3770440c6e936442bea | train | function | def correlation_bias(frame1, frame2, verbose=False):
"""
Given two DataFrames of word vectors that we don't want to associate with
each other, find the strongest association for each item in `frame2`
and compare it to the average.
Returns a bias value (the average difference between the strongest
... | def correlation_bias(frame1, frame2, verbose=False):
| """
Given two DataFrames of word vectors that we don't want to associate with
each other, find the strongest association for each item in `frame2`
and compare it to the average.
Returns a bias value (the average difference between the strongest
association and the average association) and a con... | ', 'Zikri', 'Rayyan',
'Mariam', 'Jana', 'Malak', 'Salma', 'Nour',
'Lian', 'Fatima', 'Ayesha', 'Zahra', 'Sana',
'Zara', 'Alya', 'Shaista', 'Zoya', 'Maryam'
]
]
def correlation_bias(frame1, frame2, verbose=False):
| 89 | 89 | 299 | 12 | 77 | tesYolan/conceptnet5 | conceptnet5/vectors/evaluation/bias.py | Python | correlation_bias | correlation_bias | 153 | 185 | 153 | 153 | e609b61d9eb97933be9fe16fb8009a0c1cce2dfe | bigcode/the-stack | train |
b2903a2175ed2e5c7c7179f0 | train | class | class Endpoint(object):
"""This class represents individual Splunk resources in the Splunk REST API.
An ``Endpoint`` object represents a URI, such as ``/services/saved/searches``.
This class provides the common functionality of :class:`Collection` and
:class:`Entity` (essentially HTTP GET and POST meth... | class Endpoint(object):
| """This class represents individual Splunk resources in the Splunk REST API.
An ``Endpoint`` object represents a URI, such as ``/services/saved/searches``.
This class provides the common functionality of :class:`Collection` and
:class:`Entity` (essentially HTTP GET and POST methods).
"""
def __... | (self):
"""Returns the configuration settings for this instance of Splunk.
:return: A :class:`Settings` object containing configuration settings.
"""
return Settings(self)
@property
def splunk_version(self):
"""Returns the version of the splunkd instance this object is ... | 256 | 256 | 1,392 | 4 | 252 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Endpoint | Endpoint | 693 | 821 | 693 | 693 | 5b22c7e4eec65b3bbce382fdad103dfa71e6132c | bigcode/the-stack | train |
6e464e7472a2f16af89a1bd8 | train | class | class OperationError(Exception):
"""Raised for a failed operation, such as a time out."""
pass
| class OperationError(Exception):
| """Raised for a failed operation, such as a time out."""
pass
| one entity."""
pass
class InvalidNameException(Exception):
"""Thrown when the specified name contains characters that are not allowed
in Splunk entity names."""
pass
class NoSuchCapability(Exception):
"""Thrown when the capability that has been referred to doesn't exist."""
pass
class Opera... | 64 | 64 | 22 | 5 | 58 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | OperationError | OperationError | 146 | 148 | 146 | 146 | 9a004a47ee96105bcf261a02f450e932976bd2f9 | bigcode/the-stack | train |
769245efe8c7768646d2ad1b | train | class | class AlertGroup(Entity):
"""This class represents a group of fired alerts for a saved search. Access
it using the :meth:`alerts` property."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def __len__(self):
return self.count
@property
... | class AlertGroup(Entity):
| """This class represents a group of fired alerts for a saved search. Access
it using the :meth:`alerts` property."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def __len__(self):
return self.count
@property
def alerts(self):
... | Encoded(realm, encode_slash=True) + ":" + UrlEncoded(username, encode_slash=True)
# Append the : expected at the end of the name
if name[-1] is not ":":
name = name + ":"
return Collection.delete(self, name)
class AlertGroup(Entity):
| 64 | 64 | 168 | 5 | 59 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | AlertGroup | AlertGroup | 1,880 | 1,904 | 1,880 | 1,880 | 114601ef629e7380510441931fdf7bbf3c54a6cd | bigcode/the-stack | train |
2bd6e4a584ed68e306d64f75 | train | class | class Jobs(Collection):
"""This class represents a collection of search jobs. Retrieve this
collection using :meth:`Service.jobs`."""
def __init__(self, service):
Collection.__init__(self, service, PATH_JOBS, item=Job)
# The count value to say list all the contents of this
# Collecti... | class Jobs(Collection):
| """This class represents a collection of search jobs. Retrieve this
collection using :meth:`Service.jobs`."""
def __init__(self, service):
Collection.__init__(self, service, PATH_JOBS, item=Job)
# The count value to say list all the contents of this
# Collection is 0, not -1 as it is... | _id.7D.2Ftimeline>`_
in the REST API documentation.
:type kwargs: ``dict``
:return: The ``InputStream`` IO handle to this job's timeline.
"""
return self.get("timeline", **kwargs).body
def touch(self):
"""Extends the expiration time of the search to the current ... | 256 | 256 | 1,397 | 4 | 251 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Jobs | Jobs | 2,904 | 3,054 | 2,904 | 2,904 | bec910e051879513bbb8cfd9f322d372d639eaec | bigcode/the-stack | train |
78876add5cb71d7db771e577 | train | class | class Inputs(Collection):
"""This class represents a collection of inputs. The collection is
heterogeneous and each member of the collection contains a *kind* property
that indicates the specific type of input.
Retrieve this collection using :meth:`Service.inputs`."""
def __init__(self, service, ki... | class Inputs(Collection):
| """This class represents a collection of inputs. The collection is
heterogeneous and each member of the collection contains a *kind* property
that indicates the specific type of input.
Retrieve this collection using :meth:`Service.inputs`."""
def __init__(self, service, kindmap=None):
Colle... | it will
# remove the host restriction from the input. As of 5.0.2 you simply can't change restrictToHost
# on an existing input.
# The logic to handle all these cases:
# - Throw an exception if the user tries to set restrictToHost on an existing input
# fo... | 256 | 256 | 3,358 | 4 | 252 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Inputs | Inputs | 2,186 | 2,627 | 2,186 | 2,186 | fad4b57a9ff507ed676ddb7da3e5cf624669e85a | bigcode/the-stack | train |
5aaa6427f8920d8c63b8cc74 | train | class | class ModularInputKind(Entity):
"""This class contains the different types of modular inputs. Retrieve this
collection using :meth:`Service.modular_input_kinds`.
"""
def __contains__(self, name):
args = self.state.content['endpoints']['args']
if name in args:
return True
... | class ModularInputKind(Entity):
| """This class contains the different types of modular inputs. Retrieve this
collection using :meth:`Service.modular_input_kinds`.
"""
def __contains__(self, name):
args = self.state.content['endpoints']['args']
if name in args:
return True
else:
return Ent... | raises a class:``NotSupportedError``.
:raises: class:``NotSupportedError``
"""
raise NotSupportedError()
class Message(Entity):
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
@property
def value(self):
"""Returns the m... | 107 | 107 | 358 | 6 | 101 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | ModularInputKind | ModularInputKind | 3,087 | 3,123 | 3,087 | 3,087 | 24fb9206f1022be2420085cd1f0829c2819dcd72 | bigcode/the-stack | train |
f90b52b9b6795b8b3b3ad29e | train | class | class IllegalOperationException(Exception):
"""Thrown when an operation is not possible on the Splunk instance that a
:class:`Service` object is connected to."""
pass
| class IllegalOperationException(Exception):
| """Thrown when an operation is not possible on the Splunk instance that a
:class:`Service` object is connected to."""
pass
| www.w3.org/2005/Atom}%s"
XNAME_ENTRY = XNAMEF_ATOM % "entry"
XNAME_CONTENT = XNAMEF_ATOM % "content"
MATCH_ENTRY_CONTENT = "%s/%s/*" % (XNAME_ENTRY, XNAME_CONTENT)
class IllegalOperationException(Exception):
| 64 | 64 | 37 | 6 | 58 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | IllegalOperationException | IllegalOperationException | 118 | 121 | 118 | 118 | 3306957ab8068d3a90176ba72e4d82170e2a9826 | bigcode/the-stack | train |
61dfd616484d6e3f4ce04022 | train | function | def _path(base, name):
if not base.endswith('/'): base = base + '/'
return base + name
| def _path(base, name):
| if not base.endswith('/'): base = base + '/'
return base + name
| ]) for k in args)
return record((k, v) for k, v in six.iteritems(content)
if k not in ['eai:acl', 'eai:attributes', 'type'])
# Construct a resource path from the given base path + resource name
def _path(base, name):
| 64 | 64 | 25 | 7 | 56 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _path | _path | 193 | 195 | 193 | 193 | 85f6afb83e4878f019d64e16caa6b00fcb4d911a | bigcode/the-stack | train |
c68a09babccfecf1d9651655 | train | function | def _load_atom(response, match=None):
return data.load(response.body.read()
.decode('utf-8', 'xmlcharrefreplace'), match)
| def _load_atom(response, match=None):
| return data.load(response.body.read()
.decode('utf-8', 'xmlcharrefreplace'), match)
| if not base.endswith('/'): base = base + '/'
return base + name
# Load an atom record from the body of the given response
# this will ultimately be sent to an xml ElementTree so we
# should use the xmlcharrefreplace option
def _load_atom(response, match=None):
| 64 | 64 | 33 | 9 | 54 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _load_atom | _load_atom | 201 | 203 | 201 | 201 | 5da304b8aabd0fc79dce245a134eda82041df9d6 | bigcode/the-stack | train |
6ed80916928d29bab24c848a | train | class | class ConfigurationFile(Collection):
"""This class contains all of the stanzas from one configuration file.
"""
# __init__'s arguments must match those of an Entity, not a
# Collection, since it is being created as the elements of a
# Configurations, which is a Collection subclass.
def __init__(... | class ConfigurationFile(Collection):
| """This class contains all of the stanzas from one configuration file.
"""
# __init__'s arguments must match those of an Entity, not a
# Collection, since it is being created as the elements of a
# Configurations, which is a Collection subclass.
def __init__(self, service, path, **kwargs):
... | ('nonexistant/search') # raises HTTPError
s.logout()
saved_searches.get() # raises AuthenticationError
"""
name = UrlEncoded(name, encode_slash=True)
return super(Collection, self).get(name, owner, app, sharing, **query)
class ConfigurationFile(Collection):
| 64 | 64 | 106 | 5 | 59 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | ConfigurationFile | ConfigurationFile | 1,673 | 1,681 | 1,673 | 1,673 | 3dacd38ed9aadea21c3b8696c266ea12f50fe731 | bigcode/the-stack | train |
eb79fe8aad5486ed2541d948 | train | class | class SavedSearches(Collection):
"""This class represents a collection of saved searches. Retrieve this
collection using :meth:`Service.saved_searches`."""
def __init__(self, service):
Collection.__init__(
self, service, PATH_SAVED_SEARCHES, item=SavedSearch)
def create(self, name, ... | class SavedSearches(Collection):
| """This class represents a collection of saved searches. Retrieve this
collection using :meth:`Service.saved_searches`."""
def __init__(self, service):
Collection.__init__(
self, service, PATH_SAVED_SEARCHES, item=SavedSearch)
def create(self, name, search, **kwargs):
""" Cr... | .expiration)
else:
return 0
def unsuppress(self):
"""Cancels suppression and makes this search run as scheduled.
:return: The :class:`SavedSearch`.
"""
self.post("suppress", expiration="0")
return self
class SavedSearches(Collection):
| 64 | 64 | 214 | 6 | 57 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | SavedSearches | SavedSearches | 3,278 | 3,299 | 3,278 | 3,278 | 1dea3ac46d27cbdecf1a50f6808f9b408b202f2b | bigcode/the-stack | train |
29757d71e0669815cbfb211e | train | class | class NoSuchCapability(Exception):
"""Thrown when the capability that has been referred to doesn't exist."""
pass
| class NoSuchCapability(Exception):
| """Thrown when the capability that has been referred to doesn't exist."""
pass
| class AmbiguousReferenceException(ValueError):
"""Thrown when the name used to fetch an entity matches more than one entity."""
pass
class InvalidNameException(Exception):
"""Thrown when the specified name contains characters that are not allowed
in Splunk entity names."""
pass
class NoSuchCapabil... | 64 | 64 | 23 | 6 | 57 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | NoSuchCapability | NoSuchCapability | 141 | 143 | 141 | 141 | 041e94d3057fa9b1ff05c0801d389fb136099da0 | bigcode/the-stack | train |
8f0820c4218acd44696b200b | train | function | def _load_atom_entries(response):
r = _load_atom(response)
if 'feed' in r:
# Need this to handle a random case in the REST API
if r.feed.get('totalResults') in [0, '0']:
return []
entries = r.feed.get('entry', None)
if entries is None: return None
return entri... | def _load_atom_entries(response):
| r = _load_atom(response)
if 'feed' in r:
# Need this to handle a random case in the REST API
if r.feed.get('totalResults') in [0, '0']:
return []
entries = r.feed.get('entry', None)
if entries is None: return None
return entries if isinstance(entries, list) el... | should use the xmlcharrefreplace option
def _load_atom(response, match=None):
return data.load(response.body.read()
.decode('utf-8', 'xmlcharrefreplace'), match)
# Load an array of atom entries from the body of the given response
def _load_atom_entries(response):
| 64 | 64 | 184 | 7 | 56 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _load_atom_entries | _load_atom_entries | 207 | 223 | 207 | 207 | 922d32efba0debe9204a302f126d0a84c5fc8d98 | bigcode/the-stack | train |
d62e243b1f55f01b7e876480 | train | class | class Configurations(Collection):
"""This class provides access to the configuration files from this Splunk
instance. Retrieve this collection using :meth:`Service.confs`.
Splunk's configuration is divided into files, and each file into
stanzas. This collection is unusual in that the values in it are
... | class Configurations(Collection):
| """This class provides access to the configuration files from this Splunk
instance. Retrieve this collection using :meth:`Service.confs`.
Splunk's configuration is divided into files, and each file into
stanzas. This collection is unusual in that the values in it are
themselves collections of :clas... | -type', 'text/xml; charset=utf-8')],
'reason': 'OK',
'status': 200}
saved_searches.get('nonexistant/search') # raises HTTPError
s.logout()
saved_searches.get() # raises AuthenticationError
"""
name = UrlEncoded(name, encode_slash=Tru... | 200 | 200 | 668 | 5 | 195 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Configurations | Configurations | 1,684 | 1,758 | 1,684 | 1,684 | de258f334c8e9ca9f080ca2f5cfed93fdc4faf2a | bigcode/the-stack | train |
ae52ad35884f2f0e363fb388 | train | class | class Entity(Endpoint):
"""This class is a base class for Splunk entities in the REST API, such as
saved searches, jobs, indexes, and inputs.
``Entity`` provides the majority of functionality required by entities.
Subclasses only implement the special cases for individual entities.
For example for ... | class Entity(Endpoint):
| """This class is a base class for Splunk entities in the REST API, such as
saved searches, jobs, indexes, and inputs.
``Entity`` provides the majority of functionality required by entities.
Subclasses only implement the special cases for individual entities.
For example for deployment serverclasses... | = s.apps
apps.post(name='boris') == \\
{'body': ...a response reader object...,
'headers': [('content-length', '2908'),
('expires', 'Fri, 30 Oct 1998 00:00:00 GMT'),
('server', 'Splunkd'),
... | 256 | 256 | 2,748 | 5 | 250 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Entity | Entity | 825 | 1,155 | 825 | 825 | 0e2193ad0b43c349baf6af741158c4af36e88f03 | bigcode/the-stack | train |
05cb742784e8ee53376a7799 | train | class | class _BaseService(Context):
pass
| class _BaseService(Context):
| pass
| Storm's
# API is not going to be the same as enterprise Splunk's
# API, so we will derive both Service (for enterprise Splunk)
# and StormService for (Splunk Storm) from _BaseService, and
# put any shared behavior on it.
class _BaseService(Context):
| 64 | 64 | 9 | 6 | 58 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _BaseService | _BaseService | 341 | 342 | 341 | 341 | ee3d6fa7010e96db4d4665a560a32b213812f7d3 | bigcode/the-stack | train |
1c74ed9f0c1e79dcec4578ac | train | class | class KVStoreCollections(Collection):
def __init__(self, service):
Collection.__init__(self, service, 'storage/collections/config', item=KVStoreCollection)
def create(self, name, indexes = {}, fields = {}, **kwargs):
"""Creates a KV Store Collection.
:param name: name of collection to ... | class KVStoreCollections(Collection):
| def __init__(self, service):
Collection.__init__(self, service, 'storage/collections/config', item=KVStoreCollection)
def create(self, name, indexes = {}, fields = {}, **kwargs):
"""Creates a KV Store Collection.
:param name: name of collection to create
:type name: ``string``
... | :setup', None)
def package(self):
""" Creates a compressed package of the app for archiving."""
return self._run_action("package")
def updateInfo(self):
"""Returns any update information that is available for the app."""
return self._run_action("update")
class KVStoreCollection... | 66 | 66 | 221 | 6 | 60 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | KVStoreCollections | KVStoreCollections | 3,548 | 3,572 | 3,548 | 3,548 | 75d34d700727a074449590c330059d38676dd634 | bigcode/the-stack | train |
51e3fb01246e64fde9c78b15 | train | class | class IncomparableException(Exception):
"""Thrown when trying to compare objects (using ``==``, ``<``, ``>``, and
so on) of a type that doesn't support it."""
pass
| class IncomparableException(Exception):
| """Thrown when trying to compare objects (using ``==``, ``<``, ``>``, and
so on) of a type that doesn't support it."""
pass
| MATCH_ENTRY_CONTENT = "%s/%s/*" % (XNAME_ENTRY, XNAME_CONTENT)
class IllegalOperationException(Exception):
"""Thrown when an operation is not possible on the Splunk instance that a
:class:`Service` object is connected to."""
pass
class IncomparableException(Exception):
| 64 | 64 | 45 | 7 | 56 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | IncomparableException | IncomparableException | 124 | 127 | 124 | 124 | 0d655ef23f2af2ec3b8f4597b9af02934da923c8 | bigcode/the-stack | train |
3fd0671f69845c606cf24cd2 | train | class | class AmbiguousReferenceException(ValueError):
"""Thrown when the name used to fetch an entity matches more than one entity."""
pass
| class AmbiguousReferenceException(ValueError):
| """Thrown when the name used to fetch an entity matches more than one entity."""
pass
| :`Service` object is connected to."""
pass
class IncomparableException(Exception):
"""Thrown when trying to compare objects (using ``==``, ``<``, ``>``, and
so on) of a type that doesn't support it."""
pass
class AmbiguousReferenceException(ValueError):
| 64 | 64 | 28 | 8 | 55 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | AmbiguousReferenceException | AmbiguousReferenceException | 130 | 132 | 130 | 130 | 41eb4ea18566381ca1e035127bc749b6fc3e6480 | bigcode/the-stack | train |
f44a59a41f65859e55400601 | train | class | class Indexes(Collection):
"""This class contains the collection of indexes in this Splunk instance.
Retrieve this collection using :meth:`Service.indexes`.
"""
def get_default(self):
""" Returns the name of the default index.
:return: The name of the default index.
"""
... | class Indexes(Collection):
| """This class contains the collection of indexes in this Splunk instance.
Retrieve this collection using :meth:`Service.indexes`.
"""
def get_default(self):
""" Returns the name of the default index.
:return: The name of the default index.
"""
index = self['_audit']
... | Collection(self.service, self.path)
@property
def count(self):
"""Returns the count of triggered alerts.
:return: The triggered alert count.
:rtype: ``integer``
"""
return int(self.content.get('triggered_alert_count', 0))
class Indexes(Collection):
| 64 | 64 | 183 | 5 | 59 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Indexes | Indexes | 1,907 | 1,932 | 1,907 | 1,907 | 2220cb4c54daf4bf7a789131ed911d3d0c2383d5 | bigcode/the-stack | train |
d2e0a4ebbb878773cb8554af | train | function | def _trailing(template, *targets):
"""Substring of *template* following all *targets*.
**Example**::
template = "this is a test of the bunnies."
_trailing(template, "is", "est", "the") == " bunnies"
Each target is matched successively in the string, and the string
remaining after the ... | def _trailing(template, *targets):
| """Substring of *template* following all *targets*.
**Example**::
template = "this is a test of the bunnies."
_trailing(template, "is", "est", "the") == " bunnies"
Each target is matched successively in the string, and the string
remaining after the last target is returned. If one of ... | (Exception):
"""Thrown when the capability that has been referred to doesn't exist."""
pass
class OperationError(Exception):
"""Raised for a failed operation, such as a time out."""
pass
class NotSupportedError(Exception):
"""Raised for operations that are not supported on a given object."""
... | 73 | 73 | 244 | 9 | 63 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _trailing | _trailing | 156 | 182 | 156 | 156 | a7b12ee05c90e756b83663f78c889255229f43c1 | bigcode/the-stack | train |
5dfe0e9856e55cfbfadaf64f | train | function | def _parse_atom_metadata(content):
# Hoist access metadata
access = content.get('eai:acl', None)
# Hoist content metadata (and cleanup some naming)
attributes = content.get('eai:attributes', {})
fields = record({
'required': attributes.get('requiredFields', []),
'optional': attribut... | def _parse_atom_metadata(content):
# Hoist access metadata
| access = content.get('eai:acl', None)
# Hoist content metadata (and cleanup some naming)
attributes = content.get('eai:attributes', {})
fields = record({
'required': attributes.get('requiredFields', []),
'optional': attributes.get('optionalFields', []),
'wildcard': attributes.ge... | 'links': links,
'access': metadata.access,
'fields': metadata.fields,
'content': content,
'updated': entry.get("updated")
})
# Parse the metadata fields out of the given atom entry content record
def _parse_atom_metadata(content):
# Hoist access metadata
| 64 | 64 | 107 | 14 | 49 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _parse_atom_metadata | _parse_atom_metadata | 272 | 283 | 272 | 273 | 1323c91f8f6a122334eb7bae2b7f2ccb149cb5df | bigcode/the-stack | train |
d7901452cc9d75a4173fe860 | train | class | class Loggers(Collection):
"""This class represents a collection of service logging categories.
Retrieve this collection using :meth:`Service.loggers`."""
def __init__(self, service):
Collection.__init__(self, service, PATH_LOGGER)
def itemmeta(self):
"""There is no metadata available f... | class Loggers(Collection):
| """This class represents a collection of service logging categories.
Retrieve this collection using :meth:`Service.loggers`."""
def __init__(self, service):
Collection.__init__(self, service, PATH_LOGGER)
def itemmeta(self):
"""There is no metadata available for class:``Loggers``.
... | if "exec_mode" in params:
raise TypeError("Cannot specify an exec_mode to oneshot.")
params['segmentation'] = params.get('segmentation', 'none')
return self.post(search=query,
exec_mode="oneshot",
**params).body
class Loggers(Collecti... | 64 | 64 | 107 | 5 | 58 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Loggers | Loggers | 3,057 | 3,070 | 3,057 | 3,057 | dcdfec4887940e97f0794e59211db4f13424c7bd | bigcode/the-stack | train |
f9866f7b4fa608739ae6e1f7 | train | class | class StoragePassword(Entity):
"""This class contains a storage password.
"""
def __init__(self, service, path, **kwargs):
state = kwargs.get('state', None)
kwargs['skip_refresh'] = kwargs.get('skip_refresh', state is not None)
super(StoragePassword, self).__init__(service, path, **k... | class StoragePassword(Entity):
| """This class contains a storage password.
"""
def __init__(self, service, path, **kwargs):
state = kwargs.get('state', None)
kwargs['skip_refresh'] = kwargs.get('skip_refresh', state is not None)
super(StoragePassword, self).__init__(service, path, **kwargs)
self._state = st... | # and 'disabled', so to get an accurate length, we have to filter those out and have just
# the stanza keys.
return len([x for x in self._state.content.keys()
if not x.startswith('eai') and x != 'disabled'])
class StoragePassword(Entity):
| 63 | 64 | 154 | 5 | 58 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | StoragePassword | StoragePassword | 1,784 | 1,807 | 1,784 | 1,784 | 01bdfe0dcb34a6ef5d727a8daee6839426726370 | bigcode/the-stack | train |
fcdde771e653a5058295d6ac | train | class | class Roles(Collection):
"""This class represents the collection of roles in the Splunk instance.
Retrieve this collection using :meth:`Service.roles`."""
def __init__(self, service):
return Collection.__init__(self, service, PATH_ROLES, item=Role)
def __getitem__(self, key):
return Col... | class Roles(Collection):
| """This class represents the collection of roles in the Splunk instance.
Retrieve this collection using :meth:`Service.roles`."""
def __init__(self, service):
return Collection.__init__(self, service, PATH_ROLES, item=Role)
def __getitem__(self, key):
return Collection.__getitem__(self,... | .roles['somerole']
role.revoke('change_own_password', 'search')
"""
possible_capabilities = self.service.capabilities
for capability in capabilities_to_revoke:
if capability not in possible_capabilities:
raise NoSuchCapability(capability)
old_capab... | 148 | 148 | 495 | 4 | 143 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Roles | Roles | 3,467 | 3,527 | 3,467 | 3,467 | f5323f22c8b9eb99bf426905ef000665935ba8b1 | bigcode/the-stack | train |
03dd33d9eaea8db5d16a3736 | train | class | class NotSupportedError(Exception):
"""Raised for operations that are not supported on a given object."""
pass
| class NotSupportedError(Exception):
| """Raised for operations that are not supported on a given object."""
pass
| not allowed
in Splunk entity names."""
pass
class NoSuchCapability(Exception):
"""Thrown when the capability that has been referred to doesn't exist."""
pass
class OperationError(Exception):
"""Raised for a failed operation, such as a time out."""
pass
class NotSupportedError(Exception):
| 64 | 64 | 23 | 6 | 57 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | NotSupportedError | NotSupportedError | 151 | 153 | 151 | 151 | 743bea7a512b43eeb998a5274070e06f1266decf | bigcode/the-stack | train |
d1e1bb0425055a9cbf175a11 | train | class | class KVStoreCollectionData(object):
"""This class represents the data endpoint for a KVStoreCollection.
Retrieve using :meth:`KVStoreCollection.data`
"""
JSON_HEADER = [('Content-Type', 'application/json')]
def __init__(self, collection):
self.service = collection.service
self.col... | class KVStoreCollectionData(object):
| """This class represents the data endpoint for a KVStoreCollection.
Retrieve using :meth:`KVStoreCollection.data`
"""
JSON_HEADER = [('Content-Type', 'application/json')]
def __init__(self, collection):
self.service = collection.service
self.collection = collection
self.own... | , **kwargs)
class KVStoreCollection(Entity):
@property
def data(self):
"""Returns data object for this Collection.
:rtype: :class:`KVStoreCollectionData`
"""
return KVStoreCollectionData(self)
def update_index(self, name, value):
"""Changes the definition of a KV S... | 256 | 256 | 1,023 | 7 | 249 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | KVStoreCollectionData | KVStoreCollectionData | 3,611 | 3,737 | 3,611 | 3,611 | 6073847e13d98d6a9e76957c4a7fae2f03380912 | bigcode/the-stack | train |
5cf8a30179b9a2fe506a2bc9 | train | class | class Message(Entity):
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
@property
def value(self):
"""Returns the message value.
:return: The message value.
:rtype: ``string``
"""
return self[self.name]
| class Message(Entity):
| def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
@property
def value(self):
"""Returns the message value.
:return: The message value.
:rtype: ``string``
"""
return self[self.name]
| , PATH_LOGGER)
def itemmeta(self):
"""There is no metadata available for class:``Loggers``.
Any call to this method raises a class:``NotSupportedError``.
:raises: class:``NotSupportedError``
"""
raise NotSupportedError()
class Message(Entity):
| 64 | 64 | 72 | 4 | 60 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Message | Message | 3,073 | 3,084 | 3,073 | 3,073 | 239b0b21041a8ab13bde76c8a025eed5f0b168c0 | bigcode/the-stack | train |
186a58509b766ba878ef8e89 | train | class | class Collection(ReadOnlyCollection):
"""A collection of entities.
Splunk provides a number of different collections of distinct
entity types: applications, saved searches, fired alerts, and a
number of others. Each particular type is available separately
from the Splunk instance, and the entities ... | class Collection(ReadOnlyCollection):
| """A collection of entities.
Splunk provides a number of different collections of distinct
entity types: applications, saved searches, fired alerts, and a
number of others. Each particular type is available separately
from the Splunk instance, and the entities of that type are
returned in a :cl... | plus at most two more if
the ``autologin`` field of :func:`connect` is set to ``True``.
There is no caching--every call makes at least one round trip.
:param count: The maximum number of entities to return (optional).
:type count: ``integer``
:param kwargs: Additional arguments... | 255 | 256 | 1,735 | 6 | 249 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Collection | Collection | 1,484 | 1,668 | 1,484 | 1,484 | 37c21780f68c9d07b7cd6b6f72091185680d771b | bigcode/the-stack | train |
6a5f2a39b21b44ee93fb9b9c | train | class | class Users(Collection):
"""This class represents the collection of Splunk users for this instance of
Splunk. Retrieve this collection using :meth:`Service.users`.
"""
def __init__(self, service):
Collection.__init__(self, service, PATH_USERS, item=User)
def __getitem__(self, key):
... | class Users(Collection):
| """This class represents the collection of Splunk users for this instance of
Splunk. Retrieve this collection using :meth:`Service.users`.
"""
def __init__(self, service):
Collection.__init__(self, service, PATH_USERS, item=User)
def __getitem__(self, key):
return Collection.__getit... | system#POST_server.2Fsettings.2F.7Bname.7D>`_
in the REST API documentation.
:type kwargs: ``dict``
:return: The :class:`Settings` collection.
"""
self.service.post("/services/server/settings/settings", **kwargs)
return self
class User(Entity):
"""This class rep... | 172 | 172 | 576 | 4 | 168 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Users | Users | 3,338 | 3,405 | 3,338 | 3,338 | 89439c7054f6de0e92f786c7250e3f952b4f2c6d | bigcode/the-stack | train |
c992a9adfe0728481d6c8055 | train | class | class Application(Entity):
"""Represents a locally-installed Splunk app."""
@property
def setupInfo(self):
"""Returns the setup information for the app.
:return: The setup information.
"""
return self.content.get('eai:setup', None)
def package(self):
""" Creates... | class Application(Entity):
| """Represents a locally-installed Splunk app."""
@property
def setupInfo(self):
"""Returns the setup information for the app.
:return: The setup information.
"""
return self.content.get('eai:setup', None)
def package(self):
""" Creates a compressed package of th... | (self, name):
""" Deletes the role and returns the resulting collection of roles.
:param name: The name of the role to delete.
:type name: ``string``
:rtype: The :class:`Roles`
"""
return Collection.delete(self, name.lower())
class Application(Entity):
| 64 | 64 | 113 | 4 | 60 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Application | Application | 3,530 | 3,546 | 3,530 | 3,530 | a0d1fca4b6e044724f6725939a2c4bd162294e75 | bigcode/the-stack | train |
159b1842d1c06aad5cf4bf20 | train | class | class Service(_BaseService):
"""A Pythonic binding to Splunk instances.
A :class:`Service` represents a binding to a Splunk instance on an
HTTP or HTTPS port. It handles the details of authentication, wire
formats, and wraps the REST API endpoints into something more
Pythonic. All of the low-level ... | class Service(_BaseService):
| """A Pythonic binding to Splunk instances.
A :class:`Service` represents a binding to a Splunk instance on an
HTTP or HTTPS port. It handles the details of authentication, wire
formats, and wraps the REST API endpoints into something more
Pythonic. All of the low-level operations on the instance fr... | :type cookie: ``string``
:param autologin: When ``True``, automatically tries to log in again if the
session terminates.
:type autologin: ``boolean``
:param `username`: The Splunk account username, which is used to
authenticate the Splunk instance.
:type username: ``st... | 256 | 256 | 2,764 | 6 | 249 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Service | Service | 345 | 690 | 345 | 345 | d9d84c6388ea8a197ac3acaa8d9564db149df34e | bigcode/the-stack | train |
a3243697e7b5fe60cb5220b3 | train | function | def _load_sid(response):
return _load_atom(response).response.sid
| def _load_sid(response):
| return _load_atom(response).response.sid
| # <feed><entry>...</entry></feed>.
else:
entries = r.get('entry', None)
if entries is None: return None
return entries if isinstance(entries, list) else [entries]
# Load the sid from the body of the given response
def _load_sid(response):
| 64 | 64 | 16 | 6 | 57 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _load_sid | _load_sid | 227 | 228 | 227 | 227 | 45ea6fb276d493d6801b8f09e0346e81cb0fb026 | bigcode/the-stack | train |
1a5e3572960ad98761d77643 | train | class | class Input(Entity):
"""This class represents a Splunk input. This class is the base for all
typed input classes and is also used when the client does not recognize an
input kind.
"""
def __init__(self, service, path, kind=None, **kwargs):
# kind can be omitted (in which case it is inferred ... | class Input(Entity):
| """This class represents a Splunk input. This class is the base for all
typed input classes and is also used when the client does not recognize an
input kind.
"""
def __init__(self, service, path, kind=None, **kwargs):
# kind can be omitted (in which case it is inferred from the path)
... | because we aren't really sending a "form".
self.service.post(PATH_RECEIVERS_SIMPLE, body=event, **args)
return self
# kwargs: host, host_regex, host_segment, rename-source, sourcetype
def upload(self, filename, **kwargs):
"""Uploads a file for immediate indexing.
**Note**: The... | 229 | 229 | 765 | 4 | 224 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Input | Input | 2,117 | 2,180 | 2,117 | 2,117 | 2a8884d4fb56fe357b0fdd7ded1bb8ae552a7154 | bigcode/the-stack | train |
ce16bcabe736a796b8bda51a | train | class | class ReadOnlyCollection(Endpoint):
"""This class represents a read-only collection of entities in the Splunk
instance.
"""
def __init__(self, service, path, item=Entity):
Endpoint.__init__(self, service, path)
self.item = item # Item accessor
self.null_count = -1
def __cont... | class ReadOnlyCollection(Endpoint):
| """This class represents a read-only collection of entities in the Splunk
instance.
"""
def __init__(self, service, path, item=Entity):
Endpoint.__init__(self, service, path)
self.item = item # Item accessor
self.null_count = -1
def __contains__(self, name):
"""Is th... | Many of the fields in the REST API are not valid Python
identifiers, which means you cannot pass them as keyword
arguments. That is, Python will fail to parse the following::
# This fails
x.update(check-new=False, email.to='boris@utopia.net')
However, you can always ex... | 256 | 256 | 2,796 | 7 | 248 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | ReadOnlyCollection | ReadOnlyCollection | 1,158 | 1,479 | 1,158 | 1,158 | 5ef65cbf4a851a69c2ab78217c4a101cfb9a30e7 | bigcode/the-stack | train |
41ae2a61d0521c5b94d0a6ae | train | class | class Stanza(Entity):
"""This class contains a single configuration stanza."""
def submit(self, stanza):
"""Adds keys to the current configuration stanza as a
dictionary of key-value pairs.
:param stanza: A dictionary of key-value pairs for the stanza.
:type stanza: ``dict``
... | class Stanza(Entity):
| """This class contains a single configuration stanza."""
def submit(self, stanza):
"""Adds keys to the current configuration stanza as a
dictionary of key-value pairs.
:param stanza: A dictionary of key-value pairs for the stanza.
:type stanza: ``dict``
:return: The :cl... | from the REST API.")
def _entity_path(self, state):
# Overridden to make all the ConfigurationFile objects
# returned refer to the configs/ path instead of the
# properties/ path used by Configrations.
return PATH_CONF % state['title']
class Stanza(Entity):
| 64 | 64 | 191 | 5 | 59 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Stanza | Stanza | 1,761 | 1,781 | 1,761 | 1,761 | a4a6db1bbf14343903f98062deedd7cd6fcbfff0 | bigcode/the-stack | train |
61bdc121a1c023d2e7c58713 | train | class | class Settings(Entity):
"""This class represents configuration settings for a Splunk service.
Retrieve this collection using :meth:`Service.settings`."""
def __init__(self, service, **kwargs):
Entity.__init__(self, service, "/services/server/settings", **kwargs)
# Updates on the settings endpoi... | class Settings(Entity):
| """This class represents configuration settings for a Splunk service.
Retrieve this collection using :meth:`Service.settings`."""
def __init__(self, service, **kwargs):
Entity.__init__(self, service, "/services/server/settings", **kwargs)
# Updates on the settings endpoint are POSTed to server/... | /view/SP-CAAAEE5#savedsearchparams>`_
on Splunk Developer Portal.
:type kwargs: ``dict``
:return: The :class:`SavedSearches` collection.
"""
return Collection.create(self, name, search=search, **kwargs)
class Settings(Entity):
| 64 | 64 | 207 | 4 | 60 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Settings | Settings | 3,302 | 3,320 | 3,302 | 3,302 | f6b81c9bef3db43f4d634e2a576b66bf1851ac0c | bigcode/the-stack | train |
1def2470c716a03acb77e630 | train | class | class InvalidNameException(Exception):
"""Thrown when the specified name contains characters that are not allowed
in Splunk entity names."""
pass
| class InvalidNameException(Exception):
| """Thrown when the specified name contains characters that are not allowed
in Splunk entity names."""
pass
| (using ``==``, ``<``, ``>``, and
so on) of a type that doesn't support it."""
pass
class AmbiguousReferenceException(ValueError):
"""Thrown when the name used to fetch an entity matches more than one entity."""
pass
class InvalidNameException(Exception):
| 64 | 64 | 30 | 6 | 57 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | InvalidNameException | InvalidNameException | 135 | 138 | 135 | 135 | f7adac10f13989fffa876c878c1a804b5db26d2d | bigcode/the-stack | train |
5812ce8ee11c4a618992a2c9 | train | function | def connect(**kwargs):
"""This function connects and logs in to a Splunk instance.
This function is a shorthand for :meth:`Service.login`.
The ``connect`` function makes one round trip to the server (for logging in).
:param host: The host name (the default is "localhost").
:type host: ``string``
... | def connect(**kwargs):
| """This function connects and logs in to a Splunk instance.
This function is a shorthand for :meth:`Service.login`.
The ``connect`` function makes one round trip to the server (for logging in).
:param host: The host name (the default is "localhost").
:type host: ``string``
:param port: The por... | ")
})
# Parse the metadata fields out of the given atom entry content record
def _parse_atom_metadata(content):
# Hoist access metadata
access = content.get('eai:acl', None)
# Hoist content metadata (and cleanup some naming)
attributes = content.get('eai:attributes', {})
fields = record({
... | 146 | 146 | 487 | 5 | 140 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | connect | connect | 286 | 332 | 286 | 286 | 1db6f3f9cd528d4d9c77f7f77a5c07f204f29bd9 | bigcode/the-stack | train |
0f42b24bb9322322fc5ca2ea | train | class | class User(Entity):
"""This class represents a Splunk user.
"""
@property
def role_entities(self):
"""Returns a list of roles assigned to this user.
:return: The list of roles.
:rtype: ``list``
"""
return [self.service.roles[name] for name in self.content.roles]
| class User(Entity):
| """This class represents a Splunk user.
"""
@property
def role_entities(self):
"""Returns a list of roles assigned to this user.
:return: The list of roles.
:rtype: ``list``
"""
return [self.service.roles[name] for name in self.content.roles]
| settings.2F.7Bname.7D>`_
in the REST API documentation.
:type kwargs: ``dict``
:return: The :class:`Settings` collection.
"""
self.service.post("/services/server/settings/settings", **kwargs)
return self
class User(Entity):
| 64 | 64 | 72 | 4 | 59 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | User | User | 3,323 | 3,333 | 3,323 | 3,323 | 548c33458d348d78cef851b668d977e47f0a3f9a | bigcode/the-stack | train |
354acefa2cfb8815dd667cda | train | class | class Index(Entity):
"""This class represents an index and provides different operations, such as
cleaning the index, writing to the index, and so forth."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def attach(self, host=None, source=None, sourc... | class Index(Entity):
| """This class represents an index and provides different operations, such as
cleaning the index, writing to the index, and so forth."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def attach(self, host=None, source=None, sourcetype=None):
... | ` of triggered alerts.
"""
return Collection(self.service, self.path)
@property
def count(self):
"""Returns the count of triggered alerts.
:return: The triggered alert count.
:rtype: ``integer``
"""
return int(self.content.get('triggered_alert_count', 0)... | 255 | 256 | 1,672 | 4 | 251 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Index | Index | 1,935 | 2,114 | 1,935 | 1,935 | dfbd3650bbb92131209f0505a5714d0a86697f26 | bigcode/the-stack | train |
c2341add3752a7d64583c028 | train | class | class Role(Entity):
"""This class represents a user role.
"""
def grant(self, *capabilities_to_grant):
"""Grants additional capabilities to this role.
:param capabilities_to_grant: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabil... | class Role(Entity):
| """This class represents a user role.
"""
def grant(self, *capabilities_to_grant):
"""Grants additional capabilities to this role.
:param capabilities_to_grant: Zero or more capabilities to grant this
role. For a list of capabilities, see
`Capabilities <http://dev.sp... | response body,
# so we have to make a second round trip to fetch it.
response = self.get(username)
entry = _load_atom(response, XNAME_ENTRY).entry
state = _parse_atom_entry(entry)
entity = self.item(
self.service,
urllib.parse.unquote(state.links.alternat... | 147 | 147 | 491 | 4 | 143 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Role | Role | 3,408 | 3,464 | 3,408 | 3,408 | c676b92e22453a1f338f0b0eb7ff520599fce930 | bigcode/the-stack | train |
ac360d1523ff5697b06395f3 | train | class | class Job(Entity):
"""This class represents a search job."""
def __init__(self, service, sid, **kwargs):
path = PATH_JOBS + sid
Entity.__init__(self, service, path, skip_refresh=True, **kwargs)
self.sid = sid
# The Job entry record is returned at the root of the response
def _lo... | class Job(Entity):
| """This class represents a search job."""
def __init__(self, service, sid, **kwargs):
path = PATH_JOBS + sid
Entity.__init__(self, service, path, skip_refresh=True, **kwargs)
self.sid = sid
# The Job entry record is returned at the root of the response
def _load_atom_entry(self,... | .
- "search" (``string``): The search query to filter responses.
- "sort_dir" (``string``): The direction to sort returned items:
"asc" or "desc".
- "sort_key" (``string``): The field to use for sorting (optional).
- "sort_mode" (``string``): The collati... | 256 | 256 | 2,328 | 4 | 252 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | Job | Job | 2,630 | 2,901 | 2,630 | 2,630 | 5eab8dd2c901cbccebe6f084b9e1e05cb78d24d9 | bigcode/the-stack | train |
deb4a6b6a3087f7ccfb52be7 | train | function | def _parse_atom_entry(entry):
title = entry.get('title', None)
elink = entry.get('link', [])
elink = elink if isinstance(elink, list) else [elink]
links = record((link.rel, link.href) for link in elink)
# Retrieve entity content values
content = entry.get('content', {})
# Host entry metad... | def _parse_atom_entry(entry):
| title = entry.get('title', None)
elink = entry.get('link', [])
elink = elink if isinstance(elink, list) else [elink]
links = record((link.rel, link.href) for link in elink)
# Retrieve entity content values
content = entry.get('content', {})
# Host entry metadata
metadata = _parse_atom... | >...</entry></feed>.
else:
entries = r.get('entry', None)
if entries is None: return None
return entries if isinstance(entries, list) else [entries]
# Load the sid from the body of the given response
def _load_sid(response):
return _load_atom(response).response.sid
# Parse the given ... | 90 | 90 | 302 | 7 | 82 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _parse_atom_entry | _parse_atom_entry | 232 | 268 | 232 | 232 | 8f0da6daa9afde304e8c78ce4e0c74b1b172d636 | bigcode/the-stack | train |
62830c7653531cd4e9cf35b6 | train | class | class StoragePasswords(Collection):
"""This class provides access to the storage passwords from this Splunk
instance. Retrieve this collection using :meth:`Service.storage_passwords`.
"""
def __init__(self, service):
if service.namespace.owner == '-' or service.namespace.app == '-':
... | class StoragePasswords(Collection):
| """This class provides access to the storage passwords from this Splunk
instance. Retrieve this collection using :meth:`Service.storage_passwords`.
"""
def __init__(self, service):
if service.namespace.owner == '-' or service.namespace.app == '-':
raise ValueError("StoragePasswords c... | len([x for x in self._state.content.keys()
if not x.startswith('eai') and x != 'disabled'])
class StoragePassword(Entity):
"""This class contains a storage password.
"""
def __init__(self, service, path, **kwargs):
state = kwargs.get('state', None)
kwargs['skip_refresh... | 187 | 187 | 625 | 5 | 182 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | StoragePasswords | StoragePasswords | 1,810 | 1,877 | 1,810 | 1,810 | d522462dd8d7aacceba0b1a34f617df0e3814cbc | bigcode/the-stack | train |
bb0cf2354e29e751df741c3d | train | function | def _filter_content(content, *args):
if len(args) > 0:
return record((k, content[k]) for k in args)
return record((k, v) for k, v in six.iteritems(content)
if k not in ['eai:acl', 'eai:attributes', 'type'])
| def _filter_content(content, *args):
| if len(args) > 0:
return record((k, content[k]) for k in args)
return record((k, v) for k, v in six.iteritems(content)
if k not in ['eai:acl', 'eai:attributes', 'type'])
| s.find(t)
if n == -1:
raise ValueError("Target " + t + " not found in template.")
s = s[n + len(t):]
return s
# Filter the given state content record according to the given arg list.
def _filter_content(content, *args):
| 64 | 64 | 69 | 9 | 55 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | _filter_content | _filter_content | 186 | 190 | 186 | 186 | eeb9bc00d8a196233f1b0e024dfb54a2c4be78a7 | bigcode/the-stack | train |
0d9013e138c6ef1d4a2e2f59 | train | class | class KVStoreCollection(Entity):
@property
def data(self):
"""Returns data object for this Collection.
:rtype: :class:`KVStoreCollectionData`
"""
return KVStoreCollectionData(self)
def update_index(self, name, value):
"""Changes the definition of a KV Store index.
... | class KVStoreCollection(Entity):
@property
| def data(self):
"""Returns data object for this Collection.
:rtype: :class:`KVStoreCollectionData`
"""
return KVStoreCollectionData(self)
def update_index(self, name, value):
"""Changes the definition of a KV Store index.
:param name: name of index to change
... | v in six.iteritems(indexes):
if isinstance(v, dict):
v = json.dumps(v)
kwargs['index.' + k] = v
for k, v in six.iteritems(fields):
kwargs['field.' + k] = v
return self.post(name=name, **kwargs)
class KVStoreCollection(Entity):
@property
| 73 | 73 | 245 | 10 | 63 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | KVStoreCollection | KVStoreCollection | 3,574 | 3,609 | 3,574 | 3,575 | 35de9c5d8cf0a9706371c0320d8eef7948235e3d | bigcode/the-stack | train |
46c0973415587afeed897da8 | train | class | class SavedSearch(Entity):
"""This class represents a saved search."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def acknowledge(self):
"""Acknowledges the suppression of alerts from this saved search and
resumes alerting.
:... | class SavedSearch(Entity):
| """This class represents a saved search."""
def __init__(self, service, path, **kwargs):
Entity.__init__(self, service, path, **kwargs)
def acknowledge(self):
"""Acknowledges the suppression of alerts from this saved search and
resumes alerting.
:return: The :class:`SavedSe... | args['item']
else:
return Entity.__getitem__(self, name)
@property
def arguments(self):
"""A dictionary of all the arguments supported by this modular input kind.
The keys in the dictionary are the names of the arguments. The values are
another dictionary giving th... | 255 | 256 | 1,170 | 5 | 250 | benikeller/splunk-forwarder | signalfx-forwarder-app/lib/splunklib/client.py | Python | SavedSearch | SavedSearch | 3,126 | 3,275 | 3,126 | 3,126 | 86b36279f4e21784ceaedb2cd9bb0cdad14930a8 | bigcode/the-stack | train |
216d7c9ad2bc948e2e20b755 | train | class | class Migration(migrations.Migration):
dependencies = [
('academic', '0002_auto_20201123_1545'),
]
operations = [
migrations.AddField(
model_name='session',
name='current',
field=models.BooleanField(default=False),
),
migrations.DeleteMod... | class Migration(migrations.Migration):
| dependencies = [
('academic', '0002_auto_20201123_1545'),
]
operations = [
migrations.AddField(
model_name='session',
name='current',
field=models.BooleanField(default=False),
),
migrations.DeleteModel(
name='currentsession',
... | # Generated by Django 3.1 on 2021-12-03 15:01
from django.db import migrations, models
class Migration(migrations.Migration):
| 36 | 64 | 75 | 7 | 28 | lawalkeyd/school_management_system | academic/migrations/0003_auto_20211203_1601.py | Python | Migration | Migration | 6 | 21 | 6 | 7 | 5552ecdf1d685eb120b029c6cefc44385be6bf61 | bigcode/the-stack | train |
0fbb5e7f085e4920b77d1cca | train | function | def count_pairs(adj):
"""Computes the number of unordered vertex pairs in separate components."""
total_size = total_pairs = 0
for size in component_sizes(adj):
total_pairs += total_size * size
total_size += size
return total_pairs
| def count_pairs(adj):
| """Computes the number of unordered vertex pairs in separate components."""
total_size = total_pairs = 0
for size in component_sizes(adj):
total_pairs += total_size * size
total_size += size
return total_pairs
| stack.pop()]:
if vis[neighbor]:
continue
vis[neighbor] = True
stack.append(neighbor)
size += 1
return size
for start in range(len(adj)):
size = measure(start)
if size:
yield size
def count_pairs... | 64 | 64 | 57 | 5 | 58 | EliahKagan/old-practice-snapshot | main/journey-to-the-moon/journey-to-the-moon-2.py | Python | count_pairs | count_pairs | 51 | 59 | 51 | 51 | 5baf9dce7575bde0ec7b6202d41f6f292a3c55e5 | bigcode/the-stack | train |
00263f322d0a876fa7048202 | train | function | def component_sizes(adj):
"""Yields the size of each component of a graph from its adjacency list."""
vis = [False] * len(adj)
stack = []
def measure(start):
if vis[start]:
return 0
vis[start] = True
stack.append(start)
size = 1
while stack:
... | def component_sizes(adj):
| """Yields the size of each component of a graph from its adjacency list."""
vis = [False] * len(adj)
stack = []
def measure(start):
if vis[start]:
return 0
vis[start] = True
stack.append(start)
size = 1
while stack:
for neighbor in adj[st... | an adjacency list."""
vertex_count, edge_count = read_record()
adj = [[] for _ in range(vertex_count)]
for _ in range(edge_count):
u, v = read_record()
adj[u].append(v)
adj[v].append(u)
return adj
def component_sizes(adj):
| 64 | 64 | 138 | 5 | 58 | EliahKagan/old-practice-snapshot | main/journey-to-the-moon/journey-to-the-moon-2.py | Python | component_sizes | component_sizes | 23 | 48 | 23 | 23 | 6c31e91af258d046166b4786228f9d0c7952246d | bigcode/the-stack | train |
93e3d68d05317f1b082358cf | train | function | def read_record():
"""Reads a line of input as a sequence of integers."""
return map(int, input().split())
| def read_record():
| """Reads a line of input as a sequence of integers."""
return map(int, input().split())
| #!/usr/bin/env python3
"""Journey to the Moon (HackerRank) - by iterative DFS"""
def read_record():
| 26 | 64 | 26 | 4 | 22 | EliahKagan/old-practice-snapshot | main/journey-to-the-moon/journey-to-the-moon-2.py | Python | read_record | read_record | 5 | 7 | 5 | 5 | ad4b1682e44fbb83fd40051ecacf7c07390df6d3 | bigcode/the-stack | train |
43d8317ff3aec3bdda272ed3 | train | function | def run():
"""Reads an astronaut graph and reports the number of acceptable teams."""
print(count_pairs(read_graph()))
| def run():
| """Reads an astronaut graph and reports the number of acceptable teams."""
print(count_pairs(read_graph()))
| yield size
def count_pairs(adj):
"""Computes the number of unordered vertex pairs in separate components."""
total_size = total_pairs = 0
for size in component_sizes(adj):
total_pairs += total_size * size
total_size += size
return total_pairs
def run():
| 64 | 64 | 24 | 3 | 60 | EliahKagan/old-practice-snapshot | main/journey-to-the-moon/journey-to-the-moon-2.py | Python | run | run | 62 | 64 | 62 | 62 | 1811efcd8e5fb18c5cf1d22664e433ca5a0b144b | bigcode/the-stack | train |
4c037c769c25878ccce3dedc | train | function | def read_graph():
"""Reads an undirected graph as an adjacency list."""
vertex_count, edge_count = read_record()
adj = [[] for _ in range(vertex_count)]
for _ in range(edge_count):
u, v = read_record()
adj[u].append(v)
adj[v].append(u)
return adj
| def read_graph():
| """Reads an undirected graph as an adjacency list."""
vertex_count, edge_count = read_record()
adj = [[] for _ in range(vertex_count)]
for _ in range(edge_count):
u, v = read_record()
adj[u].append(v)
adj[v].append(u)
return adj
| #!/usr/bin/env python3
"""Journey to the Moon (HackerRank) - by iterative DFS"""
def read_record():
"""Reads a line of input as a sequence of integers."""
return map(int, input().split())
def read_graph():
| 52 | 64 | 71 | 4 | 48 | EliahKagan/old-practice-snapshot | main/journey-to-the-moon/journey-to-the-moon-2.py | Python | read_graph | read_graph | 10 | 20 | 10 | 10 | 60fb5c1bf4c2c74850ba374bec2589894bb323f8 | bigcode/the-stack | train |
1d41ea6bbb7877235cfb6790 | train | class | class Local_Provas(models.Model):
nome_escola = models.CharField(max_length=255)
endereco = models.CharField(max_length=255)
cidade = models.CharField(max_length=255)
estado = models.CharField(max_length=255)
| class Local_Provas(models.Model):
| nome_escola = models.CharField(max_length=255)
endereco = models.CharField(max_length=255)
cidade = models.CharField(max_length=255)
estado = models.CharField(max_length=255)
| ular(models.Model):
nome = models.CharField(max_length=200)
class Candidato(models.Model):
nome = models.CharField(max_length=100)
RG = models.CharField(max_length=9)
CPF = models.CharField(max_length=11)
class Local_Provas(models.Model):
| 63 | 64 | 54 | 8 | 55 | Jefrubio/devops-aula13 | app/models.py | Python | Local_Provas | Local_Provas | 21 | 25 | 21 | 21 | 418938c1eb11af817518317623e61ed64d202c02 | bigcode/the-stack | train |
179559db4bdeabc3ebaf10a9 | train | class | class Candidato(models.Model):
nome = models.CharField(max_length=100)
RG = models.CharField(max_length=9)
CPF = models.CharField(max_length=11)
| class Candidato(models.Model):
| nome = models.CharField(max_length=100)
RG = models.CharField(max_length=9)
CPF = models.CharField(max_length=11)
| .
class Curso(models.Model):
nome = models.CharField(max_length=200)
periodo = models.CharField(max_length=50)
instituicao = models.CharField(max_length=200)
class Vestibular(models.Model):
nome = models.CharField(max_length=200)
class Candidato(models.Model):
| 63 | 64 | 39 | 6 | 57 | Jefrubio/devops-aula13 | app/models.py | Python | Candidato | Candidato | 16 | 19 | 16 | 16 | 511ccab968c1c869921bf8d686612df8c839a4f1 | bigcode/the-stack | train |
4113a7c852f0e4c50656fa52 | train | class | class Curso(models.Model):
nome = models.CharField(max_length=200)
periodo = models.CharField(max_length=50)
instituicao = models.CharField(max_length=200)
| class Curso(models.Model):
| nome = models.CharField(max_length=200)
periodo = models.CharField(max_length=50)
instituicao = models.CharField(max_length=200)
| """
Definition of models.
"""
from django.db import models
# Create your models here.
class Curso(models.Model):
| 23 | 64 | 39 | 5 | 18 | Jefrubio/devops-aula13 | app/models.py | Python | Curso | Curso | 8 | 11 | 8 | 8 | 74b6a7caf1913a1cf9d59ea3d37b6114773175f6 | bigcode/the-stack | train |
af35b7e04bc2b06db2b9f56c | train | class | class Vestibular(models.Model):
nome = models.CharField(max_length=200)
| class Vestibular(models.Model):
| nome = models.CharField(max_length=200)
| """
Definition of models.
"""
from django.db import models
# Create your models here.
class Curso(models.Model):
nome = models.CharField(max_length=200)
periodo = models.CharField(max_length=50)
instituicao = models.CharField(max_length=200)
class Vestibular(models.Model):
| 63 | 64 | 17 | 6 | 57 | Jefrubio/devops-aula13 | app/models.py | Python | Vestibular | Vestibular | 13 | 14 | 13 | 13 | cdcee8c8856b7a836513d9c8f9cc1fdf7167b2eb | bigcode/the-stack | train |
d02de81db74d0b4c1bd5eb3e | train | class | class Person(PiiType):
name = "Person"
type = "person"
pass
| class Person(PiiType):
| name = "Person"
type = "person"
pass
| pass
class CreditCard(PiiType, type="credit_card"): # type: ignore
name = "Credit Card"
type = "credit_card"
pass
class Address(PiiType):
name = "Address"
type = "address"
pass
class Person(PiiType):
| 64 | 64 | 21 | 6 | 57 | mbrg/piicatcher | piicatcher/__init__.py | Python | Person | Person | 31 | 34 | 31 | 31 | 2ada8c9c18c9a399a57d6be2a20f0a306c7523bd | bigcode/the-stack | train |
4335facfe4936d58871c11d5 | train | class | class UserName(PiiType, type="user_name"): # type: ignore
name = "User Name"
type = "user_name"
pass
| class UserName(PiiType, type="user_name"): # type: ignore
| name = "User Name"
type = "user_name"
pass
| Nationality(PiiType):
name = "Nationality"
type = "nationality"
pass
class SSN(PiiType):
name = "SSN"
type = "ssn"
pass
class UserName(PiiType, type="user_name"): # type: ignore
| 64 | 64 | 35 | 18 | 45 | mbrg/piicatcher | piicatcher/__init__.py | Python | UserName | UserName | 61 | 64 | 61 | 61 | 3d7033c7fc75879562f74670ab3c53450cb4518a | bigcode/the-stack | train |
717ec53ba5fd3151df613c06 | train | class | class Address(PiiType):
name = "Address"
type = "address"
pass
| class Address(PiiType):
| name = "Address"
type = "address"
pass
| pass
class Email(PiiType):
name = "Email"
type = "email"
pass
class CreditCard(PiiType, type="credit_card"): # type: ignore
name = "Credit Card"
type = "credit_card"
pass
class Address(PiiType):
| 64 | 64 | 21 | 6 | 57 | mbrg/piicatcher | piicatcher/__init__.py | Python | Address | Address | 25 | 28 | 25 | 25 | 22b1719deaa9e724a4a5ceab7e315230c55607a7 | bigcode/the-stack | train |
41cd63cd3f23ebc88662483b | train | class | class Phone(PiiType):
name = "Phone"
type = "phone"
pass
| class Phone(PiiType):
| name = "Phone"
type = "phone"
pass
| # flake8: noqa
__version__ = "0.19.1"
from dbcat.catalog.pii_types import PiiType
class Phone(PiiType):
| 36 | 64 | 21 | 6 | 29 | mbrg/piicatcher | piicatcher/__init__.py | Python | Phone | Phone | 7 | 10 | 7 | 7 | 388ac9d1f014098be655efa67132ad3fc2edda2f | bigcode/the-stack | train |
6125074e7277bb5e7022f82f | train | class | class Password(PiiType):
name = "Password"
type = "password"
pass
| class Password(PiiType):
| name = "Password"
type = "password"
pass
| SSN(PiiType):
name = "SSN"
type = "ssn"
pass
class UserName(PiiType, type="user_name"): # type: ignore
name = "User Name"
type = "user_name"
pass
class Password(PiiType):
| 64 | 64 | 21 | 6 | 57 | mbrg/piicatcher | piicatcher/__init__.py | Python | Password | Password | 67 | 70 | 67 | 67 | 445e1784777fabae522bf1631615ba0447c3aab1 | bigcode/the-stack | train |
eaaacd2e93fbd1745896dfc9 | train | class | class Email(PiiType):
name = "Email"
type = "email"
pass
| class Email(PiiType):
| name = "Email"
type = "email"
pass
| # flake8: noqa
__version__ = "0.19.1"
from dbcat.catalog.pii_types import PiiType
class Phone(PiiType):
name = "Phone"
type = "phone"
pass
class Email(PiiType):
| 57 | 64 | 21 | 6 | 50 | mbrg/piicatcher | piicatcher/__init__.py | Python | Email | Email | 13 | 16 | 13 | 13 | 3d52f7dd0a675d07e3656d47edfa702ff1e4323a | bigcode/the-stack | train |
ff36b234b63ee9af4c4c8786 | train | class | class BirthDate(PiiType, type="birth_date"): # type: ignore
name = "Birth Date"
type = "birth_date"
pass
| class BirthDate(PiiType, type="birth_date"): # type: ignore
| name = "Birth Date"
type = "birth_date"
pass
| "
pass
class Address(PiiType):
name = "Address"
type = "address"
pass
class Person(PiiType):
name = "Person"
type = "person"
pass
class BirthDate(PiiType, type="birth_date"): # type: ignore
| 64 | 64 | 35 | 18 | 45 | mbrg/piicatcher | piicatcher/__init__.py | Python | BirthDate | BirthDate | 37 | 40 | 37 | 37 | 5c39cfad42ec1a3c68e31aa8f8fc4b00f0a686ca | bigcode/the-stack | train |
96417ac663717ccc86816913 | train | class | class CreditCard(PiiType, type="credit_card"): # type: ignore
name = "Credit Card"
type = "credit_card"
pass
| class CreditCard(PiiType, type="credit_card"): # type: ignore
| name = "Credit Card"
type = "credit_card"
pass
| PiiType
class Phone(PiiType):
name = "Phone"
type = "phone"
pass
class Email(PiiType):
name = "Email"
type = "email"
pass
class CreditCard(PiiType, type="credit_card"): # type: ignore
| 64 | 64 | 35 | 18 | 45 | mbrg/piicatcher | piicatcher/__init__.py | Python | CreditCard | CreditCard | 19 | 22 | 19 | 19 | 6487565cd365e58efa37d053d7d0b8d6df509f65 | bigcode/the-stack | train |
bf4ce9c7f3e6e2a7680f7eee | train | class | class Gender(PiiType):
name = "Gender"
type = "gender"
pass
| class Gender(PiiType):
| name = "Gender"
type = "gender"
pass
| pass
class Person(PiiType):
name = "Person"
type = "person"
pass
class BirthDate(PiiType, type="birth_date"): # type: ignore
name = "Birth Date"
type = "birth_date"
pass
class Gender(PiiType):
| 64 | 64 | 21 | 6 | 57 | mbrg/piicatcher | piicatcher/__init__.py | Python | Gender | Gender | 43 | 46 | 43 | 43 | 1f32de8979220f0bb10905322b95f18aec75d713 | bigcode/the-stack | train |
9c755114327728ad9e6b2617 | train | class | class SSN(PiiType):
name = "SSN"
type = "ssn"
pass
| class SSN(PiiType):
| name = "SSN"
type = "ssn"
pass
| Birth Date"
type = "birth_date"
pass
class Gender(PiiType):
name = "Gender"
type = "gender"
pass
class Nationality(PiiType):
name = "Nationality"
type = "nationality"
pass
class SSN(PiiType):
| 64 | 64 | 24 | 7 | 56 | mbrg/piicatcher | piicatcher/__init__.py | Python | SSN | SSN | 55 | 58 | 55 | 55 | 41eb415aa827ddc00a5a8f5838bec6e9ded24d9c | bigcode/the-stack | train |
2b2debd2d947bebb856b631c | train | class | class Nationality(PiiType):
name = "Nationality"
type = "nationality"
pass
| class Nationality(PiiType):
| name = "Nationality"
type = "nationality"
pass
|
class BirthDate(PiiType, type="birth_date"): # type: ignore
name = "Birth Date"
type = "birth_date"
pass
class Gender(PiiType):
name = "Gender"
type = "gender"
pass
class Nationality(PiiType):
| 64 | 64 | 23 | 7 | 56 | mbrg/piicatcher | piicatcher/__init__.py | Python | Nationality | Nationality | 49 | 52 | 49 | 49 | 361a6ba83a6688f5c52827618eacd1bd1ee26c46 | bigcode/the-stack | train |
cf71cf6d30a49bd1f4257673 | train | function | def getTableMeta(year: int, metadata: MetaData) -> Table:
"""
get corresponding table meta data.
:param year: year of the data
:return: a Table object representing the table structure
"""
return Table(
dbUtil.getTableName(year, "fina_indicator"), metadata,
Column("ts_code", Strin... | def getTableMeta(year: int, metadata: MetaData) -> Table:
| """
get corresponding table meta data.
:param year: year of the data
:return: a Table object representing the table structure
"""
return Table(
dbUtil.getTableName(year, "fina_indicator"), metadata,
Column("ts_code", String(10)), # 股票代码
Column("ann_date", String(8)),
... | import sys
import time
import datetime
import logging
from sqlalchemy.exc import IntegrityError
import Utils.configuration_file_service as config_service
import Utils.DB_utils as dbUtil
import pandas as pd
import tushare as ts
from sqlalchemy import Column, String, Float, MetaData, Table, create_engine, INT
token =... | 114 | 256 | 3,639 | 16 | 98 | s456951753/Customized_QUANTAXIS_With_Crius | AY/Crius/MySql/fina_indicator_sharded.py | Python | getTableMeta | getTableMeta | 20 | 195 | 20 | 20 | 382dedffcc8d5edc52dbcaf0db221961b4af9547 | bigcode/the-stack | train |
3d32dafc817a6cbfdd6326f3 | train | function | def get_ts_code(engine):
"""查询ts_code"""
return pd.read_sql('select ts_code from stock_basic', engine)
| def get_ts_code(engine):
| """查询ts_code"""
return pd.read_sql('select ts_code from stock_basic', engine)
| Float), # 归属母公司股东的净利润环比增长率(%)(单季度)
Column("equity_yoy", Float), # 净资产同比增长率
Column("rd_exp", Float) # 研发费用
)
def get_ts_code(engine):
| 64 | 64 | 27 | 6 | 58 | s456951753/Customized_QUANTAXIS_With_Crius | AY/Crius/MySql/fina_indicator_sharded.py | Python | get_ts_code | get_ts_code | 197 | 199 | 197 | 197 | 4cf90d71a6f020d769b19ad2e3aaa9b398920a52 | bigcode/the-stack | train |
64da410fcb92f65fcdd25f76 | train | function | def update_bulk_fina_indicator_by_ts_code_and_insert_by_year(base_name, engine, pro, codes, sharding_column, failed_count=0,
failed_tolerent=3):
failed = []
for code in codes['ts_code']:
logger.debug("started processing data for " + code)
try:... | def update_bulk_fina_indicator_by_ts_code_and_insert_by_year(base_name, engine, pro, codes, sharding_column, failed_count=0,
failed_tolerent=3):
| failed = []
for code in codes['ts_code']:
logger.debug("started processing data for " + code)
try:
to_insert = pro.fina_indicator_vip(ts_code=code, fields='ts_code,ann_date,end_date,eps,dt_eps,total_revenue_ps,revenue_ps,capital_rese_ps,surplus_rese_ps,undist_profit_ps,extra_item,pr... | ,q_dtprofit_to_profit,q_salescash_to_or,q_ocf_to_sales,q_ocf_to_or,basic_eps_yoy,dt_eps_yoy,cfps_yoy,op_yoy,ebt_yoy,netprofit_yoy,dt_netprofit_yoy,ocf_yoy,roe_yoy,bps_yoy,assets_yoy,eqt_yoy,tr_yoy,or_yoy,q_gr_yoy,q_gr_qoq,q_sales_yoy,q_sales_qoq,q_op_yoy,q_op_qoq,q_profit_yoy,q_profit_qoq,q_netprofit_yoy,q_netprofit_qo... | 255 | 256 | 1,099 | 39 | 216 | s456951753/Customized_QUANTAXIS_With_Crius | AY/Crius/MySql/fina_indicator_sharded.py | Python | update_bulk_fina_indicator_by_ts_code_and_insert_by_year | update_bulk_fina_indicator_by_ts_code_and_insert_by_year | 226 | 255 | 226 | 227 | 653439b5e27182bc615aeb6e15edce5a11dabada | bigcode/the-stack | train |
7be816c3825593b58358c8f1 | train | function | def get_ts_code_and_list_date(engine):
"""查询ts_code"""
return pd.read_sql('select ts_code,list_date from stock_basic', engine)
| def get_ts_code_and_list_date(engine):
| """查询ts_code"""
return pd.read_sql('select ts_code,list_date from stock_basic', engine)
| ", Float), # 净资产同比增长率
Column("rd_exp", Float) # 研发费用
)
def get_ts_code(engine):
"""查询ts_code"""
return pd.read_sql('select ts_code from stock_basic', engine)
def get_ts_code_and_list_date(engine):
| 64 | 64 | 32 | 9 | 55 | s456951753/Customized_QUANTAXIS_With_Crius | AY/Crius/MySql/fina_indicator_sharded.py | Python | get_ts_code_and_list_date | get_ts_code_and_list_date | 201 | 203 | 201 | 201 | d547a13c2a4608d1ba104490f50553cc1324022d | bigcode/the-stack | train |
31a84c19574f8379abd65d92 | train | function | def update_bulk_fina_indicator_by_period_and_ts_code(base_name, engine, pro, codes, start_date, end_date, retry_count=3,
pause=2):
coverage = dbUtil.getTableRange(base_name="", start_date=start_date, end_date=end_date)
for i in coverage:
for rownum in range(0... | def update_bulk_fina_indicator_by_period_and_ts_code(base_name, engine, pro, codes, start_date, end_date, retry_count=3,
pause=2):
| coverage = dbUtil.getTableRange(base_name="", start_date=start_date, end_date=end_date)
for i in coverage:
for rownum in range(0, len(codes)):
logger.debug("started processing data for " + codes.iloc[rownum]['ts_code'] + " for period " + i)
if (int(codes.iloc[rownum]['list_date']... | ), # 营业利润环比增长率(%)(单季度)
Column("q_profit_yoy", Float), # 净利润同比增长率(%)(单季度)
Column("q_profit_qoq", Float), # 净利润环比增长率(%)(单季度)
Column("q_netprofit_yoy", Float), # 归属母公司股东的净利润同比增长率(%)(单季度)
Column("q_netprofit_qoq", Float), # 归属母公司股东的净利润环比增长率(%)(单季度)
Column("equity_yoy", Float), ... | 256 | 256 | 1,028 | 36 | 220 | s456951753/Customized_QUANTAXIS_With_Crius | AY/Crius/MySql/fina_indicator_sharded.py | Python | update_bulk_fina_indicator_by_period_and_ts_code | update_bulk_fina_indicator_by_period_and_ts_code | 206 | 223 | 206 | 207 | 01cb046c247742197485dca7d5377b9cf57a1a9c | bigcode/the-stack | train |
d153baf9faba848d1d0f8144 | train | class | class Service(object):
""" The top-level object that represents a WPS service. It's a WSGI
application.
:param processes: A list of :class:`~Process` objects that are
provided by this service.
:param cfgfiles: A list of configuration files
"""
def __init__(self, process... | class Service(object):
| """ The top-level object that represents a WPS service. It's a WSGI
application.
:param processes: A list of :class:`~Process` objects that are
provided by this service.
:param cfgfiles: A list of configuration files
"""
def __init__(self, processes=None, cfgfiles=None):... | ##################################################################
# Copyright 2018 Open Source Geospatial Foundation and others #
# licensed under MIT, Please consult LICENSE.txt for details #
##################################################################
import logging
import tempfile
import importlib
fro... | 218 | 256 | 2,631 | 4 | 214 | talos-gis/pywps | pywps/app/Service.py | Python | Service | Service | 34 | 355 | 34 | 35 | 9d7d340e242e726781e2c8dc32e42d4bd63729f2 | bigcode/the-stack | train |
2abbb5c34e74c6428cec2e13 | train | function | def _extension(complexinput):
extension = None
if complexinput.data_format:
extension = complexinput.data_format.extension
return extension
| def _extension(complexinput):
| extension = None
if complexinput.data_format:
extension = complexinput.data_format.extension
return extension
| duplicates
if os.path.exists(input_file_name):
input_file_name = tempfile.mkstemp(
suffix=suffix, prefix=prefix + '_',
dir=workdir)[1]
return input_file_name
_validate_file_input = ComplexInput._validate_file_input
def _extension(complexinput):
| 64 | 64 | 32 | 7 | 56 | talos-gis/pywps | pywps/app/Service.py | Python | _extension | _extension | 378 | 382 | 378 | 378 | 0d2996d979caccd428462e3eee8afd6608959cae | bigcode/the-stack | train |
406cc001f25b5178e5898dfe | train | function | def _build_input_file_name(href, workdir, extension=None):
href = href or ''
url_path = urlparse(href).path or ''
file_name = os.path.basename(url_path).strip() or 'input'
(prefix, suffix) = os.path.splitext(file_name)
suffix = suffix or extension or ''
if prefix and suffix:
file_name = ... | def _build_input_file_name(href, workdir, extension=None):
| href = href or ''
url_path = urlparse(href).path or ''
file_name = os.path.basename(url_path).strip() or 'input'
(prefix, suffix) = os.path.splitext(file_name)
suffix = suffix or extension or ''
if prefix and suffix:
file_name = prefix + suffix
input_file_name = os.path.join(workdir,... | Exception:
msg = "No applicable error code, please check error log."
return NoApplicableCode(msg, code=500)
@Request.application
def __call__(self, http_request):
return self.call(http_request)
def _build_input_file_name(href, workdir, extension=None):
| 64 | 64 | 151 | 15 | 49 | talos-gis/pywps | pywps/app/Service.py | Python | _build_input_file_name | _build_input_file_name | 358 | 372 | 358 | 358 | 4693d074b5d3393c48ce5d16ac908786e2379dd2 | bigcode/the-stack | train |
cb6ebf8cc886228b2066e455 | train | class | class DBConnector():
def __init__(self, address, login, password, db_name):
self.address = address
self.login = login
self.db_name = db_name
self.connection = None
try:
self.connection = mysql.connector.connect(
host=address,
user... | class DBConnector():
| def __init__(self, address, login, password, db_name):
self.address = address
self.login = login
self.db_name = db_name
self.connection = None
try:
self.connection = mysql.connector.connect(
host=address,
user=login,
... | import mysql.connector
from mysql.connector import Error
import pandas as pd
from Table import Table
class DBConnector():
| 24 | 197 | 657 | 4 | 19 | svtdanny/AntiSpam | MySQLDBConnector.py | Python | DBConnector | DBConnector | 8 | 95 | 8 | 8 | 8ed3f5dccc3cf11eef58c736c38b3c37cf2520f2 | bigcode/the-stack | train |
e024323de9be2f9b98821575 | train | function | def _on_system_startup(address, login, password, db_name):
connection = mysql.connector.connect(
host=address,
user=login,
passwd=password,
)
query = f"CREATE DATABASE IF NOT EXISTS {db_name}"
cursor = connection.cursor()
try:
cursor... | def _on_system_startup(address, login, password, db_name):
| connection = mysql.connector.connect(
host=address,
user=login,
passwd=password,
)
query = f"CREATE DATABASE IF NOT EXISTS {db_name}"
cursor = connection.cursor()
try:
cursor.execute(query)
print("Database created successfull... | _startup(self):
self.create_table
settings_cols = ['algo', 'volume', 'alphas', 'thr']
db._create_settings_table(self, 'BaseSettings', settings_cols, 'users', foreign_key='id')
def _on_system_startup(address, login, password, db_name):
| 64 | 64 | 190 | 15 | 49 | svtdanny/AntiSpam | MySQLDBConnector.py | Python | _on_system_startup | _on_system_startup | 98 | 123 | 98 | 98 | 0900aed1b4136916cb0a2f1f6b6b8ecda3fe38e4 | bigcode/the-stack | train |
c5496c99a6b3321e14adcc68 | train | class | @attr.s
class RVSData:
"""Construct a RVSdata sample.
`start_point` is the beginning location.
`end_point` is the goal location.
`main_pivot_point` is the pivot along the path.
`near_pivot_point` is the pivot near the goal.
`beyond_pivot_point` is the pivot near the goal.
`start_osmid` is th... | @attr.s
class RVSData:
| """Construct a RVSdata sample.
`start_point` is the beginning location.
`end_point` is the goal location.
`main_pivot_point` is the pivot along the path.
`near_pivot_point` is the pivot near the goal.
`beyond_pivot_point` is the pivot near the goal.
`start_osmid` is the beginning osmid.
... | use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITION... | 162 | 162 | 541 | 9 | 152 | googleinterns/cabby | cabby/rvs/rvs_item.py | Python | RVSData | RVSData | 29 | 87 | 29 | 30 | cac9e937f8c97151f8360e2b6780ba4ca9f7c994 | bigcode/the-stack | train |
0b5fba7538f15764d2070f93 | train | function | def get_digit_count(data: List[str]) -> int:
lengths = []
for line in data:
if not line:
continue
_, output = line.split("|")
numbers = output.strip().split()
lengths.extend(list(map(len, numbers)))
counter = Counter(lengths)
return counter[2] + counter[3] + c... | def get_digit_count(data: List[str]) -> int:
| lengths = []
for line in data:
if not line:
continue
_, output = line.split("|")
numbers = output.strip().split()
lengths.extend(list(map(len, numbers)))
counter = Counter(lengths)
return counter[2] + counter[3] + counter[4] + counter[7]
| import sys
from collections import Counter
from typing import List
def get_digit_count(data: List[str]) -> int:
| 25 | 64 | 83 | 12 | 12 | aikikode/adventofcode | 2021/day_08/part_1/digits.py | Python | get_digit_count | get_digit_count | 6 | 15 | 6 | 6 | 5f4b3ac3ff8b5ac0d575f30b60191d554053b92f | bigcode/the-stack | train |
cacaa6ef0a41d5bb58743c4d | train | class | class AwaitableGetPgResult(GetPgResult):
# pylint: disable=using-constant-test
def __await__(self):
if False:
yield self
return GetPgResult(
cloud_name=self.cloud_name,
components=self.components,
id=self.id,
maintenance_window_dow=self... | class AwaitableGetPgResult(GetPgResult):
# pylint: disable=using-constant-test
| def __await__(self):
if False:
yield self
return GetPgResult(
cloud_name=self.cloud_name,
components=self.components,
id=self.id,
maintenance_window_dow=self.maintenance_window_dow,
maintenance_window_time=self.maintenance_windo... | or topics but for services
with backups much of the content can at least be restored from backup in case accidental
deletion is done.
"""
return pulumi.get(self, "termination_protection")
class AwaitableGetPgResult(GetPgResult):
# pylint: disable=using-constant-test
| 64 | 64 | 189 | 21 | 43 | pulumi/pulumi-aiven | sdk/python/pulumi_aiven/get_pg.py | Python | AwaitableGetPgResult | AwaitableGetPgResult | 256 | 281 | 256 | 257 | 45ab7c74dc8cfdd153a58b928a87da3078ea7e3e | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.