query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Returns all the current processes running | def get_all_current_processes():
p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
out, err = p.communicate()
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getActiveProcesses():\n active = []\n\n for p in PROCESSRUNNER_PROCESSES:\n if p.is_alive():\n active.append(p)\n\n return active",
"def get_running_processes(self):\n\n all_processes = []\n for _process in self.processes:\n all_processes.append(_process[\"... | [
"0.8456338",
"0.8348467",
"0.81814694",
"0.780856",
"0.75527126",
"0.73214626",
"0.7301836",
"0.72589177",
"0.71031713",
"0.70973146",
"0.7081394",
"0.70718044",
"0.7025768",
"0.7025768",
"0.70113343",
"0.6913096",
"0.68842685",
"0.684823",
"0.6841502",
"0.6802587",
"0.679586... | 0.87931204 | 0 |
Given a module name from a URL, obtain the handler function from it and return the function object. | def gethandlerfunc(modname):
try:
# Import the module
mod = __import__(modname)
except ImportError:
# No module with this name
raise404("Couldn't import module " + modname)
try:
# Find the handler function
handler = mod.handler
except AttributeError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_handler(url):\n for handler in __all__:\n # Get the symbol for handler\n mod = globals()[handler]\n # Ask handler if it can handle the url\n if getattr(mod, \"can_handle\")(url):\n return mod\n return None",
"def gethandlername(URL):\n match = re.search(\"... | [
"0.703652",
"0.67843664",
"0.5899618",
"0.58730614",
"0.5857758",
"0.5857758",
"0.5857758",
"0.58505243",
"0.58359313",
"0.580863",
"0.5804542",
"0.57574105",
"0.5730287",
"0.5711653",
"0.57108694",
"0.5693852",
"0.5678432",
"0.5673243",
"0.5655031",
"0.5647152",
"0.56082803"... | 0.78308606 | 0 |
Given a URL, find the handler module name | def gethandlername(URL):
match = re.search("/([a-zA-Z0-9_-]+)\.prog($|/|\?)", URL)
if not match:
# Couldn't find the requested module
raise404("Couldn't find a module name in URL " + URL)
return match.group(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_handler(url):\n for handler in __all__:\n # Get the symbol for handler\n mod = globals()[handler]\n # Ask handler if it can handle the url\n if getattr(mod, \"can_handle\")(url):\n return mod\n return None",
"def __extract_module_from_url(url):\n modul... | [
"0.7329028",
"0.6799866",
"0.6571339",
"0.65176964",
"0.64922774",
"0.62385327",
"0.62385327",
"0.61173797",
"0.5958094",
"0.58933336",
"0.5882599",
"0.5876819",
"0.5803288",
"0.58031505",
"0.5779282",
"0.57589215",
"0.5755825",
"0.57234514",
"0.57199085",
"0.5707681",
"0.568... | 0.835686 | 0 |
Determine the utilization rate of the aggregate prefix and return it as a percentage. | def get_utilization(self):
child_prefixes = Prefix.objects.filter(prefix__net_contained_or_equal=str(self.prefix))
# Remove overlapping prefixes from list of children
networks = cidr_merge([c.prefix for c in child_prefixes])
children_size = float(0)
for p in networks:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usage_percent(used, total, _round=None):\r\n try:\r\n ret = (used / total) * 100\r\n except ZeroDivisionError:\r\n ret = 0\r\n if _round is not None:\r\n return round(ret, _round)\r\n else:\r\n return ret",
"def percent_usage(value, total):\n if total:\n retu... | [
"0.62969273",
"0.6216252",
"0.61805874",
"0.6167256",
"0.6159693",
"0.6150952",
"0.61206144",
"0.61026776",
"0.60304207",
"0.60304207",
"0.60299826",
"0.60109663",
"0.5991576",
"0.5987215",
"0.5963927",
"0.5933034",
"0.5900829",
"0.5885009",
"0.5875576",
"0.58688074",
"0.5831... | 0.67332476 | 0 |
Iterate through a QuerySet of Prefixes and annotate the hierarchical level of each. While it would be preferable to do this using .extra() on the QuerySet to count the unique parents of each prefix, that approach introduces performance issues at scale. Because we're adding a nonfield attribute to the model, annotation ... | def annotate_depth(self, limit=None):
queryset = self
stack = []
for p in queryset:
try:
prev_p = stack[-1]
except IndexError:
prev_p = None
if prev_p is not None:
while (p.prefix not in prev_p.prefix) or p.prefi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebuild_prefixes(vrf):\n def contains(parent, child):\n return child in parent and child != parent\n\n def push_to_stack(prefix):\n # Increment child count on parent nodes\n for n in stack:\n n['children'] += 1\n stack.append({\n 'pk': [prefix['pk']],\n ... | [
"0.5682173",
"0.5620707",
"0.52825505",
"0.51227534",
"0.5075723",
"0.50714594",
"0.5029576",
"0.5010874",
"0.49602807",
"0.49544492",
"0.49525705",
"0.4912911",
"0.49022633",
"0.48917243",
"0.4878467",
"0.4842337",
"0.48361942",
"0.4820922",
"0.48130736",
"0.4796515",
"0.478... | 0.5933673 | 0 |
Each time a record or the zone is modified, the serial is incremented. | def update_serial(self):
current_date = time.strftime('%Y%m%d', time.localtime())
if not self.soa_serial:
self.soa_serial = current_date + '01'
else:
serial_date = self.soa_serial[:8]
serial_num = self.soa_serial[8:]
if serial_date != current_date... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_seqnoincrease(self):",
"def update_soa(record):\n if record and record.domain and record.domain.soa:\n record.domain.soa.serial += 1\n record.domain.soa.dirty = True\n record.domain.soa.save()",
"def updateCounter(self):\n self.counter = self.counter + 1\n self.sy... | [
"0.66880107",
"0.6164748",
"0.60421455",
"0.60311395",
"0.5971428",
"0.58435035",
"0.5806637",
"0.5700466",
"0.5664041",
"0.5663809",
"0.5650433",
"0.5644291",
"0.55386907",
"0.552171",
"0.5513814",
"0.5507396",
"0.547886",
"0.54493624",
"0.54472667",
"0.5414568",
"0.54057187... | 0.64695793 | 1 |
By default, PostgreSQL will order INETs with shorter (larger) prefix lengths ahead of those with longer (smaller) masks. This makes no sense when ordering IPs, which should be ordered solely by family and host address. We can use HOST() to extract just the host portion of the address (ignoring its mask), but we must th... | def get_queryset(self):
qs = super(IPAddressManager, self).get_queryset()
return qs.annotate(host=RawSQL('INET(HOST(ipam_ipaddress.address))', [])).order_by('family', 'host') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_ip(ip):\n if \".\" in ip:\n return (int(ip.split(\"/\")[1] or \"0\"),\n int(ip.split(\"/\")[0].split(\".\")[0]),\n int(ip.split(\"/\")[0].split(\".\")[1]),\n int(ip.split(\"/\")[0].split(\".\")[2]),\n int(ip.split(\"/\")[0].split(\".\")... | [
"0.6319297",
"0.58167803",
"0.5814441",
"0.5797147",
"0.56700313",
"0.5613662",
"0.5600801",
"0.5575775",
"0.5550464",
"0.55437094",
"0.5528353",
"0.55149114",
"0.54637724",
"0.54330945",
"0.5394444",
"0.5389342",
"0.5371418",
"0.53696537",
"0.5367245",
"0.5361503",
"0.533072... | 0.6582377 | 0 |
Autocreate a corresponding A/AAAA DNS record (if possible) whenever the PTR field is modified | def update_dns(self):
if self.ptr:
which_zone = None
zones = dns.models.Zone.objects.all()
for zone in zones:
if self.ptr.endswith(zone.name) or self.ptr.endswith(zone.name + '.'):
which_zone = zone
break
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_dns_atype ( route53_conn, dns_name, atype_value ) :\n r53 = boto.route53.record.ResourceRecordSets( route53_conn, route_53_hosted_zoneid )\n monitor_dns = r53.add_change( 'UPSERT', dns_name, 'A', ttl=60 )\n monitor_dns.add_value( atype_value )\n r53.commit( )",
"def test_updatednsrecord(kasserver... | [
"0.6175719",
"0.6069661",
"0.60505503",
"0.6043105",
"0.60109985",
"0.59973186",
"0.5895656",
"0.5868057",
"0.5690527",
"0.56834763",
"0.56530905",
"0.56523496",
"0.5632768",
"0.5625833",
"0.5624635",
"0.5618774",
"0.5581644",
"0.5570107",
"0.5546243",
"0.5546115",
"0.5522549... | 0.71578366 | 0 |
Parses lexicon into valid rewrite rules. | def _get_lexicon_rules(lexicon_dir: str) -> _RewriteRuleSet:
def _read_rule_set(path: str) -> _RewriteRule:
logging.info(f"reading rewrite rules from '{path}'")
entries = lexicon_reader.read_lexicon_entries(path) # might throw IOError.
for index, entry in entries.items():
try:
lexicon_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_rules_and_lexicon(self):\n\n # Get a function that will split words into morphemes\n morpheme_splitter = self.morpheme_splitter\n # Get the unique morphemes from the lexicon corpus\n morphemes = {}\n if (self.lexicon_corpus and\n (not self.rules_corpus or... | [
"0.56139296",
"0.5591229",
"0.5527879",
"0.54040474",
"0.5386398",
"0.52106386",
"0.51804394",
"0.5177677",
"0.51449215",
"0.51025224",
"0.504116",
"0.49598598",
"0.49496937",
"0.49448723",
"0.4906003",
"0.4897008",
"0.4895634",
"0.48914123",
"0.48295358",
"0.48112032",
"0.47... | 0.64983183 | 0 |
Parses morphotactics model into valid rewrite rules. | def _get_morphotactics_rules(morphotactics_dir: str) -> _RewriteRuleSet:
def _read_rule_set(path: str) -> _RewriteRule:
logging.info(f"reading rewrite rules from '{path}'")
# Below read call might throw IOError.
lines = morphotactics_reader.read_rule_definitions(path)
for index, line in lines.items(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_from_morph_rules(\n self, morph_rules: Dict[str, Dict[str, Dict[Union[int, str], Union[int, str]]]]\n ) -> None:\n for tag in morph_rules:\n for word in morph_rules[tag]:\n pattern = [{\"ORTH\": word, \"TAG\": tag}]\n attrs = morph_rules[tag][word]... | [
"0.5840182",
"0.55535984",
"0.51799554",
"0.5069606",
"0.5051608",
"0.50513303",
"0.49753022",
"0.49660093",
"0.49515072",
"0.4919437",
"0.48867586",
"0.48522",
"0.48373777",
"0.4799141",
"0.47971752",
"0.47930145",
"0.4788843",
"0.4775847",
"0.47617608",
"0.47600308",
"0.474... | 0.5980429 | 0 |
Removes duplicate rewrite rules objects that are in the rule set. This function preserves the order of the rewrite rules in the rule set and does deduplication inplace by just keeping the last occurrence of a duplicate rule. | def _remove_duplicate_rules(rule_set: _RewriteRuleSet) -> None:
RuleKey = Tuple[str, str, str, str]
def _key_and_value(rule: _RewriteRule) -> Tuple[RuleKey, _RewriteRule]:
return (rule.from_state, rule.to_state, rule.input, rule.output), rule
inverted = collections.OrderedDict(map(_key_and_value, rule_set.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_duplicated_links (self):\n # Collect backward links\n backwards = [(src, dst, key) for src, dst, key, link in\n self.network.edges_iter(keys=True, data=True) if (\n link.type == Link.STATIC or link.type == Link.DYNAMIC) and\n link.backward is True]\... | [
"0.6079783",
"0.5707271",
"0.5631043",
"0.5405995",
"0.5405514",
"0.536701",
"0.53547156",
"0.5305289",
"0.52767164",
"0.52653193",
"0.52208674",
"0.5214076",
"0.5193104",
"0.5186206",
"0.51850516",
"0.5170991",
"0.5167085",
"0.51482874",
"0.51319295",
"0.5107508",
"0.5105704... | 0.8605161 | 0 |
Extracts FST symbols that compose complex input label of the rewrite rule. FST symbols of a complex input label is; Epsilon symbol if the complex input label is an epsilon symbol (e.g. [''] for label ''). Digits of the complex input label if it is only composed of digits without any feature analysis tags (e.g. ['9', '0... | def _symbols_of_input(label: str) -> List[str]:
if label == common.EPSILON:
return [label]
# We add a state transition arc for each digit of a multi-digit number.
if "[" not in label:
return list(label)
# We add a state transition arc for each inflectional or derivational
# morpheme, inflectional gr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transform_compound(self, compound):\n assert isinstance(compound, str), \"Input is not a string!\"\n cmpd_features = np.array(compound_short_descriptors(compound),\n dtype=np.float)\n cmpd_features = np.pad(cmpd_features, (0, 80-cmpd_features.shape[0]),\n ... | [
"0.52776694",
"0.49526072",
"0.49122655",
"0.48906052",
"0.4840586",
"0.48198035",
"0.47981805",
"0.47640973",
"0.46877915",
"0.46727678",
"0.46708876",
"0.4634626",
"0.46228975",
"0.46164334",
"0.45988402",
"0.4594093",
"0.45656273",
"0.45655215",
"0.4559517",
"0.45564628",
... | 0.59415656 | 0 |
Extracts FST symbols that compose complex output label of the rewrite rule. FST symbols of a complex output label is; Epsilon symbol if the complex output label is an epsilon symbol (e.g. [''] for the label ''). All characters of the complex output label if it is not an epsilon symbol (e.g. ['{', 'l', 'p'] for the labe... | def _symbols_of_output(label: str) -> List[str]:
if label == common.EPSILON:
return [label]
# We add a new state transition arc for each character of the output token.
return list(label) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _symbols_of_input(label: str) -> List[str]:\n if label == common.EPSILON:\n return [label]\n\n # We add a state transition arc for each digit of a multi-digit number.\n if \"[\" not in label:\n return list(label)\n\n # We add a state transition arc for each inflectional or derivational\n # morpheme,... | [
"0.5881027",
"0.53526294",
"0.53450996",
"0.5294573",
"0.50718004",
"0.50265986",
"0.50232095",
"0.5006316",
"0.49348602",
"0.4923187",
"0.4909728",
"0.48874924",
"0.4883918",
"0.48639122",
"0.4845914",
"0.48448756",
"0.4844453",
"0.48414075",
"0.4839914",
"0.4830731",
"0.481... | 0.6123915 | 0 |
r"""Generates the content of the complex symbols table file. Generated file is in AT&T format. It defines the labels for state transition arcs and assigns a unique index to each. The first label in the file get the index 983040 (decimal value for the beginning of the Unicode private use area). Successive labels have in... | def _symbols_table_file_content(
rule_set: _RewriteRuleSet) -> Generator[str, None, None]:
def _line(symbol: str, index: int) -> str:
return f"{symbol}\t{index}\n"
fst_symbols = []
for rule in rule_set.rule:
fst_symbols.extend(_symbols_of_input(rule.input))
fst_symbols.extend(_symbols_of_output... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\n # First, just allocate enough memory for the SDAT header.\n data = bytearray(0x40)\n\n # -------------------\n # Make the SYMB block\n\n symbolsStringTable = bytearray()\n def addSymbolAndGetOffset(symbol):\n if symbol is None:\n ... | [
"0.5849805",
"0.5413301",
"0.53558016",
"0.5234502",
"0.5228045",
"0.51632726",
"0.5125793",
"0.5085775",
"0.50833756",
"0.5082366",
"0.5081895",
"0.5077303",
"0.50645727",
"0.5060005",
"0.50593895",
"0.5053085",
"0.5021432",
"0.50182503",
"0.50168055",
"0.49868885",
"0.49842... | 0.66138935 | 0 |
r"""Generates the content of the text FST file. Generated file is in AT&T format. It defines the state transition arcs and input/output label pairs of the morphotactics model. | def _text_fst_file_content(
rule_set: _RewriteRuleSet) -> Generator[str, None, None]:
class _Local:
state_count = 0
def _new_state_index() -> int:
_Local.state_count += 1
return _Local.state_count
def arc(from_: str,
to: str,
input_: str = common.EPSILON,
output: s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_flow_txt(self):\r\n flow_fp = os.path.join(self.sff_dir, 'test.txt')\r\n flow_gz_fp = os.path.join(self.gz_sff_dir, 'test_gz.txt')\r\n make_flow_txt(self.sff_fp, flow_fp)\r\n make_flow_txt(self.sff_gz_fp, flow_gz_fp)\r\n self.assertEqual(open(flow_fp).read(), flow_t... | [
"0.6127326",
"0.6039715",
"0.59984165",
"0.58013976",
"0.578428",
"0.57156134",
"0.5675818",
"0.5628369",
"0.557599",
"0.5498544",
"0.5491181",
"0.5416907",
"0.5413934",
"0.5403777",
"0.53988117",
"0.5386455",
"0.5377619",
"0.5375378",
"0.5355942",
"0.535454",
"0.53346777",
... | 0.68856895 | 0 |
Makes the output directory if it does not exist. | def _make_output_directory(output_dir: str) -> None:
if output_dir and not os.path.exists(output_dir):
os.makedirs(output_dir)
logging.info(f"output directory does not exist, made '{output_dir}'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_output_directory(self):\n fs = self._filesystem\n output_filename = fs.join(self._root_output_dir, self._test_name)\n fs.maybe_make_directory(fs.dirname(output_filename))",
"def _make_output_dir(self):\n out_dir = os.path.dirname(self._out_format)\n if not os.path.exi... | [
"0.83254516",
"0.82470155",
"0.7971942",
"0.79512066",
"0.7879319",
"0.7845083",
"0.772621",
"0.77161586",
"0.7657744",
"0.7641563",
"0.74298275",
"0.74211967",
"0.7351358",
"0.7329179",
"0.73192096",
"0.7261498",
"0.7255115",
"0.7237214",
"0.71339095",
"0.71255136",
"0.71160... | 0.8270133 | 1 |
r"""Writes the file content to the output path as a text file. | def _write_file(output_path: str, file_content: Iterable[str]) -> None:
with open(output_path, "w+", encoding="utf-8") as f:
f.writelines(file_content)
logging.info(f"wrote to '{output_path}'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fileWrite(content):\n file = open('./result.txt', 'w')\n file.write(content)\n file.close()",
"def write_text_tofile(text):\n try:\n with open(os.path.join(script_dir, 'output_file.txt'), 'a') as output:\n output.write(text + '\\n')\n except:\n pass",
"def write_to_f... | [
"0.7704573",
"0.7301734",
"0.72312963",
"0.71394956",
"0.7093242",
"0.69964176",
"0.6989156",
"0.69638515",
"0.6942887",
"0.6878225",
"0.68769836",
"0.6869035",
"0.6862951",
"0.68133956",
"0.6745909",
"0.6725797",
"0.670779",
"0.6668074",
"0.6640407",
"0.6637989",
"0.6637467"... | 0.73362166 | 1 |
Return the canonical path to /etc/rc.local or an equivalent shell script that gets executed during boot up. The last component in the path must not be be a symlink, other components may be. | def _get_rc_local_path( self ):
# might be a symlink but prepend_remote_shell_script doesn't work with symlinks
return sudo( 'readlink -f /etc/rc.local' ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launcher_path() -> Optional[str]:\n return u.resource(LAUNCHER_SCRIPT)",
"def executable_path(self):\n prepend = self._active_environment(ActiveEnvironment).prepend\n return prepend.get(\"PATH\", \"\")",
"def determine_usr_bin():\n if git_install_requested():\n projects_yaml = conf... | [
"0.6142366",
"0.61250097",
"0.6099698",
"0.6046178",
"0.6010571",
"0.6000824",
"0.59402305",
"0.5883539",
"0.58717144",
"0.58534086",
"0.58243835",
"0.58120936",
"0.57910746",
"0.57867146",
"0.5785221",
"0.5725474",
"0.57024145",
"0.56905836",
"0.5689721",
"0.56822443",
"0.56... | 0.80080163 | 0 |
Insert the given script into the remote file at the given path before the first script line. See prepend_shell_script() for a definition of script line. | def _prepend_remote_shell_script( self, script, remote_path, **put_kwargs ):
with closing( StringIO( ) ) as out_file:
with closing( StringIO( ) ) as in_file:
get( remote_path=remote_path, local_path=in_file )
in_file.seek( 0 )
prepend_shell_script( '\n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_start_script_tmp_sh(tmp_path: Path) -> Path:\n tmp_file = tmp_path / \"prestart.sh\"\n with open(Path(tmp_file), \"x\") as f:\n f.write('echo \"Hello World, from a temporary pre-start shell script\"\\n')\n return Path(tmp_file)",
"def insert(self, line, where=0):\n self.buffer.inse... | [
"0.5698845",
"0.5542687",
"0.5500571",
"0.54082674",
"0.528102",
"0.52535087",
"0.52462095",
"0.5182523",
"0.5134501",
"0.507421",
"0.50361365",
"0.5027348",
"0.50166833",
"0.49855557",
"0.49790967",
"0.4978083",
"0.49382308",
"0.49119568",
"0.48901075",
"0.48578307",
"0.4856... | 0.827533 | 0 |
r""" Patch /etc/environment by A) adding a list of directories to a PATH o PATHlike variable and/or B) adding other environment variables to it. | def _patch_etc_environment( cls, env_file, dirs=None, dirs_var='PATH', env_pairs=None ):
def parse_entry( s ):
m = cls.env_entry_re.match( s )
return m.group( 1 ), m.group( 2 )
env_file.seek( 0 )
env = dict( parse_entry( _ ) for _ in env_file.read( ).splitlines( ) )
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_env(self, path, value):\n name = [MakeEnvironArgs.CONFIG]\n for element in path:\n name.append(MakeEnvironArgs.DOT)\n name.append(element)\n self.env[''.join(name)] = value\n return self.env",
"def setUpEnvironmentVariables(basedir):\n\tif sys.platform... | [
"0.67909825",
"0.65598273",
"0.6248789",
"0.62381274",
"0.61344135",
"0.61076623",
"0.6048537",
"0.60125136",
"0.5980316",
"0.5967851",
"0.58665335",
"0.5862674",
"0.5858224",
"0.5845886",
"0.5845145",
"0.58326834",
"0.58200264",
"0.58082944",
"0.580371",
"0.5799828",
"0.5742... | 0.7579833 | 0 |
Dependencies are expressed as a dictionary whose keys are items and whose values are a set of dependent items. Output is a list of sets in topological order. The first set consists of items with no dependences, each subsequent set consists of items that depend upon items in the preceeding sets. >>> toposort2({ | def toposort2( data ):
from functools import reduce
# Ignore self dependencies.
for k, v in data.items( ):
v.discard( k )
# Find all items that don't depend on anything.
extra_items_in_deps = reduce( set.union, data.itervalues( ) ) - set( data.iterkeys( ) )
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topological_sort(deps: Dict[str, Set[str]]) -> List[str]:\n # TODO: implement cycle detection\n # Let's make a deep copy of the dictionary, so that we are a good citizen and don't\n # modify the parameter\n deps = {k: set(v) for k, v in deps.items()}\n flat: List[str] = []\n while deps:\n ... | [
"0.7946563",
"0.7501466",
"0.7435545",
"0.7102352",
"0.69701874",
"0.69135773",
"0.68873614",
"0.6655312",
"0.6642737",
"0.6591969",
"0.65904367",
"0.6499221",
"0.6433072",
"0.64172924",
"0.63997835",
"0.63847566",
"0.63627267",
"0.6321794",
"0.62746567",
"0.6258455",
"0.6251... | 0.77973616 | 1 |
[if cond form] ([else form]) | def special_if(self, form):
testforms = [form[1:]]
elseform = None
startIndex = None
parent = form.up()
for i in range(len(parent)):
x = parent[i]
if x is form:
startIndex = i
if startIndex is None:
raise RuntimeErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _IfExp(self, t):\n self.dispatch(t.test)\n self.write(\" ? \")\n self.dispatch(t.body)\n self.write(\" : \")\n self.dispatch(t.orelse)",
"def conditional(self) -> global___Statement.Conditional:",
"def switch(cond, ift, iff):",
"def ifelse(test, if_true, if_false):\n ... | [
"0.6044314",
"0.5981861",
"0.5975344",
"0.5948368",
"0.58330333",
"0.56861645",
"0.56861645",
"0.56803143",
"0.56476486",
"0.56476486",
"0.56476486",
"0.56476486",
"0.56255823",
"0.5613256",
"0.5593953",
"0.557144",
"0.5535713",
"0.5535713",
"0.54777485",
"0.54220575",
"0.541... | 0.6206543 | 0 |
Lambda function that runs on cloudformation create. It populates the metrics definition table with information about each metric. | def lambda_handler(event, context):
ddb_client = boto3.resource('dynamodb')
table = ddb_client.Table(os.environ['METRICSDEF_TABLE'])
metrics_def = SettingsDefinition()
#This just gets a list of funcs in SettingsDefinition via tuples.
function_list = inspect.getmembers(metrics_def, predicate=ins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_metrics():\n all = monitor_client.list_metric_descriptors(\n project_path, filter_='metric.type=starts_with(\"custom.\")'\n )\n for a in all:\n if \"accumulator\" in str(a) or \"biquery\" in str(a):\n metric_name = monitor_client.metric_descriptor_path(\n ... | [
"0.62973464",
"0.6232039",
"0.58734256",
"0.5825737",
"0.57151",
"0.5661247",
"0.5646527",
"0.5569144",
"0.55343616",
"0.55289",
"0.5513814",
"0.5499376",
"0.54892343",
"0.54830444",
"0.54804415",
"0.54654485",
"0.5418523",
"0.54166085",
"0.5406935",
"0.5386698",
"0.53412855"... | 0.7163048 | 0 |
Get the Redis password from the configuration | def redis_pwd():
with open("/etc/redis/redis.conf") as fd:
secret_cfg = fd.read().splitlines()
for line in secret_cfg:
line = line.strip()
if line.startswith("requirepass"):
return line.split(" ")[1].strip()
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_password(self) -> str:\n try:\n return self[\"password\"]\n except KeyError:\n raise MarathonNotConfigured(\n \"Could not find marathon password in system marathon config\"\n )",
"def password(self) -> str:\n return pulumi.get(self, \"p... | [
"0.7542461",
"0.7292464",
"0.7292464",
"0.7292464",
"0.716412",
"0.7142628",
"0.71423846",
"0.71384716",
"0.70613617",
"0.70174724",
"0.70174724",
"0.70080954",
"0.69805366",
"0.6949162",
"0.693224",
"0.69274074",
"0.689853",
"0.68978876",
"0.6888722",
"0.6888722",
"0.6888722... | 0.7801456 | 0 |
Checks if the current device of `device_mesh` supports DTensor's random APIs. Currently DTensor Random APIs only supports cuda/cudalike devices. We suggest users call this API to test the availability before using our random APIs. | def is_rng_supported_mesh(device_mesh: DeviceMesh) -> bool:
device_handle = _get_device_handle(device_mesh.device_type)
if device_handle and hasattr(device_handle, "set_rng_state"):
return True
else:
warnings.warn(
f"DTensor random operators may not have complete support on {devi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gpu_availability():\n # assume if using tensorflow-gpu, then Nvidia GPU is available\n if is_built_with_cuda():\n return len(tf.config.list_physical_devices(\"GPU\")) > 0\n else:\n return False",
"def detect_available():\n global _CUDA_AVAILABLE\n if _CUDA_AVAILABLE is not None: ... | [
"0.584912",
"0.58147293",
"0.57266724",
"0.55685794",
"0.5564945",
"0.54525566",
"0.5374313",
"0.53115326",
"0.52874994",
"0.52724636",
"0.5206334",
"0.51691324",
"0.5138846",
"0.5133226",
"0.5077793",
"0.506437",
"0.50338316",
"0.50119895",
"0.5010054",
"0.5010054",
"0.50036... | 0.8336198 | 0 |
Set the starting RNG offset for current device's local shard before actual op execution. The pre_op_offset value should start from the current RNG offset and increment by the size of local shard until it reaches the size of the whole DTensor. For different ranks that hold the same DTensor shard, their pre_op_offset wil... | def _set_pre_op_offset(self, spec: DTensorSpec) -> None:
dtensor_shape = spec.shape
mesh = spec.mesh
dim_map = spec.dim_map
# Compute shard coordinate:
# The coordinate on each tensor dim is a tuple (idx, range)
# If a DTensor is partitioned on its dim i into n shards, a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_post_op_offset(self, spec: DTensorSpec, old_offset: int) -> None:\n dtensor_shape = spec.shape\n\n from torch.distributed._tensor.ops.utils import prod\n\n numel = prod(dtensor_shape)\n # pytorch: offset must be multiple of 4\n # source: aten/src/ATen/cuda/CUDAGeneratorI... | [
"0.6240967",
"0.5669493",
"0.5669493",
"0.5669493",
"0.54019994",
"0.53623265",
"0.5219316",
"0.521635",
"0.5167405",
"0.50177777",
"0.49872008",
"0.4977033",
"0.49528822",
"0.49195656",
"0.49027094",
"0.48578644",
"0.4843479",
"0.48360705",
"0.48027",
"0.47935167",
"0.478323... | 0.8119143 | 0 |
Create a mapping from binomial terms to abbreviated binomials. | def abbreviate_binomials(binomials: list[dict], single_expanded_name=True):
abbrevs = defaultdict(set)
for term in binomials:
pattern = term["pattern"]
abbrev = abbreviate(pattern)
abbrevs[abbrev].add(pattern.split()[0])
if single_expanded_name:
abbrevs = {k: v.pop().title(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word2vec_mapping_func():\n return {\"belonging to\": \"belonging\", \"parked on\": \"parked\", \"growing on\": \"growing\", \"standing on\": \"standing\",\n \"made of\": \"made\", \"attached to\": \"attached\", \"hanging from\": \"hanging\", \"in front of\": \"front\",\n \"lying on\": ... | [
"0.596231",
"0.56996095",
"0.56565887",
"0.56336045",
"0.56131876",
"0.5507035",
"0.5407744",
"0.5394013",
"0.5345998",
"0.5345086",
"0.5334324",
"0.53331065",
"0.53101665",
"0.5308835",
"0.52683884",
"0.52648175",
"0.5257812",
"0.5256144",
"0.52431834",
"0.5231941",
"0.52281... | 0.7119786 | 0 |
Constructor. Instantiating an updater object causes all the metadata files for the toplevel roles to be read from disk, including the key and role information for the delegated targets of 'targets'. The actual metadata for delegated roles is not loaded in __init__. The metadata for these delegated roles, including nest... | def __init__(self, updater_name, repository_mirrors):
# Do the arguments have the correct format?
# These checks ensure the arguments have the appropriate
# number of objects and object types and that all dict
# keys are properly named.
# Raise 'tuf.FormatError' if there is a mistmatch.
tuf.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _refresh_targets_metadata(self, rolename='targets', include_delegations=False):\n\n roles_to_update = []\n\n # See if this role provides metadata and, if we're including\n # delegations, look for metadata from delegated roles.\n role_prefix = rolename + '/'\n for metadata_path in self.metadata['... | [
"0.67134696",
"0.58107144",
"0.57709205",
"0.5663369",
"0.56254727",
"0.5605019",
"0.560434",
"0.5399462",
"0.5245718",
"0.52128386",
"0.5182947",
"0.5175609",
"0.516285",
"0.5137553",
"0.5126536",
"0.5122762",
"0.5112088",
"0.5105605",
"0.5076615",
"0.5076116",
"0.50703824",... | 0.67343026 | 0 |
Load current or previous metadata if there is a local file. If the expected file belonging to 'metadata_role' (e.g., 'root.txt') cannot be loaded, raise an exception. The extracted metadata object loaded from file is saved to the metadata store (i.e., self.metadata). | def _load_metadata_from_file(self, metadata_set, metadata_role):
# Ensure we have a valid metadata set.
if metadata_set not in ['current', 'previous']:
raise tuf.Error('Invalid metadata set: '+repr(metadata_set))
# Save and construct the full metadata path.
metadata_directory = self.metadata_dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load(self) -> None:\n try:\n self._logger.debug('Load metafile %s.', self._path)\n with codecs.open(self._path, 'r', 'utf-8') as ff:\n self._data = json.load(ff)\n # TODO Validate Meta Dict\n except OSError as ex:\n msg = 'Unable to ... | [
"0.6726712",
"0.66560674",
"0.61084676",
"0.60199374",
"0.59750575",
"0.5961096",
"0.59146667",
"0.57406485",
"0.5625859",
"0.56245166",
"0.5618372",
"0.55644155",
"0.55479753",
"0.551915",
"0.5503802",
"0.5485509",
"0.54633296",
"0.5457984",
"0.5455698",
"0.5450701",
"0.5427... | 0.74305725 | 0 |
Rebuild the key and role databases from the currently trusted 'root' metadata object extracted from 'root.txt'. This private function is called when a new/updated 'root' metadata file is loaded. This function will only store the role information for the toplevel roles (i.e., 'root', 'targets', 'release', 'timestamp'). ... | def _rebuild_key_and_role_db(self):
# Clobbering this means all delegated metadata files are rendered outdated
# and will need to be reloaded. However, reloading the delegated metadata
# files is avoided here because fetching target information with methods
# like all_targets() and target() always... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self):\n self.root = self._load()\n\n if self.ignore_case_in_keys:\n self.root = self._convert_keys_to_lower(self.root)",
"def refresh(self):\n\n # The timestamp role does not have signed metadata about it; otherwise we\n # would need an infinite regress of metadata. There... | [
"0.5743582",
"0.56385076",
"0.53721976",
"0.51468635",
"0.5134066",
"0.5078618",
"0.50034493",
"0.49979895",
"0.49948904",
"0.49779555",
"0.4950957",
"0.49308586",
"0.49201196",
"0.48425183",
"0.4825396",
"0.47523007",
"0.473874",
"0.47370243",
"0.47205967",
"0.47127837",
"0.... | 0.731258 | 0 |
Import all the roles delegated by 'parent_role'. | def _import_delegations(self, parent_role):
current_parent_metadata = self.metadata['current'][parent_role]
if 'delegations' not in current_parent_metadata:
return
# This could be quite slow with a huge number of delegations.
keys_info = current_parent_metadata['delegations'].get('key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parents(cls):\n return db.relationship(ext.role_model, secondary='role_links',\n primaryjoin=f\"RoleLink.role_id==%s.{ext.role_pk}\" % cls.__name__,\n secondaryjoin=f\"RoleLink.parent_id==%s.{ext.role_pk}\" % cls.__name__,\n ... | [
"0.5542862",
"0.5484064",
"0.53176576",
"0.52519345",
"0.5243283",
"0.5170428",
"0.5165677",
"0.51483893",
"0.5015461",
"0.50147766",
"0.5009216",
"0.49793363",
"0.49722782",
"0.49593183",
"0.4957792",
"0.49368262",
"0.49309275",
"0.48666155",
"0.4833351",
"0.48196456",
"0.47... | 0.73602885 | 0 |
Update the latest copies of the metadata for the toplevel roles. The update request process follows a specific order to ensure the metadata files are securely updated. The client would call refresh() prior to requesting target file information. Calling refresh() ensures target methods, like all_targets() and target(), ... | def refresh(self):
# The timestamp role does not have signed metadata about it; otherwise we
# would need an infinite regress of metadata. Therefore, we use some
# default, sane metadata about it.
DEFAULT_TIMESTAMP_FILEINFO = {
'hashes':None,
'length': tuf.conf.DEFAULT_TIMESTAMP_REQUIRED_LE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _refresh_targets_metadata(self, rolename='targets', include_delegations=False):\n\n roles_to_update = []\n\n # See if this role provides metadata and, if we're including\n # delegations, look for metadata from delegated roles.\n role_prefix = rolename + '/'\n for metadata_path in self.metadata['... | [
"0.70679146",
"0.5714709",
"0.5503326",
"0.54583365",
"0.54566574",
"0.54549015",
"0.5347425",
"0.52819204",
"0.52689433",
"0.5257534",
"0.5254578",
"0.52315694",
"0.52265584",
"0.5155415",
"0.5107273",
"0.5079031",
"0.5068169",
"0.5066787",
"0.5056151",
"0.5014376",
"0.49083... | 0.73300976 | 0 |
A helper function that verifies multiple secure hashes of the downloaded file. If any of these fail it raises an exception. This is to conform with the TUF specs, which support clients with different hashing algorithms. The 'hash.py' module is used to compute the hashes of the 'file_object'. | def __check_hashes(self, file_object, trusted_hashes):
# Verify each trusted hash of 'trusted_hashes'. Raise exception if
# any of the hashes are incorrect and return if all are correct.
for algorithm, trusted_hash in trusted_hashes.items():
digest_object = tuf.hash.digest(algorithm)
digest_ob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CheckHashes(self, hashes):\n hash_map = {}\n for hsh in hashes:\n if hsh.HasField(\"sha256\"):\n # The canonical name of the file is where we store the file hash.\n digest = hsh.sha256\n hash_map[aff4.ROOT_URN.Add(\"files/hash/generic/sha256\").Add(\n str(digest))] = ... | [
"0.68194133",
"0.68004715",
"0.6736972",
"0.66865826",
"0.65869343",
"0.6368939",
"0.6293834",
"0.62324214",
"0.6138452",
"0.6136976",
"0.6094988",
"0.59902525",
"0.5987892",
"0.5987892",
"0.597661",
"0.59442955",
"0.5934656",
"0.59294504",
"0.5914992",
"0.5909823",
"0.587612... | 0.7769532 | 0 |
A helper function that checks the expected compressed length of a filelike object. The length of the file must be strictly equal to the expected length. This is a deliberately redundant implementation designed to complement tuf.download._check_downloaded_length(). | def __hard_check_compressed_file_length(self, file_object,
compressed_file_length):
observed_length = file_object.get_compressed_length()
if observed_length != compressed_file_length:
raise tuf.DownloadLengthMismatchError(compressed_file_length,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __soft_check_compressed_file_length(self, file_object,\n compressed_file_length):\n\n observed_length = file_object.get_compressed_length()\n if observed_length > compressed_file_length:\n raise tuf.DownloadLengthMismatchError(compressed_file_length,\n ... | [
"0.8020666",
"0.69070154",
"0.62786996",
"0.6147197",
"0.6046355",
"0.58408123",
"0.58013856",
"0.5790666",
"0.5770636",
"0.5769222",
"0.5685216",
"0.56598413",
"0.5642787",
"0.5641548",
"0.56404966",
"0.56370836",
"0.5596607",
"0.5533528",
"0.5476115",
"0.5465439",
"0.546344... | 0.808241 | 0 |
A helper function that checks the expected compressed length of a filelike object. The length of the file must be less than or equal to the expected length. This is a deliberately redundant implementation designed to complement tuf.download._check_downloaded_length(). | def __soft_check_compressed_file_length(self, file_object,
compressed_file_length):
observed_length = file_object.get_compressed_length()
if observed_length > compressed_file_length:
raise tuf.DownloadLengthMismatchError(compressed_file_length,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __hard_check_compressed_file_length(self, file_object,\n compressed_file_length):\n\n observed_length = file_object.get_compressed_length()\n if observed_length != compressed_file_length:\n raise tuf.DownloadLengthMismatchError(compressed_file_length,\n ... | [
"0.80448043",
"0.7002057",
"0.6431012",
"0.62423784",
"0.6030527",
"0.59850883",
"0.5954853",
"0.58445287",
"0.5809482",
"0.5691129",
"0.56652397",
"0.5663412",
"0.56330484",
"0.5626236",
"0.55908865",
"0.5584143",
"0.5577502",
"0.5576237",
"0.5566866",
"0.55355495",
"0.55064... | 0.8079612 | 0 |
A private helper function to verify an uncompressed downloaded metadata file. | def __verify_uncompressed_metadata_file(self, metadata_file_object,
metadata_role):
metadata = metadata_file_object.read()
try:
metadata_signable = tuf.util.load_json_string(metadata)
except Exception, exception:
raise tuf.InvalidMetadataJSONError(excep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ValidateCacheFileMetadataHeader(self, cache_file_metadata_header):\n return (cache_file_metadata_header.key_size > 0 and\n cache_file_metadata_header.key_size < self._MAXIMUM_URL_LENGTH and\n cache_file_metadata_header.format_version in (1, 2, 3) and\n cache_file_metadata_h... | [
"0.65709776",
"0.63994855",
"0.6376387",
"0.63114023",
"0.6262165",
"0.6249125",
"0.623439",
"0.6172689",
"0.61573446",
"0.61059684",
"0.6089557",
"0.6085965",
"0.60393137",
"0.6024993",
"0.60169613",
"0.60069674",
"0.5968942",
"0.5944426",
"0.5941978",
"0.59248453",
"0.59121... | 0.7640599 | 0 |
Unsafely download a metadata file up to a certain length. The actual file length may not be strictly equal to its expected length. File hashes will not be checked because it is expected to be unknown. | def unsafely_get_metadata_file(self, metadata_role, metadata_filepath,
compressed_file_length):
def unsafely_verify_uncompressed_metadata_file(metadata_file_object):
self.__soft_check_compressed_file_length(metadata_file_object,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_content_length(r: requests.Response):\n content_length = r.headers.get('Content-Length')\n if content_length is None:\n logger.debug('Cannot check length before downloading file')\n return\n\n if int(content_length) > MAX_DOWNLOAD_BYTES:\n raise FetchFileTooBigError(\n ... | [
"0.68834263",
"0.6019552",
"0.6017874",
"0.60117567",
"0.5979806",
"0.5979806",
"0.5956577",
"0.5953644",
"0.59176356",
"0.59112364",
"0.590496",
"0.5834261",
"0.5826231",
"0.58154356",
"0.57973844",
"0.57973844",
"0.57973844",
"0.5739276",
"0.57232654",
"0.57115835",
"0.5689... | 0.6091753 | 1 |
Download, verify, and 'install' the metadata belonging to 'metadata_role'. Calling this function implies the metadata has been updated by the repository and thus needs to be redownloaded. The current and previous metadata stores are updated if the newly downloaded metadata is successfully downloaded and verified. | def _update_metadata(self, metadata_role, fileinfo, compression=None):
# Construct the metadata filename as expected by the download/mirror modules.
metadata_filename = metadata_role + '.txt'
uncompressed_metadata_filename = metadata_filename
# The 'release' or Targets metadata may be compressed. ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_metadata_if_changed(self, metadata_role, referenced_metadata='release'):\n \n uncompressed_metadata_filename = metadata_role + '.txt'\n\n # Ensure the referenced metadata has been loaded. The 'root' role may be\n # updated without having 'release' available. \n if referenced_metada... | [
"0.74762315",
"0.5975187",
"0.5900152",
"0.5849737",
"0.580336",
"0.562456",
"0.5609304",
"0.56023556",
"0.5595829",
"0.55921024",
"0.55448467",
"0.55376464",
"0.5479364",
"0.542237",
"0.54155916",
"0.53572685",
"0.53532314",
"0.535209",
"0.53430897",
"0.5335187",
"0.5273859"... | 0.7117053 | 1 |
Update the metadata for 'metadata_role' if it has changed. With the exception of the 'timestamp' role, all the toplevel roles are updated by this function. The 'timestamp' role is always downloaded from a mirror without first checking if it has been updated; it is updated in refresh() by calling _update_metadata('times... | def _update_metadata_if_changed(self, metadata_role, referenced_metadata='release'):
uncompressed_metadata_filename = metadata_role + '.txt'
# Ensure the referenced metadata has been loaded. The 'root' role may be
# updated without having 'release' available.
if referenced_metadata not in s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _refresh_targets_metadata(self, rolename='targets', include_delegations=False):\n\n roles_to_update = []\n\n # See if this role provides metadata and, if we're including\n # delegations, look for metadata from delegated roles.\n role_prefix = rolename + '/'\n for metadata_path in self.metadata['... | [
"0.7246707",
"0.7186253",
"0.6441687",
"0.6422909",
"0.5998397",
"0.5584296",
"0.5539659",
"0.54305273",
"0.54012203",
"0.539539",
"0.5306128",
"0.52712166",
"0.50628555",
"0.5043398",
"0.5006379",
"0.49786666",
"0.4959843",
"0.48630646",
"0.48453847",
"0.48013136",
"0.477403... | 0.79665345 | 0 |
Ensure the delegated targets of 'metadata_role' are allowed; this is determined by inspecting the 'delegations' field of the parent role of 'metadata_role'. If a target specified by 'metadata_object' is not found in the parent role's delegations field, raise an exception. Targets allowed are either exlicitly listed und... | def _ensure_all_targets_allowed(self, metadata_role, metadata_object):
# Return if 'metadata_role' is 'targets'. 'targets' is not
# a delegated role.
if metadata_role == 'targets':
return
# The targets of delegated roles are stored in the parent's
# metadata file. Retrieve the pare... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _import_delegations(self, parent_role):\n \n current_parent_metadata = self.metadata['current'][parent_role]\n \n if 'delegations' not in current_parent_metadata:\n return\n\n # This could be quite slow with a huge number of delegations.\n keys_info = current_parent_metadata['delegatio... | [
"0.628052",
"0.57578766",
"0.55259514",
"0.54520214",
"0.5116347",
"0.4986853",
"0.49348375",
"0.49187204",
"0.49093932",
"0.48896667",
"0.48627713",
"0.48561046",
"0.48271003",
"0.48104677",
"0.47576022",
"0.47299388",
"0.4701976",
"0.46875975",
"0.4680922",
"0.46689802",
"0... | 0.86525065 | 0 |
Determine whether a list of paths are consistent with theirs alleged path hash prefixes. By default, the SHA256 hash function will be used. | def _paths_are_consistent_with_hash_prefixes(self, paths,
path_hash_prefixes):
# Assume that 'paths' and 'path_hash_prefixes' are inconsistent until
# proven otherwise.
consistent = False
if len(paths) > 0 and len(path_hash_prefixes) > 0:
for path i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkIntersections(path_list):\n som = 0\n joined_list = [hash(i) for i in list(itertools.chain.from_iterable(path_list))] # lelijk\n occurrences = np.bincount(joined_list)\n for i in occurrences:\n if i > 1:\n som += i\n return som",
"def CheckHashes(self, hashes):\n has... | [
"0.6460765",
"0.60971636",
"0.60522926",
"0.60324067",
"0.60068655",
"0.5927751",
"0.58884984",
"0.5864461",
"0.57985765",
"0.5792949",
"0.57527",
"0.57444113",
"0.57175684",
"0.5711271",
"0.57033604",
"0.5662781",
"0.56612056",
"0.56524724",
"0.5587995",
"0.5470321",
"0.5465... | 0.80761313 | 0 |
Determine whether the current fileinfo of 'metadata_filename' differs from 'new_fileinfo'. The 'new_fileinfo' argument should be extracted from the latest copy of the metadata | def _fileinfo_has_changed(self, metadata_filename, new_fileinfo):
# If there is no fileinfo currently stored for 'metadata_filename',
# try to load the file, calculate the fileinfo, and store it.
if metadata_filename not in self.fileinfo:
self._update_fileinfo(metadata_filename)
# Return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_fileinfo(self, metadata_filename):\n \n # In case we delayed loading the metadata and didn't do it in\n # __init__ (such as with delegated metadata), then get the file\n # info now.\n \n # Save the path to the current metadata file for 'metadata_filename'.\n current_filepath... | [
"0.6610963",
"0.64198935",
"0.615069",
"0.61243784",
"0.5961765",
"0.59265333",
"0.590873",
"0.59039855",
"0.5862563",
"0.586194",
"0.5858841",
"0.57861775",
"0.5778181",
"0.57122946",
"0.56918406",
"0.56588155",
"0.5657629",
"0.56488836",
"0.5645154",
"0.5627097",
"0.5625155... | 0.8372806 | 0 |
Update the 'self.fileinfo' entry for the metadata belonging to 'metadata_filename'. If the 'current' metadata for 'metadata_filename' cannot be loaded, set its fileinfo' to 'None' to signal that it is not in the 'self.fileinfo' AND it also doesn't exist locally. | def _update_fileinfo(self, metadata_filename):
# In case we delayed loading the metadata and didn't do it in
# __init__ (such as with delegated metadata), then get the file
# info now.
# Save the path to the current metadata file for 'metadata_filename'.
current_filepath = os.path.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_metadata(self, file_id, metadata):\n pass",
"def _update_filesystem_metadata(self, metadata):\n directory, fname = os.path.split(self.fname)\n fbase = os.path.splitext(fname)[0]\n \n # Test for presence and size of zip file\n zip_file = fbase + '.zip'\n ... | [
"0.67793924",
"0.66336787",
"0.6279058",
"0.58203685",
"0.58027214",
"0.5740213",
"0.5739799",
"0.5691326",
"0.5655879",
"0.55965215",
"0.5530154",
"0.5512755",
"0.550789",
"0.5398123",
"0.5380825",
"0.5296818",
"0.5247495",
"0.522319",
"0.5214021",
"0.5198123",
"0.5195354",
... | 0.8279816 | 0 |
Move the current metadata file for 'metadata_role' to the previous directory. | def _move_current_to_previous(self, metadata_role):
# Get the 'current' and 'previous' full file paths for 'metadata_role'
metadata_filepath = metadata_role + '.txt'
previous_filepath = os.path.join(self.metadata_directory['previous'],
metadata_filepath)
current_fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _delete_metadata(self, metadata_role):\n \n # The root metadata role is never deleted without a replacement.\n if metadata_role == 'root':\n return\n \n # Get rid of the current metadata file.\n self._move_current_to_previous(metadata_role)\n \n # Remove knowledge of the role.\n ... | [
"0.70138854",
"0.6071331",
"0.56894535",
"0.564957",
"0.5627171",
"0.56169873",
"0.5502331",
"0.55000734",
"0.53757805",
"0.53468674",
"0.52324885",
"0.51942086",
"0.51926607",
"0.51787686",
"0.51284546",
"0.5116568",
"0.51012844",
"0.50922936",
"0.5083969",
"0.5048785",
"0.4... | 0.8314233 | 0 |
Remove all (current) knowledge of 'metadata_role'. The metadata belonging to 'metadata_role' is removed from the current 'self.metadata' store and from the role database. The 'root.txt' role file is never removed. | def _delete_metadata(self, metadata_role):
# The root metadata role is never deleted without a replacement.
if metadata_role == 'root':
return
# Get rid of the current metadata file.
self._move_current_to_previous(metadata_role)
# Remove knowledge of the role.
if metadata_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleCleanMetadataKeep(self):\n logging.debug(\"Removing all metadata found...\")\n filePath = self.filesList.selectedItems()[0].text(2)\n self.filesList.removeAllMeta(filePath)",
"def delete_meta_file(self):\n try:\n self.logger.debug('Delete old metadata file %s.', s... | [
"0.6399154",
"0.63534534",
"0.62386084",
"0.62131715",
"0.6198965",
"0.6033478",
"0.5950016",
"0.58653796",
"0.5831039",
"0.5812334",
"0.578384",
"0.57300204",
"0.5706388",
"0.565144",
"0.56208694",
"0.5618025",
"0.5594267",
"0.5579753",
"0.5573522",
"0.55539423",
"0.55429447... | 0.8563163 | 0 |
Raise an exception if the current specified metadata has expired. | def _ensure_not_expired(self, metadata_role):
# Construct the full metadata filename and the location of its
# current path. The current path of 'metadata_role' is needed
# to log the exact filename of the expired metadata.
metadata_filename = metadata_role + '.txt'
rolepath = os.path.join(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired(self):\n raise InvalidSessionException('Need to be implemented')",
"def has_expired(self) -> bool:\n raise NotImplementedError() # pragma: nocover",
"def is_access_expired(self) -> bool:\n entitlement_contract = self.cfg.entitlements.get(self.name, {})\n # TODO(No expiry pe... | [
"0.66576964",
"0.6158783",
"0.5893915",
"0.58275145",
"0.5823112",
"0.5794615",
"0.5753321",
"0.57031006",
"0.56852293",
"0.5669985",
"0.5650522",
"0.5640487",
"0.5634891",
"0.56336796",
"0.56275904",
"0.5607949",
"0.5605594",
"0.5583486",
"0.55787855",
"0.5542038",
"0.553785... | 0.7384562 | 0 |
Get a list of the target information for all the trusted targets on the repository. This list also includes all the targets of delegated roles. The list conforms to 'tuf.formats.TARGETFILES_SCHEMA' | def all_targets(self):
# Load the most up-to-date targets of the 'targets' role and all
# delegated roles.
self._refresh_targets_metadata(include_delegations=True)
all_targets = []
# Fetch the targets for the 'targets' role.
all_targets = self._targets_of_role('targets', skip_refresh=True... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Targets(self):\n return self._targets",
"def all_targets(self):\n return self._combined_all_versioned_targets.targets",
"def ProduceTargets(self):\n\n if self.completion_wanted:\n return self._FindTarget()\n else:\n return []",
"def targets(self):\n\n ... | [
"0.6948129",
"0.67123234",
"0.66501284",
"0.66192716",
"0.6465113",
"0.64457554",
"0.6334513",
"0.6326923",
"0.6301015",
"0.6260099",
"0.6252691",
"0.6228816",
"0.62269753",
"0.62018263",
"0.6183172",
"0.6166132",
"0.61596525",
"0.61502266",
"0.6108508",
"0.61027354",
"0.6072... | 0.6962754 | 0 |
Refresh the targets metadata of 'rolename'. If 'include_delegations' is True, include all the delegations that follow 'rolename'. The metadata for the 'targets' role is updated in refresh() by the _update_metadata_if_changed('targets') call, not here. Delegated roles are not loaded when the repository is first initiali... | def _refresh_targets_metadata(self, rolename='targets', include_delegations=False):
roles_to_update = []
# See if this role provides metadata and, if we're including
# delegations, look for metadata from delegated roles.
role_prefix = rolename + '/'
for metadata_path in self.metadata['current']['r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _targets_of_role(self, rolename, targets=None, skip_refresh=False):\n\n if targets is None:\n targets = []\n\n logger.debug('Getting targets of role: '+repr(rolename)+'.')\n\n if not tuf.roledb.role_exists(rolename):\n raise tuf.UnknownRoleError(rolename)\n\n # We do not need to worry abo... | [
"0.6127298",
"0.55531466",
"0.5259424",
"0.50196505",
"0.4976388",
"0.49235946",
"0.48447338",
"0.47294107",
"0.45664093",
"0.4490421",
"0.43236414",
"0.43059507",
"0.41776976",
"0.4150512",
"0.41420183",
"0.40831453",
"0.40668333",
"0.40531123",
"0.40435153",
"0.40424895",
"... | 0.8320714 | 0 |
Return the target information for all the targets of 'rolename'. The returned information is a list conformant to | def _targets_of_role(self, rolename, targets=None, skip_refresh=False):
if targets is None:
targets = []
logger.debug('Getting targets of role: '+repr(rolename)+'.')
if not tuf.roledb.role_exists(rolename):
raise tuf.UnknownRoleError(rolename)
# We do not need to worry about the target p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def targets_of_role(self, rolename='targets'):\n \n # Does 'rolename' have the correct format?\n # Raise 'tuf.FormatError' if there is a mismatch.\n tuf.formats.RELPATH_SCHEMA.check_match(rolename)\n\n self._refresh_targets_metadata(rolename)\n \n return self._targets_of_role(rolename, skip_... | [
"0.77389604",
"0.73334914",
"0.66263235",
"0.6590217",
"0.6384551",
"0.638077",
"0.6363241",
"0.63349277",
"0.6297083",
"0.6225352",
"0.6199212",
"0.60384667",
"0.60043293",
"0.5998279",
"0.59841985",
"0.5959912",
"0.59539056",
"0.5950182",
"0.59437233",
"0.5927598",
"0.59062... | 0.7770341 | 0 |
Return a list of trusted targets directly specified by 'rolename'. The returned information is a list conformant to | def targets_of_role(self, rolename='targets'):
# Does 'rolename' have the correct format?
# Raise 'tuf.FormatError' if there is a mismatch.
tuf.formats.RELPATH_SCHEMA.check_match(rolename)
self._refresh_targets_metadata(rolename)
return self._targets_of_role(rolename, skip_refresh=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def targets(self, rolename: str = Targets.type) -> Targets:\n targets = self.open(rolename).signed\n if not isinstance(targets, Targets):\n raise RuntimeError(\"Unexpected targets type\")\n return targets",
"def _targets_of_role(self, rolename, targets=None, skip_refresh=False):\n... | [
"0.6885515",
"0.673864",
"0.5896159",
"0.58832645",
"0.5720503",
"0.5620511",
"0.55180293",
"0.55109847",
"0.5488529",
"0.54017466",
"0.5373725",
"0.5344688",
"0.5327276",
"0.5268317",
"0.5267869",
"0.52067995",
"0.51624995",
"0.51441246",
"0.5109124",
"0.50881356",
"0.507958... | 0.6902802 | 0 |
Return the target file information for 'target_filepath'. | def target(self, target_filepath):
# Does 'target_filepath' have the correct format?
# Raise 'tuf.FormatError' if there is a mismatch.
tuf.formats.RELPATH_SCHEMA.check_match(target_filepath)
# DM FIX for class code
import urllib
target_filepath = urllib.unquote(target_filepath)
# Get targ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_target_file(self, target_filepath, compressed_file_length,\n uncompressed_file_hashes):\n\n def verify_uncompressed_target_file(target_file_object):\n # Every target file must have its length and hashes inspected.\n self.__hard_check_compressed_file_length(target_file_obje... | [
"0.63364285",
"0.62955815",
"0.6287654",
"0.5937286",
"0.5810763",
"0.5805691",
"0.5794956",
"0.56686133",
"0.56082475",
"0.555415",
"0.5541651",
"0.55204785",
"0.5468416",
"0.5457092",
"0.54542214",
"0.545371",
"0.5453521",
"0.5447208",
"0.5433085",
"0.5430546",
"0.54235846"... | 0.68005747 | 0 |
Determine whether the targets role with the given 'role_name' has the target with the name 'target_filepath'. | def _get_target_from_targets_role(self, role_name, targets, target_filepath):
target = None
# Does the current role name have our target?
logger.debug('Asking role '+repr(role_name)+' about target '+\
repr(target_filepath))
for filepath, fileinfo in targets.iteritems():
if filepath == targ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_exists(role_name, file_name):\n role_processed = sudo('[ -f %s ] && grep \"^%s$\" %s && echo \"yes\" || echo \"no\"' % (file_name, role_name, file_name))\n if role_processed == 'yes':\n return True\n else:\n return False",
"def _visit_child_role(self, child_role, target_filepath):... | [
"0.69350505",
"0.67440933",
"0.6718138",
"0.63257766",
"0.6301791",
"0.627432",
"0.60713816",
"0.5954152",
"0.59138453",
"0.5836825",
"0.5782234",
"0.5780698",
"0.5761034",
"0.57535905",
"0.574139",
"0.57165617",
"0.5704403",
"0.5700803",
"0.5692873",
"0.5692873",
"0.5643786"... | 0.7351772 | 0 |
Determine whether the given 'child_role' has been delegated the target with the name 'target_filepath'. Ensure that we explore only delegated roles trusted with the target. We assume conservation of delegated paths in the complete tree of delegations. Note that the call to _ensure_all_targets_allowed in __verify_uncomp... | def _visit_child_role(self, child_role, target_filepath):
child_role_name = child_role['name']
child_role_paths = child_role.get('paths')
child_role_path_hash_prefixes = child_role.get('path_hash_prefixes')
# A boolean indicator that tell us whether 'child_role' has been delegated
# the target with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ensure_all_targets_allowed(self, metadata_role, metadata_object):\n \n # Return if 'metadata_role' is 'targets'. 'targets' is not\n # a delegated role.\n if metadata_role == 'targets':\n return\n \n # The targets of delegated roles are stored in the parent's\n # metadata file. Retr... | [
"0.71726364",
"0.57336676",
"0.554071",
"0.5227213",
"0.51975995",
"0.51790684",
"0.51129013",
"0.5097449",
"0.50932217",
"0.5032808",
"0.5009551",
"0.5002774",
"0.49467227",
"0.49132517",
"0.49037033",
"0.4885482",
"0.48389253",
"0.48268166",
"0.47559568",
"0.47556943",
"0.4... | 0.7743372 | 0 |
Compute the hash of 'target_filepath'. This is useful in conjunction with the "path_hash_prefixes" attribute in a delegated targets role, which tells us which paths it is implicitly responsible for. | def _get_target_hash(self, target_filepath, hash_function='sha256'):
# Calculate the hash of the filepath to determine which bin to find the
# target. The client currently assumes the repository uses
# 'hash_function' to generate hashes.
digest_object = tuf.hash.digest(hash_function)
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _actual_hash(self):\n return hash_of_file(join(self._temp_path, self._downloaded_filename()))",
"def get_hash(self, filepath):\n if (os.path.isfile(filepath) and not (\n os.path.islink(filepath) and self.ignorelinks)):\n file_hash = self.hashfile(open(filepath, 'rb'))\... | [
"0.66744316",
"0.63947934",
"0.6372364",
"0.62910396",
"0.626336",
"0.62408173",
"0.6168245",
"0.597555",
"0.597499",
"0.5905806",
"0.5832505",
"0.5783359",
"0.57262033",
"0.57071465",
"0.569763",
"0.5665912",
"0.565811",
"0.56297946",
"0.5606447",
"0.5602915",
"0.5594297",
... | 0.85003406 | 0 |
Remove any files that are in 'previous' but not 'current'. This makes it so if you remove a file from a repository, it actually goes away. The targets for the 'targets' role and all delegated roles are checked. | def remove_obsolete_targets(self, destination_directory):
# Does 'destination_directory' have the correct format?
# Raise 'tuf.FormatError' if there is a mismatch.
tuf.formats.PATH_SCHEMA.check_match(destination_directory)
# Iterate through the rolenames and verify whether the 'previous'
# direc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_previous_files():\n def delete(root: Path):\n shutil.rmtree(root / 'output', ignore_errors=True)\n for p in root.iterdir():\n if str(p).endswith(('.log', 'jobs.csv', 'csv.lock', '.yaml')):\n p.unlink()\n\n delete(wt_registration_dir)\n delete(mut_registra... | [
"0.6814799",
"0.6449817",
"0.6353513",
"0.61904424",
"0.6107088",
"0.5952603",
"0.5881425",
"0.58807445",
"0.586403",
"0.58522594",
"0.5755024",
"0.5734811",
"0.5718269",
"0.5690973",
"0.56899154",
"0.56445503",
"0.5625026",
"0.5623838",
"0.5616736",
"0.5609417",
"0.5593584",... | 0.65018755 | 1 |
Return the targets in 'targets' that have changed. Targets are considered changed if they do not exist at 'destination_directory' or the target located there has mismatched file properties. The returned information is a list conformant to | def updated_targets(self, targets, destination_directory):
# Do the arguments have the correct format?
# Raise 'tuf.FormatError' if there is a mismatch.
tuf.formats.TARGETFILES_SCHEMA.check_match(targets)
tuf.formats.PATH_SCHEMA.check_match(destination_directory)
updated_targets = []
for targ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid_targets(self):\n return self._combined_invalid_versioned_targets.targets",
"def all_targets(self):\n return self._combined_all_versioned_targets.targets",
"def _sort_and_validate_targets(self, targets):\r\n # We must check the targets in this order, to ensure correctness if invalidate_depe... | [
"0.59195954",
"0.59108806",
"0.5899564",
"0.5894745",
"0.5699647",
"0.5696529",
"0.56604826",
"0.5591113",
"0.55762184",
"0.55114293",
"0.55009407",
"0.54718184",
"0.54223627",
"0.53630525",
"0.5358456",
"0.5324592",
"0.5271276",
"0.52465874",
"0.5198097",
"0.5184535",
"0.518... | 0.78240633 | 0 |
Download 'target' and verify it is trusted. This will only store the file at 'destination_directory' if the downloaded file matches the description of the file in the trusted metadata. | def download_target(self, target, destination_directory):
# Do the arguments have the correct format?
# This check ensures the arguments have the appropriate
# number of objects and object types, and that all dict
# keys are properly named.
# Raise 'tuf.FormatError' if the check fail.
tuf.for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_target(target_info, temp_dir, images_dir, inventory, args):\n target_name = target_info.get(\"target\")\n target_sha256 = target_info.get(\"sha256_hash\")\n filename = target_info.get(\"filename\")\n temp_path = os.path.join(temp_dir, filename)\n # Add a trailing slash to make sure that u... | [
"0.59671676",
"0.5967019",
"0.5953204",
"0.5891534",
"0.5793983",
"0.5768841",
"0.5755365",
"0.574282",
"0.56129616",
"0.5590517",
"0.5573866",
"0.5563315",
"0.55612004",
"0.55537355",
"0.55537355",
"0.55136275",
"0.55136275",
"0.55097127",
"0.5508454",
"0.5508454",
"0.550845... | 0.7110834 | 0 |
Make a player to try to leave jail. | def try_leave_jail(self):
player = self.player_list[self.current_player]
print(player, "trying to leave jail")
if player.strategy.get_out_of_jail_with_card(self, player=player):
# we just leave jail using the card.
card = player.get_card(GetOutJailFree)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _leave(self, *args):\n if not self.game:\n raise ServerException('not playing a game')\n self.game.leave(self)\n self.game = self.player = None",
"def leaveGame(game, player): # is also called in register player if THE UNPROBABLE happens (e.g. there was a crash and bobby can't... | [
"0.6754132",
"0.63794553",
"0.6148522",
"0.6108706",
"0.6084471",
"0.5965771",
"0.5953274",
"0.58382595",
"0.58152115",
"0.57858145",
"0.57740587",
"0.5755289",
"0.5752021",
"0.5657248",
"0.565241",
"0.56184435",
"0.56099445",
"0.5607249",
"0.5576661",
"0.5569093",
"0.5567936... | 0.7402688 | 0 |
Return the index for the player. | def get_player_index(self, player):
# find the player by going through the list
for i in range(len(self.player_list)):
if player == self.player_list[i]:
return i
raise PlayerNotFound | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_index(self, id_) -> int:\n return self._players_list.index(self._nodes[id_]['player'])",
"def get_player_num(self):\r\n return self.player_control.get_player_num()",
"def get_current_player(self):\r\n\r\n return self.players[(self.turn_number) % len(self.players)].get_id()",
"... | [
"0.78155226",
"0.72656244",
"0.7010457",
"0.7005153",
"0.69597197",
"0.69525254",
"0.6930846",
"0.69154924",
"0.69154924",
"0.69154924",
"0.69154924",
"0.69154924",
"0.69094145",
"0.684157",
"0.684157",
"0.6797731",
"0.67746806",
"0.6772885",
"0.6744422",
"0.67356735",
"0.668... | 0.80226827 | 0 |
Return the index of the square. | def get_square_index(self, square):
# find the player by going through the list
for i in range(len(self.squares)):
if square == self.squares[i]:
return i
raise SquareNotFound | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_square_index(self, cell):\n return next(s for s, square in enumerate(self.squares) if cell in square)",
"def getIndex(x, y, rows, cols):\n x = cols-x-1\n if x % 2 != 0:\n return (x*rows)+y\n else:\n return (x*rows)+(rows-1-y)",
"def get_square(self, index: int):\n r... | [
"0.8003269",
"0.7540733",
"0.71379787",
"0.71144485",
"0.71032023",
"0.7096975",
"0.7057881",
"0.6839868",
"0.67621505",
"0.675864",
"0.66842747",
"0.6590778",
"0.6580608",
"0.6566204",
"0.6562753",
"0.64829534",
"0.64553094",
"0.64529425",
"0.6446773",
"0.6426442",
"0.642161... | 0.7821449 | 1 |
Return the first square of a given name. | def get_square_index_by_name(self, square_name, from_square=None):
if from_square is not None:
# don't start at the begining
raise Exception
for i in range(len(self.squares)):
print(self.squares[i].name, square_name)
if self.squares[i].name == squa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def singularize(name):\n n = str(name)\n if n[-1:] == 's':\n return n[:-1]\n return n",
"def find_square(self, target_name: str) -> int:\n found_square_num = None\n for i in range(len(self.squares)):\n if target_name == self.squares[i].name:\n found_square_... | [
"0.62641704",
"0.6074091",
"0.58869636",
"0.5863246",
"0.5843857",
"0.57271814",
"0.5718565",
"0.56371987",
"0.5565492",
"0.5564565",
"0.549277",
"0.5450085",
"0.5432684",
"0.5428434",
"0.54156905",
"0.5396309",
"0.5377145",
"0.5367631",
"0.5342714",
"0.53405",
"0.53291464",
... | 0.6145324 | 1 |
Return the first square of a given class. | def get_square_by_class(self, square_class, from_square=None):
start_index = 0
if from_square is not None:
# don't start at the begining
for i in range(0, len(self.squares)):
if self.squares[i] == from_square:
start_index = i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_closest(self, cls):\n closest = None\n shortest_dist = None\n for sprite in self.game.entities[ALL_SPRITES]:\n if isinstance(sprite, cls):\n curr_dist = distance((self.x, self.y), (sprite.x, sprite.y))\n if shortest_dist is None or curr_dist < shortest_dist:\n ... | [
"0.59225607",
"0.5723245",
"0.55512625",
"0.5535083",
"0.5414248",
"0.53844106",
"0.5375716",
"0.53355664",
"0.5303055",
"0.52700686",
"0.52453876",
"0.5232349",
"0.519124",
"0.5178258",
"0.51506567",
"0.5148435",
"0.5138552",
"0.51305276",
"0.5073375",
"0.50638586",
"0.50493... | 0.71759033 | 0 |
Move a player to the n. | def move_player_n_square(
self, player_index, n, player=None, pass_on_squares=True, thr=None
):
if player is not None:
player_index = self.get_player_index(player)
square_index = self.player_positions[player_index] + n
if square_index < 0:
square_inde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self, row, col, player):",
"async def make_move(index):\n if enough_players():\n GAME.make_move(index)\n await update_players()",
"def makeMove(self, move, player):",
"async def move_player(self, player : Player, channel):\r\n await player.move_to(channel)",
"def __play_mov... | [
"0.6816062",
"0.68137366",
"0.6647461",
"0.6624199",
"0.65511507",
"0.64370066",
"0.64218724",
"0.64007497",
"0.63077587",
"0.6304666",
"0.6243999",
"0.6195381",
"0.6159438",
"0.6115476",
"0.60905296",
"0.6081004",
"0.6080895",
"0.6078984",
"0.60673445",
"0.6060743",
"0.60380... | 0.76031613 | 0 |
Remove the player from the board. | def remove_player(self, player):
print("REMOVING", player)
player_index = self.get_player_index(player)
# if we are the current player, move back the index once
if self.current_player == player_index:
self.current_player -= 1
if self.current_player < 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_player(self, player):\n\t\tself.players.remove(player)",
"def remove_player_from_game(self, player):\n if player in self.players:\n cards = player.cards\n for card in cards:\n self.cards.append(card)\n\n self.__shuffle_cards()\n player.... | [
"0.8489572",
"0.80499756",
"0.77806044",
"0.76676995",
"0.76405525",
"0.7366387",
"0.7310438",
"0.72776914",
"0.7189522",
"0.71356475",
"0.7114337",
"0.7092161",
"0.7065603",
"0.7014058",
"0.6963003",
"0.69061786",
"0.68282884",
"0.66684633",
"0.66300315",
"0.6582116",
"0.653... | 0.81271565 | 1 |
Buy this property for the player. | def buy_property(self, player, square):
# pay the bank
print(player, "buying", square)
self.transaction_to_player(Bank(), -square.get_price(), player)
# set the owner on the property, and on the player
square.set_owner(player)
player.add_property(square) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_prop(player, prop):\r\n if player.money >= prop.price:\r\n player.money -= prop.price\r\n prop.owner = player\r\n player.properties.append(prop)\r\n return True\r\n else:\r\n return False",
"def buy_property(self, player_name, movement_manager):\n current_p... | [
"0.73201454",
"0.71901083",
"0.6011373",
"0.58200026",
"0.5769583",
"0.5717164",
"0.5642328",
"0.56227255",
"0.55898637",
"0.5552486",
"0.55257046",
"0.54936653",
"0.54706025",
"0.5382395",
"0.538109",
"0.53658086",
"0.5355954",
"0.5347377",
"0.5340484",
"0.533603",
"0.533201... | 0.757466 | 0 |
Buy this house for the player. | def buy_house(self, player, square):
# pay the bank
house_price = square.get_house_price()
if house_price is None:
return
print(player, "buying a house on", square)
self.transaction_to_player(Bank(), -house_price, player)
# set the owner on the hous... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doBuyIn(self):\n self.protocol.sendPacket(networkpackets.PacketPokerBuyIn(amount=self.max_buy_in, **self._serial_and_game_id))\n self.protocol.sendPacket(networkpackets.PacketPokerAutoBlindAnte(**self._serial_and_game_id))",
"def buy_property(self, player, square):\r\n # pay the bank\r\n... | [
"0.6828917",
"0.6799409",
"0.67829067",
"0.6736817",
"0.67134225",
"0.6636116",
"0.65728295",
"0.6543972",
"0.6479058",
"0.6419585",
"0.6382085",
"0.63807803",
"0.6303579",
"0.62601125",
"0.6240134",
"0.6233498",
"0.62123346",
"0.62091625",
"0.61930096",
"0.6190045",
"0.61501... | 0.7949733 | 0 |
Peform a transaction between 2 players. | def transaction_to_player(self, origin, amount, receiver):
print("Transfering", amount, origin, "->", receiver)
try:
origin.transfer(-amount)
except:
# the origin will became bankrupt, so declare it and remove it from the game
origin.set_bankrupt(self, r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_transaction():\n data = request.get_json()\n response = None\n status_code = None\n\n # Proposed transaction document validity checks\n if balance() < (data['amount']):\n response = dict(message='Your balance is not enough to complete transaction')\n status_code = 400\n e... | [
"0.61815363",
"0.59610337",
"0.5821514",
"0.57208735",
"0.5666299",
"0.5660158",
"0.5631508",
"0.5585961",
"0.5577441",
"0.5575177",
"0.55738866",
"0.55622536",
"0.55600274",
"0.55556196",
"0.5540459",
"0.5522409",
"0.54789543",
"0.5451003",
"0.5426924",
"0.54183215",
"0.5410... | 0.6110522 | 1 |
Return the next chance card. | def get_next_chance_card(self):
return self.chance_cards.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_card(self):\n\n card = random.randint(1,13)\n return card",
"def next_play(self):\n\t\tfor card in self.hand:\n\t\t\tif is_valid(card):\n\t\t\t\tself.play_card(card)\n\t\t\t\treturn card\n\t\tglobal forced_rank\n\t\tif forced_rank == \"2\":\n\t\t\tglobal two_multiplier\n\t\t\tself.draw(two_... | [
"0.73839265",
"0.7233632",
"0.6910416",
"0.6814642",
"0.6752508",
"0.67323685",
"0.6697044",
"0.6683003",
"0.6669536",
"0.65967244",
"0.6572759",
"0.64932215",
"0.64538753",
"0.63115644",
"0.6229882",
"0.62091255",
"0.6207595",
"0.6194546",
"0.61408436",
"0.61378855",
"0.6134... | 0.8169335 | 0 |
Receive a chance card. | def receive_chance_card(self, card):
self.chance_cards.append(card) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def cards_per_hand(ctx):\n message = NNB.cards_per_hand()\n await ctx.send(message)",
"def hit(player):\n deal_random_card(player)",
"def deal_card():\r\n cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]\r\n return (random.choice(cards))",
"def deal_card():\n cards = [11, 2,... | [
"0.67559594",
"0.6644758",
"0.65473336",
"0.6527448",
"0.6505729",
"0.6439306",
"0.6402647",
"0.638352",
"0.632512",
"0.6302483",
"0.63002384",
"0.6219421",
"0.6176694",
"0.61733097",
"0.6160437",
"0.60518074",
"0.6049033",
"0.60325867",
"0.60216695",
"0.5994193",
"0.5935299"... | 0.76488245 | 0 |
Return the next community card. | def get_next_community_card(self):
return self.community_cards.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next(self):\n if self.has_next():\n return self.pile.pop(0)\n else:\n return Card.null_card()",
"def getNextCard(deckId):\n deckOfCards = getCardsForDeck(deckId)\n card = deckOfCards.order_by('?')[0]\n return card",
"def get_next_chance_card(self):\r\n ... | [
"0.67116123",
"0.63600814",
"0.59270644",
"0.58697116",
"0.5854605",
"0.5853722",
"0.5849353",
"0.5799878",
"0.5773101",
"0.56748474",
"0.56654567",
"0.56156725",
"0.56156725",
"0.561448",
"0.555655",
"0.55324405",
"0.5530132",
"0.5528631",
"0.54927295",
"0.5477948",
"0.54527... | 0.83956087 | 0 |
Renders the default text for the shell, used to be able to render it in all the different commands. | def render_defaults(stdscr):
max_y = stdscr.getmaxyx()[0] - 1
if superglobals.information_enabled:
stdscr.addstr(0, 0, uname().system)
stdscr.addstr(1, 0, uname().machine)
for i in range(0, max_y + 1):
stdscr.addstr(i, 43, "│") # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _default(self):\n self.app.args.print_help()",
"def help_shell(self):\n help_str = \"\"\"Execute a command as if at the OS prompt.\n\n Usage: shell cmd\"\"\"\n self.stdout.write(\"{}\\n\".format(help_str))",
"def main_menu_for_testing():\n print(PROMPT_TEXT)",
"def helptext(se... | [
"0.61833084",
"0.61203045",
"0.6098549",
"0.60617983",
"0.5950336",
"0.59205765",
"0.5903588",
"0.58817387",
"0.584353",
"0.5783898",
"0.57385015",
"0.5654426",
"0.56391895",
"0.5628658",
"0.5602524",
"0.55427074",
"0.553693",
"0.55326563",
"0.55046827",
"0.5489929",
"0.54789... | 0.6152007 | 1 |
Returns a boolean based off of whether or not all the args as integers are a possible index in list. | def indexists(list, *args): # Technically doesn't have to do with the screen, but it is very useful.
return all([int(arg) < len(list) for arg in args]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _idxs_are_present(self, *args):\n return set(args).issubset(set(range(self.n_atoms)))",
"def has_args(iterable, args):\n\n try:\n return all(x in iterable for x in args)\n\n except TypeError:\n return False",
"def index_is_in_list(the_list, index):\n return bool(0 <= index < l... | [
"0.755418",
"0.67725885",
"0.6696974",
"0.64974993",
"0.64970857",
"0.6482055",
"0.64819956",
"0.6474068",
"0.63763213",
"0.6312439",
"0.6281895",
"0.6268804",
"0.62539935",
"0.6230627",
"0.62300694",
"0.6202207",
"0.6108527",
"0.60967743",
"0.60871893",
"0.6086811",
"0.60553... | 0.8298558 | 0 |
Checks if the given arguments can be turned into integers. | def is_int(*args):
try:
for i in args:
int(i)
return True
except Exception:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_int(check):",
"def int_check(*args, func=None):\n func = func or inspect.stack()[2][3]\n for var in args:\n if not isinstance(var, numbers.Integral):\n name = type(var).__name__\n raise ComplexError(\n 'Function {} expected integral number, {} got i... | [
"0.711587",
"0.7098558",
"0.70692873",
"0.69129986",
"0.68626827",
"0.6750262",
"0.6704833",
"0.67028326",
"0.6642334",
"0.65828174",
"0.65828174",
"0.65801835",
"0.65182704",
"0.6516078",
"0.6502916",
"0.6467116",
"0.6466402",
"0.6451798",
"0.64275944",
"0.64255023",
"0.6371... | 0.8308678 | 0 |
Checks if the given arguments can be turned into floats. | def is_float(*args):
try:
for i in args:
float(i)
return True
except Exception:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_arguments(arguments):\n quit = False\n for argument, value in vars(arguments).items():\n try:\n float(value)\n except:\n print(\"{} must be numeric\".format(argument))\n quit = True\n if quit:\n exit(1)",
"def check_for_float(check):",
"d... | [
"0.77807665",
"0.7744407",
"0.7359381",
"0.69544315",
"0.6885165",
"0.6864641",
"0.6821068",
"0.67614245",
"0.67499506",
"0.6736192",
"0.6709657",
"0.6687189",
"0.66818863",
"0.66159344",
"0.6614823",
"0.6611244",
"0.6589316",
"0.65854704",
"0.6578222",
"0.6568799",
"0.652709... | 0.8388929 | 0 |
Draws a box using box drawing characters. | def draw_box(stdscr, y, x, height, width, mode=0):
if mode == 0:
stdscr.addstr(y, x, "┌" + "─" * (width - 1) + "┐")
stdscr.addstr(y + height, x, "└" + "─" * (width - 1) + "┘")
for i in range(y + 1, y + height):
stdscr.addstr(i, x, "│")
stdscr.addstr(i, x + width, "│")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_box(\n draw,\n box,\n img_width,\n img_height,\n text=\"\",\n color=(255, 255, 0),\n) -> None:\n\n line_width = 3\n font_height = 8\n y_min, x_min, y_max, x_max = box\n (left, right, top, bottom) = (\n x_min * img_width,\n x_max * img_width,\n y_min * img... | [
"0.7524085",
"0.7420148",
"0.6947447",
"0.6904583",
"0.6866881",
"0.67783445",
"0.67416203",
"0.6716438",
"0.66725934",
"0.6665916",
"0.65296215",
"0.64508295",
"0.64451134",
"0.6430952",
"0.64158237",
"0.6409835",
"0.6386739",
"0.6345775",
"0.6328558",
"0.6314567",
"0.629964... | 0.7759127 | 0 |
Function to parse features from GeoDataFrame in such a manner that rasterio wants them | def getFeatures(gdf):
import json
return [json.loads(gdf.to_json())['features'][0]['geometry']] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFeatures(gdf):\n\timport json\n\treturn [json.loads(gdf.to_json())['features'][0]['geometry']]",
"def getFeatures(gdf):\r\n import json\r\n return [json.loads(gdf.to_json())['features'][0]['geometry']]",
"def getFeatures(gdf):\r\n import json\r\n features = [json.loads(gdf.to_json())['featur... | [
"0.70071805",
"0.70068884",
"0.69907653",
"0.6657737",
"0.6583149",
"0.6436121",
"0.63375276",
"0.62475395",
"0.6246845",
"0.6211411",
"0.61899287",
"0.6185225",
"0.60740775",
"0.60602796",
"0.6055743",
"0.6055743",
"0.60478085",
"0.60417706",
"0.6026995",
"0.6003534",
"0.591... | 0.70252883 | 1 |
Gets the task_name of this LoanApplicationTasks. | def task_name(self) -> str:
return self._task_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTaskName(self):\n return self._taskName",
"def task_name(self):\n pass",
"def task(self) -> str:\n return self._task",
"def get_task_id(self):\n if self.task_id:\n return self.task_id\n return (f'{self.task_type}_{self.get_source_system().lower()}'\n ... | [
"0.8486359",
"0.7913793",
"0.75000155",
"0.7168119",
"0.70443463",
"0.69992584",
"0.68941015",
"0.6861723",
"0.68553126",
"0.68553126",
"0.68553126",
"0.68553126",
"0.6802803",
"0.67627627",
"0.67244226",
"0.67244226",
"0.6719401",
"0.6687001",
"0.6637115",
"0.66048795",
"0.6... | 0.8500848 | 0 |
Sets the task_name of this LoanApplicationTasks. | def task_name(self, task_name: str):
if task_name is None:
raise ValueError("Invalid value for `task_name`, must not be `None`") # noqa: E501
self._task_name = task_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_name(self, task_name):\n\n self._task_name = task_name",
"def _setTaskName(self, taskName):\n self._taskName = taskName\n self._progressChangedNotifier.notify(self)",
"def task_name(self) -> str:\n return self._task_name",
"def puttaskname(self,taskname_): # 3\n res ... | [
"0.8254526",
"0.74813414",
"0.688587",
"0.6770161",
"0.65853554",
"0.65247416",
"0.6488435",
"0.6327614",
"0.62774235",
"0.6201881",
"0.61336696",
"0.6100681",
"0.5963401",
"0.59389114",
"0.5913918",
"0.5872126",
"0.5836587",
"0.56788886",
"0.56594557",
"0.56442976",
"0.55894... | 0.79433864 | 1 |
Gets the stage_name of this LoanApplicationTasks. | def stage_name(self) -> str:
return self._stage_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stage_name(self) -> str:\n return pulumi.get(self, \"stage_name\")",
"def stage_name(self) -> str:\n return pulumi.get(self, \"stage_name\")",
"def stage_name(self) -> str:\n return self._values.get(\"stage_name\")",
"def getTaskName(self):\n return self._taskName",
"def tas... | [
"0.785884",
"0.785884",
"0.78139293",
"0.718115",
"0.70540637",
"0.6642022",
"0.64218915",
"0.63033044",
"0.62711096",
"0.62711096",
"0.62711096",
"0.62335616",
"0.62320334",
"0.6219078",
"0.61579126",
"0.61254984",
"0.6106092",
"0.6102382",
"0.6053165",
"0.6023286",
"0.59876... | 0.7905333 | 0 |
Sets the stage_name of this LoanApplicationTasks. | def stage_name(self, stage_name: str):
if stage_name is None:
raise ValueError("Invalid value for `stage_name`, must not be `None`") # noqa: E501
self._stage_name = stage_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stage_name(self) -> str:\n return self._stage_name",
"def stage_name(self) -> str:\n return pulumi.get(self, \"stage_name\")",
"def stage_name(self) -> str:\n return pulumi.get(self, \"stage_name\")",
"def task_name(self, task_name):\n\n self._task_name = task_name",
"def st... | [
"0.65028423",
"0.63868105",
"0.63868105",
"0.63487524",
"0.628022",
"0.600978",
"0.57595444",
"0.5660529",
"0.550158",
"0.55004424",
"0.54686415",
"0.53505766",
"0.52731216",
"0.52383596",
"0.5148092",
"0.51372725",
"0.5131897",
"0.50910527",
"0.5033554",
"0.5031995",
"0.5024... | 0.69675004 | 0 |
Gets the task_status of this LoanApplicationTasks. | def task_status(self) -> str:
return self._task_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_task_status(task_id: TaskId):",
"def celery_task_status(self):\n return self._get_celery_queue_data()",
"def taskbystatus(self, **kwargs):\n rows = self.api.query(None, None, self.Task.TaskByStatus_sql, username_=kwargs[\"username\"], taskstatus=kwargs[\"taskstatus\"])\n\n re... | [
"0.71324706",
"0.7093253",
"0.67850393",
"0.65579414",
"0.6541642",
"0.6334591",
"0.6273188",
"0.6264664",
"0.62501335",
"0.6231414",
"0.61964184",
"0.61462724",
"0.61462724",
"0.61462724",
"0.61388564",
"0.6122741",
"0.61159295",
"0.61024487",
"0.6097303",
"0.6073409",
"0.60... | 0.7633925 | 0 |
Sets the task_status of this LoanApplicationTasks. | def task_status(self, task_status: str):
if task_status is None:
raise ValueError("Invalid value for `task_status`, must not be `None`") # noqa: E501
self._task_status = task_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_task_in_progress(self):\n\n tasks = self._get_all_tasks()\n\n task_id = tasks[self.tasks_view.currentRow()].Id\n\n self.tasks_flow.set_status(task_id, 1)\n\n # Refresh the table\n self.write_tasks_table()",
"def set_status_(self, task: Task):\n tic = time.time()\... | [
"0.6546041",
"0.63993967",
"0.6269863",
"0.6198993",
"0.6198993",
"0.6198993",
"0.6175255",
"0.61558944",
"0.60749936",
"0.6051563",
"0.5988801",
"0.5986775",
"0.5885703",
"0.5883675",
"0.5883675",
"0.5883675",
"0.5883675",
"0.5883675",
"0.5883675",
"0.5883675",
"0.5883675",
... | 0.76288915 | 0 |
Gets the loan_application_id of this LoanApplicationTasks. | def loan_application_id(self) -> str:
return self._loan_application_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_id(self):\n return self._app_id",
"def app_id(self) -> str:\n return self._app_id",
"def application_id(self) -> Optional[str]:\n return pulumi.get(self, \"application_id\")",
"def application_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"application_id\")",
... | [
"0.64398617",
"0.63063055",
"0.6300978",
"0.6264804",
"0.6140923",
"0.6061766",
"0.60486615",
"0.60486615",
"0.60486615",
"0.60020316",
"0.59677273",
"0.59677273",
"0.59677273",
"0.59677273",
"0.5940339",
"0.59222615",
"0.5908691",
"0.58757806",
"0.58466387",
"0.58241063",
"0... | 0.7899649 | 0 |
Sets the loan_application_id of this LoanApplicationTasks. | def loan_application_id(self, loan_application_id: str):
if loan_application_id is None:
raise ValueError("Invalid value for `loan_application_id`, must not be `None`") # noqa: E501
self._loan_application_id = loan_application_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loan_application_id(self) -> str:\n return self._loan_application_id",
"def application_id(self, application_id):\n\n self._application_id = application_id",
"def loan_id(self, loan_id):\n\n self._loan_id = loan_id",
"def task_id(self, task_id):\n self._task_id = task_id",
"... | [
"0.63690144",
"0.59828776",
"0.57021713",
"0.5565539",
"0.5496316",
"0.54807234",
"0.5467243",
"0.54585177",
"0.5425827",
"0.51348335",
"0.5049111",
"0.49390966",
"0.48765567",
"0.48614517",
"0.48548588",
"0.48031816",
"0.47550064",
"0.4697146",
"0.46013895",
"0.45823494",
"0... | 0.6659482 | 0 |
Serialize a search result. | def serialize_search(
self, pid_fetcher, search_result, links=None, item_links_factory=None
):
records = []
for hit in search_result["hits"]["hits"]:
processed_hit = self.transform_search_hit(
pid_fetcher(hit["_id"], hit["_source"]),
hit,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_search(self, pid_fetcher, search_result, links=None,\n item_links_factory=None, **kwargs):\n hits_dict = {\n 'hits': {\n 'hits': [\n self.transform_search_hit(\n pid_fetcher(hit['_id'], hit['_source']),... | [
"0.72805274",
"0.71256214",
"0.6633089",
"0.63286436",
"0.6074966",
"0.5878755",
"0.5834139",
"0.5825184",
"0.5819029",
"0.5762264",
"0.57363033",
"0.57293785",
"0.5727291",
"0.57013524",
"0.5679446",
"0.5613311",
"0.5610144",
"0.55878663",
"0.5585593",
"0.55538034",
"0.55349... | 0.7188329 | 1 |
Checks if the given key is contained within any of the fields. | def key_in_field(self, key, fields):
for field in fields:
if key in field:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, key):\n return self.keys[self._linear_probe(key, \"contains\")] is not None",
"def __contains__(self, key):\n\n return key in self.keys_set",
"def contains(self, key):\n if key in self.key_list:\n return True\n return False",
"def __contains__(sel... | [
"0.7070488",
"0.6968872",
"0.6961819",
"0.6932418",
"0.6916172",
"0.6817634",
"0.67951804",
"0.678997",
"0.6779572",
"0.6749631",
"0.6730777",
"0.6663097",
"0.6663021",
"0.6642367",
"0.6633289",
"0.6630922",
"0.6619883",
"0.6599063",
"0.65861446",
"0.6579086",
"0.65784895",
... | 0.84226483 | 0 |
This function will be called a form postsave/create. It adds a logging message | def callback_success_message(request):
msg = 'Sucessfully recorded form :)'
logger.info(msg)
messages.info(request._request, msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_post(self):\n return \"Ok, the stuff is being saved\"",
"def callback_fail_message(request):\n msg = 'Form storing has failed :('\n logger.error(msg)\n messages.error(request._request, msg)",
"def log(self, message):",
"def generate_log(window_info, form: SerializedForm(LogName... | [
"0.70131916",
"0.673436",
"0.6676555",
"0.6661796",
"0.6638116",
"0.6433321",
"0.64053524",
"0.63213503",
"0.6281074",
"0.627926",
"0.6102167",
"0.6007364",
"0.60037506",
"0.59628826",
"0.595433",
"0.5934547",
"0.59297633",
"0.5929501",
"0.5916433",
"0.59147054",
"0.58945763"... | 0.69311756 | 1 |
This function will be called a form postsave/create. It adds a logging message (error) | def callback_fail_message(request):
msg = 'Form storing has failed :('
logger.error(msg)
messages.error(request._request, msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback_success_message(request):\n msg = 'Sucessfully recorded form :)'\n logger.info(msg)\n messages.info(request._request, msg)",
"def error(self, tag, message, exc_info=False):\n \n self.log(logging.error,tag, message, exc_info)",
"def on_post(self):\n return \"Ok,... | [
"0.6559552",
"0.65144616",
"0.63575673",
"0.6104596",
"0.6062535",
"0.5954148",
"0.5945705",
"0.5941205",
"0.59325004",
"0.5923055",
"0.5919421",
"0.5919199",
"0.58883065",
"0.58834726",
"0.5868146",
"0.5862035",
"0.58343416",
"0.5818541",
"0.58176386",
"0.58176386",
"0.58151... | 0.76007026 | 0 |
Returns PIL.Image objects for all the images in directory.''' If directory is not specified, uses current directory. Returns a 2tuple containing a list with a PIL.Image object for each image file in root_directory, and a list with a string filename for each image file in root_directory | def get_images(directory=None): #import from mask.py
if directory == None:
directory = os.getcwd() # Use working directory if unspecified
image_list = [] # Initialize aggregaotrs
file_list = []
directory_list = os.listdir(directory) # Get list of files
for entry in directo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_images(directory=None):\n \n if directory == None:\n directory = os.getcwd() # Use working directory if unspecified\n \n image_list = [] # Initialize aggregaotrs\n file_list = []\n \n directory_list = os.listdir(directory) # Get list of files\n for entry in directory_list... | [
"0.8241939",
"0.813711",
"0.77286386",
"0.75424576",
"0.75172657",
"0.73895353",
"0.7282258",
"0.71291536",
"0.7086534",
"0.70178604",
"0.69990695",
"0.69680256",
"0.6947587",
"0.6891989",
"0.6837586",
"0.6810798",
"0.6762368",
"0.67423135",
"0.6730836",
"0.6722797",
"0.67117... | 0.8213258 | 1 |
JSON editor app for viewing config. | def json_editor(self):
json_editor = pn.widgets.JSONEditor.from_param(
self.param.config_dict,
mode="view",
menu=False,
sizing_mode="stretch_width",
)
config_viewer = pn.Card(
json_editor,
title="CONFIG Viewer",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config():\n if app.args.ui_mode == \"jinja\":\n ui_config = {\n \"p1\": {\n \"options\": {\n \"lineNumbers\": True,\n \"theme\":\"material\",\n \"lineWrapping\" : True,\n \"mode\": \"yaml\",\n ... | [
"0.7127012",
"0.64928466",
"0.64928466",
"0.6352412",
"0.630213",
"0.630213",
"0.6027477",
"0.600231",
"0.59771115",
"0.59740865",
"0.591125",
"0.58834666",
"0.58547175",
"0.58471215",
"0.58188564",
"0.5816865",
"0.5796275",
"0.57883906",
"0.5772668",
"0.5765284",
"0.57640326... | 0.78986704 | 0 |
Compute novatel checksum. Expects a StringIO with a size that is a multiple of four bytes. | def _checksum(cls, buff):
checksum = 0
while True:
data = buff.read(cls.checksum_struct.size)
if len(data) == 0:
break
if len(data) < 4:
pad_count = len(data) % 4
data = data + "\x00" * pad_count
raise ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_checksum(size1, size2, lines, tmpdir):\n fp = tmpdir.join(\"temp-data.txt\").strpath\n data = \"\\n\".join(lines)\n with open(fp, 'w') as f:\n f.write(data)\n exp = hashlib.new(\"md5\", data.encode(\"utf-8\")).hexdigest()\n res1 = checksum(fp, size1)\n res2 = checksum(fp, size2)\n... | [
"0.6441798",
"0.64138716",
"0.61732674",
"0.60550714",
"0.60465926",
"0.59932405",
"0.59910274",
"0.5981081",
"0.5977071",
"0.59749424",
"0.5952695",
"0.5949494",
"0.5903017",
"0.585889",
"0.58151466",
"0.57396185",
"0.56941354",
"0.5688313",
"0.5686545",
"0.565836",
"0.56320... | 0.71015364 | 0 |
GET method, returns department collection. | def get():
logger.debug('Catch GET request by URL /api/departments.')
departments = ds.get_all()
return marshal_departments(departments) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(id_):\n\n logger.debug('Catch GET request by URL /api/departments/%i.', id_)\n try:\n department = ds.get(id_)\n if not department.id:\n raise Exception\n except Exception:\n logger.error('There is no department with id %i', id_)\n ... | [
"0.7557787",
"0.7532816",
"0.71916354",
"0.7127789",
"0.69939005",
"0.69594824",
"0.69122684",
"0.6909003",
"0.6907418",
"0.68410194",
"0.67590916",
"0.67334664",
"0.6722613",
"0.67003804",
"0.66987646",
"0.66958904",
"0.6678866",
"0.6579981",
"0.6577867",
"0.65603775",
"0.65... | 0.79613036 | 0 |
POST method, adds new department. | def post():
logger.debug('Catch POST request by URL /api/departments.')
args = department_args.parse_args()
try:
id_ = ds.add(name=args['name'], email=args['email'])
created_department = ds.get(id_)
except IntegrityError:
return {'message': f"Departme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_department():\n logger.debug('Routed to /departments/add')\n\n if request.method == 'POST':\n name = request.form.get(\"name\")\n email = request.form.get(\"email\")\n\n try:\n ds.add(name, email)\n except IntegrityError as exception:\n logger.error('... | [
"0.83515495",
"0.8286092",
"0.80750674",
"0.78898543",
"0.78584856",
"0.7276642",
"0.71313643",
"0.6963064",
"0.66448486",
"0.6494299",
"0.6454834",
"0.63422024",
"0.6288573",
"0.62164277",
"0.62058616",
"0.59953094",
"0.592722",
"0.58748484",
"0.5860363",
"0.58289534",
"0.57... | 0.84991974 | 0 |
GET method, returns certain department by id. | def get(id_):
logger.debug('Catch GET request by URL /api/departments/%i.', id_)
try:
department = ds.get(id_)
if not department.id:
raise Exception
except Exception:
logger.error('There is no department with id %i', id_)
return {'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_department(id_: int):\n\n logger.debug('Routed to /departments/%i', id_)\n titles = ['Name', 'Average Salary', 'Employees', 'E-mail']\n department = None\n\n try:\n department = ds.get(id_)\n except IntegrityError:\n logger.error(\"Can't find employee with id %i\", id_)\n ... | [
"0.84085786",
"0.7923413",
"0.7799314",
"0.762513",
"0.7419371",
"0.74175876",
"0.7370106",
"0.6990669",
"0.6760814",
"0.6547017",
"0.6442252",
"0.6337737",
"0.63375086",
"0.6291892",
"0.62416136",
"0.6226284",
"0.62131727",
"0.62112105",
"0.6149921",
"0.60447145",
"0.5963399... | 0.8391516 | 1 |
PUT method, updates existing department by id. | def put(id_=None):
logger.debug('Catch PUT request by URL /api/departments/%i.', id_)
try:
args = department_args.parse_args()
ds.update(id_, name=args['name'], email=args['email'])
except Exception:
return {'message': "Can't update department."}, 404
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, department_id):\n department = get_department_by_id(department_id)\n department.name = request.json[\"name\"]\n db.session.commit()\n return {}, 200",
"def update_department(department_id):\n details = request.get_json()\n errors = check_department_keys(request)\n ... | [
"0.8171113",
"0.8080008",
"0.78269655",
"0.730599",
"0.6754468",
"0.668468",
"0.65975183",
"0.63646346",
"0.6236213",
"0.61737126",
"0.61372775",
"0.60807115",
"0.6018062",
"0.5967394",
"0.5767757",
"0.5758104",
"0.5758104",
"0.57168895",
"0.57055074",
"0.56856376",
"0.567995... | 0.8127168 | 1 |
POST method, doesn't relate to certain department. | def post(id_=None):
logger.debug('Catch POST request by URL /api/departments/%i.', id_)
return abort(405) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post():\n\n logger.debug('Catch POST request by URL /api/departments.')\n args = department_args.parse_args()\n try:\n id_ = ds.add(name=args['name'], email=args['email'])\n created_department = ds.get(id_)\n except IntegrityError:\n return {'message... | [
"0.7745221",
"0.6630201",
"0.6624349",
"0.65502745",
"0.64529896",
"0.64247143",
"0.6355796",
"0.62937057",
"0.62396705",
"0.6131375",
"0.6056458",
"0.6031699",
"0.6026827",
"0.5993256",
"0.5987849",
"0.5987849",
"0.5987849",
"0.5987849",
"0.5987849",
"0.5987849",
"0.5987849"... | 0.7382478 | 1 |
Query plug for energy usage data. Runs as async task. | def getEnergyUsage():
energy_data = asyncio.run(plug.get_emeter_realtime())
return energy_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def query(self, metric):\n raise NotImplementedError()",
"def consume_energy(self):\n return self.bot_client.send_command(_Command.ConsumeEnergy)",
"def get_energy(self):\n return self.bot_client.send_command(_Command.GetEnergy)",
"def query(self):\n self._measurements[self.... | [
"0.6075474",
"0.59772664",
"0.5869885",
"0.58322054",
"0.5771755",
"0.56210566",
"0.5562882",
"0.55395865",
"0.5468506",
"0.54670334",
"0.54600596",
"0.5457776",
"0.54573524",
"0.54573524",
"0.53745216",
"0.53253096",
"0.53008413",
"0.5285705",
"0.5281344",
"0.5260745",
"0.52... | 0.7689566 | 0 |
Connect to MQTT server and display server IP when successful. If error occur restart script. | def connectMQTT():
try:
mqttClient.connect(mqttServerIP)
print("Connected to %s MQTT broker" % mqttServerIP)
except OSError:
print("Failed to connect to MQTT broker. Restarting and reconnecting.")
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mqtt_connect():\n global mqtt_client\n logging.debug('connecting to mqtt broker %s', config['mqtt']['host'])\n mqtt_client = paho.Client()\n mqtt_client.tls_set()\n mqtt_client.on_connect = mqtt_on_connect\n mqtt_client.on_message = mqtt_on_message\n mqtt_client.username_pw_set(config['mqtt']['username'... | [
"0.68676937",
"0.67100126",
"0.669355",
"0.66683996",
"0.6472447",
"0.64513195",
"0.63695097",
"0.63592774",
"0.62721497",
"0.62624174",
"0.62452495",
"0.6171494",
"0.6170111",
"0.6170111",
"0.61474234",
"0.6132856",
"0.6131563",
"0.60914075",
"0.60817116",
"0.6070144",
"0.60... | 0.7611444 | 0 |
Initialize MQTT client and smart plug device instance | def initialize():
client = mqtt.Client(client_id=clientID)
p = kasa.SmartPlug(plugIP)
asyncio.run(p.update())
return client, p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.host = None\n self.port = None\n self.topic = None\n self._is_opened = False\n self.debug = 0\n self.qos = 0\n self.mqttc = mqtt.Client(\"sng_mqtt\")",
"def init_mqtt_client(self):\n self.mqtt_client = Client() # create client ob... | [
"0.774876",
"0.72923833",
"0.7255548",
"0.7248288",
"0.7223283",
"0.71822965",
"0.7165273",
"0.705659",
"0.70517665",
"0.70345664",
"0.69778866",
"0.6961443",
"0.6934719",
"0.69093215",
"0.68574363",
"0.6839927",
"0.66756827",
"0.66753244",
"0.66513395",
"0.6618242",
"0.65082... | 0.8072966 | 0 |
Main script cycle(check connection, get data, send sata). Every 5 seconds tries to send data with energy consumption and actual power state on MQTT server if connection is up. | def publish():
while True:
mqttClient.reconnect()
energy_data = getEnergyUsage()
wats = float(energy_data['power_mw']) / 1000
wat_hours = float(energy_data['total_wh'])
sentPayload(name="power", site="bathroom", value=wats)
sentPayload(name="energy_total", site="bat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n #define the callbacks\n mqttc.on_message = on_message\n mqttc.on_connect = on_connect\n mqttc.on_publish = on_publish\n mqttc.on_subscribe = on_subscribe\n \n mqttc.will_set(willtopic, payload=\"offline\", qos=0, retain=True)\n mqttc.reconnect_delay_set(delay=3, delay_max=30, ... | [
"0.6838484",
"0.6585376",
"0.6341815",
"0.6324926",
"0.63036394",
"0.6286901",
"0.6280231",
"0.6225539",
"0.61884284",
"0.6188228",
"0.615399",
"0.61532027",
"0.6128408",
"0.6082001",
"0.60575485",
"0.60568744",
"0.6038828",
"0.6026853",
"0.60169464",
"0.60107285",
"0.5966759... | 0.6958831 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.