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 |
|---|---|---|---|---|---|---|
When kwargs['flat_fields'] = True, the expected fields are put back into remaining_fields. | def test_prep_country_fields_flat(self):
original_flag = self.form.country_optional
self.form.country_optional = True
original_fields = self.form.fields
original_removed = getattr(self.form, 'removed_fields', None)
original_computed = getattr(self.form, 'computed_fields', None)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_dehydrate(self, bundle, for_list=False):\n\n # call the base class if qs param `fields` is not set\n try:\n if not len(self.specified_fields):\n self.specified_fields = []\n return super(SpecifiedFields, self).full_dehydrate( \\\n ... | [
"0.6243996",
"0.62252426",
"0.6159768",
"0.6112266",
"0.5876747",
"0.58750236",
"0.5867535",
"0.58615494",
"0.5753491",
"0.57264113",
"0.5716666",
"0.5704671",
"0.560665",
"0.56063133",
"0.555894",
"0.5558664",
"0.5553255",
"0.5545755",
"0.55451787",
"0.5522963",
"0.55055803"... | 0.68460476 | 0 |
If submitted form requested foreign display, but was showing local, set_alt_data is called as expected. | def test_on_post_display_local_to_foreign(self):
# data.get('country_flag', None)
# address_display_version = 'foreign' if country_flag else 'local'
# form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_on_post_display_foreign_to_local(self):\n # data.get('country_flag', None)\n # address_display_version = 'foreign' if country_flag else 'local'\n # form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)\n pass",
"def tes... | [
"0.77660143",
"0.74513006",
"0.5475795",
"0.5383431",
"0.5315087",
"0.52522415",
"0.52522415",
"0.52449316",
"0.5115948",
"0.5079759",
"0.5019265",
"0.4988016",
"0.49873954",
"0.4916853",
"0.4899723",
"0.48932767",
"0.4892237",
"0.48896125",
"0.4884321",
"0.48838308",
"0.4883... | 0.7731352 | 1 |
If submitted form requested foreign display, and was showing foreign, shows correctly. | def test_on_post_display_foreign_to_foreign(self):
# data.get('country_flag', None)
# address_display_version = 'foreign' if country_flag else 'local'
# form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_on_post_display_foreign_to_local(self):\n # data.get('country_flag', None)\n # address_display_version = 'foreign' if country_flag else 'local'\n # form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)\n pass",
"def tes... | [
"0.7168204",
"0.7138766",
"0.57188034",
"0.55657893",
"0.54062665",
"0.5394192",
"0.526207",
"0.52578133",
"0.52548194",
"0.5253556",
"0.5211166",
"0.5211166",
"0.5211166",
"0.52019155",
"0.5168009",
"0.51628506",
"0.5142888",
"0.5126371",
"0.5120038",
"0.51047885",
"0.508608... | 0.7608519 | 0 |
If submitted form requested local display, but was showing foreign, set_alt_data corrects to local. | def test_on_post_display_foreign_to_local(self):
# data.get('country_flag', None)
# address_display_version = 'foreign' if country_flag else 'local'
# form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_on_post_display_local_to_foreign(self):\n # data.get('country_flag', None)\n # address_display_version = 'foreign' if country_flag else 'local'\n # form.set_alt_data(name='country_display', field=self.fields['country_display'], value=address_display_version)\n pass",
"def tes... | [
"0.79282147",
"0.76382875",
"0.5292249",
"0.5248025",
"0.52416384",
"0.5228665",
"0.52174956",
"0.51686186",
"0.51686186",
"0.5072312",
"0.5057547",
"0.50152373",
"0.49532503",
"0.49409863",
"0.49361557",
"0.49005464",
"0.48473862",
"0.47833675",
"0.47592726",
"0.47376817",
"... | 0.80248636 | 0 |
get_critical_field called if form.country_optional, country_field, and needed_names. | def test_init_get_critical_for_needed(self):
# needed_names = [nf for nf in ('country_display', 'country_flag') if nf not in self.form.base_fields]
# for name in needed_names: name, field = self.get_critical_field(name, name)
# original_get_critical_field = self.form.get_critical_field
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_critical_from_existing_fields(self):\n name = 'generic_field'\n opts = {'names': (name, ), 'alt_field': '', 'computed': False}\n expected_field = self.form.fields.get(name, None)\n actual_name, actual_field = self.form.get_critical_field(opts['names'])\n self.assertE... | [
"0.7488688",
"0.6860929",
"0.64093065",
"0.62498826",
"0.59814197",
"0.5829226",
"0.56075716",
"0.54849654",
"0.54585516",
"0.54107404",
"0.54096913",
"0.54086405",
"0.5377918",
"0.5366352",
"0.51903194",
"0.5174083",
"0.5126931",
"0.5125253",
"0.51179713",
"0.5104857",
"0.51... | 0.7308993 | 1 |
The clean_country_flag method will look for country field in computed_fields if not in fields. | def test_clean_uses_computed(self):
original_request = self.request
original_form = self.form
original_cleaned = getattr(self.form, 'cleaned_data', None)
self.form = self.make_form_request()
name = self.form.country_field_name
initial = self.form.base_fields[name].initial... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_country_flag(self):\n # country_flag = self.cleaned_data.get('country_flag', None)\n # field = self.fields.get(self.country_field_name, None)\n # if not field and hasattr(self, 'computed_fields'):\n # field = self.computed_fields.get(self.country_field_name, None)\n ... | [
"0.7905743",
"0.65489554",
"0.634155",
"0.6327185",
"0.63062096",
"0.61223215",
"0.57785374",
"0.57144135",
"0.5432035",
"0.53450346",
"0.5309917",
"0.52375585",
"0.5214699",
"0.52075917",
"0.519703",
"0.5196857",
"0.5196554",
"0.51909405",
"0.5186007",
"0.51769084",
"0.51723... | 0.66551816 | 1 |
Also set `AVSC_JAR` environment variable appropriately. | def build_avsc_jar():
jar_path = osp.join(DPATH, 'deps', 'avro', 'target', 'avsc.jar')
if not osp.exists(jar_path):
_logger.info('building avsc jar')
pom_path = osp.join(DPATH, 'deps', 'avro', 'pom.xml')
code = call(['mvn', '-f', pom_path, 'clean', 'compile', 'assembly:single'])
if code:
_logg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(ctx):\n mxmlc = ctx.options.mxmlc\n\n if not mxmlc:\n mxmlc = ctx.find_program('mxmlc')\n\n ctx.env.MXMLC = os.path.abspath(os.path.expanduser(mxmlc))\n\n ctx.env.JAVA = ctx.find_program('java')\n\n if not ctx.env.SIKULI_HOME:\n ctx.env.SIKULI_HOME = get_sikuli_home(ctx)\... | [
"0.5061263",
"0.49802852",
"0.4814673",
"0.47707972",
"0.47029126",
"0.46798176",
"0.46687746",
"0.46055582",
"0.45604882",
"0.4547775",
"0.45412117",
"0.45352414",
"0.45286763",
"0.4524826",
"0.4498402",
"0.4491043",
"0.44897157",
"0.44726545",
"0.44317535",
"0.4423739",
"0.... | 0.7205339 | 0 |
Add a cell to this cell group. | def add(self, cell):
self.cells.add(cell)
cell.add_group(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_cell(self, cell: Cell):\n\n self.cells.append(cell)",
"def add_cell(self, cell: Cell):\r\n assert isinstance(cell, Cell)\r\n self.bucket_array.add_to_free_cell_list(cell)\r\n self.cells.append(cell)\r\n cell.block = self\r\n self.size += 1",
"def add_cell(self,... | [
"0.8155925",
"0.7513701",
"0.72820836",
"0.71640146",
"0.7104436",
"0.70445544",
"0.7016003",
"0.70067173",
"0.6841812",
"0.673482",
"0.6638499",
"0.65292174",
"0.64524055",
"0.64106095",
"0.6381007",
"0.6374173",
"0.6130089",
"0.6118597",
"0.6066999",
"0.60550976",
"0.601967... | 0.87547165 | 0 |
Create a mapping from ``frozenset``s of possible symbols to a lists of cells, that these are their possible symbols. | def create_possible_symbols_to_cells_mapping(self):
possibles_to_cells = defaultdict(set)
for cell in self.iterate_empty_cells():
possibles_to_cells[frozenset(cell.get_possible_symbols())].add(cell)
return possibles_to_cells | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_symbol_to_possible_cell_mapping(self):\r\n symbols_to_cells = defaultdict(set)\r\n for cell in self.iterate_empty_cells():\r\n for symbol in cell.get_possible_symbols():\r\n symbols_to_cells[symbol].add(cell)\r\n return symbols_to_cells",
"def create_cell... | [
"0.8228644",
"0.6247691",
"0.5996187",
"0.59912086",
"0.57363427",
"0.56508225",
"0.5617025",
"0.5577898",
"0.55488765",
"0.5521399",
"0.55198526",
"0.55198526",
"0.5480722",
"0.54555774",
"0.542111",
"0.5322558",
"0.5308515",
"0.5259221",
"0.5250977",
"0.52377856",
"0.520489... | 0.8634398 | 0 |
Create a mapping from symbols to a list of cells, in which this symbol is a possible assignment. | def create_symbol_to_possible_cell_mapping(self):
symbols_to_cells = defaultdict(set)
for cell in self.iterate_empty_cells():
for symbol in cell.get_possible_symbols():
symbols_to_cells[symbol].add(cell)
return symbols_to_cells | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_possible_symbols_to_cells_mapping(self):\r\n possibles_to_cells = defaultdict(set)\r\n for cell in self.iterate_empty_cells():\r\n possibles_to_cells[frozenset(cell.get_possible_symbols())].add(cell)\r\n return possibles_to_cells",
"def _create_symbol_mapping():\n nor... | [
"0.79313326",
"0.62948644",
"0.6092999",
"0.59227717",
"0.56628823",
"0.56573343",
"0.5636128",
"0.5633549",
"0.5541741",
"0.5522341",
"0.5443451",
"0.537345",
"0.53710127",
"0.5341381",
"0.5305604",
"0.5301605",
"0.526607",
"0.5264708",
"0.5264708",
"0.5264708",
"0.5242213",... | 0.8147504 | 0 |
Remove this group from other groups, when this group is a subgroup of another group. | def remove_as_subgroup(self, other_groups):
symbols_to_exclude = reduce(lambda alphabet, cell: alphabet.union(cell.get_possible_symbols()),
self.cells, set())
my_cells = set(self.cells)
for group in other_groups:
if my_cells.issubset(group.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_group(self, group):\n\n if self.in_group(group):\n self.secondary_groups.remove(group)\n return self",
"def test_remove_self_as_parent(self):\n groupa, groupb = Group('groupa'), Group('groupb')\n groupa.add_parent(groupb)\n groupb.del_... | [
"0.7457541",
"0.6660896",
"0.66377795",
"0.66275835",
"0.64256984",
"0.63906753",
"0.6237391",
"0.62194926",
"0.6219388",
"0.62129915",
"0.6203625",
"0.61968744",
"0.6175795",
"0.616916",
"0.6147823",
"0.59947467",
"0.59588474",
"0.5858979",
"0.58396405",
"0.5839059",
"0.5835... | 0.7494452 | 0 |
Remove cells that have an assigned symbol from this group. | def remove_assigned_cells(self):
cells = list(self.cells)
for cell in ifilter(lambda cell: cell.symbol is not None, cells):
cell.remove_group(self)
self.cells.remove(cell)
return len(cells) != len(self.cells) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_symbol(self, symbol):\r\n if symbol not in self._taken_symbols:\r\n for cell in self.cells:\r\n cell.remove_possible_symbol(symbol)\r\n self._taken_symbols.add(symbol)",
"def unsetSymbol(self):\n return _libsbml.InitialAssignment_unsetSymbol(self)",
"... | [
"0.6538775",
"0.5958141",
"0.5792549",
"0.57550293",
"0.5732101",
"0.56934553",
"0.56710565",
"0.5628901",
"0.5613413",
"0.55985063",
"0.5562257",
"0.5482202",
"0.5455962",
"0.5439964",
"0.54102564",
"0.5367527",
"0.53613144",
"0.53547674",
"0.530147",
"0.5270734",
"0.5245552... | 0.80309904 | 0 |
Create Column Headers for Various Modes | def make_header(mode):
return ("{}\n".format('\t'.join(
['#chrom', 'coord', 'total', 'dtotal'] +
DIVNAMES[mode] +
['{}_{}'.format(x, y)
for x in STATNAMES[mode]
for y in ('left', 'right', 'total',
'stat', 'chisq', 'Pvalue')] +
['introgression'] +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generateColumnHeader(self, obj, **args):\n result = []\n header = self._script.utilities.columnHeaderForCell(obj)\n if not header:\n return result\n\n text = self._script.utilities.displayedText(header)\n if not text:\n return result\n\n roleStri... | [
"0.7301636",
"0.68024063",
"0.66927755",
"0.6617009",
"0.6617009",
"0.6566764",
"0.6508237",
"0.649484",
"0.6321167",
"0.63026154",
"0.6261138",
"0.62600505",
"0.62569094",
"0.61962223",
"0.6120518",
"0.60768306",
"0.6066733",
"0.6040872",
"0.6030909",
"0.6017008",
"0.6016963... | 0.73253417 | 0 |
Returns a file name containing the log physical use a physical file or not a pointer to a log file str OSError if this file cannot be created | def GetLogFile (physical = False) :
if sys.hal_log_values ["__log_file"] is None :
if physical :
path = GetPath ()
if sys.hal_log_values ["__log_file_name"] is None :
if os.path.exists (path) : sys.hal_log_values ["__log_file_name"] = os.path.join (path, sys.hal_log_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tempfile_name():\n ret = os.path.join(tempfile.gettempdir(), 'system_monitor.log')\n if os.access(ret, os.F_OK) and not os.access(ret, os.W_OK):\n print(\"WARNING: Couldn't write to log file {0}: (Permission denied)\".format(ret))\n ret = tempfile.mkstemp(prefix='system_monitor', suffix='.t... | [
"0.65035456",
"0.6242941",
"0.6138833",
"0.6034926",
"0.5939936",
"0.58189434",
"0.58029103",
"0.57990223",
"0.5787745",
"0.5775017",
"0.57370406",
"0.5699442",
"0.5673442",
"0.56574756",
"0.5648243",
"0.5603709",
"0.5595422",
"0.5588167",
"0.5581843",
"0.5575622",
"0.5570398... | 0.7608302 | 0 |
Builds a message on a single line with the date, it deals with encoding issues. l list of fields p dictionary of fields if p contains OutputPrint, call Print (OutputPrint), if p contains LogPath, it calls init (v) if p contains LogFile, it changes the log file name (it creates a new one, the previous is closed). if p c... | def fLOG (*l, **p) :
path_add = p.get ("LogPathAdd", [] )
lock = p.get("Lock", None)
if lock is not None : sys.hal_log_values["Lock"] = lock
if "LogFile" in p and "LogPath" in p : init (p ["LogPath"], p ["LogFile"])
elif "LogFile" in p : init (filename = p ["LogFile"], path_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_log_entry(\n hostname: str, user: str, date: dt.datetime, wdir: Path, cmd: str\n) -> str:\n return (\n f'[{date.strftime(\"%Y-%m-%d %H:%M:%S\")}] ({user}@{hostname}) '\n f\"{wdir}\\n\\t{cmd}\\n\"\n )",
"def Create_log():\r\n \"\"\"And Maintain log file to the current date in M... | [
"0.5940724",
"0.5826949",
"0.57114995",
"0.5540157",
"0.54971814",
"0.5481836",
"0.54646546",
"0.54116577",
"0.5368127",
"0.5306057",
"0.52894217",
"0.52886254",
"0.5274615",
"0.52668566",
"0.52148986",
"0.52125263",
"0.51963454",
"0.5185633",
"0.5158358",
"0.51370734",
"0.51... | 0.6367271 | 0 |
return the relative path between a folder and a file folder folder file file relative path str | def get_relative_path (folder, file) :
if not os.path.exists (folder) : raise PQHException (folder + " does not exist.")
if not os.path.exists (file) : raise PQHException (file + " does not exist.")
sd = folder.replace("\\","/").split("/")
sf = file.replace("\\","/").split("/")
for i in range (0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_path(cls, file_name, folder_name):\n return cls.file_path.parent / folder_name / file_name",
"def get_relative_path(self, file_path):\n file_path = os.path.abspath(file_path)\n if self.base_dir is not None:\n file_path = file_path.replace(os.path.abspath(self.base_dir... | [
"0.79193115",
"0.7430679",
"0.72578657",
"0.7221772",
"0.7174331",
"0.69166344",
"0.6843943",
"0.68290794",
"0.6818401",
"0.6815434",
"0.68043053",
"0.67901987",
"0.6769839",
"0.6764841",
"0.6727673",
"0.6724213",
"0.6714352",
"0.6676587",
"0.66659003",
"0.66582036",
"0.66348... | 0.8269769 | 0 |
Download a file to the folder path_unzip if not present, if the downloading is interrupted, the next time, it will start from where it stopped. Before downloading, the function creates a temporary file, which means the downloading has began. If the connection is lost, an exception is raised and the program stopped. Nex... | def download (httpfile, path_unzip = None, outfile = None) :
if path_unzip is None : path_unzip = GetPath ()
file = _check_source (httpfile, path_unzip = path_unzip, outfile = outfile)
return file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getzip(url, zipfile, unzipdir):\n done_file = os.path.join(unzipdir, '.'+os.path.basename(zipfile)+'.done')\n if file_exists(done_file):\n print('{} already downloaded and extracted; skipping. To reinstall \"rm {}\"'.format(os.path.basename(zipfile), done_file))\n else:\n print('Download... | [
"0.7106732",
"0.7035156",
"0.67302674",
"0.66116464",
"0.65801996",
"0.65664876",
"0.6558638",
"0.65487367",
"0.6536646",
"0.6485532",
"0.642969",
"0.6391242",
"0.63488287",
"0.63421416",
"0.62707514",
"0.62670064",
"0.6254896",
"0.6252065",
"0.6247422",
"0.6233285",
"0.62292... | 0.8036328 | 0 |
unzip a file into the temporary folder file (str) zip files path_unzip (str) where to unzip the file, if None, choose GetPath () outfile (str) if None, the function will assign a filename unless this parameter is specified expanded file name | def unzip (file, path_unzip = None, outfile = None) :
if path_unzip is None : path_unzip = GetPath ()
fLOG ("unzip file", file)
file = _check_source (file, path_unzip = path_unzip, outfile = outfile)
nb = 0
while not os.path.exists (file) and nb < 10 :
time.sleep(0.5)
nb += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unzip_file(data_zip, path_unzip):\r\n with zipfile.ZipFile(data_zip, \"r\") as zip_temp:\r\n zip_temp.extractall(path_unzip)",
"def _unzip_file(zip_file_path: str, unzip_dir: str = \"\") -> None:\n if not unzip_dir:\n unzip_dir = os.path.dirname(zip_file_path)\n op_desc = f\"Extracting... | [
"0.7139041",
"0.70639694",
"0.70058393",
"0.6817799",
"0.6761051",
"0.6689558",
"0.6671697",
"0.6654961",
"0.65346366",
"0.64469576",
"0.64213866",
"0.64149886",
"0.6412602",
"0.6362819",
"0.62293935",
"0.6175127",
"0.61503965",
"0.61491144",
"0.61399084",
"0.6136558",
"0.612... | 0.7314113 | 0 |
this function tests if a file is a zip file (extension zip), if it is the case, it unzips it into another file and return the new name, if the unzipped file already exists, the file is not unzipped a second time filename any filename (.zip or not), if txt, it has no effect path_unzip if None, unzip it where it stands, ... | def _check_zip_file (filename, path_unzip, outfile) :
assert path_unzip is not None
file,ext = os.path.splitext (filename)
ext = ext.lower ()
if ext == ".gz" :
import gzip
if outfile is None :
dest = filename.split ("!")
dest = dest [ len(de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unzip_file(zip_file: str) -> None:\n destination = tempfile.mkdtemp(prefix='gaelo_pross_unzip_')\n with ZipFile(zip_file) as my_zip:\n for member in my_zip.namelist():\n filename = os.path.basename(member)\n # skip directories\n if not filen... | [
"0.670198",
"0.6678802",
"0.65714586",
"0.64862216",
"0.6424468",
"0.63759226",
"0.63185555",
"0.6291177",
"0.6253069",
"0.61296326",
"0.60893184",
"0.5970322",
"0.5967116",
"0.59316283",
"0.59183365",
"0.59079635",
"0.5901411",
"0.5886114",
"0.5879796",
"0.5841547",
"0.58181... | 0.7003948 | 0 |
checks if the first file (opened url) is more recent of the second file (path) f1 opened url path path name boolean | def _first_more_recent (f1, path) :
import datetime
import re
import time
s = str (f1.info ())
da = re.compile ("Last[-]Modified: (.+) GMT").search (s)
if da is None :
return True
da = da.groups () [0]
gr = re.compile ("[\w, ]* ([ \d]{2}) ([\w]{3}) ([\d]{4}) ([\d]{2}):([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_newer(filename1, filename2):\n return os.stat(filename1).st_mtime > os.stat(filename2).st_mtime",
"def IsFileNewer(name1, name2):\n\n\tif not os.path.exists(name1):\n\t\treturn 0\n\n\tif not os.path.exists(name2):\n\t\treturn 1\n\n\tmod_time1 = os.stat(name1)[stat.ST_MTIME]\n\tmod_time2 = os.stat(name2... | [
"0.7023369",
"0.67877334",
"0.66630054",
"0.66364807",
"0.6428826",
"0.63028544",
"0.62502795",
"0.6238821",
"0.6196319",
"0.61771303",
"0.617126",
"0.6169872",
"0.6125706",
"0.61131996",
"0.609536",
"0.6085871",
"0.6009534",
"0.5816924",
"0.5813216",
"0.5807121",
"0.58070153... | 0.6840222 | 1 |
return the interpreter path | def get_interpreter_path () :
if sys.platform.startswith("win") : return sys.executable.replace ("pythonw.exe", "python.exe")
else : return sys.executable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_python_path():\n\n return get_executable_path('python')",
"def executable_path(self):\n prepend = self._active_environment(ActiveEnvironment).prepend\n return prepend.get(\"PATH\", \"\")",
"def get_path(self):\r\n path = [\"/bin\", \"/usr/bin\", \"/usr/local/bin\"]\r\n if... | [
"0.7354625",
"0.72487605",
"0.70609933",
"0.70519686",
"0.69643044",
"0.69575727",
"0.6889702",
"0.68254983",
"0.68254983",
"0.67586106",
"0.67049986",
"0.6704595",
"0.66673666",
"0.6665867",
"0.66172516",
"0.66151",
"0.66151",
"0.655819",
"0.65428525",
"0.65145975",
"0.64984... | 0.7817029 | 0 |
splits a command line cmd command line remove_quotes True by default list | def split_cmp_command(cmd, remove_quotes = True) :
if isinstance (cmd, str) :
spl = cmd.split()
res = []
for s in spl :
if len(res) == 0 :
res.append(s)
elif res[-1].startswith('"') and not res[-1].endswith('"') :
res[-1] += " " + s
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_and_honor_quotation_marks(cmdline):\n\n # See\n # http://msdn.microsoft.com/library/en-us/vccelng/htm/progs_12.asp\n\n # Step 1: Translate all literal quotes into QUOTE. Justify number\n # of backspaces before quotes.\n tokens = []\n bs_buf = \"\"\n QUOTE = 1 # \\\", literal quote\n... | [
"0.7222235",
"0.68670875",
"0.68347687",
"0.68330204",
"0.6794882",
"0.66859853",
"0.6655126",
"0.66494465",
"0.66008824",
"0.6600495",
"0.6596832",
"0.6523082",
"0.64387125",
"0.625679",
"0.62543994",
"0.62076086",
"0.6084892",
"0.60701495",
"0.60104656",
"0.6010308",
"0.600... | 0.7064252 | 1 |
decode the output or the error after running a command line instructions outerr output or error encoding encoding encerror how to handle errors msg part of the error to add message converted string | def decode_outerr(outerr, encoding, encerror, msg):
if not isinstance(outerr,bytes):
raise TypeError("only able to decode bytes, not " + str(type(outerr)))
try :
out = outerr.decode(encoding, errors=encerror)
return out
except UnicodeDecodeError as exu :
try :
out... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_to_text(ex):\n\tif isinstance(ex, FailedProcessError) and ex.args[0] == 'youtube-dl' and ex.exitcode == 1:\n\t\treturn 'Download error: {}'.format(ex.stderr)\n\treturn \"Internal error {}: {}\".format(type(ex).__name__, ex)",
"def handle_error(e, error_response_str):\n error_output = e.decode(encodi... | [
"0.64598864",
"0.62169755",
"0.6093039",
"0.6090095",
"0.6007613",
"0.5802997",
"0.5792216",
"0.57130677",
"0.5682947",
"0.5641948",
"0.5634072",
"0.56156194",
"0.55839014",
"0.5551853",
"0.5543839",
"0.55256593",
"0.5465533",
"0.5462396",
"0.545408",
"0.5436861",
"0.54050845... | 0.75364584 | 0 |
run a script script script to execute l other parameters | def run_script (script, *l) :
if not os.path.exists (script) :
raise PQHException ("file %s not found" % script)
py = get_interpreter_path ()
cmd = "%s %s" % (py, script)
if len (l) > 0 :
cmd += " " + " ".join ( [str (x) for x in l])
out,err = run_cmd (cmd)
return out,err | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_script(self, params, config_no):\n raise NotImplementedError()",
"def runScript(self, script):\n c = self\n game = self.game\n app = self.game.app\n shell = self.shell\n sprite = self.sprite\n s = shell\n self = self.env\n exec(open(\"script/... | [
"0.70747274",
"0.6891864",
"0.67501086",
"0.6722625",
"0.6709817",
"0.6659978",
"0.6600384",
"0.6596219",
"0.6582011",
"0.6568014",
"0.65097755",
"0.6352416",
"0.63355607",
"0.6309203",
"0.62741786",
"0.62620753",
"0.6250904",
"0.6215831",
"0.61932105",
"0.6190089",
"0.615302... | 0.83252746 | 0 |
return a prefix for a file based on time | def get_prefix () :
t = datetime.datetime (2010,1,1).now ()
t = str(t).replace (":", "_").replace ("/", "_").replace (" ", "_")
t += "_" + str (random.randint (0,1000)) + "_"
return os.path.join (GetPath (), "temp_" + t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix_from_filename(input_file):\n prefix = \"\"\n \n if str(input_file).find(\"medication_bner_\") != -1:\n prefix = \"drugbank\"\n elif str(input_file).find(\"_bc5cdr\") != -1:\n prefix = \"bc5cdr\"\n elif str(input_file).find(\"_bionlp13cg\") != -1:\n prefix = \"bionlp13... | [
"0.6537689",
"0.6446945",
"0.634372",
"0.62493694",
"0.6221671",
"0.6185408",
"0.61169964",
"0.60952646",
"0.60952646",
"0.60697746",
"0.60191506",
"0.5899234",
"0.587953",
"0.5868552",
"0.58580756",
"0.5856218",
"0.57993394",
"0.5782173",
"0.5760891",
"0.5745738",
"0.5724817... | 0.7512885 | 0 |
remove all files and folder in folder folder folder silent silent mode or not list of not remove files or folders | def removedirs (folder, silent = False) :
file, rep = [], []
for r, d, f in os.walk (folder) :
for a in d :
rep.append (os.path.join (r, a))
for a in f :
file.append (os.path.join (r, a))
impos = []
file.sort ()
rep.sort (reverse = True)
for f in file :
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_all_folder():\n LOGGER.warning('removal of old files has been temporarily disabled')\n # paths_to_clean = CFG.remove_files\n # if paths_to_clean: # pylint: disable=using-constant-test\n # for remove_config in paths_to_clean: # pylint: disable=not-an-iterable\n # name = tuple(... | [
"0.68569785",
"0.6794698",
"0.6593606",
"0.64101917",
"0.6376012",
"0.630781",
"0.6273378",
"0.6262631",
"0.6248296",
"0.62475854",
"0.6217406",
"0.61763805",
"0.6172198",
"0.61609787",
"0.6159008",
"0.615758",
"0.6146862",
"0.6136629",
"0.6123533",
"0.6111762",
"0.6106777",
... | 0.68708473 | 0 |
guess the type of a value x type none if True and all values are empty, return None type if an integer starts with a zero, then it is a string | def guess_type_value (x, none = None) :
try :
int (x)
if x [0] == '0' and len (x) > 1 : return str
else : return int if len (x) < 9 else str
except :
try :
x = float (x)
return float
except :
if none :
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guess_type_value_type (none = True) :\n return [ None, str, int, float ] if none else [ str, int, float ]",
"def get_default_value_type (ty, none = True) :\n if ty is None and none : return None\n elif ty == str : return \"\"\n elif ty == int : return 0\n elif ty == decim... | [
"0.7983696",
"0.7474755",
"0.723659",
"0.71754414",
"0.6950673",
"0.69060194",
"0.6875436",
"0.68705696",
"0.6865456",
"0.6744836",
"0.6703542",
"0.66924196",
"0.6653156",
"0.6632004",
"0.6625986",
"0.66196996",
"0.6605846",
"0.65747064",
"0.6553645",
"0.6553337",
"0.65027356... | 0.87734115 | 0 |
none if True and all values are empty, return None the list of types recognized by guess_type_value | def guess_type_value_type (none = True) :
return [ None, str, int, float ] if none else [ str, int, float ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_datatypes(input_dict):\n return set(filter(None.__ne__, set(input_dict.keys())))",
"def _proper_type_return(val):\n if len(val) == 0:\n return None\n elif len(val) == 1:\n return list(val.values())[0]\n else:\n return val",
"def _get_type_to_one_of():\n\n return {... | [
"0.6287529",
"0.6126239",
"0.58844453",
"0.57816195",
"0.57365364",
"0.57071155",
"0.5659363",
"0.5649177",
"0.5534212",
"0.55004627",
"0.54905343",
"0.54832405",
"0.54824364",
"0.5471524",
"0.5426873",
"0.5413267",
"0.54029876",
"0.5387826",
"0.53806627",
"0.53801656",
"0.53... | 0.812747 | 0 |
ty type in guess_type_value_type none if True and all values are empty, return None a default value for this type | def get_default_value_type (ty, none = True) :
if ty is None and none : return None
elif ty == str : return ""
elif ty == int : return 0
elif ty == decimal.Decimal : return decimal.Decimal(0)
elif ty == float : return 0.0
else :
raise PQHException ("type expe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guess_type_value_type (none = True) :\n return [ None, str, int, float ] if none else [ str, int, float ]",
"def _get_default_value(type_name, is_simple, is_iterative, is_required):\n # Iterables: convert via pre-defined mappings.\n if is_iterative:\n if is_required:\n return _get_... | [
"0.76320404",
"0.7274249",
"0.72691476",
"0.69537956",
"0.6808499",
"0.6762997",
"0.6752358",
"0.67162085",
"0.6660357",
"0.6356065",
"0.6338377",
"0.628572",
"0.6268206",
"0.61693776",
"0.6162946",
"0.61595625",
"0.6150493",
"0.6132494",
"0.60981387",
"0.60981387",
"0.605782... | 0.7841762 | 0 |
guess the type of a list l list tolerance let's denote m as the frequency of the most representative type, and m2 the second one, if m2 > m tolerance > str none if True and all values are empty, return None type, length (order of preference (int, float, str)) the parameter length has a meaning only for str result | def guess_type_list (l, tolerance = 0.01, none = True) :
defa = None if none else str
length = 0
if l in [str, float, int, None, decimal.Decimal] :
raise PQHException ("this case is unexpected %s" % str (l))
if len (l) == 0 :
res = defa
elif len (l) == 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_of_equal_len():\n\n @type_checked\n def _run_test(something:[str, int, bool]):\n assert isinstance(something[0], str)\n assert isinstance(something[1], int)\n assert isinstance(something[2], bool)\n\n _run_test(something=[None, \"12\", 1])",
"def lungime_multimi(multim... | [
"0.57079786",
"0.56396145",
"0.5636325",
"0.55957866",
"0.55709916",
"0.54808486",
"0.5406149",
"0.5359623",
"0.5297381",
"0.52449346",
"0.5231122",
"0.5199308",
"0.51951873",
"0.5139221",
"0.5139221",
"0.5138084",
"0.51315254",
"0.51269794",
"0.51135665",
"0.510849",
"0.5096... | 0.7832862 | 0 |
determine many parameters on this machine machine name user name domain... | def guess_machine_parameter () :
val = [ "COMPUTERNAME", "NUMBER_OF_PROCESSORS", "OS",
"PATH", "USERDOMAIN", "USERNAME", "USERPROFILE",
"windir", "TEMP" ]
res = { }
for v in val :
if v == "PATH" :
x = os.getenv (v)
x = x.split (";")
res [v]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHostInfo():",
"def domainparams(self):\n\t\traise Exception(NotImplemented)",
"def test_parameters(self):\n # Try to create a machine without an image.\n status = self.proxy.server.create(PROVIDER_ID)\n self.check_xmlrpc_command_result(status, has_error=True)\n\n # Try to cr... | [
"0.55696225",
"0.55040246",
"0.5490704",
"0.5457476",
"0.53774184",
"0.52768856",
"0.5258111",
"0.51880157",
"0.5074766",
"0.5068662",
"0.5068662",
"0.5053315",
"0.5036607",
"0.50341004",
"0.5030835",
"0.49431947",
"0.49221584",
"0.49181613",
"0.49145168",
"0.4904791",
"0.489... | 0.60301954 | 0 |
empty string or not? s any string (str, None) is it empty or not? bool PQHException When a type is unexpected | def IsEmptyString (s) :
if s is None : return True
elif isinstance (s, str) :
return len (s) == 0
else :
raise PQHException ("the type is unexpected %s" % str (type (s))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_typeerror_in_case_of_string(self):\n eq_(None,grepit(\"\",\"\",\"\"))",
"def is_str_null(msg):\n\n if None == msg or \"\" == msg:\n return True\n return False",
"def is_str_none_or_empty(val):\n if val is None:\n return True\n if isinstance(val, string_types):\n ... | [
"0.74072754",
"0.72107166",
"0.7186775",
"0.70678073",
"0.70505446",
"0.6966357",
"0.6778749",
"0.6723711",
"0.67125064",
"0.66950375",
"0.6687345",
"0.66824704",
"0.6678631",
"0.6661755",
"0.6641918",
"0.6618534",
"0.6617177",
"0.6611896",
"0.6606371",
"0.660463",
"0.6593820... | 0.81841487 | 0 |
try different encoding to load a file, tries utf8, latin1 and None filename filename couple (content, encoding) | def load_content_file_with_encoding (filename) :
error = None
for enc in [ "utf8", "latin1", None ] :
try :
with open(filename, "r", encoding = enc) as f : content = f.read()
return content, enc
except Exception as e :
error = e
raise error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_encoding(file_path):\n with open(file_path, 'r', encoding='utf-8') as f:\n try:\n for line in f:\n pass\n except UnicodeDecodeError:\n return 'ISO-8859-1'\n else:\n return 'utf-8'",
"def detect_encoding(filename, default_to_utf8... | [
"0.7207956",
"0.7092595",
"0.67391837",
"0.6677408",
"0.66623574",
"0.6612854",
"0.6486865",
"0.64271533",
"0.6374884",
"0.635114",
"0.63398594",
"0.6299602",
"0.6258015",
"0.62392825",
"0.6193841",
"0.6187641",
"0.61355126",
"0.6065543",
"0.6036637",
"0.6028947",
"0.5985771"... | 0.78901494 | 0 |
Convert TheMovieDB movies to fresh tomatoes format | def _convert_to_movies(the_movie_db, raw_movies):
movies = list()
for movie in raw_movies:
poster = ""
if 'poster_path' in movie:
poster = constants.POSTER_URL + movie['poster_path']
success, movie_trailer_url = the_movie_db.get_movie_trailer(movie['id'])
if not suc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_to_Movie(self, MovieDB):\n return Movie(MovieDB['original_title'].encode('utf-8'),\n MovieDB['overview'].encode('utf-8'),\n self._get_image_url(MovieDB['poster_path']),\n self._get_trailer_url(MovieDB['id']))",
"def __movies_to_title... | [
"0.64902",
"0.5829091",
"0.5827195",
"0.5817335",
"0.5812168",
"0.57020813",
"0.5697801",
"0.56902397",
"0.5665576",
"0.56347865",
"0.55452704",
"0.545847",
"0.5440439",
"0.54200333",
"0.5404067",
"0.53978586",
"0.5383835",
"0.53561413",
"0.5301769",
"0.5294081",
"0.52641225"... | 0.71199316 | 0 |
Set a log message in the session log area of the web page | def sessionLog(self, logStr):
if self.ioLoopInst is not None:
cmd = {'cmd': 'sessionLog', 'value': logStr}
self._sendMessageToWeb(cmd)
else:
print("SessionLog: " + logStr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_message(self, msg):\n\t\tself.logView.log_message(msg)",
"def add_session_logger(request, log):\n request.session.log = log",
"def logToScreen(message):\n\tif CyGame().isFinalInitialized():\n\t\tCyInterface().addImmediateMessage(escapeXml(message), \"\")",
"def log(self, message):",
"def log(sel... | [
"0.71520805",
"0.7133883",
"0.6981249",
"0.6750899",
"0.67124015",
"0.6626074",
"0.6558042",
"0.65579414",
"0.65232515",
"0.6516738",
"0.64253914",
"0.635889",
"0.6347469",
"0.6347148",
"0.6331337",
"0.62725055",
"0.62225693",
"0.6218292",
"0.62155837",
"0.61898637",
"0.61354... | 0.7516804 | 0 |
Set an error message in the debug display area of the web page | def setDebugError(self, errStr):
if self.ioLoopInst is not None:
cmd = {'cmd': 'debugError', 'error': errStr}
self._sendMessageToWeb(cmd)
else:
print("DebugError: " + errStr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(self, text):\n\n debug_text = self._get_debug_text(text)\n if self._live_debug_level < logging.ERROR and self._live_debug_enabled:\n if self.py_cui_root is not None:\n self.py_cui_root.status_bar.set_text(debug_text)\n super().debug(debug_text)\n ... | [
"0.73833704",
"0.72650695",
"0.7009634",
"0.6869299",
"0.6852875",
"0.6805506",
"0.6801954",
"0.6663326",
"0.666139",
"0.66274875",
"0.66182554",
"0.6591868",
"0.6587565",
"0.6587565",
"0.65738654",
"0.6552163",
"0.65453845",
"0.65323395",
"0.65281844",
"0.6509303",
"0.648632... | 0.7387137 | 0 |
Send previously plotted data points to the web page | def sendPreviousDataPoints(self):
if self.ioLoopInst is not None:
cmd = {'cmd': 'setDataPoints', 'value': self.dataPoints}
self._sendMessageToWeb(cmd)
else:
print("sendPreviousDataPoints: " + self.dataPoints) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_data(self):",
"def publish_data(username):\n x1 = []\n x2 = []\n y1 = []\n y2 = []\n\n for point_set in __data:\n x1.append(point_set[0][0])\n y1.append(point_set[0][1])\n\n x2.append(point_set[1][0])\n y2.append(point_set[1][1])\n\n figure = plt.figure()\n ... | [
"0.6557775",
"0.63170487",
"0.62147385",
"0.6023356",
"0.60091656",
"0.60037726",
"0.59407425",
"0.59238297",
"0.5918431",
"0.58549476",
"0.5839202",
"0.581282",
"0.5794438",
"0.5786289",
"0.5779231",
"0.5779231",
"0.5779231",
"0.5779231",
"0.5779231",
"0.5770608",
"0.5725653... | 0.6515899 | 1 |
Clear all data plots in the web page | def clearAllPlots(self):
self.dataPoints = [[{'x': 0, 'y': 0}]]
self.sendPreviousDataPoints() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n self._plots[:] = []",
"def clear_graphs(self):\n for ax in (self.master_plot, self.time_velocity, self.time_power, self.power_velocity):\n ax.cla()",
"def clear(self):\n self._plot_data_cache = {}\n self._outstanding_requests = {}",
"def plot_clear():... | [
"0.7638171",
"0.73615134",
"0.72620654",
"0.71827036",
"0.6937874",
"0.69311833",
"0.68891567",
"0.68481153",
"0.6785341",
"0.6784262",
"0.67601913",
"0.6675455",
"0.66389424",
"0.6599825",
"0.65775836",
"0.6565839",
"0.65606374",
"0.6525755",
"0.6523487",
"0.6488934",
"0.648... | 0.7805865 | 0 |
Clear the data plot for the specfied run | def clearRunPlot(self, runId):
self.plotDataPoint(runId, None, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clearAllPlots(self):\n self.dataPoints = [[{'x': 0, 'y': 0}]]\n self.sendPreviousDataPoints()",
"def plot_clear():\n plt.cla()",
"def clear(self):\n self._plots[:] = []",
"def reset(self):\n\n self.fig.clear()\n self.ax = self.fig.add_subplot(111)\n self.hasLe... | [
"0.7813099",
"0.7786517",
"0.76055056",
"0.75376326",
"0.7504365",
"0.74072784",
"0.7391547",
"0.73866606",
"0.73655605",
"0.72939986",
"0.7274155",
"0.7266801",
"0.71715695",
"0.714844",
"0.7123487",
"0.7080083",
"0.7061483",
"0.7059795",
"0.703659",
"0.69713885",
"0.6916199... | 0.81491125 | 0 |
Process and upload documents to memory | def upload(self, documents: List[Document], vectorise_func) -> None:
# Add doc_store to documents
for d in documents:
d.doc_store = self
# Check ID uniqueness
check_duplicate_documents(documents)
# Check type consistency
check_document_types(documents)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, mapping={}, *args, **kwargs):\n self.processed = 0\n for batch in self._process_by_batch(self.load(*args, **kwargs)):\n batch = list(map(lambda doc: self._apply_mapping(doc, mapping), batch))\n for doc in batch:\n self._ingest(iterable=doc, doctype=d... | [
"0.6526872",
"0.6464491",
"0.6338085",
"0.6282727",
"0.62149245",
"0.61992455",
"0.61971223",
"0.6139438",
"0.6122199",
"0.60769445",
"0.60100853",
"0.6003393",
"0.59760845",
"0.5970945",
"0.5958176",
"0.59526074",
"0.59257114",
"0.58856386",
"0.58802295",
"0.58416474",
"0.58... | 0.69855595 | 0 |
Pep8 function for donnee | def function_donnee_pep1():
socio = function_data_socio()
plugs = function_data_plugs()
erup = function_data_erup()
dollars = function_data_dollars()
fire = function_data_fire()
fertilizer = function_data_ferti()
periode = function_data_periode()
pole = data_function_pole()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reckon(self):",
"def function_donnee_pep():\r\n\r\n particles = data_function_particle()\r\n weather = data_function_weather()\r\n wind = data_function_wind()\r\n temperature = data_function_temperature()\r\n season = data_function_season()\r\n deaparture = data_function_departure()\r\n ... | [
"0.61733526",
"0.5896056",
"0.5715602",
"0.5704777",
"0.56908274",
"0.5673039",
"0.56533015",
"0.55861145",
"0.5498113",
"0.548725",
"0.54335994",
"0.542311",
"0.5402919",
"0.5365584",
"0.5351271",
"0.53461313",
"0.53282666",
"0.52006626",
"0.5159694",
"0.5155111",
"0.5146370... | 0.6139485 | 1 |
Information page about pollution | def info_pollu(request):
return render(request, 'info_pollu.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_info():",
"def warning(self) -> str:\n return pulumi.get(self, \"warning\")",
"def displaysuspicions(self):\n raise NotImplementedError()",
"def warning(self) -> 'outputs.AnyResponse':\n return pulumi.get(self, \"warning\")",
"def get(self):\n WriteTemplate(self.respo... | [
"0.57769835",
"0.57013565",
"0.56552356",
"0.56520486",
"0.5593325",
"0.5581116",
"0.55377436",
"0.55259347",
"0.54547215",
"0.53984815",
"0.53958166",
"0.5375226",
"0.5328111",
"0.5316547",
"0.53163064",
"0.53163064",
"0.53009826",
"0.5300177",
"0.5263906",
"0.52632004",
"0.... | 0.57919174 | 0 |
Our predict page. By Ajax call We recup this cities and ask database by aide_analysa.py from prediction_site and try to match by condition with analysa2.py and return it in html page | def prediction(request):
if request.method == "POST":
city1 = request.POST.get('lyon')
city2 = request.POST.get('paris')
city3 = request.POST.get('marseille')
if city1:
#from predi_site.analysa2.py
predi = predi_analysa2('lyon')
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results():\n \n to_predict_list = request.form.to_dict() \n to_predict_list = list(to_predict_list.values()) \n to_predict_list = list(map(float, to_predict_list)) \n result = ValuePredictor(to_predict_list) \n if int(result)== 1: \n prediction ='Run Martha, or you\\'re gonna ... | [
"0.60719806",
"0.6044698",
"0.57561797",
"0.568547",
"0.5680097",
"0.5664656",
"0.5654453",
"0.5639726",
"0.55690736",
"0.5557861",
"0.5479778",
"0.543426",
"0.54201204",
"0.54084146",
"0.5404982",
"0.53986996",
"0.53515655",
"0.53484523",
"0.5343179",
"0.5337715",
"0.5335995... | 0.7738971 | 0 |
Return permissions for a OGC service. | def service_permission(self, identity, service_name, ows_type):
self.logger.debug("Getting permissions for identity %s", identity)
permission = {}
if ows_type:
permission = self.permission.ogc_permissions(
service_name, ows_type, identity
)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_service_permissions(self, request, service_path):\n\n service_path_permission_classes = getattr(\n settings,\n 'ODOO_API_SERVICE_PATH_PERMISSION_CLASSES',\n {}\n )\n permission_classes = None\n for pattern, perms in service_path_permission_classe... | [
"0.72820175",
"0.71609414",
"0.6613455",
"0.6587816",
"0.6386372",
"0.6377997",
"0.62134784",
"0.6197311",
"0.6146319",
"0.6117645",
"0.6071896",
"0.6031946",
"0.5966233",
"0.59371376",
"0.5926131",
"0.5926131",
"0.5890674",
"0.58691025",
"0.5860763",
"0.5859673",
"0.5855396"... | 0.7893323 | 0 |
Check presence and permitted layers for requested layers parameter. | def check_layers(self, layer_param, params, permitted_layers, mandatory):
exception = None
requested_layers = params.get(layer_param)
if requested_layers:
requested_layers = requested_layers.split(',')
for layer in requested_layers:
# allow only permitted... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_layer_exists(self) -> None:\n layer_exists = (\n self.viewer.layer_dict[self.layer_type][self.layer_name][\n self.layer_subtype\n ][\"layer\"]\n is not None\n )\n # hide button if layer doesn't exist\n if layer_exists:\n ... | [
"0.665987",
"0.6410096",
"0.6369205",
"0.6325547",
"0.62577754",
"0.6249218",
"0.6232833",
"0.6193797",
"0.61657876",
"0.5994172",
"0.5975074",
"0.5945743",
"0.5877518",
"0.57443446",
"0.5725027",
"0.5710859",
"0.56924355",
"0.5676123",
"0.5661383",
"0.56075794",
"0.5587897",... | 0.8573627 | 0 |
Adjust parameters depending on request and permissions. | def adjust_params(self, params, permission):
ogc_service = params.get('SERVICE', '')
ogc_request = params.get('REQUEST', '').upper()
if ogc_service == 'WMS' and ogc_request == 'GETMAP':
requested_layers = params.get('LAYERS')
if requested_layers:
# replac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def additional_access_token_request_parameters(self, parameters, request):",
"def _oauth2_process_params(self, request):\n self.in_canvas = (request.REQUEST.get('fb_sig_in_canvas') == '1')\n self.added = (request.REQUEST.get('fb_sig_added') == '1')\n # If app_id is not set explicitly, pick i... | [
"0.64624816",
"0.6333226",
"0.6288839",
"0.6280795",
"0.61579335",
"0.6024394",
"0.59283715",
"0.5907796",
"0.5885023",
"0.5873847",
"0.5864146",
"0.5857229",
"0.58306986",
"0.57982206",
"0.5796583",
"0.5779755",
"0.575566",
"0.57194436",
"0.5705869",
"0.56948435",
"0.5688566... | 0.6348457 | 1 |
Recursively replace group layers with permitted sublayers and return resulting layer list. | def expand_group_layers(self, requested_layers, restricted_group_layers):
permitted_layers = []
for layer in requested_layers:
if layer in restricted_group_layers.keys():
# expand sublayers
sublayers = restricted_group_layers.get(layer)
permit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_layers(parent=None):\n if parent is None:\n parent = QgsProject.instance().layerTreeRoot()\n result = []\n def do_a_group(grp, level=0):\n for child in grp.children():\n if isinstance(child, QgsLayerTreeGroup):\n do_a_group(child, level=level + 1)\n ... | [
"0.6112601",
"0.58890396",
"0.560602",
"0.5505712",
"0.5438574",
"0.5391276",
"0.53751844",
"0.534607",
"0.5330864",
"0.5309719",
"0.52444714",
"0.52316076",
"0.52214426",
"0.52197057",
"0.51853377",
"0.5167963",
"0.5166585",
"0.51286995",
"0.51079917",
"0.5064433",
"0.504346... | 0.7018871 | 0 |
Forward request to QGIS server and return filtered response. | def forward_request(self, method, hostname, params, permission):
ogc_service = params.get('SERVICE', '')
ogc_request = params.get('REQUEST', '').upper()
stream = True
if ogc_request in [
'GETCAPABILITIES', 'GETPROJECTSETTINGS', 'GETFEATUREINFO',
'DESCRIBEFEATURET... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy_request_to_geoserver(map_protocol: str, query_string: str) -> Response:\n geoserver_url = current_app.config['GEOSERVER_URL']\n geoserver_request_url = f'{geoserver_url}/dmis/{map_protocol}?{query_string}'\n\n raw_response = requests.get(geoserver_request_url)\n\n if raw_respo... | [
"0.60810876",
"0.59270155",
"0.5860892",
"0.578528",
"0.575682",
"0.5711819",
"0.5620652",
"0.55773866",
"0.5518297",
"0.5466804",
"0.5417686",
"0.5411383",
"0.534138",
"0.53378296",
"0.5283023",
"0.5280902",
"0.52778715",
"0.5232238",
"0.52306527",
"0.52265555",
"0.5209146",... | 0.70910263 | 0 |
Return WMS GetCapabilities or GetProjectSettings filtered by permissions. | def wms_getcapabilities(self, response, params, permission):
xml = response.text
if response.status_code == requests.codes.ok:
# parse capabilities XML
ElementTree.register_namespace('', 'http://www.opengis.net/wms')
ElementTree.register_namespace('qgs', 'http://www.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def octopus_permissions_get(self, msg, args):\r\n return self.permissions.get_permissions()",
"def get_permissions(self):\n return self.settings[\"permissions\"]",
"def get_permissions():\n return config.get_cfg_storage(ID_PERMISSION)",
"def permissions(self) -> 'outputs.PermissionsResponse'... | [
"0.63442475",
"0.61894834",
"0.5825412",
"0.5782706",
"0.57521266",
"0.57215184",
"0.566947",
"0.566892",
"0.55879563",
"0.5579568",
"0.5542131",
"0.5524528",
"0.5521492",
"0.5516311",
"0.5491324",
"0.54859173",
"0.5396104",
"0.53960353",
"0.5392035",
"0.53709376",
"0.5356034... | 0.62657297 | 1 |
Return WMS GetFeatureInfo filtered by permissions. | def wms_getfeatureinfo(self, response, params, permission):
feature_info = response.text
if response.status_code == requests.codes.ok:
info_format = params.get('INFO_FORMAT', 'text/plain')
if info_format == 'text/plain':
feature_info = self.wms_getfeatureinfo_pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wms_getfeatureinfo_plain(self, feature_info, permission):\n \"\"\"\n GetFeatureInfo results\n\n Layer 'Grundstuecke'\n Feature 1\n t_id = '1234'\n nbident = 'SO0123456789'\n nummer = '1234'\n ...\n \"\"\"\n if feature_info.startswith('GetFea... | [
"0.67674375",
"0.62862855",
"0.62192285",
"0.6204722",
"0.61557966",
"0.60812426",
"0.60116345",
"0.5949941",
"0.5930301",
"0.5890336",
"0.58115965",
"0.572291",
"0.5692847",
"0.5690536",
"0.5690536",
"0.5690536",
"0.5690536",
"0.56159514",
"0.5606485",
"0.55573076",
"0.55388... | 0.65387255 | 1 |
Parse feature info text and filter feature attributes by permission. | def wms_getfeatureinfo_plain(self, feature_info, permission):
"""
GetFeatureInfo results
Layer 'Grundstuecke'
Feature 1
t_id = '1234'
nbident = 'SO0123456789'
nummer = '1234'
...
"""
if feature_info.startswith('GetFeatureInfo'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wms_getfeatureinfo_html(self, feature_info, permission):\n # NOTE: info content is not valid XML, parse as text\n if feature_info.startswith('<HEAD>'):\n lines = []\n\n layer_pattern = re.compile(\n \"^<TR>.+>Layer<\\/TH><TD>(.+)<\\/TD><\\/TR>$\"\n ... | [
"0.59919715",
"0.57230556",
"0.5480841",
"0.53591084",
"0.53377175",
"0.5277078",
"0.5272189",
"0.526255",
"0.5243017",
"0.52359664",
"0.5134618",
"0.5117117",
"0.5117117",
"0.51116365",
"0.5048336",
"0.5006495",
"0.49421442",
"0.4911873",
"0.48802274",
"0.48569468",
"0.48559... | 0.6658838 | 0 |
Parse feature info HTML and filter feature attributes by permission. | def wms_getfeatureinfo_html(self, feature_info, permission):
# NOTE: info content is not valid XML, parse as text
if feature_info.startswith('<HEAD>'):
lines = []
layer_pattern = re.compile(
"^<TR>.+>Layer<\/TH><TD>(.+)<\/TD><\/TR>$"
)
tab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wms_getfeatureinfo_plain(self, feature_info, permission):\n \"\"\"\n GetFeatureInfo results\n\n Layer 'Grundstuecke'\n Feature 1\n t_id = '1234'\n nbident = 'SO0123456789'\n nummer = '1234'\n ...\n \"\"\"\n if feature_info.startswith('GetFea... | [
"0.6403695",
"0.57270837",
"0.5669662",
"0.5665216",
"0.53554523",
"0.5286516",
"0.5278501",
"0.5267335",
"0.52538925",
"0.5215828",
"0.51774246",
"0.51774246",
"0.51503915",
"0.5149752",
"0.51478523",
"0.50912863",
"0.50403017",
"0.50143975",
"0.49901897",
"0.49863157",
"0.4... | 0.7270897 | 0 |
Parse feature info XML and filter feature attributes by permission. | def wms_getfeatureinfo_xml(self, feature_info, permission):
ElementTree.register_namespace('', 'http://www.opengis.net/ogc')
root = ElementTree.fromstring(feature_info)
for layer in root.findall('./Layer'):
# get permitted attributes for layer
permitted_attributes = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_features(self):\n for root in self.roots:\n for feature in root.iter('feature'):\n api = feature.attrib.get('api', '')\n feature_name = feature.attrib.get('name', '')\n feature_number = int(float(feature.attrib.get('number', '')) * 10.0)\n\n... | [
"0.62178385",
"0.6131267",
"0.5999587",
"0.5670946",
"0.52712256",
"0.5198279",
"0.5161996",
"0.51611716",
"0.5016191",
"0.4958712",
"0.4958712",
"0.49565393",
"0.48952377",
"0.48616266",
"0.4837101",
"0.48286694",
"0.48118487",
"0.47954863",
"0.47357622",
"0.47289896",
"0.46... | 0.6285287 | 0 |
Parse feature info GML and filter feature attributes by permission. | def wms_getfeatureinfo_gml(self, feature_info, permission):
ElementTree.register_namespace('gml', 'http://www.opengis.net/gml')
ElementTree.register_namespace('qgs', 'http://qgis.org/gml')
ElementTree.register_namespace('wfs', 'http://www.opengis.net/wfs')
root = ElementTree.fromstring(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wms_getfeatureinfo_plain(self, feature_info, permission):\n \"\"\"\n GetFeatureInfo results\n\n Layer 'Grundstuecke'\n Feature 1\n t_id = '1234'\n nbident = 'SO0123456789'\n nummer = '1234'\n ...\n \"\"\"\n if feature_info.startswith('GetFea... | [
"0.6403832",
"0.6113277",
"0.60985994",
"0.5698372",
"0.5627288",
"0.56187725",
"0.5485077",
"0.5485077",
"0.5412043",
"0.53983635",
"0.5309526",
"0.525838",
"0.5250037",
"0.52406436",
"0.52171934",
"0.52121466",
"0.51926285",
"0.51715875",
"0.5127526",
"0.51179856",
"0.50818... | 0.6419726 | 0 |
Get permitted attributes for a feature info result layer. | def permitted_info_attributes(self, info_layer_name, permission):
# get WMS layer name for info result layer
wms_layer_name = permission.get('feature_info_aliases', {}) \
.get(info_layer_name, info_layer_name)
# return permitted attributes for layer
return permission['layers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attributes(self):\n\n endpoint = self._get_api_endpoint() + '/attributes'\n results = self.tq.get(endpoint, withp='attribute')\n if 'data' not in results:\n return {}\n\n return results['data']\n # tr = {}\n # for attribute in results['data']:\n #... | [
"0.63910294",
"0.6372006",
"0.62900674",
"0.6062062",
"0.6054912",
"0.6051476",
"0.6051476",
"0.6046516",
"0.6046516",
"0.6044955",
"0.603735",
"0.58969605",
"0.57916987",
"0.5715229",
"0.5692241",
"0.56833255",
"0.5683263",
"0.5661067",
"0.5644788",
"0.5635615",
"0.563487",
... | 0.76015323 | 0 |
will create a dictionary with MIX of activation functions as keys(), and as values() a list of the paths where their result.json file are. | def create_path_dict(save_path):
act_fn = [sorted(['relu', 'antirelu', 'identity', 'tanh', 'sigmoid']),
sorted(['relu', 'antirelu', 'identity', 'sigmoid']),
sorted(['relu', 'antirelu', 'identity', 'tanh']),
sorted(['relu', 'antirelu', 'sigmoid', 'tanh']),
sort... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_functions_list():\n return {\"ec2-sg\": _build_ec2_mapping_from_sg,\n \"ec2-resources\": _build_ec2_mapping_from_resources,\n \"rds-sg\": _build_rds_mapping_from_sg,\n \"rds-resources\": _build_rds_mapping_from_resources,\n \"elbv2-sg\": _build_elbv2_mappin... | [
"0.5794404",
"0.57442963",
"0.5732238",
"0.566426",
"0.5630192",
"0.5596989",
"0.55111015",
"0.5485543",
"0.5448509",
"0.5376371",
"0.5322838",
"0.5299788",
"0.52848226",
"0.5236001",
"0.5222747",
"0.5220277",
"0.5215815",
"0.52142113",
"0.52097386",
"0.520471",
"0.51961166",... | 0.6205458 | 0 |
Minimizes window to tray (statusicon) | def minimize_to_tray(self, widget, event, data=None):
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
logging.debug("minimize to tray")
self.window_state = self.check_window_state()
self.statusicon.set_visible(True)
self.wind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_minimize_to_tray(self):\r\n\t\tself.statusicon = gtk.StatusIcon()\r\n\t\ticon_path = os.path.realpath(\".\" + \"\\\\icon.png\")\r\n\t\tself.statusicon = load_status_icon(icon_path, 128, 128, gtk.STOCK_GOTO_TOP)\r\n\t\tself.statusicon.set_tooltip(\"Claimtracker\")\r\n\t\tself.statusicon.connect(\"activate\"... | [
"0.84101045",
"0.69568986",
"0.67686915",
"0.6701629",
"0.6687722",
"0.6662098",
"0.66309386",
"0.6508112",
"0.6386676",
"0.6386318",
"0.63793576",
"0.6371748",
"0.63305694",
"0.62862784",
"0.6282958",
"0.6187243",
"0.61576545",
"0.61076534",
"0.6025659",
"0.60221696",
"0.596... | 0.78925043 | 1 |
Check that bucket has been selected | def _check_queryable(self):
if not self._bucket:
raise Exception('Bucket has not been selected') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_control_panel_bucket(name, bucket):\n is_valid = name.startswith(\"alpha-app-\")\n if name.startswith(\"dev-\"):\n # Ignore this since it's a bucket associated with the dev instance.\n is_valid = False\n elif not is_valid:\n try:\n tags = bucket.Tagging()\n ... | [
"0.60982263",
"0.59170085",
"0.5550665",
"0.55480874",
"0.5523471",
"0.5507626",
"0.5479987",
"0.54688084",
"0.5426117",
"0.53947604",
"0.5357052",
"0.53375906",
"0.5332464",
"0.5312817",
"0.5307807",
"0.53009874",
"0.5283366",
"0.52795064",
"0.52631134",
"0.5257124",
"0.5252... | 0.7113258 | 0 |
Check that file exists in bucket | def check_file_exists_in_bucket(self, file):
self._check_queryable()
try:
self._client.get_object(Bucket=self._bucket, Key=file)
except self._client.exceptions.NoSuchKey:
raise Exception('File {} not found in bucket {}'.format(file, self._bucket)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exists(path):\n if path.startswith('gs://'):\n return gcsio.GcsIO().exists(path)\n else:\n return os.path.exists(path)",
"def test_bucket_availability(self):\n s3 = boto3.resource('s3')\n bucket = s3.Bucket(app.config['S3_PHOTO_BUCKET'])\n exists = True\n try:\n ... | [
"0.7652608",
"0.76365834",
"0.76209396",
"0.7487296",
"0.7461448",
"0.7449851",
"0.7337285",
"0.73094934",
"0.7305053",
"0.7244931",
"0.72251844",
"0.7200634",
"0.7111337",
"0.70806926",
"0.7041153",
"0.7033018",
"0.70185465",
"0.70138866",
"0.6980778",
"0.6973387",
"0.695588... | 0.82178646 | 0 |
Get list of S3 locations from timebase pattern parts with possible lag. | def get_S3_paths_with_lag(*paths, **kwargs):
lag = kwargs.get('lag', '01:00')
lag_as_date = datetime.datetime.strptime(lag, '%H:%M')
lag_as_delta = datetime.timedelta(hours=lag_as_date.hour, minutes=lag_as_date.minute, seconds=lag_as_date.second)
times = [
datetime.datetime.u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_backups(self, bucketname, prefix):\n backups = []\n \n bucket = self.conn.get_bucket(bucketname)\n\n logger.info(\"Scanning for backups: s3://%s/%s\", bucketname, prefix)\n\n for entry in natsort([key.name for key in bucket.list(prefix)]):\n # Check for a t... | [
"0.5553879",
"0.5373015",
"0.52267677",
"0.50609094",
"0.5051911",
"0.5023184",
"0.50068414",
"0.49989265",
"0.4967261",
"0.49669662",
"0.4930386",
"0.48923874",
"0.4880217",
"0.48494568",
"0.4843274",
"0.48396668",
"0.48355362",
"0.4834737",
"0.48299235",
"0.48269066",
"0.48... | 0.6611707 | 0 |
Set positioning of Pinky's eyes based on PacMan's coordinates | def update_eyes(self, up_down_part, left_right_part):
if up_down_part and abs(up_down_part) > 5:
y = up_down_part/abs(up_down_part)
else:
y = 0
if left_right_part and abs(left_right_part) > 5:
x = left_right_part/abs(left_right_part)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPosition(self):\n # determine posX, posY for battle\n (x1,y1) = globals.battlemapQuadrants[self.systemGrid]\n self.posX = x1+self.setX\n self.posY = y1+self.setY",
"def set_new_location(self, xPos, yPos):",
"def set_pos(self, x, y, orien):\n self.pos_x = x\n sel... | [
"0.65328586",
"0.6508323",
"0.6434197",
"0.64220273",
"0.63514304",
"0.6293591",
"0.62664384",
"0.6252575",
"0.6111345",
"0.61039346",
"0.6084001",
"0.60804886",
"0.6058369",
"0.60549945",
"0.60224134",
"0.59905356",
"0.5935536",
"0.59203494",
"0.5913262",
"0.59098",
"0.58949... | 0.68247646 | 0 |
Append item to set. This method does not save object! | def add(self, item):
item = self._prepare_item(len(self), item)
if item not in self._data:
self._data.append(item)
self.__log__.append(SetAdd(value=item)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, item):\n self.update(set([item]))",
"def append(self, item):\n self.update([item])",
"def add_to_set(self, item, reload=True):\n index = len(self)\n item = self._prepare_item(index, item)\n data = self._field.item_field.to_mongo(self.__document__, item)\n\n ... | [
"0.79363596",
"0.7526422",
"0.7515836",
"0.74165773",
"0.7331249",
"0.7069965",
"0.7059942",
"0.70584714",
"0.7025516",
"0.69851726",
"0.6967807",
"0.69535244",
"0.68928784",
"0.6875286",
"0.687117",
"0.6854746",
"0.68296975",
"0.6811986",
"0.6811986",
"0.6811986",
"0.6811986... | 0.8173588 | 0 |
Remove item from set. This method does not save object! | def remove(self, item):
try:
self._data.remove(item)
except ValueError as exc:
raise KeyError from exc
else:
self.__log__.append(SetRemove(value=item)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, item):\n try:\n entry = self.set.pop(item)\n entry[-1] = self.REMOVED\n except KeyError:\n print(\"Can't remove a non-existing item\")",
"def discard(self, item):\n try:\n self._data.remove(item)\n except ValueError:\n ... | [
"0.8421894",
"0.75798225",
"0.7519389",
"0.7402691",
"0.7387822",
"0.72861737",
"0.72861737",
"0.71671855",
"0.7151665",
"0.7125882",
"0.7112938",
"0.7072577",
"0.70445186",
"0.70413494",
"0.70383376",
"0.7036314",
"0.7003476",
"0.6928036",
"0.6928036",
"0.6921462",
"0.690894... | 0.8193228 | 1 |
Pull item from database. See `$pull` in MongoDB's `update_one`. | def pull(self, query, reload=True):
qs = self._get_queryset()
qs.update_one({'$pull': {self.__field_name__: query}})
self.__log__.append(SetPull(query=query))
if reload:
self.reload() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull(self, *arg, **kwds):\n pass",
"def make_pull(db,url):\n result = db.product_mstator.find_one({\"url\":url})\n return result",
"def pull(self, pull: Optional[int] = None) -> Optional[int]:\n ...",
"async def _pull(self) -> None:\n raise NotImplementedError()",
"def get_on... | [
"0.6538052",
"0.63186467",
"0.6040806",
"0.6029069",
"0.59004635",
"0.5854365",
"0.5729563",
"0.5702147",
"0.5686264",
"0.5669243",
"0.56689715",
"0.56077796",
"0.5606335",
"0.55896586",
"0.55583566",
"0.55535597",
"0.5551364",
"0.5546508",
"0.5537837",
"0.55240315",
"0.55179... | 0.6360697 | 1 |
Generate string from symbols. | def generate_random_string(symbols, length):
sym_list = symbols.split()
str_list = random.sample(sym_list, length)
gen_string = ''.join(str_list)
return gen_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r_string(symbols, length):\n return ''.join(R.choice(symbols)\n for _ in range(length))",
"def to_string(self):\r\n production_dict = self.get_production_dict()\r\n\r\n string_prods = ['S -> ' + ' | '.join([''.join(symbols) for symbols in production_dict.pop('S')])]\r\n ... | [
"0.65853775",
"0.63188434",
"0.62873995",
"0.62873995",
"0.6264359",
"0.6238999",
"0.6125742",
"0.6105235",
"0.60517746",
"0.60211015",
"0.59943384",
"0.5946436",
"0.5872985",
"0.57784",
"0.5774602",
"0.57340676",
"0.5729776",
"0.5718029",
"0.5713585",
"0.56909215",
"0.568244... | 0.66242063 | 0 |
Generate unique value of field of object | def generate_object_field(symbols, length, object, field):
string = generate_random_string(symbols, length)
try:
instance = object.objects.get(**{field:string})
if instance:
string = generate_object_field(symbols, length, object, field)
except object.DoesNotExist:
pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _unique_key(self):\n key = f'factor_{self.counter}'\n self.counter += 1\n return key",
"def unique_id():\n global _unique_id_counter\n _unique_id_counter += 1\n return \"_element_{}\".format(_unique_id_counter)",
"def unique_id() -> str:",
"def get_unique_value(query_set, field_na... | [
"0.6485617",
"0.6468718",
"0.6443546",
"0.64268094",
"0.6342841",
"0.63409305",
"0.63334376",
"0.62932295",
"0.62595534",
"0.6258071",
"0.62518674",
"0.62270314",
"0.6215765",
"0.62076354",
"0.6207109",
"0.6184692",
"0.61518097",
"0.6139777",
"0.613857",
"0.6138417",
"0.61279... | 0.65939534 | 0 |
Generate activation token as sha1 hash of random number + sha1 hash of username | def generate_activation_token(username):
salt = hashlib.sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]
encoded_string = salt + username
token = hashlib.sha1(encoded_string.encode('utf-8')).hexdigest()
try:
profile = ActivationProfile.objects.get(token=token)
if profile:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gen_activation_hash():\r\n # for now just cheat and generate an api key, that'll work for now\r\n return User.gen_api_key()",
"def generate_token():\n return uuid4()",
"def _generate_token(self):\n return sha1(\"%s#%s\" % (time(),\n self.app.cfg['s... | [
"0.7930364",
"0.732733",
"0.7284244",
"0.72545826",
"0.7070762",
"0.70537156",
"0.7041763",
"0.7013381",
"0.700369",
"0.6981259",
"0.69533074",
"0.69524884",
"0.692625",
"0.6890338",
"0.6884929",
"0.687067",
"0.687067",
"0.6851789",
"0.68499076",
"0.6831315",
"0.6826171",
"... | 0.8487366 | 0 |
Find activation profile by field (token or sms) and code. Activate user object, set password, and delete activation profile. Also authenticate user. | def activate_profile(field, code, request):
try:
activation = ActivationProfile.objects.get(**{field:code})
except ActivationProfile.DoesNotExist:
messages.error(request, _('Activation code expired or not valid!'))
return False
if timezone.now() < activation.valid_through:
ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate_account(self, activation_key):\n try:\n registration_profile = self.get(activation_key=activation_key)\n except self.model.DoesNotExist:\n return None\n\n if not registration_profile.is_expired():\n user = registration_profile.user\n use... | [
"0.68785006",
"0.6514229",
"0.64548576",
"0.6426541",
"0.64197016",
"0.63910127",
"0.6378009",
"0.63755804",
"0.63652694",
"0.62683344",
"0.6250443",
"0.6241231",
"0.6199857",
"0.6191263",
"0.6141303",
"0.6119849",
"0.6073964",
"0.606942",
"0.6056606",
"0.60392773",
"0.599749... | 0.78744406 | 0 |
Convert base 64 string withe headers to image | def convert_str_to_image(image_string):
image = image_string.partition('base64,')[2]
img_data = base64.b64decode(image)
return img_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatImage(imgData):\n imgstr = re.search(b'base64,(.*)', imgData).group(1)\n with open('output.png','wb') as output:\n output.write(base64.decodebytes(imgstr))",
"def base64_decode_image(inStr):\n imgDat, imgType, imgShape = json.loads(inStr)\n imgDat = bytes(imgDat, encoding=\"utf-8\")\... | [
"0.746931",
"0.73137474",
"0.7189252",
"0.7102462",
"0.7000746",
"0.69148093",
"0.6903235",
"0.68649226",
"0.6849316",
"0.67165977",
"0.67024094",
"0.668832",
"0.66554683",
"0.66335756",
"0.66325825",
"0.66167563",
"0.65795285",
"0.6556288",
"0.6536883",
"0.65069014",
"0.6489... | 0.74544173 | 1 |
List all available boxes in the catalog. | def list(self, arguments):
print("{}\t{}".format(
'BOX'.rjust(35),
'VERSION'.rjust(12),
))
path = os.path.abspath(os.path.join(HOME, 'boxes'))
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, '*.box'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def list(self, ctx):\n server = ctx.message.server\n if server.id not in self.db:\n self.db[server.id] = {}\n dataIO.save_json(\"data/lootbox/servers.json\", self.db)\n if len(self.db[server.id]) < 1:\n await self.bot.say(\"No boxes have been created for ... | [
"0.6789714",
"0.6467714",
"0.64102626",
"0.6343046",
"0.62305814",
"0.62055796",
"0.6174118",
"0.616372",
"0.6149185",
"0.584758",
"0.58460945",
"0.5771759",
"0.5769471",
"0.57662725",
"0.5710648",
"0.57082415",
"0.5686935",
"0.5678659",
"0.56130964",
"0.554044",
"0.55158705"... | 0.6993446 | 0 |
Repackage the box that is in use in the current mech environment. | def repackage(self, arguments):
puts_err(colored.red("Not implemented!")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _provision_package(self):",
"def updaterun(self):\n self.comp('packmanager').updaterun_allpacks()",
"def updatecheck(self):\n self.comp('packmanager').updatecheck_allpacks()",
"def unintallpack(package_name: str) -> None:\n\tresp = subprocess.call(['pip', 'uninstall', '-y', package_name])",... | [
"0.6154953",
"0.58410996",
"0.5439497",
"0.5417384",
"0.5338681",
"0.5287142",
"0.52402675",
"0.5207523",
"0.51990336",
"0.5193477",
"0.51707906",
"0.50902545",
"0.5075615",
"0.50582254",
"0.50577927",
"0.502458",
"0.4999124",
"0.49943903",
"0.4990816",
"0.49826893",
"0.49786... | 0.588097 | 1 |
Initializes a new mech environment by creating a Mechfile. | def init(self, arguments):
url = arguments['<location>']
if url:
name = arguments['<name>']
else:
url = arguments['<name>']
name = None
version = arguments['--box-version']
instance_name = arguments['--name']
force = arguments['--force'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self): \n\t\n\t # get the environment\n\t\tself.env = env()",
"def SetUp(self):\n self.buffer_file = buffer_file_common.BufferFile(\n self.args, self.logger.name, self.GetDataDir())\n\n self.attachments_tmp_dir = os.path.join(self.GetDataDir(),\n ... | [
"0.59631246",
"0.588322",
"0.5817756",
"0.57999754",
"0.5796112",
"0.5791291",
"0.5737065",
"0.57075596",
"0.5706491",
"0.5700405",
"0.5675861",
"0.56662416",
"0.5640394",
"0.5640394",
"0.5637696",
"0.56174433",
"0.56106085",
"0.55529803",
"0.55174655",
"0.55148506",
"0.55057... | 0.7118378 | 0 |
Output OpenSSH valid configuration to connect to the machine. | def ssh_config(self, arguments):
instance_name = arguments['<instance>']
instance_name = self.activate(instance_name)
print(utils.config_ssh_string(self.config_ssh)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh(args, config):\n print('{}'.format(ssh.__doc__))",
"def bootstrap_config(self):\n self.logger.info(\"applying bootstrap configuration\")\n self.wait_write(\"\\r\", None)\n # Wait for the prompt\n time.sleep(1)\n self.wait_write(\"system-view\", \"<HPE>\")\n se... | [
"0.6099966",
"0.60891026",
"0.60809517",
"0.5902394",
"0.58439136",
"0.58291984",
"0.5805959",
"0.5784745",
"0.57688177",
"0.5761952",
"0.56910163",
"0.56236494",
"0.562262",
"0.5595992",
"0.55930495",
"0.5480706",
"0.5446128",
"0.54187673",
"0.5414092",
"0.5410241",
"0.53677... | 0.6446934 | 0 |
If TLS 1.3 support is missing and it's configured, it will raise a ConfigError. | def test_tls_client_minimum_1_point_3_missing(self):
# thanks i hate it
if hasattr(SSL, "OP_NO_TLSv1_3"):
OP_NO_TLSv1_3 = SSL.OP_NO_TLSv1_3
delattr(SSL, "OP_NO_TLSv1_3")
self.addCleanup(setattr, SSL, "SSL.OP_NO_TLSv1_3", OP_NO_TLSv1_3)
assert not hasattr(S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _config_tls(self):\n pass",
"def test_tls_client_minimum_1_point_3_exists(self):\n # thanks i hate it, still\n if not hasattr(SSL, \"OP_NO_TLSv1_3\"):\n SSL.OP_NO_TLSv1_3 = 0x00\n self.addCleanup(lambda: delattr(SSL, \"OP_NO_TLSv1_3\"))\n assert hasattr(S... | [
"0.73794323",
"0.7187562",
"0.6202741",
"0.608287",
"0.60574615",
"0.5968533",
"0.5968185",
"0.59237605",
"0.5923406",
"0.59213465",
"0.5912386",
"0.58577335",
"0.5834019",
"0.5784727",
"0.5690416",
"0.5681512",
"0.5679992",
"0.562341",
"0.55832535",
"0.55645514",
"0.5561639"... | 0.79050493 | 0 |
If TLS 1.3 support exists and it's configured, it will be settable. | def test_tls_client_minimum_1_point_3_exists(self):
# thanks i hate it, still
if not hasattr(SSL, "OP_NO_TLSv1_3"):
SSL.OP_NO_TLSv1_3 = 0x00
self.addCleanup(lambda: delattr(SSL, "OP_NO_TLSv1_3"))
assert hasattr(SSL, "OP_NO_TLSv1_3")
config = {"federation_clie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tls_client_minimum_1_point_3_missing(self):\n # thanks i hate it\n if hasattr(SSL, \"OP_NO_TLSv1_3\"):\n OP_NO_TLSv1_3 = SSL.OP_NO_TLSv1_3\n delattr(SSL, \"OP_NO_TLSv1_3\")\n self.addCleanup(setattr, SSL, \"SSL.OP_NO_TLSv1_3\", OP_NO_TLSv1_3)\n ass... | [
"0.73433053",
"0.7166888",
"0.693749",
"0.6911747",
"0.6790053",
"0.6767721",
"0.6685774",
"0.660896",
"0.6553318",
"0.654518",
"0.6388313",
"0.63858914",
"0.63777804",
"0.6243128",
"0.6116154",
"0.6102289",
"0.6054786",
"0.6047724",
"0.59661496",
"0.59522796",
"0.5937201",
... | 0.71868205 | 1 |
The configured TLS version is correctly configured by the ContextFactory. | def test_tls_client_minimum_set_passed_through_1_2(self):
config = {"federation_client_minimum_tls_version": 1.2}
t = TestConfig()
t.read_config(config, config_dir_path="", data_dir_path="")
cf = FederationPolicyForHTTPS(t)
options = _get_ssl_context_options(cf._verify_ssl_conte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tls_client_minimum_set_passed_through_1_0(self):\n config = {\"federation_client_minimum_tls_version\": 1}\n t = TestConfig()\n t.read_config(config, config_dir_path=\"\", data_dir_path=\"\")\n\n cf = FederationPolicyForHTTPS(t)\n options = _get_ssl_context_options(cf._v... | [
"0.7221435",
"0.7129749",
"0.70612466",
"0.6946584",
"0.69393426",
"0.6594127",
"0.65869886",
"0.65678525",
"0.6503111",
"0.6450828",
"0.6446566",
"0.64110285",
"0.63336414",
"0.6328864",
"0.63021713",
"0.62453425",
"0.62098765",
"0.6187503",
"0.6182842",
"0.61263424",
"0.611... | 0.7200872 | 1 |
The configured TLS version is correctly configured by the ContextFactory. | def test_tls_client_minimum_set_passed_through_1_0(self):
config = {"federation_client_minimum_tls_version": 1}
t = TestConfig()
t.read_config(config, config_dir_path="", data_dir_path="")
cf = FederationPolicyForHTTPS(t)
options = _get_ssl_context_options(cf._verify_ssl_context... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tls_client_minimum_set_passed_through_1_2(self):\n config = {\"federation_client_minimum_tls_version\": 1.2}\n t = TestConfig()\n t.read_config(config, config_dir_path=\"\", data_dir_path=\"\")\n\n cf = FederationPolicyForHTTPS(t)\n options = _get_ssl_context_options(cf.... | [
"0.7200872",
"0.7129749",
"0.70612466",
"0.6946584",
"0.69393426",
"0.6594127",
"0.65869886",
"0.65678525",
"0.6503111",
"0.6450828",
"0.6446566",
"0.64110285",
"0.63336414",
"0.6328864",
"0.63021713",
"0.62453425",
"0.62098765",
"0.6187503",
"0.6182842",
"0.61263424",
"0.611... | 0.7221435 | 0 |
Checks acme is enabled if the acme_domain arg is set to some string. | def test_acme_enabled_in_generated_config_domain_provided(self):
conf = TestConfig()
conf.read_config(
yaml.safe_load(
TestConfig().generate_config(
"/config_dir_path",
"my_super_secure_server",
"/data_dir_path",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_domain_allowed(email):\n domains = local_config.AuthConfig().get('whitelisted_domains', default=[])\n for domain in domains:\n if utils.normalize_email(email).endswith('@%s' % domain.lower()):\n return True\n\n return False",
"def test_acme_disabled_in_generated_config_no_acme_domain_provied(s... | [
"0.5735511",
"0.5725383",
"0.553573",
"0.5405438",
"0.54000163",
"0.52613115",
"0.5258438",
"0.5212149",
"0.5205378",
"0.51893073",
"0.5159638",
"0.5120427",
"0.5111011",
"0.50925523",
"0.5068178",
"0.5066398",
"0.5062281",
"0.50507987",
"0.49955666",
"0.49874535",
"0.4962486... | 0.65662074 | 0 |
The federation certificate whitelist will not allow IDNA domain names. | def test_whitelist_idna_failure(self):
config = {
"federation_certificate_verification_whitelist": [
"example.com",
"*.ドメイン.テスト",
]
}
t = TestConfig()
e = self.assertRaises(
ConfigError, t.read_config, config, config_dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_whitelist_idna_result(self):\n config = {\n \"federation_certificate_verification_whitelist\": [\n \"example.com\",\n \"*.xn--eckwd4c7c.xn--zckzah\",\n ]\n }\n t = TestConfig()\n t.read_config(config, config_dir_path=\"\", dat... | [
"0.75625795",
"0.617024",
"0.58902013",
"0.56733066",
"0.56661296",
"0.56661296",
"0.5613816",
"0.5505714",
"0.5429969",
"0.52565783",
"0.52504295",
"0.52081794",
"0.5184741",
"0.5165055",
"0.515711",
"0.515711",
"0.5116744",
"0.5116744",
"0.50894976",
"0.5084205",
"0.5051419... | 0.6794298 | 1 |
The federation certificate whitelist will match on IDNA encoded names. | def test_whitelist_idna_result(self):
config = {
"federation_certificate_verification_whitelist": [
"example.com",
"*.xn--eckwd4c7c.xn--zckzah",
]
}
t = TestConfig()
t.read_config(config, config_dir_path="", data_dir_path="")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_whitelist_idna_failure(self):\n config = {\n \"federation_certificate_verification_whitelist\": [\n \"example.com\",\n \"*.ドメイン.テスト\",\n ]\n }\n t = TestConfig()\n e = self.assertRaises(\n ConfigError, t.read_config... | [
"0.6425439",
"0.5514384",
"0.5432561",
"0.52561045",
"0.5184046",
"0.49741006",
"0.4893893",
"0.48836952",
"0.48803678",
"0.48803678",
"0.48693806",
"0.4830566",
"0.4822639",
"0.48119327",
"0.48084122",
"0.4804135",
"0.4793144",
"0.47902942",
"0.47870547",
"0.47870547",
"0.47... | 0.7812035 | 0 |
get the options bits from an openssl context object | def _get_ssl_context_options(ssl_context: SSL.Context) -> int:
# the OpenSSL.SSL.Context wrapper doesn't expose get_options, so we have to
# use the low-level interface
return SSL._lib.SSL_CTX_get_options(ssl_context._context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssl_options_to_context(ssl_options):\n ...",
"def test_set_options(self):\n context = Context(SSLv23_METHOD)\n options = context.set_options(OP_NO_SSLv2)\n assert options & OP_NO_SSLv2 == OP_NO_SSLv2",
"def _context(use_tls=False):\n if use_tls is False:\n return None\n ... | [
"0.73579234",
"0.64249",
"0.62168473",
"0.61505395",
"0.605283",
"0.6007271",
"0.5896078",
"0.58376265",
"0.5828241",
"0.58178514",
"0.58104944",
"0.5766421",
"0.57381654",
"0.5734007",
"0.5730924",
"0.5724922",
"0.57243115",
"0.57175404",
"0.5710651",
"0.5698366",
"0.5667754... | 0.75272393 | 0 |
Extracts latitude and longitude from geotags. | def get_coordinates(geotags) -> Tuple[float, float]:
lat = get_decimal_from_dms(
geotags['GPSLatitude'],
geotags['GPSLatitudeRef'],
)
lon = get_decimal_from_dms(
geotags['GPSLongitude'],
geotags['GPSLongitudeRef'],
)
return lat, lon | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_geotag(post_content):\n post_map = post_content.find(\"div\", {\"id\": \"map\"})\n geotag_attr = {\"lat\": \"\", \"lon\": \"\"}\n if post_map is not None:\n geotag_attr[\"lat\"] = post_map.attrs[\"data-latitude\"]\n geotag_attr[\"lon\"] = post_map.attrs[\"data-longitude\"]\n retur... | [
"0.69120336",
"0.6498285",
"0.64313525",
"0.6263169",
"0.6131598",
"0.58735377",
"0.57471067",
"0.57270646",
"0.57160133",
"0.5713735",
"0.56999207",
"0.5634059",
"0.5619045",
"0.5606678",
"0.5577931",
"0.5576704",
"0.5569433",
"0.5567942",
"0.5556589",
"0.5555639",
"0.554910... | 0.78406644 | 0 |
Gets geocoding response from passed lat and long. | def get_geocoding_response(lat: float, long: float):
payload = {}
headers = {}
url = URL_TEMPLATE.format(
api_key=GEOCODING_API_KEY,
long_lat=','.join(
(str(long), str(lat)),
),
)
response = requests.request("GET", url, headers=headers, data=payload)
return re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geocoding(address):\n AUTH = json.loads(open(\"auth.json\", \"r\").read())\n\n r = requests.get(f\"https://maps.googleapis.com/maps/api/geocode/json\", params={\n \"address\": address,\n \"key\": AUTH[\"GMAP_API\"]\n })\n\n if r.status_code == 200:\n r = r.json()\n resul... | [
"0.733597",
"0.7196635",
"0.71830773",
"0.7144319",
"0.70891005",
"0.70880294",
"0.69447345",
"0.68647265",
"0.68523586",
"0.68478686",
"0.6834369",
"0.68198144",
"0.68149424",
"0.68012166",
"0.6715046",
"0.6687212",
"0.6680827",
"0.66554797",
"0.66531104",
"0.6628361",
"0.66... | 0.82419246 | 0 |
register events for each ticks gateway for each hand | def _registerEvent(self):
# new DyStockDataTicksGateway instance for each ticks hand to avoid mutex
self._ticksGateways = [DyStockDataTicksGateway(self._eventEngine, self._info, i) for i in range(DyStockDataEventHandType.stockHistTicksHandNbr)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tick(self):\n for method in self.on_ticker:\n getattr(self, method)()",
"def _add_event_detect(self):\n for gpio_channel in self.registered_gpio:\n self.gpio_add_event_detect(gpio_channel, bouncetime=300)",
"def _add_event_callback(self):\n for gpio_channel in sel... | [
"0.5968426",
"0.5917992",
"0.56636107",
"0.56423134",
"0.5584876",
"0.5492231",
"0.5486046",
"0.5438875",
"0.5428285",
"0.5386084",
"0.535901",
"0.535302",
"0.5332035",
"0.53188497",
"0.5287094",
"0.52672625",
"0.52583253",
"0.5256934",
"0.52462757",
"0.52174073",
"0.52080256... | 0.77605575 | 0 |
Return a list of media from default storage | def list_media(storage, filter_list):
results = []
total = 0
try:
for media in storage.listdir('.')[1]:
if not media.endswith('/') and media != "":
location = storage.url(media).split('?')[0]
total += 1
if no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list(self ):\n headers = { 'Authorization' : self.client.authorization_header }\n response = requests.get(\n self.client.url + '/media', \n headers = headers\n )\n\n return json.loads(response.text)",
"def get_available_galleries(include_default=False):\n galleries = ... | [
"0.73105615",
"0.6960371",
"0.6935916",
"0.66127723",
"0.6541802",
"0.6517254",
"0.6499656",
"0.6441851",
"0.6408212",
"0.6389894",
"0.638803",
"0.63024044",
"0.6233786",
"0.61984754",
"0.6091993",
"0.6090939",
"0.6084087",
"0.6084087",
"0.6084087",
"0.6072663",
"0.60158885",... | 0.7200995 | 1 |
Call function of matrix_calculator.py to return matrices for each cluster. Select 'requested_'+classification_column_transaction of weblog that are only in entry "classification_wanted_transaction" | def cluster_classification(weblog,classification_column_transaction,\
classification_column_diversity, session_data_threshold, cluster_type, classification_wanted_transaction, verbose = False):
if verbose== True:
start_time = timelib.time()
print("\n * Computing cluste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_classification_tex(f,browsing_matrix,diversifying_matrix, weblog,session_data_threshold,cluster_type,classification_column_diversity,classification_wanted_transaction):\n divpat_classification_wanted_transaction = classification_wanted_transaction\n divpat_N_classification_wanted_transaction=len(... | [
"0.6683406",
"0.6142232",
"0.5941017",
"0.5886404",
"0.57107574",
"0.56908506",
"0.56840414",
"0.56270343",
"0.5577767",
"0.54864204",
"0.54859143",
"0.54727614",
"0.54714465",
"0.5455581",
"0.54445",
"0.5434564",
"0.5425108",
"0.54225826",
"0.541594",
"0.5410452",
"0.5405825... | 0.7701423 | 0 |
Arbitry choices to associate number of requests with length | def length(requests_mean):
if requests_mean<=5.:
return 'short';
elif requests_mean<=10:
return 'medium';
else:
return 'long'; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NUMBER_OF_REC_CHOICE():\n return 13",
"def get_num_to_request():\n #ALLOWABLE_REQUEST_SIZES = [1, 3, 5, 8, 12]\n ALLOWABLE_REQUEST_SIZES = [1, 3, 5, 8]\n avgrate = jobtracker.query(\"SELECT AVG(files.size/\" \\\n \"(TO_SECONDS(download_attempts.updated_at)*1/86400. ... | [
"0.60413057",
"0.5787301",
"0.5696149",
"0.56239843",
"0.5614543",
"0.554054",
"0.55402803",
"0.54318595",
"0.5417974",
"0.54012364",
"0.5351382",
"0.53226864",
"0.53211933",
"0.53190243",
"0.5317493",
"0.5313957",
"0.52929085",
"0.52625877",
"0.52498925",
"0.522541",
"0.5171... | 0.588172 | 1 |
Write on latex file variables that are calculated with cluster classification | def cluster_classification_tex(f,browsing_matrix,diversifying_matrix, weblog,session_data_threshold,cluster_type,classification_column_diversity,classification_wanted_transaction):
divpat_classification_wanted_transaction = classification_wanted_transaction
divpat_N_classification_wanted_transaction=len(divpat_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output(\n self,\n fileformat,\n **keywords\n ):\n \n # add the default parameters, they will be checked against the keywords\n defaults = {\n 'ref':'cogid',\n 'entry':'concept',\n 'missing':0,\n ... | [
"0.58711535",
"0.5794212",
"0.577263",
"0.576856",
"0.5729977",
"0.5719904",
"0.5699117",
"0.5625929",
"0.55732876",
"0.5559315",
"0.5549494",
"0.55457133",
"0.5542708",
"0.5537047",
"0.5492166",
"0.54771644",
"0.5458965",
"0.545175",
"0.5443052",
"0.5383917",
"0.5383866",
... | 0.6494704 | 0 |
Estimate radii for stars on the main sequence using their ``BV`` color, using a simple relation calibrated on interferometry by Boyajian et al. 2012 | def bv_to_radius(b_minus_v):
# Boyajian 2012
X = b_minus_v
a0 = 0.3830
a1 = 0.9907
a2 = -0.6038
Y = 0
# Ignore metallicity
a3 = 0
a4 = 0
a5 = 0
return (a0 + a1 * X + a2 * X ** 2 + a3 * X * Y +
a4 * Y + a5 * Y ** 2) * R_sun | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_rsi(image):\n\n # roll axes to conventional row,col,depth\n img = np.rollaxis(image, 0, 3)\n\n # bands: Coastal(0), Blue(1), Green(2), Yellow(3), Red(4), Red-edge(5), NIR1(6), NIR2(7)) Multispectral\n COAST = img[:, :, 0]\n B = img[:, :, 1]\n G = img[:, :, 2]\n Y = img[:, :, 3]\n R... | [
"0.59634537",
"0.59169656",
"0.5846073",
"0.5812182",
"0.5738116",
"0.57252634",
"0.5717098",
"0.56898355",
"0.56139106",
"0.5604561",
"0.5550189",
"0.5483282",
"0.54414994",
"0.5432839",
"0.54192543",
"0.5417974",
"0.5405411",
"0.5389052",
"0.53736633",
"0.5373638",
"0.53550... | 0.6301096 | 0 |
Create a class to import and parse the excel spreadsheet that is used as an input file for V/UQpredictivity. | def __init__(self, input_file):
self.file_name = input_file
# Import the excel file:
self.xlfile = ExcelFile(self.file_name) # to retrieve & work w/ input | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_data(self):\n\n self.worksheet = (\n xlrd.open_workbook(filename=self.source).sheet_by_index(0)\n )\n # Import conversion data from worksheet and store as scipy arrays\n self.T_exp = np.array(\n self.worksheet.col_values(0, start_rowx=4, end_rowx=None)\n ) + 273.15\n... | [
"0.7165949",
"0.6775792",
"0.6591296",
"0.65136635",
"0.6475",
"0.6339719",
"0.63090634",
"0.63020563",
"0.627618",
"0.6165925",
"0.61505485",
"0.60875565",
"0.60049736",
"0.5965323",
"0.59106916",
"0.58891374",
"0.58874655",
"0.587729",
"0.58750814",
"0.58100104",
"0.5798638... | 0.74365103 | 0 |
Like tf.train.range_input_producer, but randomizes every index instead of taking a range and shuffling every epoch (random reordering). | def random_index_input_producer(limit, num_epochs=None, seed=None,
capacity=32, shared_name=None, name=None):
with ops.op_scope([limit], name, "input_producer") as name:
index_tensor = tf.random_uniform([limit], minval=0, maxval=limit, dtype=tf.int64, seed=seed)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_slice_input_producer(tensor_list, num_epochs=None, seed=None,\n capacity=32, shared_name=None, name=None):\n with ops.op_scope(tensor_list, name, \"input_producer\"):\n tensor_list = ops.convert_n_to_tensor_or_indexed_slices(tensor_list)\n if not tensor_li... | [
"0.67417186",
"0.59812593",
"0.5888701",
"0.5693134",
"0.56846994",
"0.56515205",
"0.56035835",
"0.5600005",
"0.55920666",
"0.5584618",
"0.557734",
"0.5556954",
"0.55525434",
"0.553969",
"0.55269265",
"0.5495206",
"0.5448808",
"0.5438618",
"0.5402123",
"0.5388766",
"0.5382812... | 0.7107893 | 0 |
Like tf.train.slice_input_producer, but uses random_index_input_producer instead of range_input_producer. | def random_slice_input_producer(tensor_list, num_epochs=None, seed=None,
capacity=32, shared_name=None, name=None):
with ops.op_scope(tensor_list, name, "input_producer"):
tensor_list = ops.convert_n_to_tensor_or_indexed_slices(tensor_list)
if not tensor_list:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_index_input_producer(limit, num_epochs=None, seed=None,\n capacity=32, shared_name=None, name=None):\n with ops.op_scope([limit], name, \"input_producer\") as name:\n index_tensor = tf.random_uniform([limit], minval=0, maxval=limit, dtype=tf.int64, seed=seed)\n ... | [
"0.7482561",
"0.66467416",
"0.6395901",
"0.63573223",
"0.6236432",
"0.62344116",
"0.621293",
"0.56327856",
"0.5514279",
"0.5450747",
"0.54114723",
"0.5390393",
"0.5366445",
"0.53125083",
"0.53047395",
"0.5300707",
"0.5293415",
"0.5252793",
"0.5236909",
"0.52050155",
"0.520145... | 0.7959238 | 0 |
Set the order attr to the selected one. | def set_order(self, order):
self.order = order | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setOrder(self, order):\n\t\tself.orderInData = order",
"def order(self, order):\n self._order = order",
"def SetOrder(self, order):\n if self.__order != order:\n self.__order = order\n self.Modified()",
"def order(self, order):\n\n self._order = order",
"def o... | [
"0.7143052",
"0.70097286",
"0.69960636",
"0.6928143",
"0.6928143",
"0.6928143",
"0.6850993",
"0.6164734",
"0.61367893",
"0.6133654",
"0.6111504",
"0.59993577",
"0.59993577",
"0.5986225",
"0.5986225",
"0.5852736",
"0.5828744",
"0.57500434",
"0.5696392",
"0.56741315",
"0.564109... | 0.7511348 | 0 |
Gets the discriminator of this RecurrencePatternDto. | def discriminator(self) -> str:
return self.__class__.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discriminator(self) -> str:",
"def discriminator (self) -> tf.keras.Sequential:\n return self._discriminator",
"def discriminator(self) -> Any:\r\n return self._qda",
"def discriminator(self) -> Any:\r\n return self._lda",
"def discriminator(self) -> undefined.UndefinedOr[str]:",
"de... | [
"0.6453223",
"0.64276195",
"0.6355683",
"0.6312236",
"0.6309491",
"0.62741375",
"0.6186774",
"0.6178921",
"0.61462843",
"0.6067946",
"0.5821017",
"0.56907356",
"0.5532988",
"0.5486713",
"0.54712415",
"0.54712415",
"0.54712415",
"0.54712415",
"0.5469352",
"0.5446628",
"0.53888... | 0.71240664 | 0 |
Sets the discriminator of this RecurrencePatternDto. | def discriminator(self, discriminator: str):
pass # setter is ignored for discriminator property | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discriminator(self, images): # pylint: disable=R0201\n return standard_discriminator(images)",
"def discriminator(self) -> str:\n return self.__class__.__name__",
"def discriminator(self) -> str:",
"def discriminator (self) -> tf.keras.Sequential:\n return self._discriminator",
"def d... | [
"0.5866368",
"0.56900775",
"0.5577675",
"0.5529219",
"0.54537046",
"0.5423825",
"0.5362164",
"0.51858824",
"0.5153772",
"0.51449656",
"0.5103829",
"0.508909",
"0.50875735",
"0.50779355",
"0.5076143",
"0.5073615",
"0.5065901",
"0.4970589",
"0.49438852",
"0.488279",
"0.47471884... | 0.7696652 | 0 |
Returns True if the test object "obj" matches the prototype object "proto". If obj and proto are mappings, obj matches proto if (key in obj) and (obj[key] matches proto[key]) for every key in proto. If obj and proto are sequences, obj matches proto if they are of the same length and (a matches b) for every (a,b) in zip... | def matches(obj, proto):
if isinstance(obj, Mapping):
if not isinstance(proto, Mapping):
return False
return all((key in obj and matches(obj[key], val)) for key, val in proto.items())
if isinstance(obj, Sequence) and not isinstance(obj, str):
if not (isinstance(proto, Sequ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equals(self, obj):\n if obj == None:\n return False\n if not (isinstance(obj, (SentenceForm, ))):\n return False\n o = obj\n if self.__name__ != o.__name__:\n return False\n if self.getTupleSize() != o.getTupleSize():\n return False... | [
"0.5698699",
"0.5630985",
"0.539721",
"0.52875316",
"0.51983243",
"0.5193745",
"0.5188951",
"0.51687074",
"0.5071189",
"0.5066488",
"0.5043099",
"0.5028768",
"0.5018447",
"0.49935037",
"0.49558058",
"0.4921788",
"0.49159846",
"0.4899973",
"0.48826578",
"0.48544973",
"0.484786... | 0.82880807 | 0 |
Returns the test mapping "obj" after factoring out the items it has in common with the prototype mapping "proto". Consider a recursive merge operation, merge(a, b) on mappings a and b, that returns a mapping, m, whose keys are the union of the keys of a and b, and | def subkeys(obj, proto):
if not (isinstance(obj, Mapping) and isinstance(proto, Mapping)):
return obj
new_obj = {}
for key, value in obj.items():
if key not in proto:
new_obj[key] = value
continue
if matches(value, proto[key]) and matches(proto[key], value):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches(obj, proto):\n if isinstance(obj, Mapping):\n if not isinstance(proto, Mapping):\n return False\n\n return all((key in obj and matches(obj[key], val)) for key, val in proto.items())\n\n if isinstance(obj, Sequence) and not isinstance(obj, str):\n\n if not (isinstan... | [
"0.5256622",
"0.5186322",
"0.49844736",
"0.49193838",
"0.47653937",
"0.4669957",
"0.46696606",
"0.46444932",
"0.4550077",
"0.4536834",
"0.45043802",
"0.450001",
"0.44756943",
"0.44490245",
"0.44445476",
"0.4428748",
"0.442491",
"0.4419134",
"0.4414419",
"0.4387293",
"0.437227... | 0.6700285 | 0 |
Modifies the given object "yaml" so that it includes an "extends" key whose value features "key". If "extends" is not in yaml, then yaml is modified such that yaml["extends"] == key. If yaml["extends"] is a str, then yaml is modified such that yaml["extends"] == [yaml["extends"], key] If yaml["extends"] is a list that ... | def add_extends(yaml, key):
has_key = "extends" in yaml
extends = yaml.get("extends")
if has_key and not isinstance(extends, (str, Sequence)):
return
if extends is None:
yaml["extends"] = key
return
if isinstance(extends, str):
if extends != key:
yaml[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deep_extend(self):\n sdict = {\"bar\": {\"baz\": [1, 2]}}\n res = dictupdate.extend_dict_key_value(sdict, \"bar:baz\", [42, 42])\n self.assertEqual({\"bar\": {\"baz\": [1, 2, 42, 42]}}, res)\n\n # Extend a not-yet existing list\n res = dictupdate.extend_dict_key_value({}... | [
"0.5486271",
"0.5451538",
"0.5246947",
"0.5115644",
"0.49650216",
"0.4926991",
"0.49184754",
"0.4715134",
"0.4715134",
"0.46654904",
"0.46643496",
"0.46112788",
"0.46058592",
"0.4584441",
"0.45826346",
"0.45754874",
"0.4569336",
"0.4566999",
"0.45589757",
"0.45538986",
"0.455... | 0.8145743 | 0 |
Factor prototype object "sub" out of the values of mapping "yaml". | def common_subobject(yaml, sub):
match_list = set(k for k, v in yaml.items() if matches(v, sub))
if not match_list:
return yaml, None
common_prefix = ".c"
common_index = 0
while True:
common_key = "".join((common_prefix, str(common_index)))
if common_key not in yaml:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __construct(config, yml):\n\n for key in yml:\n if type(yml[key]) == dict:\n # create an object for the subsection\n klass = type(key, (), {})\n klass.__repr__ = repr_fx\n klass.__str__ = str_fx\n klass.__getitem__ = get_item_fx\n klas... | [
"0.5672593",
"0.56290704",
"0.5447974",
"0.5426063",
"0.5008521",
"0.49819303",
"0.49602154",
"0.49591035",
"0.49587813",
"0.4902017",
"0.48708162",
"0.48490623",
"0.48394424",
"0.48307833",
"0.48064047",
"0.4801588",
"0.47973585",
"0.47964248",
"0.47927532",
"0.47637695",
"0... | 0.64096737 | 0 |
Try applying an optimization pass and return information about the result "name" is a string describing the nature of the pass. If it is a nonempty string, summary statistics are also printed to stdout. "yaml" is the object to apply the pass to. "optimization_pass" is the function implementing the pass to be applied. "... | def try_optimization_pass(name, yaml, optimization_pass, *args, **kwargs):
result = optimization_pass(yaml, *args, **kwargs)
new_yaml, other_results = result[0], result[1:]
if new_yaml is yaml:
# pass was not applied
return (yaml, new_yaml, False, other_results)
pre_size = len(syaml.du... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Optimization(*args, **kwargs):\n from warnings import warn\n\n warn(\n \"Optimization has been renamed to OptimizationResult and will be removed as soon as v0.13.0\", DeprecationWarning\n )\n return OptimizationResult(*args, **kwargs)",
"def get_optimizer(name: str, **kwargs: Optional[Dict... | [
"0.51373553",
"0.48719892",
"0.48290378",
"0.4802629",
"0.47797635",
"0.47134107",
"0.4667771",
"0.46635738",
"0.45581153",
"0.4458564",
"0.4437545",
"0.4433735",
"0.44055456",
"0.44029266",
"0.43912202",
"0.43725234",
"0.43424857",
"0.43341213",
"0.42941284",
"0.4288936",
"0... | 0.82080066 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.