code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def find_ge(self, item):
'Return first item with a key >= equal to item. Raise ValueError if not found'
k = self._key(item)
i = bisect_left(self._keys, k)
if i != len(self):
return self._items[i]
raise ValueError('No item found with key at or above: %r' % (k,)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_ge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Return first item with a key >= equal to item. Raise ValueError if not found |
def stdin_to_vobject(self, lines):
cal = iCalendar()
for event in self._parse_remind('-', lines)['-'].values():
self._gen_vevent(event, cal.add('vevent'))
return cal | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stdin_to_vobject'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Return iCal object of the Remind commands in lines |
def filter_contour(imageFile, opFile):
im = Image.open(imageFile)
im1 = im.filter(ImageFilter.CONTOUR)
im1.save(opFile) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_contour'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | convert an image by applying a contour |
def _parse_attribute(
self,
element,
attribute,
state
):
parsed_value = self._default
attribute_value = element.get(attribute, None)
if attribute_value is not None:
parsed_value = self._parser_func(attribute_value, state)
el... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_attribute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':... | Parse the primitive value within the XML element's attribute. |
def create_option_pool(self):
return OptionPool(
self.networkapi_url,
self.user,
self.password,
self.user_ldap) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_option_pool'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Get an instance of option_pool services facade. |
def export(self, out_filename):
with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc:
id_list = list(self.get_thread_info())
for num, my_info in enumerate(id_list):
logging.info('Working on item %i : %s', num, my_info['number'])
my_thread =... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Export desired threads as a zipfile to out_filename. |
def documents(cls, filter=None, **kwargs):
documents = [cls(document) for document in cls.find(filter, **kwargs)]
return [document for document in documents if document.document] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'documents'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Returns a list of Documents if any document is filtered |
def handle_purge(environ, start_response):
from utils import is_valid_security, get_cached_files
from settings import DEBUG
server = environ['SERVER_NAME']
try:
request_uri = get_path(environ)
path_and_query = request_uri.lstrip("/")
query_string = environ.get('QUERY_STRING', '')... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_purge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Handle a PURGE request. |
def disconnect(self):
self.__stop_timer()
for event in self.__in_flight.values():
event.set()
self.__mqtt.disconnect()
thread = threading.Thread(target=self.__mqtt.loop_stop)
thread.daemon = True
thread.start()
thread.join(4) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disconnect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Disconnects from the MQTT server |
async def run_checks(self):
async for check in self.fsm.health_check():
yield check
async for check in self.self_check():
yield check
for check in MiddlewareManager.health_check():
yield check | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_checks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Run checks on itself and on the FSM |
def cublasZtpsv(handle, uplo, trans, diag, n, AP, x, incx):
status = _libcublas.cublasZtpsv_v2(handle,
_CUBLAS_FILL_MODE[uplo],
_CUBLAS_OP[trans],
_CUBLAS_DIAG[diag],
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cublasZtpsv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'identi... | Solve complex triangular-packed system with one right-hand size. |
def run_with_werkzeug(self, **options):
threaded = self.threads is not None and (self.threads > 0)
self.app.run(
host=self.host,
port=self.port,
debug=self.debug,
threaded=threaded,
**options
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_with_werkzeug'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Run with werkzeug simple wsgi container. |
def staking_leaderboard(round_num=0, tournament=1):
click.echo(prettify(napi.get_staking_leaderboard(tournament=tournament,
round_num=round_num))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'staking_leaderboard'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children'... | Retrieves the staking competition leaderboard for the given round. |
def pubmed_citation(args=sys.argv[1:], out=sys.stdout):
parser = argparse.ArgumentParser(
description='Get a citation using a PubMed ID or PubMed URL')
parser.add_argument('query', help='PubMed ID or PubMed URL')
parser.add_argument(
'-m', '--mini', action='store_true', help='get mini citati... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pubmed_citation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '13']}; {'id': '4', 'type': 'default_parameter', 'children': [... | Get a citation via the command line using a PubMed ID or PubMed URL |
def newest(self):
if self._order_by == 'newest':
return self.first
if self._order_by == 'oldest':
return self.last
return max(self.entries, key=lambda x: (x.date, x.id)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'newest'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Gets the newest entry in the view, regardless of sort order |
def _fit_bmr_model(self, X, y):
self.f_bmr = BayesMinimumRiskClassifier()
X_bmr = self.predict_proba(X)
self.f_bmr.fit(y, X_bmr)
return self | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fit_bmr_model'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Private function used to fit the BayesMinimumRisk model. |
def to_match(self):
self.validate()
mark_name, field_name = self.location.get_location_name()
validate_safe_string(mark_name)
validate_safe_string(field_name)
return u'%s.%s' % (mark_name, field_name) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_match'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Return a unicode object with the MATCH representation of this GlobalContextField. |
def V_(x, requires_grad=False, volatile=False):
return create_variable(x, volatile=volatile, requires_grad=requires_grad) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'V_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}... | equivalent to create_variable, which creates a pytorch tensor |
def disbatch(self):
ret = []
for low in self.lowstate:
if not self._verify_client(low):
return
if self.token is not None and 'token' not in low:
low['token'] = self.token
if not (('token' in low)
or ('username' in lo... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disbatch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Disbatch all lowstates to the appropriate clients |
def create_api_deployment(self):
try:
self.client.create_deployment(restApiId=self.api_id, stageName=self.env)
self.log.info('Created a deployment resource.')
except botocore.exceptions.ClientError as error:
error_code = error.response['Error']['Code']
if ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_api_deployment'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Create API deployment of ENV name. |
def thumbnail_source_for_display_item(self, ui, display_item: DisplayItem.DisplayItem) -> ThumbnailSource:
with self.__lock:
thumbnail_source = self.__thumbnail_sources.get(display_item)
if not thumbnail_source:
thumbnail_source = ThumbnailSource(ui, display_item)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'thumbnail_source_for_display_item'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'ident... | Returned ThumbnailSource must be closed. |
def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name):
def types_spec():
return [
graphql_types[x]
for x in sorted(list(schema_graph.get_subclass_set(base_name)))
if x not in hidden_classes
]
return types_spec | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_union_types_specification'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identif... | Return a function that gives the types in the union type rooted at base_name. |
def Parse(self, stat, file_object, knowledge_base):
_, _ = stat, knowledge_base
field_parser = NtpdFieldParser()
for line in field_parser.ParseEntries(
utils.ReadFileBytesAsUnicode(file_object)):
field_parser.ParseLine(line)
yield rdf_config_file.NtpConfig(
config=field_parser.conf... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Parse a ntp config into rdf. |
def sky2px(wcs,ra,dec,dra,ddec,cell, beam):
dra = beam if dra<beam else dra
ddec = beam if ddec<beam else ddec
offsetDec = int((ddec/2.)/cell)
offsetRA = int((dra/2.)/cell)
if offsetDec%2==1:
offsetDec += 1
if offsetRA%2==1:
offsetRA += 1
raPix,decPix = map(int, wcs.wcs2pix(r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sky2px'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'chi... | convert a sky region to pixel positions |
def recordlookup(table, key, dictionary=None):
if dictionary is None:
dictionary = dict()
it = iter(table)
hdr = next(it)
flds = list(map(text_type, hdr))
keyindices = asindices(hdr, key)
assert len(keyindices) > 0, 'no key selected'
getkey = operator.itemgetter(*keyindices)
for ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recordlookup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Load a dictionary with data from the given table, mapping to record objects. |
def _normalize_batch(b:Tuple[Tensor,Tensor], mean:FloatTensor, std:FloatTensor, do_x:bool=True, do_y:bool=False)->Tuple[Tensor,Tensor]:
"`b` = `x`,`y` - normalize `x` array of imgs and `do_y` optionally `y`."
x,y = b
mean,std = mean.to(x.device),std.to(x.device)
if do_x: x = normalize(x,mean,std)
if... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32', '40']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_normalize_batch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '14', '18', '22', '27']}; {'id': '4', 'type': 'typed_pa... | `b` = `x`,`y` - normalize `x` array of imgs and `do_y` optionally `y`. |
def _geom_points(geom):
if geom['type'] == 'Point':
yield tuple(geom['coordinates'])
elif geom['type'] in ('MultiPoint', 'LineString'):
for position in geom['coordinates']:
yield tuple(position)
else:
raise InvalidFeatureError(
"Unsupported geometry type:{0}".... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_geom_points'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'geom... | GeoJSON geometry to a sequence of point tuples |
def printSequences(x, formatString="%d"):
[seqLen, numElements] = x.shape
for i in range(seqLen):
s = ""
for j in range(numElements):
s += formatString % x[i][j]
print s | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'printSequences'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Print a bunch of sequences stored in a 2D numpy array. |
async def _get_tshark_process(self, packet_count=None, stdin=None):
if self.use_json:
output_type = 'json'
if not tshark_supports_json(self.tshark_path):
raise TSharkVersionException("JSON only supported on Wireshark >= 2.2.0")
else:
output_type = 'psm... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_tshark_process'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': ... | Returns a new tshark process with previously-set parameters. |
def partition(self, ref=None, **kwargs):
from .exc import NotFoundError
from six import text_type
if ref:
for p in self.partitions:
if (text_type(ref) == text_type(p.name) or text_type(ref) == text_type(p.id) or
text_type(ref) == text_type(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partition'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Returns partition by ref. |
def _validate_func_args(func, kwargs):
args, varargs, varkw, defaults = inspect.getargspec(func)
if set(kwargs.keys()) != set(args[1:]):
raise TypeError("decorator kwargs do not match %s()'s kwargs"
% func.__name__) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_func_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Validate decorator args when used to decorate a function. |
def detect_port(port):
socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
socket_test.connect(('127.0.0.1', int(port)))
socket_test.close()
return True
except:
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detect_port'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'port'... | Detect if the port is used |
def _pwr_optfcn(df, loc):
I = _lambertw_i_from_v(df['r_sh'], df['r_s'],
df['nNsVth'], df[loc], df['i_0'], df['i_l'])
return I * df[loc] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pwr_optfcn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Function to find power from ``i_from_v``. |
def retrieve_layers(self, *args, **options):
queryset = Q()
if len(args) < 1:
all_layers = Layer.objects.published().external()
if options['exclude']:
exclude_list = options['exclude'].replace(' ', '').split(',')
return all_layers.exclude(slug__in=... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve_layers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Retrieve specified layers or all external layers if no layer specified. |
def _set_line_indent(src, line, indent):
if not indent:
return line
idt = []
for c in src:
if c not in ['\t', ' ']:
break
idt.append(c)
return ''.join(idt) + line.lstrip() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_line_indent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Indent the line with the source line. |
def _call_mount(self, volume, mountpoint, type=None, opts=""):
if opts and not opts.endswith(','):
opts += ","
opts += 'loop,offset=' + str(volume.offset) + ',sizelimit=' + str(volume.size)
cmd = ['mount', volume.get_raw_path(), mountpoint, '-o', opts]
if not volume.disk.read... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_call_mount'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children... | Calls the mount command, specifying the mount type and mount options. |
def draw_text(self, text:str, x:float, y:float, *,
font_name:str, font_size:float, fill:Color) -> None:
pass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_text'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17', '18', '22', '26']}; {'id': '4', 'type': ... | Draws the given text at x,y. |
def summary(self):
return "\n".join([
"Transaction:",
" When: " + self.date.strftime("%a %d %b %Y"),
" Description: " + self.desc.replace('\n', ' '),
" For amount: {}".format(self.amount),
" From: {}".format(
", ".joi... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'summary'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Return a string summary of transaction |
def clear(self):
self.log(u"Clearing cache...")
for file_handler, file_info in self.cache.values():
self.log([u" Removing file '%s'", file_info])
gf.delete_file(file_handler, file_info)
self._initialize_cache()
self.log(u"Clearing cache... done") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Clear the cache and remove all the files from disk. |
def update_grid(self):
info_map = self.ms_game.get_info_map()
for i in xrange(self.ms_game.board_height):
for j in xrange(self.ms_game.board_width):
self.grid_wgs[(i, j)].info_label(info_map[i, j])
self.ctrl_wg.move_counter.display(self.ms_game.num_moves)
if s... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_grid'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Update grid according to info map. |
def commentmap(self, cache=True):
if self.__commentmap is not None and cache==True:
return self.__commentmap
else:
x = self.xml(src='word/comments.xml')
d = Dict()
if x is None: return d
for comment in x.root.xpath("w:comment", namespaces=self.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'commentmap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | return the comments from the docx, keyed to string id. |
def browse_path(self, window):
text = self.gui_helper.create_file_chooser_dialog("Choose project directory", self.path_window, name="Select")
if text is not None:
self.dir_name.set_text(text) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'browse_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Function opens the file chooser dialog for settings project dir |
def GetUcsMethodMeta(classId, key):
if classId in _MethodFactoryMeta:
if key in _MethodFactoryMeta[classId]:
return _MethodFactoryMeta[classId][key]
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetUcsMethodMeta'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Methods returns the method meta of the ExternalMethod. |
def to_code_array(self):
state = None
first_line = True
self.pys_file.seek(0)
for line in self.pys_file:
if first_line:
if line == "[Pyspread save file version]\n":
first_line = False
else:
raise ValueErr... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_code_array'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Replaces everything in code_array from pys_file |
def rootChild_resetPassword(self, req, webViewer):
from xmantissa.signup import PasswordResetResource
return PasswordResetResource(self.store) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rootChild_resetPassword'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children... | Return a page which will allow the user to re-set their password. |
def _list_format(self, occur):
if self.keys:
self.attr["nma:key"] = " ".join(self.keys)
keys = ''.join([self.keymap[k].serialize(occur=2)
for k in self.keys])
else:
keys = ""
if self.maxEl:
self.attr["nma:max-elements"] ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_list_format'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Return the serialization format for a _list_ node. |
def add_size_info (self):
if self.is_directory():
return
filename = self.get_os_filename()
self.size = fileutil.get_size(filename)
self.modified = datetime.utcfromtimestamp(fileutil.get_mtime(filename)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_size_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Get size of file content and modification time from filename path. |
def validate_empty_attributes(fully_qualified_name: str, spec: Dict[str, Any],
*attributes: str) -> List[EmptyAttributeError]:
return [
EmptyAttributeError(fully_qualified_name, spec, attribute)
for attribute in attributes
if not spec.get(attribute, None)
] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_empty_attributes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '18']}; {'id': '4', 'type': 'typed_parame... | Validates to ensure that a set of attributes do not contain empty values |
def normalize(s, replace_spaces=True):
whitelist = (' -' + string.ascii_letters + string.digits)
if type(s) == six.binary_type:
s = six.text_type(s, 'utf-8', 'ignore')
table = {}
for ch in [ch for ch in s if ch not in whitelist]:
if ch not in table:
try:
repla... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'... | Normalize non-ascii characters to their closest ascii counterparts |
def content_break(self, el):
should_break = False
if self.type == 'odp':
if el.name == 'page' and el.namespace and el.namespace == self.namespaces['draw']:
should_break = True
return should_break | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'content_break'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Break on specified boundaries. |
def listen_dataset_events(self, owner_id, project_id, dataset_id):
if not self._user_id:
raise AmigoCloudError(self.error_msg['logged_in_websockets'])
url = '/users/%s/projects/%s/datasets/%s/start_websocket_session'
response = self.get(url % (owner_id, project_id, dataset_id))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listen_dataset_events'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Authenticate to start using dataset events. |
def _process_version_lines(self):
if len(self._lines_seen["version"]) > 1:
self._add_error(_("Multiple version lines appeared."))
elif self._lines_seen["version"][0] != 1:
self._add_error(_("The version must be on the first line.")) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_version_lines'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Process version line rules. |
async def create(self, **kwargs):
try:
obj = self._meta.object_class()
self.data.update(kwargs)
await obj.deserialize(self.data)
await obj.insert(db=self.db)
return await obj.serialize()
except Exception as ex:
logger.exception(ex)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Corresponds to POST request without a resource identifier, inserting a document into the database |
def dispatch(self, *args, **kwargs):
return super(GetAppListJsonView, self).dispatch(*args, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Only staff members can access this view |
def read_record(self, dtype, shape=1, byteorder=None):
rec = numpy.rec
try:
record = rec.fromfile(self._fh, dtype, shape, byteorder=byteorder)
except Exception:
dtype = numpy.dtype(dtype)
if shape is None:
shape = self._size // dtype.itemsize
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_record'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],... | Return numpy record from file. |
def webdriver_assert(self, assertion, failure_message='Failed Assertion'):
try:
assert assertion() is True
except AssertionError:
raise WebDriverAssertionException.WebDriverAssertionException(self.driver_wrapper, failure_message)
return True | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'webdriver_assert'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Assert the assertion, but throw a WebDriverAssertionException if assertion fails |
def save_loop(self):
last_hash = hash(repr(self.hosts))
while self.running:
eventlet.sleep(self.save_interval)
next_hash = hash(repr(self.hosts))
if next_hash != last_hash:
self.save()
last_hash = next_hash | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_loop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Saves the state if it has changed. |
def pull(self):
for item in self.input_stream:
print('%s -' % item['timestamp'], end='')
if item['transport']:
print(item['transport']['type'], end='')
packet_type = item['packet']['type']
print(packet_type, end='')
packet = item['packe... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pull'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Print out summary information about each packet from the input_stream |
def ability(cls, id_, name, function_type, ability_id, general_id=0):
assert function_type in ABILITY_FUNCTIONS
return cls(id_, name, ability_id, general_id, function_type,
FUNCTION_TYPES[function_type], None) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ability'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children... | Define a function represented as a game ability. |
def secret_loader(self, callback):
if not callback or not callable(callback):
raise Exception("Please pass in a callable that loads secret keys")
self.secret_loader_callback = callback
return callback | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'secret_loader'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Decorate a method that receives a key id and returns a secret key |
def _check_mapper(self, mapper):
if not hasattr(mapper, 'parse') or not callable(mapper.parse):
raise ValueError('mapper must implement parse()')
if not hasattr(mapper, 'format') or not callable(mapper.format):
raise ValueError('mapper must implement format()') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_mapper'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Check that the mapper has valid signature. |
def _filter_messages(messages, products=None, levels=None):
if products is None:
products = []
if levels is None:
levels = []
segments = []
bounds = len(messages)
for i, message in enumerate(messages):
if (message[3] in products or len(products) == 0) and \
(m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_filter_messages'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | filter messages for desired products and levels. |
def backup(path, name=None):
from PyHardLinkBackup.phlb.phlb_main import backup
backup(path, name) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'backup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'... | Start a Backup run |
def info(self, callback=None, **kwargs):
self.client.fetch(
self.mk_req('', method='GET', **kwargs),
callback = callback
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Get the basic info from the current cluster. |
def crud_url_name(model, action, prefix=None):
if prefix is None:
prefix = ""
app_label = model._meta.app_label
model_lower = model.__name__.lower()
return '%s%s_%s_%s' % (prefix, app_label, model_lower, action) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'crud_url_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Returns url name for given model and action. |
def _format_params(self, type_, params):
if 'initial_state' in params:
initial_state = params['initial_state']
if isinstance(initial_state, Mapping):
initial_state_list = [3]*self.properties['num_qubits']
low = -1 if type_ == 'ising' else 0
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Reformat some of the parameters for sapi. |
def root_dataset(self):
ds = self.dataset(ROOT_CONFIG_NAME_V)
ds._database = self
return ds | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'root_dataset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Return the root dataset, which hold configuration values for the library |
def can(self, event):
return [t.new_state for t in self._transitions if t.event.equals(event)] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'can'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | returns a list of states that can result from processing this event |
def create(spellchecker_cache_path):
user_dictionary = os.path.join(os.getcwd(), "DICTIONARY")
user_words = read_dictionary_file(user_dictionary)
valid_words = Dictionary(valid_words_set(user_dictionary, user_words),
"valid_words",
[user_dictionary],... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'spellcheck... | Create a Dictionary at spellchecker_cache_path with valid words. |
def ExceptionHook(exctype, value, tb):
for line in traceback.format_exception_only(exctype, value):
log.error(line.replace('\n', ''))
for line in traceback.format_tb(tb):
log.error(line.replace('\n', ''))
sys.__excepthook__(exctype, value, tb) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ExceptionHook'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | A custom exception handler that logs errors to file. |
def add(self, value):
if self._disposed:
raise ValueError(
'Cannot add value: this _WatchStore instance is already disposed')
self._data.append(value)
if hasattr(value, 'nbytes'):
self._in_mem_bytes += value.nbytes
self._ensure_bytes_limits() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Add a tensor the watch store. |
def base_url(klass, space_id='', resource_id=None, environment_id=None, **kwargs):
url = "spaces/{0}".format(
space_id)
if environment_id is not None:
url = url = "{0}/environments/{1}".format(url, environment_id)
url = "{0}/{1}".format(
url,
base_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'base_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children':... | Returns the URI for the resource. |
def exit_with_error(message):
click.secho(message, err=True, bg='red', fg='white')
sys.exit(0) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exit_with_error'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'm... | Display formatted error message and exit call |
def add_build_configuration_to_set(
set_id=None, set_name=None, config_id=None, config_name=None):
content = add_build_configuration_to_set_raw(set_id, set_name, config_id, config_name)
if content:
return utils.format_json(content) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_build_configuration_to_set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default... | Add a build configuration to an existing BuildConfigurationSet |
def prepare_data_loader(args, dataset, vocab, test=False):
dataset = dataset.transform(lambda s1, s2, label: (vocab(s1), vocab(s2), label),
lazy=False)
batchify_fn = btf.Tuple(btf.Pad(), btf.Pad(), btf.Stack(dtype='int32'))
data_lengths = [max(len(d[0]), len(d[1])) for d in d... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare_data_loader'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr... | Read data and build data loader. |
def AddNoiseToLatLng(lat, lng):
m_per_tenth_lat = Distance(lat, lng, lat + 0.1, lng)
m_per_tenth_lng = Distance(lat, lng, lat, lng + 0.1)
lat_per_100m = 1 / m_per_tenth_lat * 10
lng_per_100m = 1 / m_per_tenth_lng * 10
return (lat + (lat_per_100m * 5 * (random.random() * 2 - 1)),
lng + (lng_per_100m ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AddNoiseToLatLng'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Add up to 500m of error to each coordinate of lat, lng. |
def wait(self, log_file):
"Wait until the process is ready."
lines = map(self.log_line, self.filter_lines(self.get_lines(log_file)))
return any(
std.re.search(self.pattern, line)
for line in lines
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Wait until the process is ready. |
def ExpireRules(self):
rules = self.Get(self.Schema.RULES)
new_rules = self.Schema.RULES()
now = time.time() * 1e6
expired_session_ids = set()
for rule in rules:
if rule.expires > now:
new_rules.Append(rule)
else:
for action in rule.actions:
if action.hunt_id:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ExpireRules'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Removes any rules with an expiration date in the past. |
def encode(self, s):
sentence = s
tokens = sentence.strip().split()
if self._replace_oov is not None:
tokens = [t if t in self._token_to_id else self._replace_oov
for t in tokens]
ret = [self._token_to_id[tok] for tok in tokens]
return ret[::-1] if self._reverse else ret | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Converts a space-separated string of tokens to a list of ids. |
def ast_to_headings(node):
Heading = namedtuple('Heading', ['level', 'title'])
level = None
walker = node.walker()
headings = []
event = walker.nxt()
while event is not None:
entering = event['entering']
node = event['node']
if node.t == 'Heading':
if entering... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ast_to_headings'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'n... | Walks AST and returns a list of headings |
def _format_help_dicts(help_dicts, display_defaults=False):
help_strs = []
for help_dict in help_dicts:
help_str = "%s (%s" % (
help_dict["var_name"],
"Required" if help_dict["required"] else "Optional",
)
if help_dict.get("default") and display_defaults:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_help_dicts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Format the output of _generate_help_dicts into a str |
def text_from_affiliation_elements(department, institution, city, country):
"format an author affiliation from details"
return ', '.join(element for element in [department, institution, city, country] if element) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'text_from_affiliation_elements'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier... | format an author affiliation from details |
def run_with_pmids(model_path, pmids):
from indra.tools.machine.machine import run_with_pmids_helper
run_with_pmids_helper(model_path, pmids) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_with_pmids'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Run with given list of PMIDs. |
def annotate_gemini(data, retriever=None):
r = dd.get_variation_resources(data)
return all([r.get(k) and objectstore.file_exists_or_remote(r[k]) for k in ["exac", "gnomad_exome"]]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'annotate_gemini'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Annotate with population calls if have data installed. |
def _null_date(self):
try:
return self.__null_date
except AttributeError:
number_settings = self._target.getNumberFormatSettings()
d = number_settings.getPropertyValue('NullDate')
self.__null_date = datetime.datetime(d.Year, d.Month, d.Day)
return ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_null_date'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Returns date which is represented by a integer 0. |
def checkConfig():
config_file_dir = os.path.join(cwd, "config.py")
if os.path.exists(config_file_dir):
print("Making a backup of your config file!")
config_file_dir2 = os.path.join(cwd, "config.py.oldbak")
copyfile(config_file_dir, config_file_dir2) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'checkConfig'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '17']}; {'id': '5', '... | If the config.py file exists, back it up |
def join(tokens, start, result):
texts = []
if len(result) > 0:
for e in result:
for child in e.iter():
if child.text is not None:
texts.append(child.text)
return [E(result[0].tag, ' '.join(texts))] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'join'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'to... | Join tokens into a single string with spaces between. |
def date_from_quarter(base_date, ordinal, year):
interval = 3
month_start = interval * (ordinal - 1)
if month_start < 0:
month_start = 9
month_end = month_start + interval
if month_start == 0:
month_start = 1
return [
datetime(year, month_start, 1),
datetime(year,... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'date_from_quarter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Extract date from quarter of a year |
def ret_list_minions(self):
tgt = _tgt_set(self.tgt)
return self._ret_minions(tgt.intersection) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ret_list_minions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Return minions that match via list |
def visit_Starred(self, node: AST, dfltChaining: bool = True) -> str:
with self.op_man(node):
return f"*{self.visit(node.value)}" | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_Starred'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': ... | Return representation of starred expresssion. |
def to_dict(self):
return {name: {'value': self._process_value(str, value)}
for name, value in self._ea_dict.items()
if not (value is None or value == "" or value == [])} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Converts extensible attributes into the format suitable for NIOS. |
def handle_set_row(self):
row = self.reader.int()
logger.info(" -> row: %s", row)
self.controller.row = row | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_set_row'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Read incoming row change from server |
def url(self, key):
return urlunparse((self.protocol, '%s:%s' % (self.domain, self.port),
'%s/api/v1%s' % (self.prefix, URLS[key]),
'', '', '')) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Creates a full URL to the API using urls dict |
def wr_tsv(self, fout_tsv, goea_results, **kws):
prt_flds = kws.get('prt_flds', self.get_prtflds_default(goea_results))
tsv_data = MgrNtGOEAs(goea_results).get_goea_nts_prt(prt_flds, **kws)
RPT.wr_tsv(fout_tsv, tsv_data, **kws) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wr_tsv'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Write tab-separated table data to file |
def upload_hub(hub, host, remote_dir, user=None, port=22, rsync_options=RSYNC_OPTIONS, staging=None):
hub.render()
if staging is None:
staging = tempfile.mkdtemp()
staging, linknames = stage_hub(hub, staging=staging)
local_dir = os.path.join(staging)
upload(host, user, local_dir=local_dir, r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload_hub'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16']}; {'id': '4', 'type': 'identifier'... | Renders, stages, and uploads a hub. |
def _check_type(name, obj, expected_type):
if not isinstance(obj, expected_type):
raise TypeError(
'"%s" must be an a %s' % (name, expected_type.__name__)
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Raise a TypeError if object is not of expected type |
def duration(label, stop_it=True, stop_at=None):
if label not in labels:
return None
if "duration" in labels[label]:
return Duration(labels[label]["duration"])
if stop_it:
return stop(label, at=stop_at)
else:
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'duration'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Returns duration in seconds for label |
def call(cmd, shell=True, cwd=None, universal_newlines=True, stderr=STDOUT):
return Shell._run(call, cmd, shell=shell, cwd=cwd, stderr=stderr,
universal_newlines=universal_newlines) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [],... | Just execute a specific command. |
def _create_penwidth_combo(self):
choices = map(unicode, xrange(12))
self.pen_width_combo = \
_widgets.PenWidthComboBox(self, choices=choices,
style=wx.CB_READONLY, size=(50, -1))
self.pen_width_combo.SetToolTipString(_(u"Border width"))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_penwidth_combo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Create pen width combo box |
def append(self, item):
if len(self) == 0:
self.index = 0
self.items.append(item) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Adds a new item to the end of the collection. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.