query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Returns an itirator over all ngrams for n in range(ngramRange) given a list of tokens. | def range_ngrams(tokens, ngramRange=(1,2)):
return chain(*(n_grams(tokens, i) for i in range(*ngramRange))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ngramize(items: List[str], ngram_range=(1, 1)) -> Generator[List[str], Any, None]:\n\n ngrams = []\n ranges = [(0, i) for i in range(ngram_range[0], ngram_range[1] + 1)]\n for r in ranges:\n ngrams += list(zip(*[items[j:] for j in range(*r)]))\n\n formatted_ngrams = [' '.join(item) for item ... | [
"0.77018356",
"0.7479281",
"0.74121964",
"0.74022996",
"0.7253089",
"0.7199664",
"0.7115451",
"0.70956486",
"0.708296",
"0.70244306",
"0.6999506",
"0.6986396",
"0.6947342",
"0.6940619",
"0.6927285",
"0.6926673",
"0.6888308",
"0.68828356",
"0.6871958",
"0.682038",
"0.6817774",... | 0.8547429 | 0 |
Clear the summary dictionary. | def clear_summary(self):
self._summary.clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_summaries(self):\n\n\t\tself.summaries = [{ key: 0 for key in self.keys() }, 0]\n\t\tif self.encoded_summary == 1:\n\t\t\tfor i in range(len(self.encoded_keys)):\n\t\t\t\tself.encoded_counts[i] = 0",
"def clearSummary(self):\n self.summary(DiagnosticStatus.OK, '')",
"def reset(self) -> None:\n... | [
"0.81930006",
"0.7744242",
"0.7526364",
"0.7524949",
"0.7348229",
"0.72681165",
"0.72200364",
"0.71623015",
"0.71330416",
"0.70410275",
"0.7039112",
"0.6935825",
"0.6934039",
"0.69223726",
"0.6921015",
"0.68289196",
"0.68142843",
"0.6779447",
"0.6761134",
"0.6751369",
"0.6727... | 0.8200098 | 0 |
Regrid ORAS4 to MOM. | def test_oras4_to_mom(self, input_dir, output_dir):
output = os.path.join(output_dir, 'mom_oras4_temp.nc')
if os.path.exists(output):
os.remove(output)
src_name = 'ORAS4'
src_data_file = os.path.join(input_dir, 'thetao_oras4_1m_2014_grid_T.nc')
dest_name = 'MOM'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_oras4_to_mom1(self, input_dir, output_dir):\n\n output = os.path.join(output_dir, 'mom1_oras4_temp.nc')\n if os.path.exists(output):\n os.remove(output)\n\n src_name = 'ORAS4'\n src_data_file = os.path.join(input_dir, 'so_oras4_1m_2014_grid_T.nc')\n dest_name ... | [
"0.6696749",
"0.5472097",
"0.5131155",
"0.5071717",
"0.5061862",
"0.5038171",
"0.49968898",
"0.496674",
"0.4937408",
"0.4932757",
"0.49031186",
"0.4871228",
"0.4843777",
"0.48415455",
"0.48366535",
"0.4836101",
"0.48330456",
"0.48307824",
"0.48289937",
"0.4805085",
"0.4799185... | 0.6836795 | 0 |
Regrid ORAS4 to MOM 1 degree. | def test_oras4_to_mom1(self, input_dir, output_dir):
output = os.path.join(output_dir, 'mom1_oras4_temp.nc')
if os.path.exists(output):
os.remove(output)
src_name = 'ORAS4'
src_data_file = os.path.join(input_dir, 'so_oras4_1m_2014_grid_T.nc')
dest_name = 'MOM1'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_oras4_to_mom(self, input_dir, output_dir):\n\n output = os.path.join(output_dir, 'mom_oras4_temp.nc')\n if os.path.exists(output):\n os.remove(output)\n\n src_name = 'ORAS4'\n src_data_file = os.path.join(input_dir, 'thetao_oras4_1m_2014_grid_T.nc')\n dest_nam... | [
"0.6384693",
"0.5832228",
"0.5281928",
"0.5183972",
"0.51822543",
"0.51589733",
"0.5147658",
"0.51439065",
"0.5104023",
"0.5096983",
"0.50910795",
"0.5061224",
"0.50440603",
"0.50376153",
"0.50355136",
"0.50339186",
"0.5033682",
"0.5008212",
"0.49874973",
"0.49730933",
"0.497... | 0.66791886 | 0 |
Update amqp client relation hooks IFF leader node is ready. Client nodes are considered ready once the leader has already run amqp_changed. | def update_clients():
if rabbit.leader_node_is_ready() or rabbit.client_node_is_ready():
for rid in relation_ids('amqp'):
for unit in related_units(rid):
amqp_changed(relation_id=rid, remote_unit=unit) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _updateHeartbeat (self) :\r\n for pw, conn in self.clients :\r\n if conn : # we do have at least one client, enable heartbeat if needed\r\n self.have_clients = True\r\n return\r\n \r\n self.have_clients = False",
"def _handle_coordinator_update(... | [
"0.5726184",
"0.5629322",
"0.5541219",
"0.551056",
"0.5471582",
"0.54037356",
"0.5383622",
"0.53529847",
"0.5351824",
"0.5332944",
"0.53299505",
"0.5322766",
"0.5321517",
"0.53153884",
"0.530414",
"0.5285929",
"0.5285929",
"0.52854335",
"0.52835894",
"0.526965",
"0.5262245",
... | 0.7011619 | 0 |
Affiche les nombres impairs entre `n` et `m` inclus. >>> affiche_impairs(42, 51) 43 45 47 49 51 | def affiche_impairs(n: int, m: int) -> None:
# Trois versions proposées
## Version itérative classique
i = n
if i % 2 == 0:
i += 1
while i <= m:
print(i, end=" ")
i += 2
print()
## Version fonctionnelle ; 1 ligne
#print(" ".join(map(str, range(n - n%2 + 1, m + 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imprimir_matriz(matriz):\n for i in matriz:\n print(i)",
"def imprime(nota_fiscal):\n\n print(\"Imprimindo nota fiscal %s\" % nota_fiscal.cnpj)",
"def _compute_imprimitivity(self):\n m = floor(self._.d / 2)\n self._.antipodal = all(full_simplify(\n self._.b[i] - self._.c[sel... | [
"0.51183224",
"0.47331733",
"0.46972212",
"0.4431077",
"0.4413606",
"0.4408542",
"0.43618786",
"0.43256623",
"0.42876646",
"0.42723647",
"0.42626938",
"0.42480263",
"0.42155024",
"0.4205314",
"0.4193979",
"0.41894197",
"0.41849914",
"0.41778257",
"0.41758695",
"0.4172205",
"0... | 0.73484516 | 0 |
Plots an individual chip in a subaxis | def plot_chip(self, aid, nRows, nCols, px, fulldraw=True, **kwargs):
ibs = self.ibs
if aid in [self.aid1, self.aid2]:
# Bold color for the matching chips
lw = 5
text_color = np.array((135, 206, 235, 255)) / 255.0
else:
lw = 2
text_color... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_channels(dat, chanaxis=-1, otheraxis=-2):\n ax = []\n n_channels = dat.data.shape[chanaxis]\n for i, chan in enumerate(dat.axes[chanaxis]):\n if i == 0:\n a = plt.subplot(10, n_channels / 10 + 1, i + 1)\n else:\n a = plt.subplot(10, n_channels / 10 + 1, i + 1, ... | [
"0.63316065",
"0.6027693",
"0.596213",
"0.5961878",
"0.5896854",
"0.5847748",
"0.5820817",
"0.58156234",
"0.5796932",
"0.5793897",
"0.5792818",
"0.5770452",
"0.57648313",
"0.5755763",
"0.5755642",
"0.57511485",
"0.5740199",
"0.5723509",
"0.57168835",
"0.56989443",
"0.5689734"... | 0.60907084 | 1 |
All the annotations are given nid | def merge_all_into_nid(self, nid, event=None):
aid_list = self.all_aid_list
self.ibs.set_annot_name_rowids(aid_list, [nid] * len(aid_list))
self.update_callback()
self.backend_callback()
self.show_page() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_annotations(self, img_id):\n return self._img_id2annotations.get(img_id, [])",
"def load_annotations(self, ann_file, N, kind):\n\n self.coco = COCOPoint(ann_file, N=N, kind=kind)\n # The order of returned `cat_ids` will not\n # change with the order of the CLASSES\n sel... | [
"0.5965637",
"0.594054",
"0.58875173",
"0.5866568",
"0.5783522",
"0.5778308",
"0.57285047",
"0.5727667",
"0.5715991",
"0.57081497",
"0.5700986",
"0.5677542",
"0.5651312",
"0.56260675",
"0.5624124",
"0.5497677",
"0.54948866",
"0.5488697",
"0.5482274",
"0.54618627",
"0.5447039"... | 0.61062497 | 0 |
All nonjunk annotations are given the SAME new name | def merge_nonjunk_into_new_name(self, event=None):
# Delete all original names
aid_list = self.all_aid_list
aid_list_filtered = ut.filterfalse_items(
aid_list, self.ibs.get_annot_isjunk(aid_list)
)
# Rename annotations
self.ibs.set_annot_names_to_same_new_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_04_remove_annotations(self):\n self.addAnnotation(\"annotation1\", self.host.id, \"HOST\")\n self.removeAnnotation(self.added_annotations[-1].annotation.id)\n del self.added_annotations[-1]",
"def fixing_annotation(key, n):\n if key + '.' + n not in self.propbank:\n ... | [
"0.62354994",
"0.619226",
"0.6170612",
"0.6045546",
"0.59696645",
"0.5833827",
"0.5801684",
"0.5790386",
"0.5656737",
"0.5653905",
"0.56522465",
"0.56447643",
"0.5641596",
"0.5641287",
"0.5592741",
"0.5537441",
"0.5534922",
"0.5529436",
"0.55039114",
"0.54505855",
"0.5441954"... | 0.6833057 | 0 |
Returns the ip address of the host default exterior access port/adapter. | def get_default_ip_address():
gws = netifaces.gateways() # get all gateways
default = gws['default'] # get the default gw
adapter = default[2][1] # get the adapter identifier
realadapter = netifaces.ifaddresses(adapter) # get the adapter
addr_dict = realadapter[2][0] # get the first ipv4 a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_ip():\r\n if CONFIG.BIND_INTERFACE is None:\r\n default_gw = netifaces.gateways()['default']\r\n if netifaces.AF_INET in default_gw:\r\n preferred_interface = default_gw[netifaces.AF_INET][1]\r\n else:\r\n interfaces = netifaces.interfaces()\r\n ... | [
"0.7631836",
"0.7160805",
"0.71426094",
"0.7098438",
"0.70112723",
"0.6928257",
"0.6869446",
"0.68464303",
"0.68386245",
"0.6819427",
"0.67678815",
"0.67554003",
"0.6754864",
"0.6745649",
"0.6723856",
"0.6662521",
"0.6648195",
"0.6618535",
"0.66100913",
"0.65531534",
"0.65409... | 0.7446385 | 1 |
Accesses the training checkpoint. | def checkpoint(self):
return self._checkpoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkpoint():",
"def load_checkpoint(self):\n if self.params.resume_from is not None and os.path.exists(self.params.resume_from):\n try:\n LOG('Loading Checkpoint at %s' % self.params.resume_from)\n ckpt = torch.load(self.params.resume_from)\n se... | [
"0.7333538",
"0.728644",
"0.71189874",
"0.70072585",
"0.6946537",
"0.6767927",
"0.67457914",
"0.66684693",
"0.6628645",
"0.66275215",
"0.6597199",
"0.6591708",
"0.6549104",
"0.65430933",
"0.6524163",
"0.6517946",
"0.64900166",
"0.64351654",
"0.6414265",
"0.6412828",
"0.639305... | 0.74751663 | 0 |
Access training loss metric objects for all tasks. | def training_losses(self):
if self._training_losses is None:
# Builds the per-task metrics and losses.
# This the total summed training loss of tasks in the joint training.
self._training_losses = dict(
total_loss=tf.keras.metrics.Mean("training_loss", dtype=tf.float32))
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def training_metrics(self):\r\n if self._training_metrics is None:\r\n # Builds the per-task metrics and losses.\r\n self._training_metrics = {}\r\n for name, task in self.multi_task.tasks.items():\r\n self._training_metrics[name] = task.build_metrics(training=True)\r\n return self._tra... | [
"0.67372334",
"0.6436993",
"0.6299553",
"0.62310845",
"0.6202372",
"0.6157093",
"0.61555773",
"0.6127681",
"0.6114597",
"0.6095806",
"0.6082403",
"0.6082403",
"0.6079341",
"0.6064714",
"0.6049644",
"0.6047267",
"0.6020964",
"0.60065204",
"0.5966593",
"0.59373814",
"0.5933041"... | 0.7341264 | 0 |
Access training metric metric objects for all tasks. | def training_metrics(self):
if self._training_metrics is None:
# Builds the per-task metrics and losses.
self._training_metrics = {}
for name, task in self.multi_task.tasks.items():
self._training_metrics[name] = task.build_metrics(training=True)
return self._training_metrics | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_multitask_metrics(metric_tasks = ()):\n\n @flax.struct.dataclass\n class MultiTaskMetric(metrics.Metric):\n \"\"\"MultiTaskMetric.\n\n This metric aggregates sub-metrics in the metric_dict and return the metrics\n of all of them by calling them separately.\n\n Attributes:\n tasks: A sequ... | [
"0.667385",
"0.6412713",
"0.6114214",
"0.61097354",
"0.61061174",
"0.60684097",
"0.602961",
"0.5939189",
"0.5872546",
"0.58626574",
"0.5764105",
"0.57264847",
"0.5720861",
"0.57078487",
"0.57022095",
"0.5697843",
"0.56895506",
"0.56850576",
"0.56800485",
"0.5675132",
"0.56665... | 0.82266814 | 0 |
Unpickle and execute task. | def work(pickled_task):
task = pickle.loads(pickled_task)
return task.execute() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, task):\n\n self._setup()\n\n runnable = load_from_module(task.task)\n runnable(*task.get_args(), **task.get_kwargs())",
"def run_task(self) -> Task:",
"def task_wrapper(serialized_task):\n task = pickle.loads(serialized_task)\n logging.info('Running %s', str(task))\n ... | [
"0.6628442",
"0.6553389",
"0.64709336",
"0.6245773",
"0.62365663",
"0.6235586",
"0.6140546",
"0.606011",
"0.6013078",
"0.6006409",
"0.6006409",
"0.58641344",
"0.58462805",
"0.58322525",
"0.5796792",
"0.57681733",
"0.57168084",
"0.57168084",
"0.57036185",
"0.5652299",
"0.56480... | 0.7416804 | 0 |
Pickle tasks and distribute work over parallel processes. | def execute(self, tasks: List[Task], progress_bar: bool = True):
n_tasks = len(tasks)
pickled_tasks = [pickle.dumps(task) for task in tasks]
n_procs = min(self.n_procs, n_tasks)
logger.info(f"Performing parallel task execution on {n_procs} "
f"processes.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks():",
"def pool_job(self, func, inputs):\n\n if self.flag_use_mp:\n output = zip(*self._pool.map(func, inputs))\n self._consolidate_mp_logs()\n else:\n logger.info(\"Performing task serially\")\n output = self.serial_job(func, inputs)\n\n ... | [
"0.6510637",
"0.6504562",
"0.6131207",
"0.6020679",
"0.59689945",
"0.59663326",
"0.59335184",
"0.5931897",
"0.58953154",
"0.58685786",
"0.58604807",
"0.582191",
"0.5813244",
"0.5809672",
"0.5804818",
"0.5782704",
"0.57782567",
"0.577521",
"0.57745594",
"0.5769893",
"0.5763244... | 0.6563995 | 0 |
Sets up this window with a simulator, a display and optionally a control widget. | def __init__(self, simulator, display, control=None, **kwargs):
super(ZasimMainWindow, self).__init__(**kwargs)
self.setAttribute(Qt.WA_DeleteOnClose)
self.simulator = simulator
self.display = display
self.control = control
central_widget = QWidget(self)
if se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _display_setup(self):\r\n display_file = \"{}/display.json\".format(self.settings_dir)\r\n with open(display_file) as json_file:\r\n win_settings = json.load(json_file)\r\n self.win = visual.Window(**win_settings)\r\n framerate = self.win.fps()\r\n self.frame_durat... | [
"0.68346995",
"0.6504775",
"0.6488538",
"0.64603406",
"0.6286316",
"0.6179651",
"0.61078423",
"0.6093484",
"0.60897326",
"0.6019644",
"0.6019345",
"0.6001433",
"0.599808",
"0.59722495",
"0.59695345",
"0.59521645",
"0.5940673",
"0.59181553",
"0.5897244",
"0.5888673",
"0.588575... | 0.76192385 | 0 |
Attach an extra display to the control. Those displays are updated whenever a step occurs. | def attach_display(self, display):
self.extra_displays.append(display)
self.addDockWidget(Qt.RightDockWidgetArea, display)
#self.display_attached.emit(display) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_displayhook(self):\n pass",
"def bs_addHeadsUpDisplay():\n # remove all headsUpDisplay.\n if pm.windows.headsUpDisplay(lh=True):\n for each in pm.windows.headsUpDisplay(lh=True):\n pm.windows.headsUpDisplay(each, rem=True)\n # add new heads up displays.\n pm.windows... | [
"0.6375533",
"0.63675547",
"0.6366979",
"0.63276595",
"0.6158632",
"0.6107422",
"0.60964465",
"0.59870285",
"0.58940417",
"0.58865005",
"0.58281237",
"0.57941467",
"0.57307637",
"0.5726875",
"0.570152",
"0.56921536",
"0.56437284",
"0.56373584",
"0.5606878",
"0.5606859",
"0.55... | 0.7561709 | 0 |
Detach an extra attached display from the control. | def detach_display(self, display):
self.extra_displays.remove(display)
self.removeDockWidget(display)
#self.display_detached.emit(display) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_display (self, display):\n z = display.z\n self.layers[z].remove(display)\n # remove layer if empty now\n if not self.layers[z]:\n del self.layers[z]\n # remove display from overlaps/overlapped lists\n for disp in display.overlaps:\n disp.ov... | [
"0.65239346",
"0.6328763",
"0.62478584",
"0.61699164",
"0.6071742",
"0.5924774",
"0.5723696",
"0.56696635",
"0.5666436",
"0.56627667",
"0.56161225",
"0.5611194",
"0.55860007",
"0.557813",
"0.5575845",
"0.5551016",
"0.5550515",
"0.55281574",
"0.5518822",
"0.55140615",
"0.54834... | 0.82741654 | 0 |
Runs the given functions using the code in the given directory. Returns True if all went well, together with a string for the user | def run_functions( functions, dir ):
res = []
for i in range(0, len(functions)):
res.append(functions[i].execute(dir))
return summarize_as_html(res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_programs_in_directory(directory):\n files = [f for f in os.listdir(directory) if f.endswith(DECAF_SUFFIX)]\n files.sort()\n files = [os.path.join(directory, f) for f in files]\n\n all_passed = True\n for f in files:\n if not check_return_value(f):\n all_passed = False\n\n... | [
"0.649745",
"0.61049306",
"0.601415",
"0.5996975",
"0.5956264",
"0.59434325",
"0.5774836",
"0.5742658",
"0.5614913",
"0.5594323",
"0.55386126",
"0.5527245",
"0.54437554",
"0.5434158",
"0.53976876",
"0.5385297",
"0.5377416",
"0.5375581",
"0.5370017",
"0.53367186",
"0.53345543"... | 0.726597 | 0 |
Method to generate dataset_name for tests. Will either use the name defined in the test configuration ("dataset_name"), or generate one using the Expectation name and index. In cases where the dataset is a list, then an additional index will be used. | def generate_dataset_name_from_expectation_name(
dataset: dict, expectation_type: str, index: int, sub_index: int | None = None
) -> str:
dataset_name: str
if not sub_index:
dataset_name = dataset.get(
"dataset_name", f"{expectation_type}_dataset_{index}"
)
else:
dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataset_name(self):\n raise NotImplementedError",
"def construct_dataset_name(self, *args):\n raise NotImplementedError",
"def dataset_name(self):\n return self.dataset.name",
"def get_dataset_name(self):\n return self.dataset_name",
"def dataset_name(self):\n ret... | [
"0.7306698",
"0.7130462",
"0.6957245",
"0.69177663",
"0.679696",
"0.67210925",
"0.63921684",
"0.63351583",
"0.6311843",
"0.6262449",
"0.60664064",
"0.60308975",
"0.60308975",
"0.60308975",
"0.5981057",
"0.59641856",
"0.5901834",
"0.5868013",
"0.5859498",
"0.58271116",
"0.5812... | 0.804055 | 0 |
Check that dataset_name (ie. table name) is valid before adding data to table. | def _check_if_valid_dataset_name(dataset_name: str) -> str:
if not re.match(r"^[A-Za-z0-9_]+$", dataset_name):
raise ExecutionEngineError(
f"dataset_name: {dataset_name} is not valid, because it contains non-alphanumeric and _ characters."
f"Please check your configuration."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_dataset_name(self, dataset_name: Optional[str]) -> str:\n if dataset_name is None:\n if self.num_datasets > 1:\n raise ValueError(\"`dataset_name` is required if there are \"\n \"more than one datasets.\")\n dataset_name = ne... | [
"0.7201624",
"0.696584",
"0.6844129",
"0.67277294",
"0.6414105",
"0.632463",
"0.62681",
"0.6216825",
"0.6144954",
"0.61314577",
"0.6130932",
"0.6114927",
"0.60404384",
"0.6018948",
"0.600851",
"0.5978239",
"0.5962034",
"0.58974594",
"0.58849335",
"0.58839834",
"0.5843434",
... | 0.7651157 | 0 |
Copied get_redshift_connection_url func from tests/test_utils.py | def _get_redshift_connection_string() -> str:
host = os.environ.get("REDSHIFT_HOST") # noqa: TID251
port = os.environ.get("REDSHIFT_PORT") # noqa: TID251
user = os.environ.get("REDSHIFT_USERNAME") # noqa: TID251
pswd = os.environ.get("REDSHIFT_PASSWORD") # noqa: TID251
db = os.environ.get("REDSH... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_redshift_connection(config: Dict, logger):\n conn_str = \"host={host} dbname={db} user={user} password={paswd} port={port}\".format(\n host=config['CLUSTER']['HOST'],\n db=config['CLUSTER']['DB_NAME'],\n user=config['CLUSTER']['DB_USER'],\n paswd=config['CLUSTER']['DB_PASSWOR... | [
"0.6826129",
"0.6124717",
"0.6010275",
"0.5927962",
"0.5850685",
"0.5733345",
"0.5726986",
"0.5710287",
"0.56841594",
"0.56101626",
"0.5597106",
"0.55189204",
"0.55136573",
"0.5498949",
"0.54822123",
"0.5470598",
"0.5457574",
"0.5453781",
"0.5428834",
"0.54282737",
"0.5426115... | 0.7788936 | 0 |
Copied get_awsathena_connection_url and get_awsathena_db_name funcs from tests/test_utils.py | def _get_athena_connection_string(db_name_env_var: str = "ATHENA_DB_NAME") -> str:
ATHENA_DB_NAME: Optional[str] = os.getenv(db_name_env_var)
ATHENA_STAGING_S3: Optional[str] = os.getenv("ATHENA_STAGING_S3")
if not ATHENA_DB_NAME:
raise ValueError(
f"Environment Variable {db_name_env_va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get():\n assert sdb.get(\"sdb://salt/foo\") == \"sdb://salt/foo\"",
"def test_url():\n return TEST_DATABASE_URL",
"def test_db_connection(env_setup, env_table):\n test_string = DbManager(SqLiteHelper, {\"db_path\": env_setup, \"master_table\": env_table})\\\n .test_connection()\n as... | [
"0.6231901",
"0.612633",
"0.5995813",
"0.5969979",
"0.5810007",
"0.5721061",
"0.56909764",
"0.56657547",
"0.5641794",
"0.5621795",
"0.5588193",
"0.5584233",
"0.551454",
"0.55139333",
"0.5426676",
"0.5410052",
"0.5409274",
"0.54009277",
"0.5392772",
"0.5385202",
"0.5337856",
... | 0.6868718 | 0 |
Copied get_snowflake_connection_url func from tests/test_utils.py | def _get_snowflake_connection_string() -> str:
sfUser = os.environ.get("SNOWFLAKE_USER") # noqa: TID251
sfPswd = os.environ.get("SNOWFLAKE_PW") # noqa: TID251
sfAccount = os.environ.get("SNOWFLAKE_ACCOUNT") # noqa: TID251
sfDatabase = os.environ.get("SNOWFLAKE_DATABASE") # noqa: TID251
sfSchema ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_url():\n return TEST_DATABASE_URL",
"def get_db_connection_url():\n return os.environ[\"DATABASE_URL\"]",
"def get_connection_string(src_or_dest):\n if src_or_dest == \"src\":\n try:\n SQL_SERVER = os.environ[\"CROP_SRC_SQL_SERVER\"]\n SQL_PASSWORD = os.environ[\"... | [
"0.6306403",
"0.593241",
"0.5894464",
"0.5894039",
"0.5661682",
"0.56526774",
"0.56200486",
"0.5572493",
"0.551084",
"0.54703426",
"0.5458792",
"0.54345244",
"0.543016",
"0.54166806",
"0.53993094",
"0.5395401",
"0.5394583",
"0.53854716",
"0.53636956",
"0.5357231",
"0.53468376... | 0.7753926 | 0 |
Creates a temporary directory and absolute path to an ephemeral sqlite_db within that temp directory. Used to support testing of multitable expectations without creating temp directories at import. | def generate_sqlite_db_path():
tmp_dir = str(tempfile.mkdtemp())
abspath = os.path.abspath( # noqa: PTH100
os.path.join( # noqa: PTH118
tmp_dir,
"sqlite_db"
+ "".join(
[random.choice(string.ascii_letters + string.digits) for _ in range(8)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tempdir():\n\n # Create a directory and return the path\n return tempfile.mkdtemp()",
"def mock_db(tmpdir_factory):\n filename = str(tmpdir_factory.mktemp(\"data\").join(\"test.db\"))\n create_test_db(filename)\n return filename",
"def create_temp_dir():\n\n try:\n temp_dir = os.ge... | [
"0.7303786",
"0.72319436",
"0.7175902",
"0.71247184",
"0.71021247",
"0.7007046",
"0.6982505",
"0.69429123",
"0.6942816",
"0.69313794",
"0.6923916",
"0.68669444",
"0.68456614",
"0.6796194",
"0.6775696",
"0.6754039",
"0.6739042",
"0.6726847",
"0.67143714",
"0.6703309",
"0.66915... | 0.735027 | 0 |
this function read cpi rate csv then returns dataframe | def get_cpi_rates():
df = pd.read_csv('cpi_usa.csv', index_col=0)
df.index = pd.to_datetime(df.index)
df = df.resample('BAS').mean() # change sampling to business year start
df.index = df.index.year # datetime to year
df.columns = ['cpi_rate']
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetRateData(directory):\n\n rt_data = pd.read_csv(directory)\n return rt_data",
"def read_csv_ur10(self, csv_file):\r\n df = pd.read_csv(csv_file, sep=';', decimal=',', header=0)\r\n return df",
"def read_csv():",
"def _get_liwc_df(self) -> pd.DataFrame:\n data = pd.read_csv(se... | [
"0.6811379",
"0.6593392",
"0.6442805",
"0.6427641",
"0.64132476",
"0.63819474",
"0.63650864",
"0.63588196",
"0.6348105",
"0.6342826",
"0.63283473",
"0.63253975",
"0.63097906",
"0.63020056",
"0.63020056",
"0.63020056",
"0.62934697",
"0.62911475",
"0.619082",
"0.6184108",
"0.61... | 0.69035745 | 0 |
function D=l2distance(X,Z) Computes the Euclidean distance matrix. | def l2distance(X, Z=None):
if Z is None:
n, d = X.shape
s1 = np.sum(np.power(X, 2), axis=1).reshape(-1,1)
D1 = -2 * np.dot(X, X.T) + repmat(s1, 1, n)
D = D1 + repmat(s1.T, n, 1)
np.fill_diagonal(D, 0)
D = np.sqrt(np.maximum(D, 0))
else:
n, d = X.shape
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_l2_distance_matrix(features_queries, features_dataset):\n sx = np.sum(features_queries ** 2, axis=1, keepdims=True)\n sy = np.sum(features_dataset ** 2, axis=1, keepdims=True)\n\n return np.sqrt(-2 * features_queries.dot(features_dataset.T) + sx + sy.T)",
"def chDist (x1,y1,z1,x2,y2,z2):\n\n... | [
"0.66955245",
"0.6539834",
"0.65245646",
"0.6406857",
"0.6404955",
"0.63448393",
"0.62766933",
"0.62603134",
"0.6219491",
"0.6203552",
"0.61489147",
"0.61423534",
"0.6136372",
"0.6129909",
"0.60990906",
"0.6084675",
"0.6078998",
"0.60646284",
"0.60477096",
"0.5988069",
"0.598... | 0.8402708 | 0 |
Generator that returns nothing | def emptyGenerator():
return
yield | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __emptygen():\n if False:\n yield",
"def nullcontext() -> Iterator[None]:\n yield",
"def __call__(self, input=None): # pragma: no cover\n while False:\n yield None",
"def no_none(decorated):\n def _func(*args, **kwargs):\n \"\"\"wrap generator\"\"\"\n ... | [
"0.83837897",
"0.7599528",
"0.7254626",
"0.67886347",
"0.67538154",
"0.6752617",
"0.67197376",
"0.65942144",
"0.6579768",
"0.6470785",
"0.6467969",
"0.6385577",
"0.63608426",
"0.6305669",
"0.6300992",
"0.62990665",
"0.6295552",
"0.62473893",
"0.62469494",
"0.62340343",
"0.621... | 0.8927865 | 0 |
GET method Get an instant task information. | def get(self, request):
feedback = {
'permission': True
}
try:
task_id = request.GET.get('task_id', None)
if task_id is None:
feedback['data'] = ErrorCode.parameter_missing('task_id')
raise natrix_exception.ParameterMissingExcep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request):\n feedback = {\n 'permission': True\n }\n\n try:\n task_id = request.GET.get('task_id', None)\n if task_id is None:\n feedback['data'] = ErrorCode.parameter_missing('task_id')\n raise natrix_exception.Parame... | [
"0.74831307",
"0.7133121",
"0.6826516",
"0.6812052",
"0.67514664",
"0.6739813",
"0.67362785",
"0.67078495",
"0.6705825",
"0.66610193",
"0.66112524",
"0.66061497",
"0.65405357",
"0.65372086",
"0.65368414",
"0.6521287",
"0.65013915",
"0.64811116",
"0.64549655",
"0.64519477",
"0... | 0.7734223 | 0 |
ingest from a particular sequence | def sequence_ingest(self,sequence):
data=self.data
counter=0
for item in data[sequence]:
datestring=item['specimenDate']
date=fetchdate(datestring)
row,created=DailyCases.objects.get_or_create(specimenDate=date,areacode=item['areaCode'])
row.areaname=item['areaName']
row.dailyLabConfirmedCases=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runingest(sdms):\n\n NotImplementedError",
"def sequence_ingest(self,areacode):\n\t\tdata=self.data[self.data['Area code']==areacode]\n\t\tareaname=data['Area name'].unique().item()\n\t\tlog.debug(f'Ingesting cases from {areacode}: {areaname}')\n\t\t\n\t\tcounter=0\n\t\tfor day in data['Specimen date']:\n... | [
"0.6136106",
"0.5331914",
"0.53135365",
"0.5175939",
"0.50551826",
"0.5026542",
"0.49525687",
"0.4925182",
"0.48475435",
"0.48164946",
"0.47848186",
"0.47665244",
"0.4746681",
"0.4724975",
"0.4722248",
"0.4703724",
"0.46878073",
"0.46619025",
"0.4656287",
"0.4650094",
"0.4643... | 0.5506488 | 1 |
ingest from a particular areacode | def sequence_ingest(self,areacode):
data=self.data[self.data['Area code']==areacode]
areaname=data['Area name'].unique().item()
log.debug(f'Ingesting cases from {areacode}: {areaname}')
counter=0
for day in data['Specimen date']:
date=fetchdate(day)
row,created=DailyCases.objects.get_or_create(specim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ingest_all(self):\n\t\tfor place in self.district_codes():\n\t\t\tself.sequence_ingest(place)\n\t\tif self.edition:\n\t\t\tconfigs.userconfig.update('PHE','latest_cases',self.edition)",
"def temp_(code):\n\n # Does the partial match criteria include at least one OLC code?\n if centroid or north... | [
"0.5511954",
"0.52550125",
"0.5201155",
"0.5177178",
"0.51257527",
"0.5105152",
"0.5058143",
"0.5027915",
"0.49984464",
"0.49700317",
"0.49276492",
"0.49143016",
"0.49059305",
"0.48697504",
"0.48524132",
"0.48495924",
"0.48474264",
"0.4834441",
"0.48077965",
"0.47952256",
"0.... | 0.6261241 | 0 |
add up total cases for a nation for integrity checks | def sum_cases(nation='England'):
_sum=0
for _code in ons_week.stored_names:
if ons_week.nation[_code]==nation:
place=ons_week.stored_names[_code]
_total=DailyCases.objects.filter(areaname=place).aggregate(Max('totalLabConfirmedCases')).get('totalLabConfirmedCases__max')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foreign(x): # electing to count 'Indian Territory' as domestic\n if x == 'United States' or x == 'Indian Territory':\n return 0\n else:\n return 1",
"def summarize(allowances):\n total_allowances = 0\n if isinstance(allowances, dict):\n for key, value in allowance... | [
"0.5884516",
"0.5413104",
"0.5396519",
"0.534488",
"0.5344416",
"0.5311308",
"0.52783656",
"0.5254872",
"0.5220287",
"0.52202386",
"0.5146511",
"0.51194024",
"0.5109611",
"0.5081266",
"0.5076306",
"0.50641674",
"0.5041381",
"0.503695",
"0.5023702",
"0.5020459",
"0.50109977",
... | 0.75075555 | 0 |
This function registers the parameters of the model to Pypet. Parameters can be nested dictionaries. They are unpacked and stored recursively. | def _addParametersToPypet(self, traj, params):
def addParametersRecursively(traj, params, current_level):
# make dummy list if just string
if isinstance(current_level, str):
current_level = [current_level]
# iterate dict
for key, value in params.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_params(self):\n for layer in self.layers:\n for name, value in layer.params.iteritems():\n self.params[name] = value",
"def _setup_params(self,**params):\n ### a parameter might be passed in for one of the extra_pos;\n ### if a key in the params dict is n... | [
"0.59744143",
"0.5886846",
"0.586683",
"0.5800144",
"0.57814205",
"0.57720727",
"0.5771282",
"0.5759148",
"0.57267505",
"0.5726273",
"0.57261705",
"0.5721666",
"0.5715509",
"0.56774455",
"0.56688505",
"0.5631474",
"0.56107694",
"0.5597048",
"0.5589862",
"0.5588286",
"0.556092... | 0.66340107 | 0 |
If not evaluation function is given, we assume that a model will be simulated. This function will be called by pypet directly and therefore wants a pypet trajectory as an argument | def _runModel(self, traj):
if self.useRandomICs:
logging.warn("Random initial conditions not implemented yet")
# get parameters of this run from pypet trajectory
runParams = self.getParametersFromTraj(traj)
if self.parameterSpace.star:
runParams = flatten_nested_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_trajectory():\n pass",
"def evaluate_model(self, t, scaling_parameters, system_parameters):\n raise NotImplementedError",
"def make_predict_step(self):\n return self.make_eval_step()",
"def evaluate(self, predictor_model) -> Any:\n raise NotImplementedError()",
"def run_mode... | [
"0.5927099",
"0.59192216",
"0.5839392",
"0.57752514",
"0.5674803",
"0.56711715",
"0.5602252",
"0.5563227",
"0.55145705",
"0.54891074",
"0.54664755",
"0.54656124",
"0.5425638",
"0.54192406",
"0.54156095",
"0.53884786",
"0.53753805",
"0.53617346",
"0.5361516",
"0.5347182",
"0.5... | 0.63979477 | 0 |
Helper to handle None's in pypet parameters (used for random number generator seed) | def _validatePypetParameters(self, runParams):
# fix rng seed, which is saved as a string if None
if "seed" in runParams:
if runParams["seed"] == "None":
runParams["seed"] = None
return runParams | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_allow_none():\n value = None\n num_a = param.Integer(value=value, allow_None=True)\n assert num_a.value == value",
"def test_rng_null(self):\n assert check_random_state(None) is np.random.mtrand._rand",
"def noneType(value):\r\n return ''",
"def test_get_with_None_... | [
"0.62218755",
"0.602136",
"0.60112995",
"0.5922588",
"0.58687824",
"0.58633107",
"0.5859123",
"0.58180076",
"0.5806624",
"0.5767758",
"0.56836206",
"0.5663786",
"0.56127363",
"0.56008166",
"0.5596845",
"0.55941707",
"0.55930674",
"0.55622345",
"0.55609566",
"0.5521717",
"0.55... | 0.6851421 | 0 |
Aggregate all results in to dfResults dataframe. | def aggregateResultsToDfResults(self, arrays=True, fillna=False):
nan_value = np.nan
# defines which variable types will be saved in the results dataframe
SUPPORTED_TYPES = (float, int, np.ndarray, list)
SCALAR_TYPES = (float, int)
ARRAY_TYPES = (np.ndarray, list)
loggin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate_results(self):\n\n raise NotImplementedError",
"def _make_results_dataframe(self):\n LOG.debug(\"Creating Results Dataframes.\")\n results_df = tfs.TfsDataFrame(index=self.twiss_df.index)\n results_df[\"S\"] = self.twiss_df[\"S\"]\n return results_df",
"def make... | [
"0.69664747",
"0.6740201",
"0.6676644",
"0.6570679",
"0.64964044",
"0.6288518",
"0.6284019",
"0.6193791",
"0.61452377",
"0.6103424",
"0.608616",
"0.60509396",
"0.6011559",
"0.59929734",
"0.59141815",
"0.58985555",
"0.5862192",
"0.5848644",
"0.5842289",
"0.5819599",
"0.5788575... | 0.738837 | 0 |
Return `xr.Dataset` from the exploration results. | def xr(self, bold=False):
def _sanitize_nc_key(k):
return k.replace("*", "_").replace(".", "_").replace("|", "_")
assert self.results is not None, "Run `loadResults()` first to populate the results"
assert len(self.results) == len(self.dfResults)
# create intrisinsic dims f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataset(self):\n if self.mode == \"test\":\n return OnlineQueryDataset(self.mode, self.df, self.tokenizer)\n else:\n return OnlineQueryDataset(self.mode, self.df_reindex, self.tokenizer)",
"def get_pandas(self):\n return pd.DataFrame(self.results)",
"def to_da... | [
"0.62103707",
"0.6039698",
"0.6023591",
"0.601906",
"0.59815496",
"0.59300596",
"0.5848126",
"0.581404",
"0.5806816",
"0.580024",
"0.57943356",
"0.5780146",
"0.57669896",
"0.57436913",
"0.5633727",
"0.5601604",
"0.5577262",
"0.5559064",
"0.55575436",
"0.55522215",
"0.55362487... | 0.65473825 | 0 |
Create a new SRPAuthenticationPolicy from a settings dict. | def from_settings(cls, settings={}, prefix="srpauth.", **kwds):
# Grab out all the settings keys that start with our prefix.
auth_settings = {}
for name, value in settings.iteritems():
if not name.startswith(prefix):
continue
auth_settings[name[len(prefix)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_settings(settings):",
"def from_settings(cls, settings: SimulationSettingsModel):\n return cls(\n start=settings.project.simulation_range.start,\n end=settings.project.simulation_range.end,\n )",
"def from_dictionary(cls,\r\n dictionary):\r\n ... | [
"0.6121792",
"0.5455022",
"0.53785753",
"0.5297272",
"0.5285958",
"0.5271405",
"0.522127",
"0.51688355",
"0.5129926",
"0.51216954",
"0.50879085",
"0.5074323",
"0.50737494",
"0.50673383",
"0.50673383",
"0.50573564",
"0.5042459",
"0.500692",
"0.500038",
"0.4994687",
"0.4989003"... | 0.70107263 | 0 |
Get the unauthenticated userid for this request. When using HTTPSRPHMACAuth, this involves looking in the HTTP Authorization header to find the reported username. | def unauthenticated_userid(self, request):
params = self._get_auth_params(request)
if params is None:
return None
return params.get("username") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unauthenticated_userid(self, request):\n authorization = request.headers.get('Authorization')\n if authorization is None:\n return None\n token_object = find_token_for_authorization(authorization)\n if token_object is None:\n raise httpexceptions.HTTPUnauthoriz... | [
"0.86458576",
"0.86111814",
"0.82587343",
"0.81629455",
"0.7881346",
"0.71495134",
"0.70761484",
"0.6976793",
"0.6847131",
"0.6801054",
"0.6793066",
"0.67122",
"0.6617604",
"0.6589437",
"0.6586149",
"0.6583202",
"0.65430385",
"0.65210736",
"0.6506743",
"0.6506743",
"0.6495544... | 0.8799287 | 0 |
Get the list of effective principals for this request. | def effective_principals(self, request):
principals = [Everyone]
params = self._get_auth_params(request)
if params is None:
return principals
if not self._authenticate(request, params):
return principals
username = params["username"]
if self.groupf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def effective_principals(self, principal_id, request=None, context=None):",
"def get_all_principals(self, principal_id):",
"def get_cm_kerberos_principals(self):\n return self._get(endpoint='{}/cm/kerberosPrincipals'.format(self.api_version)).json()",
"def _principals_for_authenticated_user(user):\n ... | [
"0.68408215",
"0.6034431",
"0.5508367",
"0.5466632",
"0.5356161",
"0.5305189",
"0.52793163",
"0.52767515",
"0.5255969",
"0.51875716",
"0.5126472",
"0.5123606",
"0.5084907",
"0.5058053",
"0.5046586",
"0.50261647",
"0.5022569",
"0.5021784",
"0.49984184",
"0.49808112",
"0.496968... | 0.66565347 | 1 |
View that challenges for credentials with a "401 Unauthorized". This method can be used as a pyramid "forbidden view" in order to challenge for auth credentials when necessary. | def challenge_view(self, request):
headerlist = [("Content-Type", "text/plain")]
headerlist.extend(self._get_challenge_headers(request))
return Response("Unauthorized", status="401 Unauthorized",
headerlist=headerlist) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_401(error):\n return render_template('/error401.html'), 401",
"def user_must_authenticate():\n return Response(\n 'Could not verify your access level for that URL.\\n'\n 'You have to login with proper credentials', 401,\n {'WWW-Authenticate': 'Basic realm=\"Login Required\"... | [
"0.7490076",
"0.73721296",
"0.73475176",
"0.734617",
"0.7247712",
"0.71779835",
"0.71317047",
"0.7059749",
"0.7015688",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
"0.6969938",
... | 0.75270486 | 0 |
Get headers necessary for a fresh srphmacauth challenge. This method generates a new srphmacauth challenge for the given request, including a fresh nonce. If the environment is marked as having a stale nonce then this is indicated in the challenge. | def _get_challenge_headers(self, request, check_stale=True):
params = {}
params["realm"] = self.realm
if self.domain is not None:
params["domain"] = self.domain
# Escape any special characters in those values, so we can send
# them as quoted-strings. The extra values... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_headers(credentials, path, nonce, body):\n\n sig = '/api/' + path + nonce + body\n sig_hash = hmac.new(\n credentials['secret'].encode('utf-8'),\n sig.encode('utf-8'),\n hashlib.sha384\n ).hexdigest()\n\n headers = {\n 'bfx-nonce': nonce,\n 'bfx-apikey': ... | [
"0.61025995",
"0.5901304",
"0.5791251",
"0.5778743",
"0.56111044",
"0.5487719",
"0.5440298",
"0.54147327",
"0.53871363",
"0.53820187",
"0.536679",
"0.5350175",
"0.53226167",
"0.53192484",
"0.5319032",
"0.52954966",
"0.5290292",
"0.52816975",
"0.5227853",
"0.5152028",
"0.51323... | 0.74318314 | 0 |
Extract srphmacauth parameters from the request. This method extracts srphmacauth parameters from the Authorization header and returns them as a dict. If they are missing then None is returned. | def _get_unvalidated_auth_params(self, request):
try:
params = parse_authz_header(request)
except ValueError:
params = None
if params is None:
return None
if params["scheme"].lower() != "srp-hmac":
return None
return params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_auth_params(self, request):\n params = self._get_unvalidated_auth_params(request)\n if params is None:\n return None\n # Check that they're valid srp-hmac-auth parameters.\n if not validate_parameters(params, self.realm):\n return None\n # Check tha... | [
"0.6592601",
"0.62808114",
"0.6254532",
"0.6068169",
"0.6067721",
"0.60282284",
"0.5955428",
"0.5917826",
"0.5900995",
"0.58761734",
"0.5870564",
"0.58591247",
"0.58245647",
"0.5797018",
"0.5796605",
"0.57675487",
"0.5755379",
"0.57153034",
"0.56880015",
"0.5687705",
"0.56730... | 0.7045831 | 0 |
Extract srphmacauth parameters from the request. This method extracts srphmacauth parameters from the Authorization header and returns them as a dict. If they are missing then None is returned. | def _get_auth_params(self, request):
params = self._get_unvalidated_auth_params(request)
if params is None:
return None
# Check that they're valid srp-hmac-auth parameters.
if not validate_parameters(params, self.realm):
return None
# Check that the digest... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_unvalidated_auth_params(self, request):\n try:\n params = parse_authz_header(request)\n except ValueError:\n params = None\n if params is None:\n return None\n if params[\"scheme\"].lower() != \"srp-hmac\":\n return None\n retu... | [
"0.70454544",
"0.62824553",
"0.625724",
"0.6068481",
"0.6067896",
"0.60297483",
"0.5957361",
"0.5918057",
"0.5902953",
"0.5877564",
"0.5871777",
"0.58604544",
"0.58254915",
"0.57967126",
"0.57958364",
"0.57685727",
"0.57565445",
"0.5715781",
"0.5688506",
"0.5688009",
"0.56737... | 0.6592623 | 1 |
Obtain the password verifier data to use for the given user. This method returns a tuple (algorithm, salt, verifier) giving the necessary information to verify the user's password. If no information is available for the user then a tuple of Nones is returned. | def _get_verifier(self, username):
# If we have a get_verifier callback, use it directly.
if self.get_verifier is not None:
verifier = self.get_verifier(username)
if verifier is not None and verifier[0] is not None:
return verifier
# Otherwise, we need t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_verified_password(self):\n raise NotImplementedError('get_verified_password')",
"def get_verified_password(self):\n return self.controller.dbfilter.db.get('passwd/user-password-again')",
"def check_password() -> tuple:\n user_data: dict = request.get_json()\n uid: str = user_data.ge... | [
"0.6216303",
"0.61528856",
"0.59387445",
"0.5666319",
"0.548512",
"0.54241",
"0.5317666",
"0.5284316",
"0.52637374",
"0.52235824",
"0.5173144",
"0.5169702",
"0.51583606",
"0.51457644",
"0.5130701",
"0.511049",
"0.5103841",
"0.50647473",
"0.5032563",
"0.5018214",
"0.50169563",... | 0.72366863 | 0 |
Get the serverside private key for a given nonce. | def _get_privkey(self, nonce):
privkey = self.nonce_manager.get_prandom_bytes(nonce, 32)
return int_from_bytes(privkey) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_private_key():\n return DH.b2i(Random.new().read(DH_SIZE))",
"def find_private_key(self):\n\t\tp, q = self.find_hidden_primes()\n\t\tself.private_key = self.calculate_private_key(p, q)\n\t\treturn self.private_key",
"def private_key(self):\n return self.__get_option('private_key')",
"de... | [
"0.60576475",
"0.5962076",
"0.594449",
"0.5929952",
"0.5911263",
"0.5911263",
"0.58971477",
"0.5884221",
"0.58803326",
"0.586463",
"0.58440894",
"0.5813109",
"0.5810623",
"0.575331",
"0.575331",
"0.5733055",
"0.5732046",
"0.5714373",
"0.56808704",
"0.56776005",
"0.56552625",
... | 0.74581945 | 0 |
Include default srpauth settings into a pyramid config. This function provides a hook for pyramid to include the default settings | def includeme(config):
# Grab the pyramid-wide settings, to look for any auth config.
settings = config.get_settings().copy()
# Use the settings to construct an AuthenticationPolicy.
authn_policy = SRPAuthenticationPolicy.from_settings(settings)
config.set_authentication_policy(authn_policy)
# H... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def override_config(self):\n super(AuthedConfigFixture, self).override_config()\n self.conf.register_opts(auth_token._OPTS, group='keystone_authtoken')\n self.conf.set_override('auth_uri', 'http://127.0.0.1:35357',\n group='keystone_authtoken')",
"def setup_sett... | [
"0.6572887",
"0.62719035",
"0.617056",
"0.608547",
"0.6069364",
"0.60461533",
"0.6034325",
"0.601316",
"0.586339",
"0.58631706",
"0.57857096",
"0.5770519",
"0.571746",
"0.5687391",
"0.56611305",
"0.56506854",
"0.5604428",
"0.5598433",
"0.55896086",
"0.5553104",
"0.553698",
... | 0.64770824 | 1 |
Creates a dictionarylike object representing the filesystem structure starting at the given root directory. | def get_fs_dict (
initial_root, create_item=None, dict_cls=dict,
dirname_filter=None, filename_filter=None,
include_root=False, toplevel_files=True, prune_empty=False, file_key=None,
):
# TODO(could-do): max_depth=N
fsdict = dict_cls()
get_file_key = ( lambda x: x ) if file_key is None else file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dirname, defmode='r'):\n self.name = dirname\n self.defmode = defmode\n\n self.items = []\n\n for i in os.listdir(dirname):\n if os.path.isdir(os.path.join(dirname, i)):\n self.items.append(Tree(os.path.join(dirname, i), defmode))\n\n ... | [
"0.6521569",
"0.65162444",
"0.6484279",
"0.64037526",
"0.6266439",
"0.62654215",
"0.6254696",
"0.6253443",
"0.62238693",
"0.6207021",
"0.6196134",
"0.6184652",
"0.6175318",
"0.6164307",
"0.6069025",
"0.6048882",
"0.6022305",
"0.60057586",
"0.60057586",
"0.60057586",
"0.600575... | 0.7043223 | 0 |
Generator that iterates over the content of a filesystem tree starting at source and compares it to the filesystem tree starting at dest (which doesn't have to exist). The subdir_root can be used to control whether source should be a subdir of dest or not (which means that walk_copy_tree (source, dest, subdir_root=True... | def walk_copy_tree ( source, dest, subdir_root=False, **walk_kwargs ):
source_path = os.path.abspath ( source )
dest_path = os.path.abspath ( dest )
get_entry = lambda path: (
path, os.lstat ( path ) if os.path.lexists ( path ) else None
)
get_stat_list = lambda s, d, names: (
[ ( get_entr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertFileTree(self, source, tree):\n dirs_tree = [e for e in tree if not isinstance(e, str)]\n\n dirs, files = self.storage.listdir(source)\n expected_dirs = [e[0] for e in dirs_tree]\n expected_files = [e for e in tree if isinstance(e, str)]\n self.assertCountEqual(dirs, ex... | [
"0.6292492",
"0.5832197",
"0.58168596",
"0.5799975",
"0.5763929",
"0.57484084",
"0.5722568",
"0.56811893",
"0.567231",
"0.5659945",
"0.56529665",
"0.5623519",
"0.5603917",
"0.56004435",
"0.5587346",
"0.55472785",
"0.5534416",
"0.55120814",
"0.54979503",
"0.5481419",
"0.547965... | 0.7667128 | 0 |
Compares the given mode with a list of r/w/x bits and creates a RWX object for it. | def from_bitmask ( cls, mode, rwx_bits ):
return cls (
mode & rwx_bits[0], mode & rwx_bits[1], mode & rwx_bits[2],
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_stat_mode ( cls, stat_mode ):\n return cls (\n RWX.from_bitmask ( stat_mode, cls.USR_BITS ),\n RWX.from_bitmask ( stat_mode, cls.GRP_BITS ),\n RWX.from_bitmask ( stat_mode, cls.OTH_BITS ),\n )",
"def resMode(mode): \n if mode==0:\n makeMesh(r0x, r0y)\n elif... | [
"0.6624755",
"0.5387723",
"0.52551746",
"0.5182285",
"0.50885785",
"0.49726188",
"0.4918288",
"0.47915792",
"0.4790591",
"0.47765884",
"0.46680427",
"0.4661446",
"0.46470672",
"0.45956075",
"0.45906985",
"0.45378727",
"0.4529674",
"0.45049015",
"0.4488689",
"0.4481426",
"0.44... | 0.6783992 | 0 |
Returns an integer representing the rwx mode for the given rwx bits. | def get_bitmask ( self, rwx_bits ):
ret = 0
if self.readable:
ret |= rwx_bits[0]
if self.writable:
ret |= rwx_bits[1]
if self.executable:
ret |= rwx_bits[2]
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_bitmask ( cls, mode, rwx_bits ):\n return cls (\n mode & rwx_bits[0], mode & rwx_bits[1], mode & rwx_bits[2],\n )",
"def get_lsb(self, x, w=32):\n mask = (1 << w) - 1\n return int(x & mask)",
"def get_stat_mode ( self ):\n return (\n self.user.get_bitmask ... | [
"0.6308568",
"0.5609232",
"0.5549503",
"0.5435947",
"0.5271582",
"0.51879895",
"0.5128324",
"0.5119145",
"0.51129645",
"0.5092444",
"0.50841266",
"0.50841266",
"0.50642216",
"0.5061078",
"0.50094485",
"0.4977763",
"0.4973743",
"0.4972096",
"0.496862",
"0.49660695",
"0.4963623... | 0.76721585 | 0 |
Returns a new permissions object for the given string. | def from_str ( cls, s, strict=False ):
rwx_user = RWX.from_str ( s[0:3], strict=strict )
rwx_group = RWX.from_str ( s[3:6], strict=strict )
rwx_others = RWX.from_str ( s[6:9], strict=strict )
return cls ( rwx_user, rwx_group, rwx_others ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_string(cls, permission):\n p_read = 'r' in permission\n p_add = 'a' in permission\n p_update = 'u' in permission\n p_process = 'p' in permission\n\n parsed = cls(p_read, p_add, p_update, p_process)\n\n return parsed",
"def create_from_arg_string(cls, arg_string)... | [
"0.69934595",
"0.5844637",
"0.5794634",
"0.5684017",
"0.562672",
"0.56258774",
"0.5491144",
"0.54451984",
"0.5422989",
"0.5404011",
"0.5355926",
"0.5328249",
"0.5311455",
"0.5287373",
"0.5220261",
"0.5157838",
"0.5156501",
"0.50684",
"0.5037294",
"0.5022736",
"0.50016254",
... | 0.58623594 | 1 |
Creates a permissions object for the given stat mode. | def from_stat_mode ( cls, stat_mode ):
return cls (
RWX.from_bitmask ( stat_mode, cls.USR_BITS ),
RWX.from_bitmask ( stat_mode, cls.GRP_BITS ),
RWX.from_bitmask ( stat_mode, cls.OTH_BITS ),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return self.chmod_dir ( fspath )\n else:\n return self.chmod_file ( fspath )",
"def _getstatdict_forcreate(self, mode):\n now = getnow()\n stat = {\n 'st_mode': mode,\n 'st_nlink': 1... | [
"0.6227134",
"0.6162068",
"0.57799256",
"0.57596844",
"0.5685234",
"0.5639629",
"0.5500084",
"0.54408145",
"0.53968257",
"0.53407454",
"0.53266263",
"0.5314504",
"0.5312102",
"0.52856654",
"0.52711236",
"0.5270964",
"0.5242508",
"0.5240414",
"0.519975",
"0.519469",
"0.5187937... | 0.71357036 | 0 |
Calls chmod(fspath) and chown(fspath) after creating an intermediate ChownChmod instance. | def chown_chmod ( fspath, uid=None, gid=None, mode=None, pretend=False ):
return ChownChmod ( uid, gid, mode, pretend ).chown_chmod ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chown_chmod ( self, fspath ):\n # should be renamed to chmod_chown()\n return (\n self.chmod ( fspath ),\n self.chown ( fspath )\n )",
"def chown_dir ( self, fspath ):\n return",
"def chmod_chown ( self, fspath ):\n if os.path.isdir ( fspath ):\n return (\n ... | [
"0.81457466",
"0.7512426",
"0.75111514",
"0.7507602",
"0.7474258",
"0.7366395",
"0.734391",
"0.7337309",
"0.7254689",
"0.7141006",
"0.70009094",
"0.68603367",
"0.68487173",
"0.68058246",
"0.66050404",
"0.65938056",
"0.6492462",
"0.6466497",
"0.63773435",
"0.6361034",
"0.63574... | 0.805532 | 1 |
Similar to "touch ". | def do_touch ( self, fspath ):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def touch(name):\r\n with file(name, 'a'):\r\n os.utime(name, None)",
"def touch(path):\n fd = open(path, 'a')\n fd.close()",
"def touch_file(file_name):\n os.utime(file_name, None)",
"def _touch(path):\n open(path, \"w\").close()",
"def touch(path):\n if not os.pat... | [
"0.72858804",
"0.7187371",
"0.71445245",
"0.7061986",
"0.703371",
"0.7024376",
"0.6991309",
"0.6952427",
"0.6919515",
"0.6912042",
"0.6906273",
"0.69005775",
"0.6891966",
"0.6804933",
"0.6791455",
"0.6778573",
"0.6766807",
"0.672045",
"0.66853195",
"0.6679039",
"0.6630036",
... | 0.7773865 | 0 |
Calls chown_dir(fspath) or chown_file(fspath), depending on whether fspath is a directory or not. | def chown ( self, fspath ):
if os.path.isdir ( fspath ):
return self.chown_dir ( fspath )
else:
return self.chown_file ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chown_dir ( self, fspath ):\n return",
"def chown_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return self.chown_dir ( fspath )\n else:\n return self.chown_file ( fspath )",
"def chown_file ( self, fspath ):\n return",
"def chmod_chown ( self, fspath ):\n... | [
"0.8948717",
"0.84335893",
"0.84035283",
"0.770454",
"0.7691118",
"0.74401116",
"0.7235852",
"0.6874833",
"0.6546262",
"0.6537897",
"0.6497793",
"0.6452218",
"0.63476413",
"0.6302093",
"0.6228736",
"0.6176845",
"0.61583006",
"0.60229385",
"0.5985563",
"0.59134465",
"0.5885709... | 0.8772791 | 1 |
Similar to chown(fspath), but checks the given mode in order to decide whether fspath is a dir. | def chown_stat ( self, fspath, mode ):
if stat.S_ISDIR ( mode ):
return self.chown_dir ( fspath )
else:
return self.chown_file ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod_chown_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return (\n self.chmod_dir ( fspath ), self.chown_dir ( fspath )\n )\n else:\n return (\n self.chmod_file ( fspath ), self.chown_file ( fspath )\n )",
"def chmod_stat ( self, ... | [
"0.74052227",
"0.72158754",
"0.6905035",
"0.6810875",
"0.67720324",
"0.6705877",
"0.64470017",
"0.6443986",
"0.6299984",
"0.6216668",
"0.6183951",
"0.61443883",
"0.6120498",
"0.61022836",
"0.6096778",
"0.6015092",
"0.60054046",
"0.60038394",
"0.5932468",
"0.5914445",
"0.59057... | 0.807419 | 0 |
Changes the owner of a directory. | def chown_dir ( self, fspath ):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chown(self, path, owner=None, group=None):\n kwargs = {}\n if owner is not None:\n kwargs[\"owner\"] = owner\n if group is not None:\n kwargs[\"group\"] = group\n self._call(\"SETOWNER\", method=\"put\", path=path, **kwargs)",
"def chown_file(filename, file_o... | [
"0.7278033",
"0.62889427",
"0.61836296",
"0.6171118",
"0.60855687",
"0.6067038",
"0.60461086",
"0.6039696",
"0.60394585",
"0.60348403",
"0.60155183",
"0.59926784",
"0.59820396",
"0.5909075",
"0.5907682",
"0.5847199",
"0.5833868",
"0.58306533",
"0.57877916",
"0.5778257",
"0.56... | 0.6625209 | 1 |
Calls chmod_dir(fspath) or chmod_file(fspath), depending on whether fspath is a directory or not. | def chmod ( self, fspath ):
if os.path.isdir ( fspath ):
return self.chmod_dir ( fspath )
else:
return self.chmod_file ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod_dir ( self, fspath ):\n return",
"def chmod_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return self.chmod_dir ( fspath )\n else:\n return self.chmod_file ( fspath )",
"def chmod_chown_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n ... | [
"0.8261613",
"0.80634874",
"0.7444107",
"0.74340725",
"0.72950804",
"0.68876374",
"0.6578346",
"0.65769285",
"0.65414566",
"0.64435726",
"0.6389558",
"0.63817346",
"0.63671714",
"0.63211554",
"0.6107828",
"0.60001636",
"0.59810525",
"0.5977845",
"0.58882743",
"0.58740795",
"0... | 0.83173656 | 0 |
Similar to chmod(fspath), but checks the given mode in order to decide whether fspath is a dir. | def chmod_stat ( self, fspath, mode ):
if stat.S_ISDIR ( mode ):
return self.chmod_dir ( fspath )
else:
return self.chmod_file ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod_dir ( self, fspath ):\n return",
"def chmod_chown_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return (\n self.chmod_dir ( fspath ), self.chown_dir ( fspath )\n )\n else:\n return (\n self.chmod_file ( fspath ), self.chown_file ... | [
"0.69052184",
"0.6780001",
"0.6638909",
"0.6612683",
"0.65377444",
"0.6522304",
"0.6480368",
"0.6379503",
"0.63446534",
"0.627109",
"0.6259275",
"0.6235954",
"0.6234129",
"0.618081",
"0.6163878",
"0.6163878",
"0.6055755",
"0.5984406",
"0.5971258",
"0.5969658",
"0.595803",
"... | 0.7568901 | 0 |
Similar to chmod_chown(), but checks mode in order to decide whether fspath is a dir. | def chmod_chown_stat ( self, fspath, mode ):
if stat.S_ISDIR ( mode ):
return (
self.chmod_dir ( fspath ), self.chown_dir ( fspath )
)
else:
return (
self.chmod_file ( fspath ), self.chown_file ( fspath )
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chown_stat ( self, fspath, mode ):\n if stat.S_ISDIR ( mode ):\n return self.chown_dir ( fspath )\n else:\n return self.chown_file ( fspath )",
"def chmod_chown ( self, fspath ):\n if os.path.isdir ( fspath ):\n return (\n self.chmod_dir ( fspath ), self.chow... | [
"0.76696944",
"0.7318846",
"0.7116121",
"0.70041734",
"0.70023066",
"0.67857933",
"0.6681127",
"0.665088",
"0.65759367",
"0.6541759",
"0.6481282",
"0.6316214",
"0.6304739",
"0.62244767",
"0.60552204",
"0.60432374",
"0.597863",
"0.5969846",
"0.5941203",
"0.59405357",
"0.593930... | 0.76531845 | 1 |
Copies a file from source to dest. | def _copy_file ( self, source, dest ):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copyFile( src, dest ):\n\tinFile = open( src, 'r' )\n\toutFile = open( dest, 'w' )\n\tfor line in inFile:\n\t\toutFile.write( line )\n\toutFile.close()\n\tinFile.close()",
"def copyFile(srcPath, destPath):\n shutil.copy(srcPath, destPath)",
"def copy_file(src, dest):\n with open_local_or_gcs(src, '... | [
"0.8451881",
"0.8364238",
"0.83361626",
"0.82699907",
"0.8111486",
"0.79564",
"0.78758574",
"0.7702679",
"0.7702679",
"0.7702679",
"0.7593211",
"0.75324965",
"0.74742824",
"0.7454095",
"0.744795",
"0.73798084",
"0.73748046",
"0.73684984",
"0.7365559",
"0.73600304",
"0.735375"... | 0.84352726 | 1 |
Copies a file from source to dest and calls chmod(),chown() afterwards. | def copy_file ( self, source, dest, chown=True, chmod=True ):
if self._copy_file ( source, dest ):
if chmod:
self.chmod_file ( dest )
if chown:
self.chown_file ( dest )
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _copy_file ( self, source, dest ):\n return",
"def copyFileWithPermissions(source_path, dest_path, dist_dir):\n\n if os.path.islink(source_path) and not isWin32Windows():\n link_source_abs = os.path.abspath(source_path)\n link_target_abs = os.path.abspath(\n os.path.join(os.p... | [
"0.75960183",
"0.75810474",
"0.73564",
"0.7140633",
"0.70787334",
"0.7058556",
"0.70468634",
"0.70138454",
"0.69947135",
"0.69778115",
"0.69608563",
"0.695502",
"0.6950139",
"0.69486654",
"0.6940283",
"0.69282556",
"0.6926681",
"0.69047016",
"0.68762404",
"0.68417186",
"0.683... | 0.830945 | 0 |
Calls dodir(dir) for each dir in dirs. | def dodirs ( self, *dirs, **kwargs ):
for dirpath in dirs:
self.dodir ( dirpath, **kwargs ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dodir ( self, dirpath, mkdir_p ):\n return",
"def walk_dir(self, dir):\n if self.ppath_prefix_len:\n prefix = self.ppath_prefix[self.ppath_prefix_idx%self.ppath_prefix_len]\n self.ppath_prefix_idx += 1\n merged_path = os.path.join(prefix, dir)\n for root, dirs, files in self.fswa... | [
"0.67373455",
"0.6056506",
"0.5995078",
"0.5957818",
"0.59263694",
"0.5912053",
"0.5904246",
"0.5838539",
"0.5792521",
"0.57878745",
"0.57871544",
"0.57282823",
"0.5726129",
"0.5694284",
"0.56921166",
"0.5691485",
"0.5685755",
"0.56559676",
"0.56476575",
"0.5639799",
"0.56280... | 0.8401167 | 0 |
Removes fspath if it is an empty directory or a file (or link). | def wipe ( self, fspath ):
return self.rmdir ( fspath ) or self.unlink ( fspath ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_path(file_path):\n\n pass",
"def strip_path(fpath):\n if not fpath:\n return fpath\n try:\n file_path, file_name = os.path.split(fpath)\n except Exception:\n file_name = fpath\n return file_name",
"def _cleanup_path(path):\n return string.join(filter(None, string.... | [
"0.6562152",
"0.63822734",
"0.63800764",
"0.63273704",
"0.6302005",
"0.62554234",
"0.6191784",
"0.6151708",
"0.61012214",
"0.6026597",
"0.5998513",
"0.599304",
"0.59807295",
"0.59807295",
"0.59583515",
"0.59484076",
"0.5933473",
"0.58946943",
"0.5864218",
"0.5861272",
"0.5821... | 0.6647596 | 0 |
Recursively copies files from source_root to dest_root (while keeping its directory structure). Ownership and permissions are not preserved, instead copied files and created dirs will have to permissions set during initialization of this object. | def copy_tree ( self,
source_root, dest_root, overwrite=True, followlinks=False
):
dodir = self.dodir
copy_file = self.copy_file
if overwrite:
for source, dest, relpath, dirs, files, dirnames in walk_copy_tree (
source_root, dest_root, followlinks=followlinks
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __copyFiles(self):\n if os.path.isdir(self.__sourcePath):\n shutil.copytree(self.__sourcePath, self.__targetPath)\n else:\n shutil.copy2(self.__sourcePath, self.__targetPath)",
"def walk_copy_tree ( source, dest, subdir_root=False, **walk_kwargs ):\n source_path = os.pat... | [
"0.69874936",
"0.6962603",
"0.6929658",
"0.6741736",
"0.6719468",
"0.6689175",
"0.6660653",
"0.6599278",
"0.6598707",
"0.6578675",
"0.6560733",
"0.655713",
"0.65497947",
"0.65477866",
"0.65471786",
"0.65068245",
"0.648274",
"0.643485",
"0.63942957",
"0.63851553",
"0.63709056"... | 0.7179521 | 0 |
Creates symlinks to source_root's content in dest_root. | def copy_dirlink_tree ( self,
source_root, dest_root, overwrite=False, followlinks=False
):
unlink = self.unlink
symlink = self.symlink
source, dest, relpath, dirs, files, dirnames = next (
walk_copy_tree ( source_root, dest_root, followlinks=followlinks )
)
self.dodi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_filelink_tree ( self,\n source_root, dest_root, overwrite=False, followlinks=False\n ):\n dodir = self.dodir\n unlink = self.unlink\n symlink = self.symlink\n\n if overwrite:\n for source, dest, relpath, dirs, files, dirnames in (\n walk_copy_tree ( source_... | [
"0.68658274",
"0.65962565",
"0.6584691",
"0.65420985",
"0.65420985",
"0.6446246",
"0.6419486",
"0.63529956",
"0.633968",
"0.6323208",
"0.6282044",
"0.6085427",
"0.60373276",
"0.6013182",
"0.5988649",
"0.5983457",
"0.5963935",
"0.59410805",
"0.5917402",
"0.5914621",
"0.5870827... | 0.69057864 | 0 |
A trivial test of the StatsModelsWrapper | def test_stats_models_wrapper():
X = np.array([[1], [2], [3]])
y = np.array([1.1, 2, 3])
glm_gaussian = functools.partial(sm.GLM, family=sm.families.Gaussian())
sm_est = StatsModelsWrapper(glm_gaussian)
assert sm_est.fit(X, y) is sm_est, "fit did not return self"
assert sm_est.predict(X).shape... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testGetModelsData(self):\n models = models_logic._getModelsData()\n self.assertTrue(models)",
"def test_model():\n pass",
"def test_get_stats(self):\n pass",
"def test_model_info_basic():\n model = ModelInfo('test description', {'f1': 0.9},\n BaseLocation('protoc:/... | [
"0.6844442",
"0.6665745",
"0.6491076",
"0.6237574",
"0.6218416",
"0.6198978",
"0.6190901",
"0.6182809",
"0.6175669",
"0.61716205",
"0.6156747",
"0.6148331",
"0.6138285",
"0.61118513",
"0.6085253",
"0.60259545",
"0.6008298",
"0.59566724",
"0.593223",
"0.592766",
"0.59270495",
... | 0.78905725 | 0 |
Function that return the api key for the hypixel api. | def get_hypixel_key(self):
key = self.bot_data_file["apiKeys"]["hypixel"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE HYPIXEL KEY (get yours from https://api.hypixel.net/) - ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def api_key(self):\n # type () -> str\n return self._api_key",
"def api_key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"api_... | [
"0.7882624",
"0.7581468",
"0.7505369",
"0.7505369",
"0.7505369",
"0.7505369",
"0.74702185",
"0.7435706",
"0.74057823",
"0.7401957",
"0.73333293",
"0.73333293",
"0.7320179",
"0.7299802",
"0.72601944",
"0.7181773",
"0.7115222",
"0.711507",
"0.71141195",
"0.70895034",
"0.7085272... | 0.7944425 | 0 |
Function that return the api key for the gif api. | def get_gif_key(self):
key = self.bot_data_file["apiKeys"]["gif"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE GIF KEY (get yours from http://api.giphy.com/) - ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api_key(api_key):\n api.get(api_key)",
"def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def api_key(self):\n # type () -> str\n return self._api_key",
"def get_api_key ():\n P... | [
"0.7271017",
"0.7184897",
"0.70157254",
"0.69424164",
"0.6854634",
"0.6826018",
"0.6826018",
"0.6826018",
"0.6826018",
"0.67205614",
"0.67190504",
"0.67133266",
"0.6693411",
"0.6674918",
"0.6624762",
"0.6581685",
"0.65432197",
"0.6537641",
"0.65328526",
"0.65328526",
"0.65228... | 0.78639907 | 0 |
Function that return the default weather country to use | def get_weather_country(self):
return self.bot_data_file["weather"]["default_country"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country() -> str:",
"def get_default_country(self):\n proxy = self.env['ir.config_parameter']\n default_country = proxy.sudo().get_param('default_country')\n if not default_country:\n raise UserError('Please use Default Country as US in config parameters.')\n return def... | [
"0.7248471",
"0.72482795",
"0.72482795",
"0.7153096",
"0.7153096",
"0.6838989",
"0.6754464",
"0.6725625",
"0.66886955",
"0.6680285",
"0.6680285",
"0.6672574",
"0.6584849",
"0.6470137",
"0.64690846",
"0.6460345",
"0.6444273",
"0.6421123",
"0.6391796",
"0.6377553",
"0.6376989",... | 0.84455776 | 0 |
Function that return the default weather language for the results | def get_weather_language(self):
return self.bot_data_file["weather"]["default_language"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_locale():\n return \"he\"",
"def Language(self, default=None):\n return self.data.get('language', default)",
"def get_weather_country(self):\n return self.bot_data_file[\"weather\"][\"default_country\"]",
"def trans_weather(string):\r\n\treturn cn2en.WEATHER[string]",
"def get_... | [
"0.6565924",
"0.65229905",
"0.6455026",
"0.64302605",
"0.64252025",
"0.6408285",
"0.639051",
"0.6347569",
"0.6344524",
"0.632163",
"0.63124716",
"0.6244405",
"0.6179648",
"0.6177513",
"0.61695105",
"0.61636174",
"0.61391145",
"0.61023325",
"0.6052343",
"0.60194623",
"0.598831... | 0.8097329 | 0 |
Function that return the default rocket league platform to use | def get_rocket_league_platform(self):
return self.bot_data_file["rocketleague"]["default_platform"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_platform(self) -> Platform:\n _args: list[Arg] = []\n _ctx = self._select(\"defaultPlatform\", _args)\n return _ctx.execute_sync(Platform)",
"def platform(self):\n return self.random.choice([\n 'Laptop', \n 'Desktop', \n 'Workstation', \n ... | [
"0.6455419",
"0.6322307",
"0.62479967",
"0.6134072",
"0.60681105",
"0.6051301",
"0.5905534",
"0.5828498",
"0.5817532",
"0.5813724",
"0.57934755",
"0.5779312",
"0.5738541",
"0.57173306",
"0.5632414",
"0.5601634",
"0.5525579",
"0.5488002",
"0.54671514",
"0.54515594",
"0.5449795... | 0.7961892 | 0 |
Function that return the api key for the youtube api. | def get_youtube_api_key(self):
key = self.bot_data_file["youtube"]["key"]
if self.check_empty_key(key):
return key
else:
print(
"ERROR GETTING THE YOUTUBE KEY (check bot documentation) - ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_youtube_dev_key():\r\n return getenv('YOUTUBE_DEV_KEY')",
"def get_api_key(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'api_key')\r\n\r\n return http.Request('GET', url), parsers.parse_json",
"def api_key(self):\n return self.__creds.api_key_v2",
"def trello_api_key():\n... | [
"0.76500094",
"0.73951364",
"0.7117241",
"0.70795554",
"0.7049423",
"0.6914638",
"0.69049734",
"0.69049734",
"0.69049734",
"0.69049734",
"0.6876005",
"0.68502235",
"0.6762104",
"0.6762104",
"0.6760866",
"0.6752559",
"0.6700647",
"0.6627661",
"0.65667534",
"0.6539867",
"0.6539... | 0.83354473 | 0 |
Function that return the list of the youtube channels to check, with all the details about the notification | def get_list_youtube_channels_check(self):
return self.bot_data_file["youtube"]["channels"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_channels(youtube, channelId):\n channels_response = youtube.channels().list(\n id=AUTH_USER_CHANNEL_ID,\n part=\"contentDetails\"\n ).execute()\n \n return channels_response[\"items\"]",
"def get_channels():\n r = slack.channels.list().body\n return [ c for c in r['channels'] if c['is_mem... | [
"0.7082673",
"0.69445324",
"0.69291717",
"0.68211055",
"0.6791136",
"0.67022717",
"0.6548039",
"0.6489021",
"0.6430852",
"0.64190793",
"0.6402421",
"0.6395185",
"0.6382993",
"0.6259776",
"0.62419856",
"0.62130135",
"0.6212603",
"0.62044746",
"0.6181014",
"0.6158402",
"0.61281... | 0.82831806 | 0 |
Function that return the current version of the bot. | def get_version(self):
return self.bot_data_file["version"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version():\n click.echo(get_current_version_number())",
"async def version(self):\n # [p]version\n\n await self.bot.say(\"Current version: \" + CoreAPI.get_version())",
"def get_version():\n return about.get_version()",
"def version(self):\n return self.get_current_version(... | [
"0.77160335",
"0.75977933",
"0.7508295",
"0.7467047",
"0.74613523",
"0.74310684",
"0.7374588",
"0.7321967",
"0.72990876",
"0.7288763",
"0.72590643",
"0.72493654",
"0.7226841",
"0.72038954",
"0.7202787",
"0.71924376",
"0.7184682",
"0.71830183",
"0.71617293",
"0.7141195",
"0.71... | 0.8068609 | 0 |
Function that return the current build number of the bot. | def get_build(self):
return self.bot_data_file["build"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_number(self):\n return self.get_data(\"build_number\")",
"def get_build_number():\n try:\n return int(os.getenv(*legion.config.BUILD_NUMBER))\n except ValueError:\n raise Exception('Cannot parse build number as integer')",
"def getBuild(number):",
"def getBuild(number):",... | [
"0.7946986",
"0.7492893",
"0.7415122",
"0.7415122",
"0.74024177",
"0.71346706",
"0.7069816",
"0.7063874",
"0.6871903",
"0.68270797",
"0.67294055",
"0.6716901",
"0.6683429",
"0.6650736",
"0.66344464",
"0.657459",
"0.65717137",
"0.6549233",
"0.65007925",
"0.64656496",
"0.645879... | 0.7554891 | 1 |
Function that return the description of the bot. | def get_description(self):
return self.bot_data_file["description"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def description(ctx, bot: typing.Union[discord.Member, discord.User]):\n data = await make_request(\"https://www.motiondevelopment.top/api/v1.2/bots/\", bot.id)\n if not bot.bot:\n return await r(ctx, \"Not a bot.\")\n\n if len(data[\"Big_desc\"]) > 2000:\n desc = data[\"Big_desc\"][:2... | [
"0.8035858",
"0.7597421",
"0.7409643",
"0.7403121",
"0.7396752",
"0.7396752",
"0.73865396",
"0.7321154",
"0.72624",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0.7261715",
"0... | 0.82401824 | 0 |
Function that return the current bot icon. This icon is used for embed messages | def get_bot_icon(self):
return self.bot_data_file["bot_icon"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icon(self):\n return self._sensor[CONF_ICON]",
"def icon(self) -> str:\n return ICON_SERVER",
"def get_icon(self):\n return self.ICON",
"def icon(self):\n return self._config.get(CONF_ICON)",
"def get_icon(self) -> Dict[str, Any]:\n player = self._last_sessionplayer\n... | [
"0.7684818",
"0.7662258",
"0.7628439",
"0.75548655",
"0.75522",
"0.7551229",
"0.7547751",
"0.7547751",
"0.75120354",
"0.7508497",
"0.75049603",
"0.75049603",
"0.75049603",
"0.74850464",
"0.7462734",
"0.74546903",
"0.74382097",
"0.7438098",
"0.7424576",
"0.73911935",
"0.739108... | 0.87335 | 0 |
Function that return the current default status of the bot. | def get_default_status(self):
return self.bot_data_file["bot_status"]["defaultStatus"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Status(self, default=None):\n return self.data.get('status', default)",
"def defaultStatus(self):\n raise NotImplementedError",
"def getDefaultStatus(session_key):\n\n # Get the list of statuses\n logger.debug(\"Getting the default status\")\n statuses_list = entity.g... | [
"0.7572122",
"0.7343083",
"0.70287657",
"0.6921298",
"0.684734",
"0.67186576",
"0.666823",
"0.6652601",
"0.6652601",
"0.6652601",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.65798765",
"0.654335",
"0.65372... | 0.90379596 | 0 |
Function that return the current command prefix of the bot. | def get_command_prefix(self):
return self.bot_data_file["commands_prefix"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmdprefix(self) -> str:\n return self.config[\"Core\"].get(\"CmdPrefix\", \"!\")",
"async def get_command_prefix(self, guild: Guild) -> str:\n if (prefix := self._cache[guild.id].prefix) is None:\n db_guild = await self.find_by_id(guild.id)\n\n if db_guild is None:\n ... | [
"0.793544",
"0.7813612",
"0.74872243",
"0.72662723",
"0.7263468",
"0.7129918",
"0.6971227",
"0.6871771",
"0.6871771",
"0.6865197",
"0.6864055",
"0.67791307",
"0.67791307",
"0.67293286",
"0.6695514",
"0.66427916",
"0.66427916",
"0.66427916",
"0.6555726",
"0.65498084",
"0.65389... | 0.8556621 | 0 |
Function that return the bot source code link. | def get_open_source_link(self):
return self.bot_data_file["open_source_link"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _botsource(self, ctx):\r\n source_link = \"https://github.com/Simalary/SimsVIP.Servo\"\r\n await self.bot.say('{0.message.author.mention}, my source code is available at <{1}>.'.format(ctx, source_link))",
"async def source(self, context):\n await context.channel.send(\"https://git... | [
"0.7624818",
"0.6937835",
"0.6835078",
"0.6830835",
"0.68156576",
"0.678243",
"0.65339357",
"0.64714015",
"0.63910526",
"0.63313943",
"0.6330082",
"0.6192807",
"0.60986626",
"0.603519",
"0.5984332",
"0.5980589",
"0.59727496",
"0.5923028",
"0.5890302",
"0.5885634",
"0.5849865"... | 0.76383734 | 0 |
Function that return the bot private chat alert message | def get_private_chat_alert(self):
return self.bot_data_file["private_chat_alert"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMessage():\n return message",
"def do_something(incoming_msg):\n return \"i did what you said - {}\".format(incoming_msg.text)",
"async def chat_message(self, event):\n await self.send_json(\n return_value(\n ACTION_MESSAGE,\n event['label'],\n ... | [
"0.6508822",
"0.62238526",
"0.6108728",
"0.60552496",
"0.6001818",
"0.6000742",
"0.5984514",
"0.59744394",
"0.5974095",
"0.59739006",
"0.59720236",
"0.5966712",
"0.5966712",
"0.5936854",
"0.59354985",
"0.59330904",
"0.5886",
"0.5866715",
"0.5865388",
"0.5853917",
"0.58382535"... | 0.77665764 | 0 |
Function that return the max_cleverbot_requests. | def get_max_cleverbot_requests(self):
return int(self.bot_data_file["maxCleverbotRequests"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_count(self):\n return self.config.get('max_count', 500)",
"def limit_num_clients(self):\n return self._limit_num_clients",
"def get_max_readings( self ):\n return 2500",
"def maxclients(self) -> Optional[int]:\n return pulumi.get(self, \"maxclients\")",
"def max_findings... | [
"0.71495795",
"0.67273325",
"0.6720516",
"0.6696665",
"0.66402334",
"0.6631142",
"0.6547441",
"0.6515297",
"0.65100735",
"0.6495988",
"0.6492308",
"0.64291495",
"0.64208835",
"0.64208025",
"0.64189225",
"0.63931036",
"0.63668925",
"0.63549143",
"0.6311809",
"0.63114387",
"0.6... | 0.9331741 | 0 |
Function that return the url where to write the status. | def get_server_write_status_url(self):
write_url: str = self.bot_data_file["bot_status"]["server_state_saving"]["writeStateUrl"]
print("Api:" + self.empty_api_key)
print("Url:" + self.empty_url)
if self.get_bot_save_state_to_server() and write_url.startswith(self.empty_url):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return \"/status/%i/\" % self.id",
"def status_url(self, username, id):\n return urllib.parse.urljoin(self.instance, f'/p/{urllib.parse.quote(username)}/{id}')",
"def Url(self) -> str:",
"def url(self):\n if not os.path.exists(self.path):\n self.save(... | [
"0.72626585",
"0.6896938",
"0.6601351",
"0.63740164",
"0.6253406",
"0.61851",
"0.61851",
"0.6134751",
"0.6113722",
"0.6113722",
"0.6113722",
"0.6113722",
"0.6113722",
"0.6113722",
"0.6113722",
"0.60878825",
"0.6071305",
"0.6063158",
"0.6057401",
"0.6029894",
"0.60195893",
"... | 0.7271589 | 0 |
Function that return the url where to read the status. | def get_server_read_status_url(self):
read_url: str = self.bot_data_file["bot_status"]["server_state_saving"]["readStateUrl"]
if self.get_bot_save_state_to_server() and read_url.startswith(self.empty_url):
print(
"save_state_to_server IS TRUE BUT STATUS READ URL STARTS WITH '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return \"/status/%i/\" % self.id",
"def get_status_callback_url(self):\n return [obj for obj in self._request_uri(\"status_callback_url\")]",
"def url(self):\n _, body = self.request('/v1.1/url', 'GET')\n return body.get('url', None)",
"def url(self) ... | [
"0.75997925",
"0.7049809",
"0.7032578",
"0.6967554",
"0.6967554",
"0.6900867",
"0.6900867",
"0.6900867",
"0.6900867",
"0.6900867",
"0.6900867",
"0.6900867",
"0.6876656",
"0.6832015",
"0.6823533",
"0.68136656",
"0.6778891",
"0.6762563",
"0.6762563",
"0.67617697",
"0.67424023",... | 0.7110662 | 1 |
Function that return the username for the meme generator | def get_meme_generator_username(self):
key = self.bot_data_file["meme_generator"]["username"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE MEME USERNAME (register on https://api.imgflip.com/) - BOT ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username(self) -> str:",
"def username(self) -> str:",
"def generateUsername(self):\n retval= \"{0}.{1}\".format( self.first_name.split()[0].lower(),\n self.last_name.split()[-1].lower() )\n \n return toAscii(retval)",
"def g... | [
"0.7847496",
"0.7847496",
"0.7331012",
"0.72546655",
"0.723931",
"0.7221629",
"0.71840674",
"0.71298873",
"0.71025926",
"0.7083926",
"0.70373",
"0.70328695",
"0.70257235",
"0.7025711",
"0.69972277",
"0.69816643",
"0.6980639",
"0.69769245",
"0.6962517",
"0.692402",
"0.6922609"... | 0.8672658 | 0 |
Function that return the password for the meme generator | def get_meme_generator_password(self):
key = self.bot_data_file["meme_generator"]["password"]
if self.check_empty_key(key):
return key
else:
print("ERROR GETTING THE MEME PASSWORD (register on https://api.imgflip.com/) - BOT ABORTING")
quit(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def passwordGen() :\n\treturn __randomString(12)",
"def password(self) -> str:",
"def generate_pw(self):\n\n chunks = []\n for chunk_no in range(self.CHUNKS):\n if chunk_no < self.chunk:\n chunks.append(self.verified_chunks[chunk_no])\n elif chunk_no == self.c... | [
"0.818299",
"0.8023962",
"0.7555738",
"0.7500553",
"0.7393278",
"0.7303603",
"0.72950816",
"0.7247995",
"0.7243249",
"0.71949685",
"0.7173853",
"0.7160653",
"0.7150656",
"0.71400476",
"0.7137876",
"0.71269286",
"0.70900357",
"0.7080714",
"0.7054677",
"0.70473486",
"0.7043101"... | 0.82762927 | 0 |
Function that return the owner ID to send private messages | def get_owner_private_messages(self):
owner_id = self.bot_data_file["owners_data"]["ownerPrivateMessagesID"]
if owner_id == "":
print("ERROR GETTING THE OWNER ID - EMPTY")
return ""
else:
return owner_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner_id(self) -> int:\n return self.proto.owner",
"def owner_id(self) -> str:\n return pulumi.get(self, \"owner_id\")",
"def owner_id(self) -> str:\n return self.__owner_id",
"def send_owner_message(): \n data = order_obj.send_owner_message(request.forms)\n return data",
"de... | [
"0.71588725",
"0.7072653",
"0.6997864",
"0.6992629",
"0.6844016",
"0.6815332",
"0.67553514",
"0.64907527",
"0.6454328",
"0.6349432",
"0.63298124",
"0.63248587",
"0.63142663",
"0.629799",
"0.62715447",
"0.6219807",
"0.6200476",
"0.61841255",
"0.6167833",
"0.61574113",
"0.61382... | 0.81578904 | 0 |
Function that return all the owners of the bot that have master permissions | def get_owners_list(self):
final_list = []
for entry in self.bot_data_file["owners_data"]["owners_list"]:
final_list.append(str(entry["name"]))
if len(final_list) == 0:
print("ERROR GETTING THE OWNERS LIST (i need at least 1 owner) - BOT ABORTING")
quit(1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owners(self):\n return self.find_users_by_rel('owner')",
"def owners_only(command):\n @wraps(command)\n def wrapped_up(bot):\n if bot.message.nick not in conf.get('owners', []):\n return irc.Response('Sorry, you are not an owner thus not authorised to use this command', pm_user... | [
"0.67644495",
"0.6596586",
"0.65689915",
"0.65200084",
"0.6504249",
"0.6504249",
"0.6436979",
"0.6391575",
"0.6351989",
"0.6308154",
"0.6297625",
"0.6297625",
"0.6263222",
"0.6260391",
"0.6135052",
"0.61238444",
"0.60664177",
"0.6038699",
"0.5990057",
"0.59782493",
"0.5976417... | 0.6895028 | 0 |
Run the network with the first layer of nodes in state x | def run_network(self, x):
# We have the input vector x, this is the first layer in our nn
a = x
# So we need to run the neural network now. We are going to make
# things extra explicit by having the z term. Clearly super
# inefficient
for w, b in zip(self.weights, self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _forward(self, x):\n global global_epoch\n global_epoch += 1\n bias = -np.ones((x.shape[0], 1))\n tail = np.zeros((x.shape[0], self.dim_hid+self.dim_out))\n nodes = np.concatenate((bias, x, tail), axis=1)\n weight = self.weight * self.connectivity\n for i in ran... | [
"0.63821185",
"0.6350916",
"0.63436234",
"0.6343451",
"0.6338674",
"0.6298721",
"0.62605876",
"0.6254791",
"0.62174386",
"0.6208298",
"0.6149231",
"0.6126274",
"0.6119637",
"0.6065895",
"0.60484594",
"0.60425836",
"0.60365623",
"0.6015953",
"0.60128206",
"0.6008909",
"0.60061... | 0.7387201 | 0 |
Modify /etc/hosts and test if a log exists by running \'sudo journalctl f\' | def test_host_file_audit(host):
with host.sudo():
host.run("touch /etc/hosts")
audit_log = host.run("journalctl -u auditd --since \"10 seconds ago\" | grep \"/etc/hosts\"")
assert audit_log.stdout | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_hosts_file(self, resolution):\n self._execute_command('echo {0} >> /etc/hosts'.format(resolution),\n sudo=True)",
"def add_host_entry(ip, hostname, domain):\n host_line = ip+\" \"+hostname+\".\"+domain+\" \"+hostname\n\n # Only add entry if it does not exist ... | [
"0.64045393",
"0.630242",
"0.6119651",
"0.6042859",
"0.58638054",
"0.578382",
"0.57800317",
"0.55004096",
"0.54827553",
"0.5457473",
"0.54408246",
"0.54313713",
"0.5353777",
"0.5333098",
"0.53144336",
"0.53130835",
"0.5285852",
"0.5245373",
"0.5223455",
"0.5212901",
"0.521281... | 0.7312464 | 0 |
Modify /etc/sudoers and test if a log exists by running \'sudo journalctl f\' | def test_sudoers_audit(host):
with host.sudo():
sudoers_access = host.run("touch /etc/sudoers")
audit_log = host.run("journalctl -u auditd --since \"10 seconds ago\" | grep \"/etc/sudoers\"")
assert audit_log.stdout | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_sudo_mode():\n if not 'SUDO_UID' in os.environ.keys():\n print(\"Try running this program with sudo.\")\n exit()",
"def check_sudo(self, uid: str) -> None:\n stdout, stderr = self.syscall(os.popen(\"which sudo\").read().strip(), \"-nu\", uid, \"-S\", \"true\", \"/bin/bash\")\n ... | [
"0.64434725",
"0.625049",
"0.61129206",
"0.61046714",
"0.6042901",
"0.5995111",
"0.5981245",
"0.595383",
"0.595321",
"0.5922493",
"0.5753546",
"0.57430065",
"0.5703084",
"0.5694894",
"0.568475",
"0.5654135",
"0.564468",
"0.56377536",
"0.561018",
"0.5570623",
"0.5528348",
"0... | 0.7631633 | 0 |
s > hash code | def get_hash_code(s):
h = 0
n = len(s)
for i, c in enumerate(s):
h = h + ord(c) * 31 ** (n - 1 - i)
return StrUtil.convert_4_bytes(h) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hashcode(o):",
"def hash(self) -> str:\r\n ...",
"def elf_hash(s):\n h = 0\n for c in s:\n h = (h << 4) + ord(c)\n t = (h & 0xF0000000)\n if t != 0:\n h = h ^ (t >> 24)\n h = h & ~t\n return h",
"def hash(self) -> bytes:",
"def hash(x) -> int:\n p... | [
"0.7849163",
"0.76975936",
"0.74788135",
"0.74515873",
"0.7448918",
"0.74175584",
"0.73752755",
"0.736382",
"0.7322883",
"0.72037613",
"0.7167543",
"0.71318203",
"0.7103698",
"0.7055194",
"0.70461094",
"0.70433646",
"0.7012222",
"0.7006303",
"0.7006017",
"0.7004447",
"0.69899... | 0.82550454 | 0 |
get default channel list | def get_api_default_channel_list(self):
url = "http://api.applezhuan.com/api/c/get_default_channellist?&"
params = {
"android_id": self.mobile.android_id,
"platform": "2",
"av": "2",
"type": "1",
"time": self.get_current_time,
"ov":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def channels(self):\n if not self.is_loaded():\n return []\n else:\n return ipmi_channels()",
"def default_channel(self) -> int:\r\n ...",
"def _channels_list(self):\n result = self.slack.api_call(\"channels.list\")\n\n if not result.get(\"ok\"):\n ... | [
"0.69699097",
"0.685595",
"0.68018174",
"0.668857",
"0.65878475",
"0.65467113",
"0.6529256",
"0.6497529",
"0.64888537",
"0.63858175",
"0.63354135",
"0.6327543",
"0.63058734",
"0.62887496",
"0.62406474",
"0.6229618",
"0.62196255",
"0.6214428",
"0.6173595",
"0.6123503",
"0.6101... | 0.720246 | 0 |
accept the img captcha and request send sms captcha | def get_sms_captcha(self, img_ts, img_captcha):
url = "http://api.applezhuan.com/api/get_sms_captcha?&"
params = {
"img_captcha": img_captcha,
"time": self.get_current_time,
"ts": img_ts,
"device_code": self.device_code,
"mobile": self.mobile.m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def captcha(self):\n notification.send_sms(message=message)\n notification.send_emails(emails=email, message=message)\n sleep(25)\n\n ### this code snippet is for reference only, not to be used ###\n # sleep(3)\n # captcha = self.driver.find_element_by_xpath('/html/body/di... | [
"0.7563033",
"0.7049562",
"0.6603564",
"0.6600111",
"0.64076126",
"0.6371104",
"0.6334581",
"0.6282515",
"0.6243216",
"0.6157799",
"0.6151368",
"0.6085415",
"0.60629886",
"0.597998",
"0.5968537",
"0.58884144",
"0.5865535",
"0.5841705",
"0.5816367",
"0.57923406",
"0.576051",
... | 0.71202487 | 1 |
get content info by id | def get_content_by_id(self, content_id):
url = "http://api.applezhuan.com/api/m/get_content?content_id=%s" % content_id
headers = {
"Host": "api.applezhuan.com",
"Connection": "keep-alive",
"Accept": "application/json",
"Origin": "http://m.applezhuan.com",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_content_by_id_get(self, head, id, locale):\n # TODO: Assuming first server is good - need to make fallback logic\n return self.session.get_any(\"{base}{request_url}\".format(base=self.servers[0],\n request_url=F\"/Content/GetCont... | [
"0.7491383",
"0.7386878",
"0.7337057",
"0.70705456",
"0.70664924",
"0.6717087",
"0.6689234",
"0.66503906",
"0.65968055",
"0.65881276",
"0.6506912",
"0.6382121",
"0.63475037",
"0.6342468",
"0.6333151",
"0.6325207",
"0.6293055",
"0.629015",
"0.6267186",
"0.6173501",
"0.6167295"... | 0.746825 | 1 |
Padding s to 16bits. | def pad(s):
return s + (16 - len(s) % 16) * chr(16 - len(s) % 16) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad(s):\n\ttry:\n\t\tfrom Cryptodome.Cipher import AES\n\texcept ImportError:\n\t\tfrom Crypto.Cipher import AES\n\treturn s + b\"\\0\" * (AES.block_size - len(s) % AES.block_size)",
"def zeropad(s):\n\n npad = 16 - len(s) % 16\n return s + '\\x00' * npad",
"def pad16(data: bytes) -> bytes:\n\n ... | [
"0.69346625",
"0.6807775",
"0.6797431",
"0.6661236",
"0.6636684",
"0.6550715",
"0.6318116",
"0.62260115",
"0.59978324",
"0.59684944",
"0.58873004",
"0.5858596",
"0.58571833",
"0.58209276",
"0.57891655",
"0.577834",
"0.5753556",
"0.5745127",
"0.57439864",
"0.57319933",
"0.5698... | 0.75771606 | 0 |
generate lat and lon | def gen_lat_lon(self):
delta = round(random.random() * random.randint(1, 4), 4)
sign = random.randint(1, 100)
if sign % 2 == 0:
self.lat += delta
else:
self.lat -= delta
delta = round(random.random() * random.randint(1, 4), 4)
sign = random.randin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_gps_gen_from_range(s_lat,n_lat, e_lon, w_lon):\n #print(s_lat, n_lat, e_lon, w_lon)\n latitude = random.uniform(s_lat, n_lat)\n longitude = random.uniform(e_lon, w_lon)\n return latitude, longitude",
"def genLatLong(lat1, long1, lat2, long2):\n\tlat = lat1 + (lat2 - lat1) * random.random()... | [
"0.7581835",
"0.7333437",
"0.72476673",
"0.709161",
"0.70625556",
"0.69933414",
"0.69697577",
"0.69488233",
"0.6847795",
"0.6811374",
"0.6656267",
"0.66469145",
"0.6581302",
"0.6519071",
"0.6518511",
"0.6500831",
"0.64401203",
"0.64244574",
"0.64127237",
"0.6407213",
"0.63670... | 0.7594734 | 0 |
get a mobile info | def get_mobile_info(self):
# 1. select brand
self.select_brand()
# 2. select os
self.select_os()
# 3. device_id
self.gen_device_id()
# 4. lat lon
self.gen_lat_lon()
# 5. mac
self.gen_mac() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile(self) -> Optional[str]:\n return pulumi.get(self, \"mobile\")",
"def phone_mobile(self, instance):\r\n return instance.user.profile.phone_mobile",
"def mobile_phone(self):\n if \"mobilePhone\" in self._prop_dict:\n return self._prop_dict[\"mobilePhone\"]\n else... | [
"0.6920831",
"0.65805537",
"0.640192",
"0.640192",
"0.63525945",
"0.62655234",
"0.62214077",
"0.6203879",
"0.6175521",
"0.6166035",
"0.6148727",
"0.61350715",
"0.58731014",
"0.5816996",
"0.5743894",
"0.57154775",
"0.56877965",
"0.56614953",
"0.56607634",
"0.56430876",
"0.5625... | 0.8020666 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.