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 |
|---|---|---|---|---|---|---|
Report the detailed timesheet for today. | def do_rrt(self, arg):
self.do_timesheet('report extend track today') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_rt(self, arg):\n self.do_timesheet('report today')",
"def show_today_tasks(self):\n today = datetime.today()\n tasks = self.session.query(self.Table).filter(self.Table.deadline == today.strftime('%Y-%m-%d')).all()\n print(f'Today {today.strftime(\"%d %b\")}:')\n if tasks... | [
"0.72559977",
"0.62758464",
"0.62248325",
"0.6223336",
"0.6099756",
"0.60254157",
"0.5918867",
"0.58366483",
"0.58032715",
"0.5800318",
"0.57899195",
"0.5779033",
"0.5711421",
"0.5580187",
"0.552534",
"0.55175817",
"0.5431576",
"0.54253596",
"0.53975874",
"0.539205",
"0.53869... | 0.6635239 | 1 |
Report the timesheet for a week. | def do_rw(self, arg):
self.do_timesheet('report week') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reporting_week(self):\n\n print(\"Week Numbers:\")\n print(self.time_stamp)\n print(self.time_stamp_iso)\n print(\"Current = {}\".format(self.current_week()))\n print(\"Reporting = {}\".format(self.current_week() - 1))",
"def do_rrw(self, arg):\n self.do_timesheet('r... | [
"0.78466284",
"0.744055",
"0.7247169",
"0.688721",
"0.65291095",
"0.65165263",
"0.6470279",
"0.64689136",
"0.64216584",
"0.63769406",
"0.63683814",
"0.63074833",
"0.62996227",
"0.62685275",
"0.62551403",
"0.623483",
"0.62168926",
"0.62150455",
"0.6206032",
"0.62004954",
"0.61... | 0.75920844 | 1 |
Report the timesheet for a month. | def do_rm(self, arg):
self.do_timesheet('report month') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_to_generate_monthly_report(today):\n # We will make three attempts to generate the monthly report every month\n return today.day in (1, 2, 3)",
"def monthly_schedule(self,month):\n response = requests.get(f'http://company.com/{self.lname}/{month}')\n if response.ok:\n retu... | [
"0.67374146",
"0.64609563",
"0.61592793",
"0.6139588",
"0.6077845",
"0.6037842",
"0.5957328",
"0.5957328",
"0.5925088",
"0.5911148",
"0.5853519",
"0.5830335",
"0.5751275",
"0.5735978",
"0.5717099",
"0.5709584",
"0.56879324",
"0.5683817",
"0.5680816",
"0.5671539",
"0.5660934",... | 0.6691562 | 1 |
Report the timesheet for a year. | def do_ry(self, arg):
self.do_timesheet('report year') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_year(self, year):\n pass",
"def report_year(self, report_year):\n\n self._report_year = report_year",
"def report_year(self, report_year):\n\n self._report_year = report_year",
"def report_year(self, report_year):\n\n self._report_year = report_year",
"def increment_year... | [
"0.6860223",
"0.64029205",
"0.64029205",
"0.64029205",
"0.62339383",
"0.6200401",
"0.61287",
"0.6083873",
"0.5985608",
"0.5970167",
"0.59635514",
"0.58967537",
"0.5879202",
"0.58490413",
"0.5846017",
"0.58369195",
"0.57155764",
"0.5681742",
"0.56666756",
"0.5647257",
"0.56275... | 0.78585577 | 0 |
Command timesheet timesheet's related commands Usage timesheet | Desciption Timesheet is a command manipulates a tracking data and creates a report. It updates tracks for a specified period, changes time was spent and may set a track as unbilled. A data of a report can be narrowed to fetch tracks for a certain task or ... | def do_timesheet(self, arg):
def _usage():
self.do_help('timesheet')
commands = ['update', 'report']
words = shlex.split(arg)
words = [token.lower() for token in words]
if not len(words) or words[0] not in commands:
print(self.error_wrong_parameters)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_rrt(self, arg):\n self.do_timesheet('report extend track today')",
"def report_timesheet(self, args):\n if len(args) == 1:\n print(self.error_wrong_parameters)\n return\n # Shift 'report' keyword\n args = args[1:]\n pname = tname = ''\n mask ... | [
"0.6350595",
"0.5953301",
"0.5721576",
"0.5545668",
"0.53443635",
"0.5267479",
"0.52153486",
"0.51955545",
"0.5187003",
"0.50748396",
"0.50713784",
"0.50271684",
"0.4993536",
"0.49629956",
"0.49515334",
"0.49490532",
"0.49332142",
"0.49312136",
"0.4919219",
"0.49082175",
"0.4... | 0.61108553 | 1 |
Cache the Blurb instances. | def _populate_blurbs(self):
for blurb_id in _BLURB_IDS:
if getattr(self._section, "use_blurb_%s" % blurb_id):
self._blurbs.append(_Blurb(self._section, blurb_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_banners():\n banners = cache.get('banners')\n if not banners:\n banners = Banner.objects.filter(general=True)\n cache.set('banners', banners)\n return {'banners': banners}",
"def _fullcache(self):\n query = {\n \"%s__id\" % self._model: self._objid,\n \... | [
"0.6028274",
"0.56695217",
"0.55811936",
"0.5542353",
"0.5520321",
"0.5519755",
"0.5454257",
"0.54364455",
"0.54282826",
"0.5376936",
"0.5376592",
"0.5370709",
"0.53413415",
"0.5291048",
"0.5280704",
"0.52741593",
"0.52115685",
"0.5194591",
"0.51608825",
"0.51608825",
"0.5160... | 0.65004164 | 0 |
Hook the addoption to add the scenario and nosetup options | def pytest_addoption(parser):
parser.addoption(
"--scenarios",
nargs='*',
metavar="scenario",
choices=Scenario.scenarios.keys(),
help="scenarios to run, leave empty to print scenarios",
)
parser.addoption(
"--no-setup",
action="store_true",
he... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pytest_addoption(parser):\n\n parser.addoption(\n \"--skip_config\",\n action=\"store_true\",\n help=\"Apply new configurations on DUT\"\n )\n\n parser.addoption(\n \"--config_only\",\n action=\"store_true\",\n help=\"Apply new configurations on DUT\"\n )",... | [
"0.7230701",
"0.7164577",
"0.7153265",
"0.70948154",
"0.69381326",
"0.69068253",
"0.6897014",
"0.6809286",
"0.6781068",
"0.6775993",
"0.67368597",
"0.67231834",
"0.67189914",
"0.67125493",
"0.66949624",
"0.6657753",
"0.66511136",
"0.66445357",
"0.6621623",
"0.6599791",
"0.659... | 0.79354495 | 0 |
Hook the cmdline main to check if test should be run or only list available scenarios | def pytest_cmdline_main(config):
try:
if len(config.option.scenarios) == 0:
print("Available scenarios:")
for scenario in Scenario.scenarios.values():
print(f" {scenario.name} - {scenario.description}")
return 0
except:
pass
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pre_cli_list(run):\n out, err = run(dork.cli.the_predork_cli, [], *(\"\", \"-l\"))\n assert \"test.yml\" in out, \\\n \"Failed run the dork.cli.the_predork_cli method: {err}\"\\\n .format(err=err)",
"def test_validargs(clickrunner):\n for args in maincli.valid_args:\n resul... | [
"0.69539845",
"0.65052825",
"0.64269286",
"0.64269286",
"0.6341802",
"0.63390857",
"0.63270456",
"0.6313408",
"0.63101155",
"0.62681425",
"0.6258",
"0.6253013",
"0.625126",
"0.62502426",
"0.62323487",
"0.6226787",
"0.62109715",
"0.620348",
"0.6165653",
"0.61612827",
"0.612559... | 0.78428197 | 0 |
Hook pytest test generation to parametrize the tests to each scenario they are supposed to be included in and to generate the setup and teardown tests for each scenario. | def pytest_generate_tests(metafunc):
# test is setup or teardown - parametrize to all scenarios
if metafunc.function.__name__ in ["test_setup", "test_teardown"]:
metafunc.parametrize(
"scenario", Scenario.scenarios.values())
# parameterize test for each scenario it is included in
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pytest_generate_tests(metafunc):\n if \"retrospective\" in metafunc.fixturenames:\n metafunc.parametrize(\"retrospective\", [False, True])\n if \"test_type\" in metafunc.fixturenames:\n metafunc.parametrize(\"test_type\", [FILES_TEST, STATE_TEST])\n if \"raise_error\" in metafunc.fixture... | [
"0.7739637",
"0.75435764",
"0.74441427",
"0.7410751",
"0.73575944",
"0.72835654",
"0.7271091",
"0.7114842",
"0.7086104",
"0.70699865",
"0.704308",
"0.7039083",
"0.70184344",
"0.6836622",
"0.68358666",
"0.67640394",
"0.65853935",
"0.6499627",
"0.6490155",
"0.6441901",
"0.63703... | 0.84071386 | 0 |
Checks if the scenario parametrized to test should be filtered by what is set in config_scenarios | def should_skip_scenario(scenario, config_scenarios):
for config_scenario in config_scenarios:
if scenario == Scenario.scenarios[config_scenario].__name__:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches_config(cls, config):\n return (not config.measures) or all(me in cls.available_measures for me in config.measures)",
"def _has_testcase_with_same_params(testcase, testcase_map):\n for other_testcase_id in testcase_map:\n # yapf: disable\n if (testcase.project_name ==\n testcase_m... | [
"0.6195167",
"0.584315",
"0.5827648",
"0.5815462",
"0.57347786",
"0.5660867",
"0.56135815",
"0.5557565",
"0.55098784",
"0.5498779",
"0.5492603",
"0.548081",
"0.5449906",
"0.54373837",
"0.5436623",
"0.5378134",
"0.5373302",
"0.5347374",
"0.5344112",
"0.5299899",
"0.5297614",
... | 0.6798654 | 0 |
Hook collection modification to order tests by scenario, each scenario will start with it's setup, preceding with the tests and finally the teardown. | def pytest_collection_modifyitems(session, config, items):
test_scenarios = DefaultDict(TestSuite)
config_scenarios = config.option.scenarios
filter_scenarios = config_scenarios is not None
skip_setup = config.option.no_setup
if skip_setup and (not filter_scenarios or len(config_scenarios) > 1):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pytest_collection_modifyitems(config, items):\n # check if studio tests myst be skipped\n run_study = config.getoption(\"--runstudy\")\n # 'all' will match all studies, '' will not match anything\n run_study = {'': '(?!x)x', 'all': '.*'}.get(run_study, run_study)\n # --runstudy given in cli: do ... | [
"0.656119",
"0.61039406",
"0.6084039",
"0.60311735",
"0.6013919",
"0.59649473",
"0.5939651",
"0.5935594",
"0.5910891",
"0.59066004",
"0.58609056",
"0.5855353",
"0.5839861",
"0.5832981",
"0.58159596",
"0.5811885",
"0.58009213",
"0.5782111",
"0.5779561",
"0.5775907",
"0.5764255... | 0.7278946 | 0 |
Hook makereport to mark if the scenario setup has failed | def pytest_runtest_makereport(item, call):
if item.originalname == "test_setup" and call.when == "call":
try:
# TODO: not sure if this check is enough
failed = not call.result == []
except:
# call does not have valid result attribute if some exception happended
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indicate_failure(self):\n pass",
"def StepFailure(self):\n return recipe_api.StepFailure",
"def test_case_01(self):\n if True:\n self.fail()",
"def pytest_runtest_makereport(item, call):\n if \"incremental\" in item.keywords:\n if call.excinfo is not None:\n ... | [
"0.7047196",
"0.6925117",
"0.67258424",
"0.67041105",
"0.66620785",
"0.6551664",
"0.64687765",
"0.6450989",
"0.643399",
"0.6353542",
"0.6330532",
"0.63222635",
"0.63013333",
"0.62878495",
"0.62275034",
"0.6202006",
"0.619779",
"0.61859745",
"0.6149418",
"0.6101016",
"0.609423... | 0.7266723 | 0 |
Hook runtest_setup to skip test if their scenario setup has failed | def pytest_runtest_setup(item):
if not item.originalname == "test_setup":
scenario = scenario_re.match(item.name).groups()[0]
if _scenario_setup_failed[scenario]:
pytest.skip(f"Setup for {scenario} failed, skipping...") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_status_check(dp_setup):\n\n if dp_setup.setup_status == 0:\n pytest.skip(\"Skipping testcase because setup \\\n did not complete properly\")",
"def pytest_runtest_setup(item):\n if \"incremental\" in item.keywords:\n previousfailed = getattr(item.parent, \"_previ... | [
"0.7539502",
"0.7168475",
"0.680045",
"0.6769899",
"0.6741446",
"0.6730891",
"0.6708668",
"0.67018366",
"0.66657114",
"0.6512723",
"0.6464716",
"0.6456349",
"0.6433945",
"0.6433349",
"0.63669145",
"0.6332618",
"0.633232",
"0.6290003",
"0.6274346",
"0.62639135",
"0.62599593",
... | 0.79868513 | 0 |
Get list of port forwarding entities. | async def _async_port_entities_list(
avm_wrapper: AvmWrapper, device_friendly_name: str, local_ip: str
) -> list[FritzBoxPortSwitch]:
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_PORTFORWARD)
entities_list: list[FritzBoxPortSwitch] = []
if not avm_wrapper.device_conn_type:
_LOGGER.debug(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_port_forward_list(self, nPortFwdType):\n\t\treturn handle_to_object(call_sdk_function('PrlVirtNet_GetPortForwardList', self.handle, nPortFwdType))",
"def port_list(self):\n return self._port_list",
"def _get_forwarding_groups(self):\n return self.__forwarding_groups",
"def _get_forwarding_g... | [
"0.6575624",
"0.59077907",
"0.5837713",
"0.5837713",
"0.5837713",
"0.5738165",
"0.5708386",
"0.56922287",
"0.5692077",
"0.5650982",
"0.5595273",
"0.55351114",
"0.5523203",
"0.5486832",
"0.5478469",
"0.54460037",
"0.5389354",
"0.5386047",
"0.5374901",
"0.5352854",
"0.5350101",... | 0.60739696 | 1 |
Return call deflection data. | def data(self) -> dict[str, Any]:
return self.coordinator.data["call_deflections"].get(self.deflection_id, {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data():\n pass",
"def get_data(self):\n pass",
"def get_data(self):\n pass",
"def get_data(self):",
"def get_data(self):\r\n pass",
"def get_fat(self):\n if len(self.records) == 0 or self.records[0].FORMAT is None:\n return self.records, self.var_dict... | [
"0.6029236",
"0.5850787",
"0.5850787",
"0.5816029",
"0.57775885",
"0.568967",
"0.5680663",
"0.56521213",
"0.5634642",
"0.556317",
"0.556317",
"0.556317",
"0.5560738",
"0.5534589",
"0.5529225",
"0.5527906",
"0.55139613",
"0.547582",
"0.547582",
"0.5412613",
"0.54075426",
"0.... | 0.82881063 | 0 |
Returns None if file is not locked, otherwise returns the user and the client the file is locked with. | def locked(self):
for result in p4run('opened', '-a', self.__path):
if '+l' in result['type'] or '+m' in result['type']:
user = P4User(result['user'])
client = P4Client(result['client'])
return user, client | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_lockfile(self):\n try:\n with open(self.lockfile) as f:\n return f.read()\n except EnvironmentError as e:\n if e.errno in self.NOT_EXIST_ERRORS:\n return None\n raise",
"def acquire(self):\r\n start_time = time.time()\r... | [
"0.62164235",
"0.6191714",
"0.6041426",
"0.6023689",
"0.56963855",
"0.5626865",
"0.56259793",
"0.5596826",
"0.5577915",
"0.5561635",
"0.55318743",
"0.5522971",
"0.54924977",
"0.54642296",
"0.54564303",
"0.54481745",
"0.5433529",
"0.53933084",
"0.537763",
"0.53640884",
"0.5345... | 0.67735803 | 0 |
Creates backup folder if doesn't exist, and moves all data into it. | def create_backup():
if not os.path.exists(backup_directory):
print("Creating backup folder as 'FINGER DATA BACKUP'...")
os.makedirs(backup_directory)
for directory in directories:
print("Backing up data for label '{}'...".format(directory))
shutil.copytree('./'+directory, backup_directory+'/'+directory)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup_directory(self, source_directory, destination_directory):\n pass",
"def reset_backup_folder(self):\n pass",
"def makeBackup(self):\n #--File Path\n original = self.path\n #--Backup\n backup = self.path+'.bak'\n shutil.copy(original,backup)\n #-... | [
"0.65214306",
"0.6510049",
"0.6464436",
"0.63852924",
"0.63724446",
"0.6301501",
"0.62980753",
"0.626059",
"0.61886007",
"0.6152971",
"0.6086255",
"0.6069988",
"0.60538745",
"0.60263026",
"0.59899116",
"0.59500426",
"0.5910163",
"0.5907927",
"0.59050465",
"0.5874849",
"0.5867... | 0.74460024 | 0 |
Deletes old data folders, and recreates them from the backup folder. | def restore_backup():
for directory in directories:
shutil.rmtree('./'+directory)
for directory in directories:
print("Restoring data for label '{}'...".format(directory))
shutil.copytree(backup_directory+'/'+directory, './'+directory)
print("Data restoration complete!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all():\n if os.path.exists(DATA_DIR):\n shutil.rmtree(DATA_DIR)",
"def reset_backup_folder(self):\n pass",
"def backup_data():\n\ttry:\n\t\tos.chdir(backup_directory)\n\texcept:\n\t\tprint(\"Backup folder does not exist!\")\n\tfor directory in directories:\n\t\tshutil.rmtree... | [
"0.6959087",
"0.6932837",
"0.67664707",
"0.6507157",
"0.6495482",
"0.63897157",
"0.63854295",
"0.63776475",
"0.6273897",
"0.6213164",
"0.615991",
"0.61418915",
"0.6131707",
"0.60488254",
"0.60122275",
"0.6010502",
"0.60085917",
"0.6005368",
"0.5998081",
"0.5968873",
"0.596529... | 0.693683 | 1 |
Initial stab at the requires_numpy function raises a warning | def requires_numpy(f):
@wraps(f)
def wrapper(*args, **kwargs):
if _NUMPY_AVAILABLE:
return f(*args, **kwargs)
else:
raise Warning("Numpy not available. Cannot call %s" % f.__name__)
return f(*args, **kwargs)
return wrapper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, strict=True):\n self.strict = strict\n self.testwithoutnp = test_without_numpy()",
"def with_numpy(func):\r\n return func",
"def check_numpy(x):\n if isinstance(x, torch.Tensor):\n x = x.detach().cpu().numpy()\n x = np.asarray(x)\n assert isinstance(x, np... | [
"0.6546872",
"0.63643485",
"0.62574387",
"0.6253495",
"0.6237235",
"0.6213361",
"0.6105712",
"0.6105712",
"0.60214335",
"0.5940299",
"0.59354603",
"0.5872245",
"0.5869582",
"0.57768196",
"0.57631403",
"0.57466626",
"0.5744809",
"0.57393456",
"0.57375014",
"0.5700972",
"0.5700... | 0.72376585 | 0 |
Rate a single value based on linear interpolation. | def rate (self, indep):
data = self.data
index = len(data)-2
for i in xrange(len(data)-1):
if indep < float(data[i+1][0]):
index = i
break
return self.interpolateValue(float(data[index][0]),float(data[index][2]),float(data[index+1][0]),float(data[index+1][2]),indep) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speed_interpolation(val):\n if val == 0.5:\n return 1.0\n elif val < 0.5:\n return low_interp(val)\n else:\n return hi_interp(val)",
"def _set_rate(self):\r\n interval = self.data.iloc[2, 0] - self.data.iloc[1, 0]\r\n self.rate = int(1 / interval)",
"def rate(sel... | [
"0.6729182",
"0.6307266",
"0.62642294",
"0.61200744",
"0.59919167",
"0.5961092",
"0.58677727",
"0.5847443",
"0.58286476",
"0.5828598",
"0.5707358",
"0.5697539",
"0.5661246",
"0.5659527",
"0.56492877",
"0.5610367",
"0.56028885",
"0.5597788",
"0.559511",
"0.55597943",
"0.555223... | 0.6847074 | 0 |
Reverse rate a single value based on linear interpolation | def reverseRate (self, indep):
data = self.data
index = len(data)-2
for i in xrange(len(data)-1):
if indep < float(data[i+1][2]):
index = i
break
return self.interpolateValue(float(data[index][2]),float(data[index][0]),float(data[index+1][2]),float(data[index+1][0]),indep) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_rate(rate_tuple):\n return 1 / rate_tuple[2]",
"def rate (self, indep):\n data = self.data\n index = len(data)-2\n for i in xrange(len(data)-1):\n if indep < float(data[i+1][0]):\n index = i\n break\n return self.interpolateValue(float(data[index][0]),float(data[inde... | [
"0.67719895",
"0.642719",
"0.6261974",
"0.6227211",
"0.59597015",
"0.591231",
"0.5859282",
"0.5853899",
"0.58244973",
"0.5791869",
"0.5731416",
"0.57247967",
"0.56826323",
"0.5661443",
"0.56369877",
"0.5628915",
"0.56039304",
"0.55694044",
"0.5539542",
"0.5478829",
"0.5469235... | 0.81297004 | 0 |
Generates a new time series with reverserated values from another | def reverseRateTS (self,ts):
output = []
for line in ts.data:
output.append([line[0],self.rate2(line[1]),line[2]])
return timeseries(output) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_compress(self, pieces, start):\n \n time_series = [start]\n # stitch linear piece onto last\n for j in range(0, len(pieces)):\n x = np.arange(0,pieces[j,0]+1)/(pieces[j,0])*pieces[j,1]\n #print(x)\n y = time_series[-1] + x\n time_s... | [
"0.56737614",
"0.56737614",
"0.56249565",
"0.5581555",
"0.55597603",
"0.5551499",
"0.5501329",
"0.5489588",
"0.5466132",
"0.5429593",
"0.5420211",
"0.540473",
"0.53927773",
"0.5344522",
"0.52980465",
"0.5276862",
"0.5262544",
"0.52320635",
"0.522053",
"0.5171074",
"0.51193786... | 0.59851074 | 0 |
Tests loading config with a module callable that has no config. | def test_none_in_config(self, mocked_callable_loader, mocked_load_config):
config_filename = 'aconfigfile'
importer.Finder(config_filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_config(self, mocked_callable_loader, mocked_load_config):\n config_filename = 'aconfigfile'\n finder = importer.Finder(config_filename)\n mocked_load_config.assert_called_once_with(config_filename)\n\n module_config = finder.config.get('fake_package.fake_module')\n self.... | [
"0.7291979",
"0.71385074",
"0.6929926",
"0.67423624",
"0.6735557",
"0.6493901",
"0.6454785",
"0.64439315",
"0.6443603",
"0.64419734",
"0.63877636",
"0.63867325",
"0.6380733",
"0.63782287",
"0.6355612",
"0.6320208",
"0.6302732",
"0.6293869",
"0.62638265",
"0.6169299",
"0.61679... | 0.80493516 | 0 |
Function to abstract output image filename construction. Current approach is to create a 'PROCESSED' subdir inside the subdirectory corresponding to the midperiod of the date range for the fullsize images and a 'SPLIT' subdirectory for the subimages. | def construct_image_savepath(self, date_string, coords_string, image_type="RGB"):
if "SUB" in image_type:
output_location = os.path.join(self.output_location, date_string, "SPLIT")
else:
output_location = os.path.join(self.output_location, date_string, "PROCESSED")
# fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_subdirectory(subdir_path, regex_images, output_folder_if_pickle,\n min_n_leftside_metadata=10, only_ionogram_content_extraction_on_leftside_metadata=True, to_pickle=True):\n # Run segment_images on the subdirectory \n df_img,df_loss,df_outlier = segment_images(subdir_path,... | [
"0.63908",
"0.6056102",
"0.59397084",
"0.59102297",
"0.5876066",
"0.5860729",
"0.5819184",
"0.58062077",
"0.580037",
"0.5758858",
"0.57563317",
"0.5748149",
"0.57457376",
"0.5732462",
"0.56949836",
"0.56919485",
"0.56668204",
"0.5616348",
"0.56162333",
"0.5608194",
"0.5601554... | 0.6616829 | 0 |
Function to run the module. Loop over all datesubranges and call process_single_date() on each of them. | def run(self):
super().run()
date_subdirs = sorted(self.list_directory(self.input_location,
self.input_location_type))
for date_subdir in date_subdirs:
if not re.search("^([\d]{4}-[\d]{2}-[\d]{2})", date_subdir):
print... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # dates lists for testing\n dates = [\n datetime.date(2010, 1, 15),\n datetime.date(2012, 6, 29)\n ]\n targets = [\n datetime.date(2000, 1, 1),\n datetime.date(2016, 10, 3)\n ]\n #loop through cases\n for d in dates:\n for t in targets:\n ... | [
"0.598406",
"0.58095527",
"0.5807055",
"0.5773897",
"0.57469034",
"0.5707404",
"0.5694574",
"0.56121904",
"0.56060857",
"0.5522661",
"0.54842377",
"0.5463781",
"0.538987",
"0.5376148",
"0.5323573",
"0.5313236",
"0.5301901",
"0.52983844",
"0.52903414",
"0.5290009",
"0.5263263"... | 0.63575816 | 0 |
Check the RGB subimage corresponding to this NDVI image looks OK. | def check_sub_image(self, ndvi_filename, input_path):
rgb_filename = re.sub("BWNDVI","RGB",ndvi_filename)
rgb_img = Image.open(self.get_file(os.path.join(input_path, rgb_filename),
self.input_location_type))
img_ok = check_image_ok(rgb_img, 0.05)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sub_image(self, ndvi_filename, input_path):\n rgb_filename = re.sub(\"NDVI\",\"RGB\",ndvi_filename)\n rgb_img = self.get_image(os.path.join(input_path, rgb_filename))\n\n img_ok = check_image_ok(rgb_img, 0.05)\n return img_ok",
"def is_RGB(self,img_path):\n image=Imag... | [
"0.8038135",
"0.6662857",
"0.65129346",
"0.6423486",
"0.62485963",
"0.62480164",
"0.6097359",
"0.60779303",
"0.60570514",
"0.6055576",
"0.6054975",
"0.6044617",
"0.5984661",
"0.597382",
"0.5965496",
"0.59394634",
"0.5909699",
"0.59011686",
"0.5898578",
"0.5880267",
"0.5876283... | 0.8215671 | 0 |
Check the RGB subimage corresponding to this NDVI image looks OK. | def check_sub_image(self, ndvi_filename, input_path):
rgb_filename = re.sub("NDVI","RGB",ndvi_filename)
rgb_img = self.get_image(os.path.join(input_path, rgb_filename))
img_ok = check_image_ok(rgb_img, 0.05)
return img_ok | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sub_image(self, ndvi_filename, input_path):\n rgb_filename = re.sub(\"BWNDVI\",\"RGB\",ndvi_filename)\n rgb_img = Image.open(self.get_file(os.path.join(input_path, rgb_filename),\n self.input_location_type))\n img_ok = check_image_ok(rgb_img,... | [
"0.8215671",
"0.6662857",
"0.65129346",
"0.6423486",
"0.62485963",
"0.62480164",
"0.6097359",
"0.60779303",
"0.60570514",
"0.6055576",
"0.6054975",
"0.6044617",
"0.5984661",
"0.597382",
"0.5965496",
"0.59394634",
"0.5909699",
"0.59011686",
"0.5898578",
"0.5880267",
"0.5876283... | 0.8038135 | 1 |
Each date will have a subdirectory called 'SPLIT' with ~400 NDVI subimages. | def process_single_date(self, date_string):
# see if there is already a ndvi.json file in
# the output location - if so, skip
output_location = os.path.join(self.output_location, date_string,"JSON","NDVI")
if (not self.replace_existing_files) and \
self.check_for_existing_file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splitMerge(self):\n\t\tpath_merge = self.aug_merge_path\n\t\tpath_train = self.aug_train_path\n\t\tpath_label = self.aug_label_path\n\t\tfor i in range(self.slices):\n\t\t\tpath = path_merge + \"/\" + str(i)\n\t\t\ttrain_imgs = glob.glob(path+\"/*.\"+self.img_type)\n\t\t\tsavedir = path_train + \"/\" + str(i)\... | [
"0.595133",
"0.58945966",
"0.58325934",
"0.5802168",
"0.57542825",
"0.5715518",
"0.5714086",
"0.5603562",
"0.557431",
"0.5570771",
"0.5569425",
"0.55580586",
"0.55430764",
"0.5533043",
"0.55239487",
"0.55221367",
"0.5467713",
"0.5467154",
"0.54571563",
"0.53589416",
"0.535622... | 0.6070169 | 0 |
Create a tailored SVM classifier to further use to predict | def custom_training(nb_tweet_sample, randomised, equal_pos_neg, language, name_kernel, Resource, keep_null_vector):
m_features, m_labels = get_characteristic_label_vectors(nb_tweet_sample, randomised, equal_pos_neg, Resource,
keep_null_vector, language)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_SVM(data: np.array, labels: np.array)->None:\n print(\"SVM is not implemented yet!\")",
"def svm():",
"def classify(self, data):\n \"*** YOUR CODE HERE ***\"\n return self.sklearn_svm.predict(data)",
"def train(self, trainingData, trainingLabels, validationData, validationLabels ):... | [
"0.74245536",
"0.72653663",
"0.72029406",
"0.71481",
"0.71425575",
"0.71343595",
"0.7121671",
"0.71049994",
"0.70486885",
"0.69977236",
"0.6995051",
"0.69354665",
"0.6934409",
"0.69329035",
"0.6879862",
"0.68783337",
"0.6872857",
"0.6791274",
"0.67844033",
"0.677671",
"0.6768... | 0.7278228 | 1 |
Checks a single file and reports imbalanced quotes. | def check_file(filename):
for line, imbalance in check_file_balance(filename):
print '{name}:{line} {imbalance} quotes are imbalanced'.format(
name=filename, line=line, imbalance=' and '.join(imbalance)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duplicate_quotes(self):\n\n # Setup\n path = tests.test_util.init_quotefile(self.tempdir, \"quotes8.txt\")\n\n # Call function being tested\n with self.assertRaisesRegexp(Exception, re.escape(\"a duplicate quote was found on line 5 of '{}'. Quote: \\\"The depressing thing abou... | [
"0.64514214",
"0.63728905",
"0.6251669",
"0.61318374",
"0.6038755",
"0.6014769",
"0.59573436",
"0.5918087",
"0.5877048",
"0.57132167",
"0.56868976",
"0.56821746",
"0.5636283",
"0.55373394",
"0.5532979",
"0.55020666",
"0.5496599",
"0.54439133",
"0.5369307",
"0.5299016",
"0.529... | 0.7980774 | 0 |
Check all matching files in the directory, recursive or not. | def check_directory(directory, file_exts, recursive):
for filename in tree_walker(directory, file_exts, recursive=recursive):
check_file(filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_files(folder_path):\n for dataset_file in listdir(folder_path):\n verify_file(folder_path + dataset_file)",
"def _match_all(abs_dir, matching, not_matching):\n num_not_matching = 0\n\n for expression in matching:\n if not fnmatch.fnmatch(abs_dir, expression):\n num_no... | [
"0.68475485",
"0.6748209",
"0.6720091",
"0.65586984",
"0.64987665",
"0.6392444",
"0.6379973",
"0.6374137",
"0.63139343",
"0.62979114",
"0.62551415",
"0.6251213",
"0.6240236",
"0.6220307",
"0.6212094",
"0.6209517",
"0.6161811",
"0.616029",
"0.6156458",
"0.6141434",
"0.61388713... | 0.7785399 | 0 |
Find the start position of the maze | def findStart(maze):
start_Position = 0
for i in range(0, len(maze)):
for j in range(0, len(maze[0])):
if maze[i][j] == 'P':
start_Position = i * len(maze[0]) + j
return start_Position
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_start_node(self) -> MazeCell:\n return self._start_node",
"def backtrack_to_start(board, end):\r\n cell = board.at(end)\r\n # print(cell)\r\n path = []\r\n lis = []\r\n while cell != None:\r\n path.append(cell)\r\n cell = cell.path_from\r\n for i in path[-1:]:\r... | [
"0.73054814",
"0.70507145",
"0.6931038",
"0.6863873",
"0.66988903",
"0.6598483",
"0.6526041",
"0.6505516",
"0.649952",
"0.6399859",
"0.6399859",
"0.6399859",
"0.637604",
"0.6371917",
"0.6324958",
"0.6307789",
"0.6246911",
"0.62361574",
"0.6212202",
"0.6210481",
"0.614648",
... | 0.79864275 | 0 |
Find the end position of the maze | def findEnd(maze):
final_Position = 0
for i in range(0, len(maze)):
for j in range(0, len(maze[0])):
if maze[i][j] == '.':
final_Position = i * len(maze[0]) + j
return final_Position
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_end_node(self) -> MazeCell:\n return self._end_node",
"def get_end_loc(self) -> Tuple[int, int]:\n assert self.pos_marker\n return self.pos_marker.working_loc_after(\n self.raw,\n )",
"def findStart(maze):\n start_Position = 0\n for i in range(0, len(maze)):... | [
"0.717331",
"0.6836621",
"0.67375916",
"0.662352",
"0.6482371",
"0.63844573",
"0.6366002",
"0.6249933",
"0.61706",
"0.6140208",
"0.61023366",
"0.6072212",
"0.60102415",
"0.60079265",
"0.60019976",
"0.6000571",
"0.59502167",
"0.5941163",
"0.5914859",
"0.58956844",
"0.5878427",... | 0.82256186 | 0 |
Find the number of goals | def num_of_goals(maze):
count = 0
for i in range(0, len(maze)):
for j in range(0, len(maze[0])):
if maze[i][j] == '.':
count += 1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_goal_done(self, season=None, stage=None):\n cnt = 0\n matches = self.get_matches(season=season, ordered=True)\n for m in matches:\n if util.is_None(m.goal):\n continue\n if not util.is_None(stage) and m.stage >= stage:\n return cnt\n ... | [
"0.7134005",
"0.6836646",
"0.680982",
"0.66096485",
"0.66093063",
"0.65508413",
"0.641527",
"0.63940704",
"0.63724166",
"0.63724166",
"0.63724166",
"0.63724166",
"0.62400764",
"0.6205538",
"0.61994475",
"0.61957324",
"0.61829734",
"0.6176286",
"0.61710906",
"0.61667156",
"0.6... | 0.712693 | 1 |
This function finds the nearest fruit of current position | def closest_fruit(maze, currX, currY, fruit_list):
curr_min = sys.maxsize
for position in fruit_list:
distance = Astar(maze, currX, currY, position[0], position[1])
if distance < curr_min:
curr_min = distance
return curr_min | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closestFood(pos, food, walls):\n fringe = [(pos[0], pos[1], 0)]\n expanded = set()\n while fringe:\n pos_x, pos_y, dist = fringe.pop(0)\n if (pos_x, pos_y) in expanded:\n continue\n expanded.add((pos_x, pos_y))\n # if we find a food at this location then exit\n ... | [
"0.7051569",
"0.7051569",
"0.6634373",
"0.64470977",
"0.6331274",
"0.63046014",
"0.6298118",
"0.6280977",
"0.6156889",
"0.6088076",
"0.60613",
"0.6055863",
"0.6047264",
"0.6038702",
"0.60233784",
"0.6021113",
"0.60130227",
"0.60057616",
"0.5998253",
"0.59963185",
"0.59912944"... | 0.7583291 | 0 |
Assert that env variables are replaced in parsed config. | def test_env_variables_replaced(self):
password = "ABC123qwe"
parsed_config = self._get_parsed_config("full_config.yml")
logger_with_replaced_password = parsed_config.loggers[0]
# replaced if env variable is present
self.assertEqual(
password,
logger_with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_env_var_verify():\n with open('skywalking/config.py', 'r') as config_file:\n data = config_file.read().replace('\\n', '')\n for each in OPTIONS.keys():\n if f'_{each.upper()}' not in data:\n raise Exception(f'Environment variable for {each.upper()} is not found... | [
"0.73749894",
"0.73658586",
"0.7352894",
"0.7328954",
"0.7326987",
"0.73115546",
"0.7239576",
"0.7118701",
"0.70504314",
"0.6948533",
"0.6660295",
"0.6642592",
"0.6521425",
"0.6511922",
"0.6486655",
"0.64748263",
"0.64657277",
"0.64488757",
"0.6378391",
"0.63549876",
"0.63463... | 0.79440945 | 0 |
Exports the current board to an FEN format meant for exporting | def export_to_FEN(self):
final_FEN_array = []
# Output state of pieces
final_FEN_array.append(self._export_board())
final_FEN_array.append('w' if self.white_to_move else 'b')
final_FEN_array.append(self.available_castles if self.available_castles else "-")
final_FEN_arra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toFEN(self):\n row_strs = []\n for row in range(0,8):\n row = self.board[row]\n \n counter = 0\n row_str = \"\"\n for cell in row:\n if cell:\n if counter == 0:\n row_str += pieces_s[cell]\... | [
"0.681017",
"0.6483553",
"0.61728805",
"0.59665763",
"0.5963671",
"0.5932981",
"0.5874577",
"0.58599985",
"0.58199704",
"0.56737715",
"0.5647533",
"0.55947274",
"0.55381477",
"0.5481513",
"0.54759187",
"0.5461627",
"0.5449034",
"0.5441245",
"0.54395163",
"0.54376006",
"0.5423... | 0.7740351 | 0 |
converts a EAN move to internal coordinates in the board | def _EAN_coords_to_board_coords(EAN_move: str) -> (int, int):
assert EAN_move[0] in "abcdefgh" and EAN_move[1] in "12345678", "failed to get " + EAN_move
col = ord(EAN_move[0]) - ord('a')
row = 8 - int(EAN_move[1])
return row, col | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _AN_to_coords(self, move: str):\n\n orig_move = move\n\n extra_info = \"\"\n\n # remove all characters that don't matter when parsing\n for pointless_char in \"x+#\":\n move = move.replace(pointless_char, \"\")\n\n # Handle castling\n if CASTLE_QUEENSIDE in ... | [
"0.77504724",
"0.6948253",
"0.64844483",
"0.6003651",
"0.59367543",
"0.5791499",
"0.5699505",
"0.5690667",
"0.5684613",
"0.56577367",
"0.5653698",
"0.563426",
"0.5631644",
"0.5626147",
"0.56250554",
"0.55736893",
"0.5568672",
"0.55596614",
"0.55477536",
"0.5547573",
"0.554298... | 0.7544965 | 1 |
Invalidates castling if either the king or rook was moved | def _invalidate_castles(self):
if self.board[0][0] != 'r': # Black queenside
self.available_castles = self.available_castles.replace('q', '')
if self.board[0][7] != 'r': # Black kingside
self.available_castles = self.available_castles.replace('k', '')
if self.board[7][... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_valid_moves(self):\r\n # castling and en-passant rights are stored, because move affects these values\r\n temp_enpassant_possible = self.enpas_pos\r\n temp_castle = CastleRights(self.cr_castle_r.wks, self.cr_castle_r.bks,\r\n self.cr_castle_r.wqs, self... | [
"0.6392645",
"0.621743",
"0.6217085",
"0.61273366",
"0.608021",
"0.60771215",
"0.60581195",
"0.60546935",
"0.6036227",
"0.5978879",
"0.5968202",
"0.59250015",
"0.5924627",
"0.5899445",
"0.58952796",
"0.5890645",
"0.58730435",
"0.58223784",
"0.5810963",
"0.5798069",
"0.5772823... | 0.6648356 | 0 |
Converts an algebraic notation move to internal coordinates | def _AN_to_coords(self, move: str):
orig_move = move
extra_info = ""
# remove all characters that don't matter when parsing
for pointless_char in "x+#":
move = move.replace(pointless_char, "")
# Handle castling
if CASTLE_QUEENSIDE in move:
row ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_move_to_square(self, uci_move: str):\n chars = utils.split_string_to_chars(uci_move)\n square_from = ''.join(chars[0] + chars[1])\n square_to = ''.join(chars[2] + chars[3])\n return square_from, square_to",
"def test_move_initialization():\r\n m = Move('A1', 'B2')\r\n ... | [
"0.63731796",
"0.5935379",
"0.5798718",
"0.5784685",
"0.56920767",
"0.5684874",
"0.5637243",
"0.55397224",
"0.5485789",
"0.5454764",
"0.54507494",
"0.54258645",
"0.5371932",
"0.5371518",
"0.5364488",
"0.53356934",
"0.53237957",
"0.532104",
"0.5312109",
"0.5268661",
"0.5268661... | 0.69260526 | 0 |
Request the service (set thymio state values) exposed by the simulated thymio. A teleportation tool, by default in gazebo world frame. Be aware, this does not mean a reset (e.g. odometry values). | def thymio_state_service_request(self, position, orientation):
rospy.wait_for_service('/gazebo/set_model_state')
try:
model_state = ModelState()
model_state.model_name = self.thymio_name
model_state.reference_frame = '' # the frame for the pose information
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service(ants=0, tmo=200, waiton=-2) :\n return stow( ants, tmo, waiton, SERVICE );",
"def startService(self):\n self.world.start()",
"def init(self):\n try:\n yield self._connect_dbus()\n logger.info(\"Request the GSM resource\")\n yield WaitFSOResource('GS... | [
"0.62242675",
"0.5637222",
"0.55345064",
"0.53431636",
"0.53285766",
"0.530147",
"0.52767605",
"0.5229516",
"0.5223119",
"0.5223119",
"0.51513463",
"0.51237404",
"0.5123625",
"0.5117781",
"0.5117781",
"0.5034022",
"0.5029458",
"0.5021611",
"0.49992025",
"0.49782804",
"0.49595... | 0.64819825 | 0 |
Run vcftools to sort/compress/index a vcf file | def vcf_compress(fn):
ret = cmd_exe(f"vcf-sort {fn} | bgzip > {fn}.gz && tabix {fn}.gz") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compilevcf(args):\n from jcvi.variation.str import LobSTRvcf\n\n p = OptionParser(compilevcf.__doc__)\n opts, args = p.parse_args(args)\n\n if len(args) != 1:\n sys.exit(not p.print_help())\n\n folder, = args\n vcf_files = iglob(folder, \"*.vcf,*.vcf.gz\")\n for vcf_file in vcf_file... | [
"0.65551376",
"0.6353839",
"0.6204274",
"0.6045592",
"0.6039398",
"0.6026456",
"0.60237366",
"0.6014583",
"0.5893786",
"0.5844245",
"0.58375883",
"0.58292997",
"0.5802896",
"0.5797852",
"0.5705959",
"0.55909956",
"0.5515224",
"0.5505494",
"0.5427722",
"0.5370823",
"0.5360676"... | 0.70393276 | 0 |
Get the configured lxc root for containers | def get_root_path(path):
if not path:
path = __opts__.get("lxc.root_path", DEFAULT_PATH)
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_conda_root():\n root_path = \"\"\n try:\n conda_json = subprocess.check_output(\"conda info --json\",\n shell=True, stderr=subprocess.PIPE)\n if sys.version_info.major > 2:\n conda_json = conda_json.decode(\"utf-8\")\n\n dec ... | [
"0.637064",
"0.6228243",
"0.611554",
"0.610834",
"0.6107005",
"0.6073694",
"0.6021122",
"0.59645015",
"0.59363914",
"0.5918172",
"0.59082437",
"0.5842891",
"0.58324474",
"0.5808479",
"0.58053213",
"0.5800716",
"0.5797924",
"0.57776356",
"0.5768648",
"0.5768153",
"0.5752801",
... | 0.68899256 | 0 |
Clear any lxc variables set in __context__ | def _clear_context():
for var in [x for x in __context__ if x.startswith("lxc.")]:
log.trace("Clearing __context__['%s']", var)
__context__.pop(var, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_cxt_vars(cxt):\n if hasattr(cxt, '_cl'):\n del cxt._cl\n if hasattr(cxt, '_pairs'):\n del cxt._pairs",
"def context_reset(self):\n self._context_state = None\n logging.info('Resetting the context')",
"def controlVariablesClear() :\n s.clearScriptAll()",
"def reset_conte... | [
"0.7920712",
"0.7487981",
"0.66750956",
"0.66598994",
"0.662593",
"0.65864086",
"0.6567458",
"0.65108454",
"0.6506112",
"0.63643444",
"0.63367957",
"0.63300246",
"0.62848675",
"0.62818927",
"0.6278924",
"0.6275691",
"0.62550807",
"0.6248847",
"0.62454367",
"0.62208486",
"0.62... | 0.86192983 | 0 |
Search which bridges are potentially available as LXC bridges | def search_lxc_bridges():
bridges = __context__.get("lxc.bridges", None)
# either match not yet called or no bridges were found
# to handle the case where lxc was not installed on the first
# call
if not bridges:
bridges = set()
running_bridges = set()
bridges.add(DEFAULT_BR)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_lxc_bridge():\n return search_lxc_bridges()[0]",
"def list_bridges(self):\n return [x for x,y in self.devices.items() if y.device_type == \"Bridge\"]",
"def bridge(gwc = 0, brc = bridge_int):\n# bridge interface list\n br_interface = []\n# bridge ip addresses list\n gw_ipaddr = []\n# b... | [
"0.69621164",
"0.6684033",
"0.6341434",
"0.6117558",
"0.59657085",
"0.5825182",
"0.5812872",
"0.58122027",
"0.567891",
"0.55831635",
"0.5522842",
"0.54669815",
"0.5444635",
"0.54241157",
"0.5409699",
"0.53783625",
"0.52660066",
"0.5216317",
"0.5207417",
"0.5168369",
"0.516427... | 0.82118034 | 0 |
Search the first bridge which is potentially available as LXC bridge | def search_lxc_bridge():
return search_lxc_bridges()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_lxc_bridges():\n bridges = __context__.get(\"lxc.bridges\", None)\n # either match not yet called or no bridges were found\n # to handle the case where lxc was not installed on the first\n # call\n if not bridges:\n bridges = set()\n running_bridges = set()\n bridges.... | [
"0.7521935",
"0.67016417",
"0.61291337",
"0.5933337",
"0.58334655",
"0.57994896",
"0.5795875",
"0.55923074",
"0.55749744",
"0.55578643",
"0.55345637",
"0.5504249",
"0.5502816",
"0.5501173",
"0.5464856",
"0.545991",
"0.54234004",
"0.5419086",
"0.5386185",
"0.5383288",
"0.53652... | 0.8340334 | 0 |
Interface between salt.cloud.lxc driver and lxc.init ``vm_`` is a mapping of vm opts in the salt.cloud format as documented for the lxc driver. | def cloud_init_interface(name, vm_=None, **kwargs):
if vm_ is None:
vm_ = {}
vm_ = copy.deepcopy(vm_)
vm_ = salt.utils.dictupdate.update(vm_, kwargs)
profile_data = copy.deepcopy(vm_.get("lxc_profile", vm_.get("profile", {})))
if not isinstance(profile_data, (dict, (str,))):
profile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cloud_init(name, vm_=None, **kwargs):\n init_interface = cloud_init_interface(name, vm_, **kwargs)\n name = init_interface.pop(\"name\", name)\n return init(name, **init_interface)",
"def __init__(self, conn, vm_name):\n self.vm = self.get_obj(conn, vim.VirtualMachine, vm_name)\n asser... | [
"0.61599976",
"0.59049606",
"0.5878049",
"0.56407505",
"0.56327516",
"0.5571679",
"0.55569005",
"0.55493927",
"0.5482196",
"0.5421474",
"0.54148704",
"0.5407343",
"0.5358224",
"0.5309503",
"0.5301207",
"0.5281789",
"0.5264342",
"0.52136207",
"0.5203196",
"0.5161978",
"0.51240... | 0.71750826 | 0 |
Network configuration defaults network_profile as for containers, we can either call this function either with a network_profile dict or network profile name in the kwargs nic_opts | def _network_conf(conf_tuples=None, **kwargs):
nic = kwargs.get("network_profile", None)
ret = []
nic_opts = kwargs.get("nic_opts", {})
if nic_opts is None:
# coming from elsewhere
nic_opts = {}
if not conf_tuples:
conf_tuples = []
old = _get_veths(conf_tuples)
if not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_networking(\n self, network_obj, ip, netmask, gateway, domain, dns, guest_hostname\n ):\n\n global_ip = vim.vm.customization.GlobalIPSettings()\n adapter_map = vim.vm.customization.AdapterMapping()\n adapter_map.adapter = vim.vm.customization.IPSettings()\n adapter_... | [
"0.6846558",
"0.66064805",
"0.65819055",
"0.65819055",
"0.6472075",
"0.63825357",
"0.63816035",
"0.6364383",
"0.63634956",
"0.63634956",
"0.63531065",
"0.62706405",
"0.61537826",
"0.6037617",
"0.59884",
"0.5984904",
"0.59825045",
"0.59778434",
"0.5948426",
"0.5938443",
"0.589... | 0.7293378 | 0 |
Removes parameters which match the pattern from the config data | def _filter_data(self, pattern):
removed = []
filtered = []
for param in self.data:
if not param[0].startswith(pattern):
filtered.append(param)
else:
removed.append(param)
self.data = filtered
return removed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteConfig(matcher, config):\n result = matcher.search(config)\n if not result:\n return config, ()\n start, end = result.span()\n captures = result.groups()\n return (config[:start] + config[end:]), captures",
"def _config_regex(self):",
"def remove_info(config):\n clean_con... | [
"0.6340481",
"0.6108231",
"0.6008967",
"0.5884418",
"0.5812272",
"0.5797809",
"0.57954615",
"0.5749245",
"0.5746013",
"0.5710172",
"0.56394845",
"0.56007004",
"0.5600398",
"0.5578663",
"0.55692947",
"0.55566084",
"0.5534305",
"0.5529074",
"0.5525302",
"0.5521977",
"0.55085266... | 0.744032 | 0 |
If the needed base does not exist, then create it, if it does exist create nothing and return the name of the base lxc container so it can be cloned. | def _get_base(**kwargs):
profile = get_container_profile(copy.deepcopy(kwargs.get("profile")))
kw_overrides = copy.deepcopy(kwargs)
def select(key, default=None):
kw_overrides_match = kw_overrides.pop(key, _marker)
profile_match = profile.pop(key, default)
# let kwarg overrides be t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createname(cls):\n name = config.get(\"pyzombie_filesystem\", \"execbase\")\n name = \"{0}_{1}\".format(name, datetime.utcnow().strftime(\"%Y%jT%H%M%SZ\"))\n if os.path.isdir(Executable.execdirpath(name)):\n #Need to handle the rare case of duplicate resource names---this\n ... | [
"0.60583836",
"0.5907243",
"0.5885327",
"0.57861507",
"0.56870806",
"0.5686935",
"0.56822044",
"0.5660491",
"0.5565593",
"0.554921",
"0.54963577",
"0.5486417",
"0.5474102",
"0.54729396",
"0.54644406",
"0.5462381",
"0.54609567",
"0.5460335",
"0.5419726",
"0.53880507",
"0.52886... | 0.6840039 | 0 |
Initialize a new container. This is a partial idempotent function as if it is already provisioned, we will reset a bit the lxc configuration file but much of the hard work will be escaped as markers will prevent reexecution of harmful tasks. name Name of the container image A tar archive to use as the rootfs for the co... | def init(
name,
config=None,
cpuset=None,
cpushare=None,
memory=None,
profile=None,
network_profile=None,
nic_opts=None,
cpu=None,
autostart=True,
password=None,
password_encrypted=None,
users=None,
dnsservers=None,
searchdomains=None,
bridge=None,
gat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_node(self, **kwargs):\n default = \"ubuntu.precise\"\n template = {\"name\":\"ubuntu\", \"args\":[]}\n if 'image' not in kwargs:\n kwargs['image'] = default\n \n for image in self.list_images():\n if image.name == kwargs['image']:\n ... | [
"0.66820186",
"0.5803766",
"0.57493997",
"0.5640015",
"0.5627814",
"0.56264293",
"0.5565917",
"0.5543074",
"0.5533584",
"0.5519633",
"0.55153155",
"0.54776216",
"0.54776216",
"0.54749733",
"0.5470206",
"0.5462942",
"0.5453705",
"0.5453369",
"0.54431856",
"0.54233575",
"0.5423... | 0.60662985 | 1 |
Thin wrapper to lxc.init to be used from the saltcloud lxc driver name Name of the container may be None and then guessed from saltcloud mapping `vm_` saltcloud mapping defaults for the vm | def cloud_init(name, vm_=None, **kwargs):
init_interface = cloud_init_interface(name, vm_, **kwargs)
name = init_interface.pop("name", name)
return init(name, **init_interface) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cloud_init_interface(name, vm_=None, **kwargs):\n if vm_ is None:\n vm_ = {}\n vm_ = copy.deepcopy(vm_)\n vm_ = salt.utils.dictupdate.update(vm_, kwargs)\n\n profile_data = copy.deepcopy(vm_.get(\"lxc_profile\", vm_.get(\"profile\", {})))\n if not isinstance(profile_data, (dict, (str,))):... | [
"0.7191671",
"0.59593487",
"0.5664225",
"0.5561173",
"0.5544013",
"0.5525819",
"0.5516496",
"0.549404",
"0.5465016",
"0.5461598",
"0.546096",
"0.5455348",
"0.5424041",
"0.53970885",
"0.53882545",
"0.53578675",
"0.5315698",
"0.5307036",
"0.5298775",
"0.5289854",
"0.5282188",
... | 0.6503301 | 1 |
Create a new container. name Name of the container config The config file to use for the container. Defaults to systemwide config (usually in /etc/lxc/lxc.conf). profile Profile to use in container creation (see | def create(
name, config=None, profile=None, network_profile=None, nic_opts=None, **kwargs
):
# Required params for 'download' template
download_template_deps = ("dist", "release", "arch")
cmd = f"lxc-create -n {name}"
profile = get_container_profile(copy.deepcopy(profile))
kw_overrides = copy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(\n name,\n config=None,\n cpuset=None,\n cpushare=None,\n memory=None,\n profile=None,\n network_profile=None,\n nic_opts=None,\n cpu=None,\n autostart=True,\n password=None,\n password_encrypted=None,\n users=None,\n dnsservers=None,\n searchdomains=None,\n ... | [
"0.6075936",
"0.5841215",
"0.5806689",
"0.5630651",
"0.55597794",
"0.55063236",
"0.5456116",
"0.5427631",
"0.5425852",
"0.5322353",
"0.5300968",
"0.5300968",
"0.52974516",
"0.5293702",
"0.5282008",
"0.5237458",
"0.5212504",
"0.51788056",
"0.5174497",
"0.5166467",
"0.51633656"... | 0.7305001 | 0 |
Create a new container as a clone of another container name Name of the container orig Name of the original container to be cloned profile Profile to use in container cloning (see | def clone(name, orig, profile=None, network_profile=None, nic_opts=None, **kwargs):
profile = get_container_profile(copy.deepcopy(profile))
kw_overrides = copy.deepcopy(kwargs)
def select(key, default=None):
kw_overrides_match = kw_overrides.pop(key, None)
profile_match = profile.pop(key, d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):",
"def clone( m, orig):\r\n if m.ObjType not in (1, 6): return\r\n if not orig: return\r\n \r\n if m.ObjType == 6: # Target is a Folder\r\n if orig.ObjType == 6: cloned = m.CopyFolderDisp( orig) # Orig is Folder too\... | [
"0.5772289",
"0.5650864",
"0.56195503",
"0.5611972",
"0.5600566",
"0.5599026",
"0.5561393",
"0.55396396",
"0.55313313",
"0.5530797",
"0.5530685",
"0.552028",
"0.55201644",
"0.55154884",
"0.5503272",
"0.54946333",
"0.5460324",
"0.54556835",
"0.54381055",
"0.5433605",
"0.541069... | 0.7597853 | 0 |
Raise an exception if the container does not exist | def _ensure_exists(name, path=None):
if not exists(name, path=path):
raise CommandExecutionError(f"Container '{name}' does not exist") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_nonexistant_container(self):\n ref = self.container_client._get_base_url() + '/invalid_uuid'\n get_resp = self.container_client.get_container(ref)\n self.assertEqual(get_resp.status_code, 404)",
"def create_container_if_missing(container, swift_conn, options):\n try:\n ... | [
"0.7576816",
"0.6658006",
"0.6570468",
"0.6503031",
"0.6378414",
"0.6369641",
"0.62627816",
"0.6254908",
"0.6067033",
"0.59998596",
"0.5997909",
"0.5931003",
"0.5895688",
"0.5895688",
"0.5887455",
"0.58845174",
"0.5854507",
"0.57873976",
"0.57844317",
"0.57744735",
"0.5717459... | 0.68097353 | 1 |
If the container is not currently running, start it. This function returns the state that the container was in before changing path path to the container parent directory | def _ensure_running(name, no_start=False, path=None):
_ensure_exists(name, path=path)
pre = state(name, path=path)
if pre == "running":
# This will be a no-op but running the function will give us a pretty
# return dict.
return start(name, path=path)
elif pre == "stopped":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n try:\n print('Starting container: {}'.format(self.cfg['name']))\n start = self.docker_client.run(**self.env)\n except docker_errors.APIError as error:\n print(error)\n print('Container {} is already running'.format(self.cfg['name']))\n ... | [
"0.6525386",
"0.5892428",
"0.58381957",
"0.5799751",
"0.5768178",
"0.55822957",
"0.5555275",
"0.5545344",
"0.55098873",
"0.5495534",
"0.5403357",
"0.5391542",
"0.5390164",
"0.5354356",
"0.53539497",
"0.5352874",
"0.5324362",
"0.53116184",
"0.5291704",
"0.5286928",
"0.52610266... | 0.6442831 | 1 |
Freeze the named container path path to the container parent directory | def freeze(name, **kwargs):
use_vt = kwargs.get("use_vt", None)
path = kwargs.get("path", None)
_ensure_exists(name, path=path)
orig_state = state(name, path=path)
start_ = kwargs.get("start", False)
if orig_state == "stopped":
if not start_:
raise CommandExecutionError(f"Con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cwd (self, path):\r\n pass",
"def component_docker_path(self, name: str) -> str:\n return str(self.component_path(name).parent.absolute())",
"def cwd_in_path():\n ...",
"def unfreeze(name, path=None, use_vt=None):\n _ensure_exists(name, path=path)\n if state(name, path=path) == \"s... | [
"0.5830676",
"0.5546616",
"0.55015755",
"0.54711205",
"0.5459175",
"0.5365298",
"0.53491515",
"0.5209383",
"0.5198676",
"0.5176276",
"0.51726145",
"0.51573443",
"0.5126788",
"0.5097986",
"0.5097181",
"0.5077351",
"0.5048799",
"0.50351375",
"0.50339293",
"0.5004525",
"0.500128... | 0.5833475 | 0 |
Unfreeze the named container. path path to the container parent directory | def unfreeze(name, path=None, use_vt=None):
_ensure_exists(name, path=path)
if state(name, path=path) == "stopped":
raise CommandExecutionError(f"Container '{name}' is stopped")
cmd = "lxc-unfreeze"
if path:
cmd += f" -P {shlex.quote(path)}"
return _change_state(cmd, name, "running",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_mount(self, path: str) -> \"Container\":\n _args = [\n Arg(\"path\", path),\n ]\n _ctx = self._select(\"withoutMount\", _args)\n return Container(_ctx)",
"def unfrozen(self):\n archive_name = self.get_archive_name()\n\n # Decompilation for all .pyc... | [
"0.5753504",
"0.55691415",
"0.5461836",
"0.5432628",
"0.5406749",
"0.53986204",
"0.5376133",
"0.5342398",
"0.53159845",
"0.5308569",
"0.5266518",
"0.5231988",
"0.52299297",
"0.5228473",
"0.5225309",
"0.5223065",
"0.52178305",
"0.51595366",
"0.5118637",
"0.51029444",
"0.510013... | 0.7536665 | 0 |
Returns whether the named container exists. path | def exists(name, path=None):
_exists = name in ls_(path=path)
# container may be just created but we did cached earlier the
# lxc-ls results
if not _exists:
_exists = name in ls_(cache=False, path=path)
return _exists | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def container_exists(self, id=None, name=None):\n exists = False\n if id and self.container_by_id(id):\n exists = True\n elif name and self.container_by_name(name):\n exists = True\n\n return exists",
"def Exists(self, path: str) -> bool:\n ...",
"def te... | [
"0.73341024",
"0.679069",
"0.67812216",
"0.6701584",
"0.6686739",
"0.66246325",
"0.6556786",
"0.65370065",
"0.652017",
"0.64798504",
"0.64441574",
"0.6364728",
"0.6331161",
"0.632475",
"0.63070565",
"0.62872106",
"0.6267875",
"0.62601227",
"0.6252627",
"0.62207246",
"0.619901... | 0.77212536 | 0 |
Returns the state of a container. path | def state(name, path=None):
# Don't use _ensure_exists() here, it will mess with _change_state()
cachekey = f"lxc.state.{name}{path}"
try:
return __context__[cachekey]
except KeyError:
if not exists(name, path=path):
__context__[cachekey] = None
else:
cmd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return self._container_dir",
"def _state_data_path(self) -> Path:\n return Path(self._state_dir, 'state')",
"def solution_path(self) -> list[State]:",
"def lookup_container(path):\n for container in containers():\n rpath = probe_path_in_container(container, path)\n ... | [
"0.637723",
"0.58938307",
"0.585438",
"0.5835431",
"0.5798212",
"0.5772527",
"0.5686279",
"0.5683623",
"0.56019366",
"0.5528277",
"0.5528032",
"0.54865354",
"0.5476503",
"0.54574996",
"0.5451577",
"0.5444445",
"0.5443946",
"0.5442292",
"0.54314566",
"0.5414911",
"0.5414911",
... | 0.6676328 | 0 |
Returns the value of a cgroup parameter for a container path path to the container parent directory | def get_parameter(name, parameter, path=None):
_ensure_exists(name, path=path)
cmd = "lxc-cgroup"
if path:
cmd += f" -P {shlex.quote(path)}"
cmd += f" -n {name} {parameter}"
ret = __salt__["cmd.run_all"](cmd, python_shell=False)
if ret["retcode"] != 0:
raise CommandExecutionError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cgroup(self):\n if os.environ.get(\"NO_CGROUP\"):\n return None\n pid = os.getpid()\n cfile = \"/proc/{}/cgroup\".format(pid)\n # TODO REMOVE THIS OR FIGURE OUT FOR TESTING WHAT TO DO ABOUT THIS\n if not os.path.exists(cfile):\n raise Exception(f\"C... | [
"0.65769273",
"0.62457204",
"0.5867603",
"0.5534241",
"0.5521419",
"0.5441542",
"0.5439973",
"0.5414378",
"0.53632414",
"0.5348421",
"0.52795565",
"0.5239584",
"0.5190792",
"0.51211596",
"0.5106422",
"0.5100882",
"0.5077889",
"0.50685614",
"0.5065297",
"0.50638187",
"0.503881... | 0.6499566 | 1 |
Set the value of a cgroup parameter for a container. path path to the container parent directory | def set_parameter(name, parameter, value, path=None):
if not exists(name, path=path):
return None
cmd = "lxc-cgroup"
if path:
cmd += f" -P {shlex.quote(path)}"
cmd += f" -n {name} {parameter} {value}"
ret = __salt__["cmd.run_all"](cmd, python_shell=False)
if ret["retcode"] != 0:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(self, name, path):\n self.yaml[IDK_YAML_GROUP][name] = path\n self.write()",
"def setPath(*args):",
"def set_zonepath(self, path):\n self.set_attr(ZONE_ENTRY['ZROOT'], path)",
"def get_parameter(name, parameter, path=None):\n _ensure_exists(name, path=path)\n cmd = \"lxc-cg... | [
"0.5628445",
"0.5346549",
"0.52035743",
"0.52012026",
"0.5184149",
"0.5179433",
"0.5116018",
"0.5091567",
"0.5006781",
"0.49869108",
"0.49837905",
"0.49817753",
"0.49750057",
"0.4939701",
"0.4900112",
"0.4869992",
"0.48482382",
"0.4794292",
"0.47680622",
"0.47667417",
"0.4684... | 0.69942623 | 0 |
Get the operational state of a systemd based container path path to the container parent | def systemd_running_state(name, path=None):
try:
ret = run_all(
name, "systemctl is-system-running", path=path, ignore_retcode=True
)["stdout"]
except CommandExecutionError:
ret = ""
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(name, path=None):\n # Don't use _ensure_exists() here, it will mess with _change_state()\n\n cachekey = f\"lxc.state.{name}{path}\"\n try:\n return __context__[cachekey]\n except KeyError:\n if not exists(name, path=path):\n __context__[cachekey] = None\n else:... | [
"0.59621274",
"0.5824988",
"0.5726111",
"0.5703246",
"0.56873155",
"0.5641615",
"0.5511324",
"0.54945695",
"0.54908264",
"0.54837257",
"0.5480335",
"0.5418569",
"0.5393705",
"0.53738993",
"0.53738993",
"0.53121793",
"0.5269728",
"0.52653515",
"0.52647144",
"0.51990974",
"0.51... | 0.59827733 | 0 |
Return True if the named container can be attached to via the lxcattach command path path to the container parent | def attachable(name, path=None):
cachekey = f"lxc.attachable{name}{path}"
try:
return __context__[cachekey]
except KeyError:
_ensure_exists(name, path=path)
# Can't use run() here because it uses attachable() and would
# endlessly recurse, resulting in a traceback
log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_docker():\n rc, out, _ = j.sals.process.execute(\"cat /proc/1/cgroup\", die=False, showout=False)\n if rc == 0 and \"/docker/\" in out:\n return True\n return False",
"def req_build(container):\n try:\n return 'dockerfile' in self.kard.env.get_container(container)... | [
"0.63328063",
"0.6257298",
"0.60977393",
"0.5650763",
"0.56292164",
"0.55628216",
"0.55491996",
"0.55406547",
"0.54978305",
"0.54968077",
"0.5455763",
"0.54142636",
"0.5397942",
"0.53714055",
"0.5338586",
"0.5338043",
"0.531101",
"0.52852744",
"0.52593184",
"0.52390534",
"0.5... | 0.73680145 | 0 |
Reboot a container. path path to the container parent | def reboot(name, path=None):
ret = {"result": True, "changes": {}, "comment": f"{name} rebooted"}
does_exist = exists(name, path=path)
if does_exist and (state(name, path=path) == "running"):
try:
stop(name, path=path)
except (SaltInvocationError, CommandExecutionError) as exc:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reboot(self, instance):\n try:\n out, err = utils.execute('sudo', 'vzctl', 'restart',\n instance['id'])\n if err:\n LOG.error(err)\n except ProcessExecutionError:\n raise exception.Error('Failed to restart contain... | [
"0.64766204",
"0.61042136",
"0.60781366",
"0.588684",
"0.5737953",
"0.569218",
"0.5689162",
"0.5683573",
"0.56762296",
"0.5630647",
"0.56163853",
"0.56092185",
"0.55962807",
"0.55416054",
"0.5506293",
"0.5498973",
"0.54100186",
"0.539479",
"0.53912336",
"0.5376954",
"0.534544... | 0.6835589 | 0 |
Reconfigure a container. This only applies to a few property name Name of the container. utsname utsname of the container. | def reconfigure(
name,
cpu=None,
cpuset=None,
cpushare=None,
memory=None,
profile=None,
network_profile=None,
nic_opts=None,
bridge=None,
gateway=None,
autostart=None,
utsname=None,
rootfs=None,
path=None,
**kwargs,
):
changes = {}
cpath = get_root_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __set_container_info(self):\n self.container = \"{}_{}_1\".format(self.build, self.service.lower())\n self.mysql_container = \"{}_{}-mysql_1\".format(self.build, self.service.lower())",
"def reconfigure(client, instance_name, command):\n\n # 'command' has 3 parts in a list (1 Command and 2 ... | [
"0.5688802",
"0.5612379",
"0.5199279",
"0.5175965",
"0.5149504",
"0.5137428",
"0.5076634",
"0.50598806",
"0.5049449",
"0.5042591",
"0.5017216",
"0.49024123",
"0.48940125",
"0.48901016",
"0.488051",
"0.48335877",
"0.48168996",
"0.48078325",
"0.48078325",
"0.47639975",
"0.47560... | 0.60598457 | 0 |
Returns a container pid. Throw an exception if the container isn't running. | def get_pid(name, path=None):
if name not in list_(limit="running", path=path):
raise CommandExecutionError(
f"Container {name} is not running, can't determine PID"
)
info = __salt__["cmd.run"](f"lxc-info -n {name}").split("\n")
pid = [
line.split(":")[1].strip()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pid_from_container(container_id):\n\n cmd = ['pgrep', '-f', container_id]\n try:\n return subprocess.check_output(cmd, stderr=subprocess.STDOUT)\n except subprocess.CalledProcessError as error:\n LOG.error('Could not get pid, error=%s', error)\n return 1",
"def container_id(self... | [
"0.7870028",
"0.7010304",
"0.70092154",
"0.687627",
"0.68020564",
"0.6793576",
"0.67661756",
"0.6732722",
"0.6683302",
"0.6612565",
"0.65184677",
"0.64688176",
"0.6462593",
"0.645608",
"0.6442939",
"0.6440602",
"0.6401523",
"0.63934046",
"0.63591",
"0.6311469",
"0.6294774",
... | 0.7870223 | 0 |
Add a veth to a container. | def add_veth(name, interface_name, bridge=None, path=None):
# Get container init PID
pid = get_pid(name, path=path)
# Generate a ramdom string for veth and ensure that is isn't present on the system
while True:
random_veth = "veth" + "".join(
random.choice(string.ascii_uppercase + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_container(self, account, container):\n \n pass",
"def test_sample_container_add(self):\n retval = self.container.add(\"key1\", [\"value1\"], 5)\n\n self.assertEqual(retval, None)\n self.assertEqual([\"value1\", ], self.container._data[\"key1\"])",
"def addContainer(se... | [
"0.58298266",
"0.58002985",
"0.56908727",
"0.56471306",
"0.5491566",
"0.54700404",
"0.54462945",
"0.54462945",
"0.54462945",
"0.54462945",
"0.543176",
"0.54148674",
"0.53822345",
"0.5328974",
"0.53262883",
"0.52914095",
"0.52834374",
"0.52764374",
"0.52595776",
"0.5217109",
"... | 0.6933137 | 0 |
This function takes a spectrum and integrates the given axis. The function assumes that the incoming data is in the histogram form. | def integrate_axis_py(obj, **kwargs):
# import the helper functions
import hlr_utils
# set up for working through data
o_descr = hlr_utils.get_descr(obj)
if o_descr == "number" or o_descr == "list":
raise RuntimeError("Must provide a SOM of a SO to the function.")
# Go on
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integral(self, axis=None):\n if axis is None:\n return (self * self.bset.area).sum()\n\n try:\n measure = numpy.prod([self.bset.binwidths[ax] for ax in axis],\n axis=0)\n except TypeError:\n measure = self.bset.binwidths[axis... | [
"0.5965463",
"0.5722021",
"0.55001545",
"0.54563475",
"0.5267387",
"0.51354736",
"0.5102577",
"0.50662524",
"0.49761945",
"0.49703512",
"0.4968417",
"0.4947284",
"0.49409816",
"0.49374717",
"0.49055633",
"0.48579165",
"0.48439932",
"0.47934014",
"0.4778929",
"0.4778446",
"0.4... | 0.65771925 | 0 |
Declarative request hook for TPU Start command. | def StartRequestHook(ref, args, request):
del ref
del args
start_request = GetMessagesModule().StartNodeRequest()
request.startNodeRequest = start_request
return request | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start():\n log(\"=========== hook: start ===========\")",
"def start( *args, **kwargs ):",
"def start():\n request.start = time.time()",
"def start_procedure(self):\n pass",
"def start(self):\n self.log.setLevel(logging.INFO)\n super().start()\n \n self._dts = rift.task... | [
"0.62123007",
"0.6009447",
"0.5895262",
"0.58739084",
"0.58359814",
"0.568772",
"0.5687707",
"0.56750745",
"0.56750745",
"0.56496805",
"0.5641725",
"0.56403697",
"0.56364733",
"0.5618818",
"0.56165755",
"0.560966",
"0.5591064",
"0.5584766",
"0.5584766",
"0.5584766",
"0.558476... | 0.63984233 | 0 |
Declarative request hook for TPU Stop command. | def StopRequestHook(ref, args, request):
del ref
del args
stop_request = GetMessagesModule().StopNodeRequest()
request.stopNodeRequest = stop_request
return request | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_stop(self):\n self._messaged.emit((\"stop\",None,0,None))",
"def StopRecordEnv(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def Stop(self, request... | [
"0.6810477",
"0.66077775",
"0.65568364",
"0.6482014",
"0.6473083",
"0.6434593",
"0.6422207",
"0.63642",
"0.6363843",
"0.62955624",
"0.62584615",
"0.62437326",
"0.6208099",
"0.6195634",
"0.6164148",
"0.6162522",
"0.6145841",
"0.61360335",
"0.6122276",
"0.60925007",
"0.6089813"... | 0.7161485 | 0 |
Add TPU resource args to parser for reimage command. | def AddReimageResourcesToParser(parser):
custom_help = {
'tpu': 'The Cloud TPU to reimage.'
}
resource_specs = LoadTPUResourceSpecs(custom_help)
presentation_specs = []
for arg in (spec for spec in resource_specs if spec.name in custom_help):
presentation_specs.append(presentation_specs_lib.Resourc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_args(parser):\n # fmt: off\n parser.add_argument('--pixel-loss-type', type=str, default='l1')\n # fmt: on",
"def add_args(parser):\n parser.add_argument(\"data\", metavar=\"FILE\", help=\"file prefix for data\")\n parser.add_argument(\n \"--num-classes0\",\n ... | [
"0.54705244",
"0.51580477",
"0.5047737",
"0.50449234",
"0.50383246",
"0.5009963",
"0.49864167",
"0.49745366",
"0.49586836",
"0.49418563",
"0.49120963",
"0.4862225",
"0.48517346",
"0.48434925",
"0.48415738",
"0.48293468",
"0.48072395",
"0.47596607",
"0.47467905",
"0.4669572",
... | 0.7974637 | 0 |
Retrieves the project field from the provided network value. | def _ParseProjectNumberFromNetwork(network, user_project):
try:
registry = resources.REGISTRY.Clone()
network_ref = registry.Parse(network,
collection='compute.networks')
project_identifier = network_ref.project
except resources.Error:
# If not a parseable resource s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_project(self, i):\r\n return self.__projects[i]",
"def __project(uri):\n uri = uri.lower().split('/')[-1].split('_')[0]\n project = {\n 'as': \"ICOS\",\n 'es': \"ICOS\",\n 'os': \"ICOS\",\n 'neon': 'NEON',\n 'ingos': 'INGOS',\n 'fluxnet': 'FLUXNET'\n... | [
"0.63224125",
"0.62142074",
"0.6150654",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
"0.6148387",
... | 0.71506685 | 0 |
Validates that supplied network has been peered to a GoogleOrganization. Uses the Service Networking API to check if the network specified via network flag has been peered to Google Organization. If it has, proceeds with TPU create operation otherwise will raise ServiceNetworking exception. Check is only valid if usese... | def CreateValidateVPCHook(ref, args, request):
del ref
service_networking_enabled = args.use_service_networking
if service_networking_enabled:
project = args.project or properties.VALUES.core.project.Get(required=True)
try:
network_project_number = _ParseProjectNumberFromNetwork(args.network,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_whole_network(self):\n if not self.network.check_network():\n # check_network has failed, issue error\n self._display_semantic_error(\"network\")",
"def test_03_network_create(self):\n # Validate the following\n # 1. Create a project.\n # 2. Add virtua... | [
"0.5467901",
"0.5072414",
"0.49279153",
"0.49249402",
"0.47891456",
"0.47063342",
"0.4651699",
"0.4650548",
"0.46425897",
"0.46351308",
"0.459492",
"0.45683298",
"0.45626068",
"0.4539677",
"0.45239413",
"0.4492794",
"0.4486676",
"0.4437604",
"0.4424795",
"0.44181558",
"0.4412... | 0.58377224 | 0 |
Get a person by the slugged name | def getBySlug( self, person_slug ):
qry = """SELECT * FROM `%s`.`people` WHERE `slug` = "%s"; """ % ( self.db_name, Mysql.escape_string( person_slug ) )
person = Mysql.ex( qry )
return person[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_person(name):\n if ' ' in name:\n name = name.replace(',', '')\n else:\n return None\n\n try:\n (first, last) = name.split(' ', 1)\n return Person.get(Person.first_name ** first, Person.last_name ** last)\n except Person.DoesNotExist:\n pass\n\n try:\n ... | [
"0.70989084",
"0.62111163",
"0.6066751",
"0.60478956",
"0.60363996",
"0.6035082",
"0.6015536",
"0.60052705",
"0.60052705",
"0.5968631",
"0.5958393",
"0.5953464",
"0.59316057",
"0.5920444",
"0.5912399",
"0.5907915",
"0.59019643",
"0.5862391",
"0.58374894",
"0.58150226",
"0.578... | 0.76045847 | 0 |
Get a person by the exact name | def getByName( self, people_name ):
qry = """SELECT * FROM `%s`.`people` WHERE `name` = "%s"; """ % ( self.db_name, Mysql.escape_string( person_name ) )
person = Mysql.ex( qry )
if len( person ) == 0:
return False
return person[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_person(name):\n if ' ' in name:\n name = name.replace(',', '')\n else:\n return None\n\n try:\n (first, last) = name.split(' ', 1)\n return Person.get(Person.first_name ** first, Person.last_name ** last)\n except Person.DoesNotExist:\n pass\n\n try:\n ... | [
"0.7679349",
"0.72173005",
"0.7037681",
"0.6901341",
"0.6892602",
"0.6857909",
"0.6857909",
"0.68539655",
"0.6847011",
"0.68377894",
"0.6833678",
"0.68050104",
"0.67762274",
"0.6773553",
"0.6739922",
"0.6739922",
"0.6681286",
"0.6669767",
"0.6653531",
"0.6648262",
"0.66175056... | 0.74054974 | 1 |
Get a person by the LIKE wiki url | def getByWiki( self, wikipedia_url ):
qry = 'SELECT * FROM `'+self.db_name+'`.`people` WHERE `wikipedia` LIKE "%'+ Mysql.escape_string( wikipedia_url ) + '%";'
person = Mysql.ex( qry )
return person[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def wiki(self, ctx, *, parse: str):\n parse = parse.split(' ', 1)\n anti = [\"antibirth\", \"anti\"]\n rev = [\"revelations\", \"rev\"]\n subdomain = \"antibirth\" if parse[0] in anti else \"tboirevelations\" if parse[0] in rev \\\n else \"bindingofisaacrebirth\"\n ... | [
"0.5960064",
"0.5766146",
"0.5766146",
"0.5717716",
"0.567234",
"0.5618703",
"0.55293447",
"0.5504833",
"0.54560703",
"0.54344946",
"0.5419914",
"0.53738326",
"0.53666824",
"0.53523976",
"0.5303817",
"0.5298844",
"0.5276349",
"0.52679694",
"0.52637225",
"0.52612007",
"0.52215... | 0.78201723 | 0 |
getRandom Gets a random person person | def getRandom( self ):
import random
count = Mysql.ex( "SELECT count(*) AS c FROM `%s`.`people`;" % self.db_name )
the_id = random.randint( 1, count[0]['c'] )
people = self.getByID( the_id )
return people | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_user():\n return random.choice(User.query.all())",
"def random_image(context, person):\n collection = db['people']\n images = collection.find({'person': person})\n row = []\n for image in images:\n row.append(image['image_url'])\n rand_img = random.choice(list(row))\n r... | [
"0.6894421",
"0.6801399",
"0.6705311",
"0.6636933",
"0.6617121",
"0.6617121",
"0.66101205",
"0.654614",
"0.6543784",
"0.65312624",
"0.6529804",
"0.6522531",
"0.6499706",
"0.649846",
"0.64737636",
"0.6387686",
"0.6385814",
"0.6367649",
"0.6353488",
"0.6353425",
"0.6351073",
... | 0.77666205 | 0 |
Updates a person record by a diff of the values | def updateDiff( self, person_new, person_rec ):
person_id = person_rec['id']
diff = {}
if 'slug' in person_new and person_new['slug'] != person_rec['slug']:
diff['slug'] = person_new['slug']
if 'wikipedia' in person_new and person_new['wikipedia'] != person_rec['wikipedia']:
diff['wikipedia'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(lname, person):\n # Does the person exist in people?\n if lname in PEOPLE:\n PEOPLE[lname][\"fname\"] = person.get(\"fname\")\n PEOPLE[lname][\"timestamp\"] = get_timestamp()\n\n return PEOPLE[lname]\n\n # otherwise, nope, that's an error\n else:\n abort(\n ... | [
"0.6076236",
"0.5890265",
"0.5691879",
"0.56393296",
"0.5562567",
"0.556077",
"0.5553972",
"0.55507255",
"0.5535648",
"0.5531998",
"0.54642683",
"0.53892994",
"0.5387568",
"0.5334643",
"0.5320626",
"0.5311849",
"0.52786183",
"0.5250379",
"0.5241066",
"0.5220597",
"0.5213094",... | 0.73809475 | 0 |
Determine the minum of three values min=x | def minimum(x,y,z):
return min(min(x,y),z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min(x):\n pass",
"def localmin(x):\r\n return (np.diff(np.sign(np.diff(x))) > 0).nonzero()[0] + 1",
"def min(self):\n return self._reduce_for_stat_function(F.min, only_numeric=False)",
"def localmin(x):\n return (np.diff(np.sign(np.diff(x))) > 0).nonzero()[0] + 1",
"def Min(data):\n re... | [
"0.7294391",
"0.71236384",
"0.709427",
"0.7075521",
"0.70469224",
"0.69684076",
"0.6939228",
"0.6930442",
"0.6890841",
"0.6890841",
"0.68730426",
"0.68183523",
"0.6759273",
"0.67541385",
"0.67298275",
"0.67280006",
"0.67271304",
"0.67210686",
"0.6683923",
"0.6676451",
"0.6675... | 0.8020329 | 0 |
Print source matrix for visual representation | def print_matrix(matrix,source,target):
print(u"\t (s)\u2192 \t",end='')
for c in target:
print("%2s\t"%c,end='')
print()
for x in range(0,len(matrix)):
if(x==0):
print(u"(t)\u2193 \t",end='')
else:
print("%2s\t"%source[x-1],end='')
for y in range(0,len(matrix[0])):
#print("%2d (%d,%d)\t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_matrix(self):\n print(self.matrix)",
"def PrintMatrix(self):\n # loop through the rows\n for i in range(self.rows):\n # intialise the matrix\n mat = []\n # loop through the column\n for j in range(self.cols):\n # append ma... | [
"0.7653871",
"0.7148127",
"0.70552987",
"0.6862053",
"0.66274035",
"0.6617468",
"0.66046643",
"0.6604163",
"0.6551498",
"0.6539895",
"0.6511098",
"0.6499741",
"0.648501",
"0.64522415",
"0.6444947",
"0.6436321",
"0.6391782",
"0.6391782",
"0.6387855",
"0.63827",
"0.638262",
"... | 0.74877894 | 1 |
Take an ordered list and return a set of pairs >>> list_to_pairs([1, 2, 3, 4]) set([(1, 2), (3, 4)]) >>> list_to_pairs(['a', 'b', 'c', 'd']) set([('a', 'b'), ('c', 'd')]) | def list_to_pairs(l):
return {(l[2*i], l[2*i+1]) for i in range(len(l)/2)} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list2pair(s_list):\n return s_list.pair",
"def __unordered_pairs(l):\n\n return [(l[i], l[j]) for i in range(len(l) - 1) for j in range(i + 1, len(l))]",
"def pairs(lst):\r\n\tfor i in range(1, len(lst), 2):\r\n\t\tyield lst[i-1], lst[i]",
"def pairs(lst):\n i = iter(lst)\n prev = next(i)\n ... | [
"0.660942",
"0.64966893",
"0.6364352",
"0.61183286",
"0.605809",
"0.6053188",
"0.6031079",
"0.5851849",
"0.58477825",
"0.58477825",
"0.58171743",
"0.5804332",
"0.56152576",
"0.5568751",
"0.5562793",
"0.5527791",
"0.5483368",
"0.54775673",
"0.5433456",
"0.54054826",
"0.5394198... | 0.69936943 | 0 |
Whether we have any path or not | def __nonzero__(self):
return any(self.path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Exists(self, path: str) -> bool:\n ...",
"def started_path(self):\n if self.ros_node.get_data('/diff_drive/path_achieved') is None:\n return False\n return not self.ros_node.get_data('/diff_drive/path_achieved')",
"def exists(self, path):",
"def exists(self):\r\n return... | [
"0.71787864",
"0.70898473",
"0.7088618",
"0.7060411",
"0.7047555",
"0.70403135",
"0.701854",
"0.6938369",
"0.6864744",
"0.6841349",
"0.6832685",
"0.6822189",
"0.67805845",
"0.67735195",
"0.67616457",
"0.676147",
"0.675315",
"0.6720118",
"0.67038804",
"0.67023015",
"0.67017573... | 0.8143155 | 0 |
The length of our path If we have no path, then 0 if path is a string, then 1 if path is an array, then the length of the array | def __len__(self):
if self.path_is_string:
if self.path:
return 1
else:
return 0
else:
if self.path_type in (list, tuple):
if not any(item for item in self.path):
return 0
return len(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self.path)",
"def __len__(self):\n return len(self.paths)",
"def __len__(self):\n return len(self.paths)",
"def get_path_length(self) :\n return self.path_length",
"def __len__(self):\n return len(self.A_paths)",
"def __len__(self):\n ... | [
"0.7701619",
"0.7640768",
"0.7640768",
"0.7519123",
"0.73827785",
"0.73827785",
"0.73827785",
"0.73827785",
"0.7197739",
"0.7128884",
"0.69983554",
"0.6982287",
"0.697171",
"0.697171",
"0.697171",
"0.6954649",
"0.6872361",
"0.6815414",
"0.68066716",
"0.6795057",
"0.6773987",
... | 0.8607569 | 0 |
Iterate through the parts of our path | def __iter__(self):
if self.path_is_string:
if self.path:
yield self.path
else:
for part in self.path:
yield part | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterPath(self, path):\n \n pathIndex = 0\n folderNames = path.split(self.PATH_SEPARATOR)\n \n while pathIndex < len(folderNames):\n yield folderNames[pathIndex], self.PATH_SEPARATOR.join(folderNames[0:pathIndex + 1])\n pathIndex += 1",
"def path_entrie... | [
"0.6414649",
"0.63788563",
"0.63580775",
"0.6353441",
"0.63335335",
"0.61753285",
"0.6140012",
"0.6139662",
"0.6131938",
"0.611136",
"0.600778",
"0.5968926",
"0.59639174",
"0.5872381",
"0.58316004",
"0.58115816",
"0.57891244",
"0.57866406",
"0.5755483",
"0.5751014",
"0.571890... | 0.7063032 | 0 |
If the path is a string, treat it as a list of that one string, otherwise, treat path as it is and get the index of the path as specified by key | def __getitem__(self, key):
path = self.path
if self.path_is_string:
path = [path]
return path[key] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self, path):\n try:\n indices = [int(x) if x.isdigit() else x for x in split(r'[\\/\\[\\]]+', path[1:])]\n return reduce(lambda x, y: x[y], indices, self.document)\n except:\n return None",
"def _get_array_index(array_path):\n\n if not array_path.starts... | [
"0.7110364",
"0.6245824",
"0.5962914",
"0.5931321",
"0.58305013",
"0.5829733",
"0.5766378",
"0.57603914",
"0.5714388",
"0.5689732",
"0.56681454",
"0.56269306",
"0.5546474",
"0.55295324",
"0.547897",
"0.5431614",
"0.54167795",
"0.54066426",
"0.5379117",
"0.5333005",
"0.5333005... | 0.65758604 | 1 |
Return whether the first part of this path is this string | def first_part_is(self, key):
if self.path_is_string:
return self.path.startswith(str(key) + '.')
if not self.path:
return not bool(key)
if self.path_type is list:
return self.path[0] == key
if self.path_type is Path:
return self.path.first... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasSubstring(self, s):\n node, off = self.followPath(s)\n return node is not None",
"def is_path(self, s):\n return True",
"def match_substring(self, str):\n if self.repo_relative_path.find(str) >= 0:\n return True\n\n if self.uuid:\n if (\"uuid://%s... | [
"0.7293922",
"0.6914573",
"0.68029654",
"0.66941047",
"0.6247078",
"0.62381357",
"0.622055",
"0.61871207",
"0.61856234",
"0.6183542",
"0.61692894",
"0.61627215",
"0.6134897",
"0.6134897",
"0.61286926",
"0.61160666",
"0.60987896",
"0.6065164",
"0.60475963",
"0.60429084",
"0.60... | 0.77528477 | 0 |
Does the path start with this string? | def startswith(self, base):
if self.path_is_string:
return self.path.startswith(base)
if not self.path:
return not bool(base)
if self.path_type is list and len(self.path) is 1:
return self.path[0].startswith(base)
return self.joined().startswith(base) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matches_path(cls, path):\n return path.startswith('/') or \\\n path.startswith('./') or \\\n path.startswith('../') or \\\n path.startswith('file://')",
"def starts_with(self, prefix: str) -> bool:\n return self.search(prefix, True)",
"def startsWi... | [
"0.75289965",
"0.7167043",
"0.71369225",
"0.7123099",
"0.70859516",
"0.7052085",
"0.7035095",
"0.7010681",
"0.69964033",
"0.6967141",
"0.6956085",
"0.69028676",
"0.6893171",
"0.6884508",
"0.68805164",
"0.68793577",
"0.68676823",
"0.68597203",
"0.68597203",
"0.6850657",
"0.682... | 0.7676601 | 0 |
Return a clone of this path with all the same values | def clone(self):
joined_function = lambda: dot_joiner(self.path, self.path_type)
return self.__class__(self.path, self.configuration, self.converters, self.ignore_converters, joined_function=joined_function) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\n # Run the constructor.\n other = BoardPath()\n # Copy the object variables\n other._current_cost = self._current_cost\n other._path = self._path[:]\n other._current_loc = self._current_loc\n return other",
"def copy(self):\n return Path... | [
"0.7665588",
"0.7400094",
"0.704908",
"0.70057935",
"0.70057935",
"0.70057935",
"0.70057935",
"0.6978792",
"0.6946278",
"0.6935552",
"0.69177884",
"0.68884027",
"0.68542576",
"0.6847932",
"0.6830563",
"0.679955",
"0.67944586",
"0.67944586",
"0.67944586",
"0.67944586",
"0.6794... | 0.74887073 | 1 |
Do the conversion on some path if any conversion exists Return (converted, did_conversion) Where ``did_conversion`` is a boolean indicating whether a conversion took place. | def do_conversion(self, value):
converter, found = self.find_converter()
if not found:
return value, False
else:
converted = converter(self, value)
self.converters.done(self, converted)
if hasattr(converted, "post_setup"):
converted... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def converted(self):\n if self.converters:\n return self.converters.converted(self)\n return False",
"def find_converter(self):\n if self.ignore_converters:\n return None, False\n return self.converters.matches(self)",
"def performConversion(self):\n ret... | [
"0.5848007",
"0.566183",
"0.5174522",
"0.51070803",
"0.49476284",
"0.4783851",
"0.47672653",
"0.47506908",
"0.46229607",
"0.45591906",
"0.44457802",
"0.44202554",
"0.44014907",
"0.44013757",
"0.43933994",
"0.438883",
"0.43888274",
"0.43719685",
"0.43644443",
"0.43442747",
"0.... | 0.6817883 | 0 |
Find appropriate converter for this path | def find_converter(self):
if self.ignore_converters:
return None, False
return self.converters.matches(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getConverterFor(self, *args):\n return _libsbml.SBMLConverterRegistry_getConverterFor(self, *args)",
"def converter(self):\r\n return self._converter",
"def converter(self):\n return self._converter",
"def converter(self):\r\n return self._endpoint.converter",
"def getConver... | [
"0.6894406",
"0.6664965",
"0.6639402",
"0.6496533",
"0.6168772",
"0.61331046",
"0.6112294",
"0.60424626",
"0.59838074",
"0.59664655",
"0.5777416",
"0.56580913",
"0.5560846",
"0.5559826",
"0.55199546",
"0.54745203",
"0.54502314",
"0.5372859",
"0.5343171",
"0.5282362",
"0.52743... | 0.7259743 | 0 |
Return the converted value for this path | def converted_val(self):
return self.converters.converted_val(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(self, value):\n return value",
"def convert(self, value):\r\n return value",
"def convert(self, value, context):\n return value",
"def convert(self, value):\r\n return Converter.convert(self, value)",
"def _conversion(self, val):\n if (self.__set_type == \"str... | [
"0.7295479",
"0.7265097",
"0.66316205",
"0.6538032",
"0.65285426",
"0.63996595",
"0.63996595",
"0.63584256",
"0.63584256",
"0.63554263",
"0.6269452",
"0.6219786",
"0.61724675",
"0.6151281",
"0.60600317",
"0.60472697",
"0.6013175",
"0.5997187",
"0.59565735",
"0.5947187",
"0.59... | 0.7291777 | 1 |
Returns the weekday of the product. Used only for products that are bound to a specific day. | def get_weekday(self):
weekdays = dict(PRODUCT_WEEKDAYS)
return weekdays.get(self.weekday, "N/A") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_of_week():\n return calendar.day_name[datetime.date.today().weekday()]",
"def weekday(self) -> int:\n return WD_EN.index(self.time.day.lower())",
"def weekday(self):\n\n return func.extract('dow', self.start_date) + 1",
"def day_of_week(self) -> str:\n return pulumi.get(self, ... | [
"0.7443026",
"0.72535807",
"0.72381914",
"0.71214",
"0.71214",
"0.7113097",
"0.7078143",
"0.7078143",
"0.7075242",
"0.7074787",
"0.70650786",
"0.7055152",
"0.7055152",
"0.69736695",
"0.6911523",
"0.6890648",
"0.67727506",
"0.67682344",
"0.6700004",
"0.6569597",
"0.6561082",
... | 0.79881895 | 0 |
Checks if the contact has expired invoices, returns True or False | def is_debtor(self):
return bool(self.expired_invoices_count()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired_invoices_count(self):\n return self.get_expired_invoices().count()",
"def expired(self):\n\n return self.getNotAfter() <= rpki.sundial.now()",
"def is_expired(self):\n expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)\n return (self.date_joined ... | [
"0.70427215",
"0.70207226",
"0.6923476",
"0.68999964",
"0.6830679",
"0.6823518",
"0.67947525",
"0.67519253",
"0.6697096",
"0.66647214",
"0.6662017",
"0.66469795",
"0.66408515",
"0.6632337",
"0.6622034",
"0.6621522",
"0.6588166",
"0.6573824",
"0.65544784",
"0.6533347",
"0.6527... | 0.71151036 | 0 |
Returns a queryset with the expired invoices for the contact. | def get_expired_invoices(self):
return self.invoice_set.filter(
expiration_date__lte=date.today(),
paid=False,
debited=False,
canceled=False,
uncollectible=False,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired_invoices_count(self):\n return self.get_expired_invoices().count()",
"def get_subscriptions_with_expired_invoices(self):\n subscriptions = []\n for invoice in self.get_expired_invoices():\n for invoice_item in invoice.invoiceitem_set.all():\n if (\n ... | [
"0.67440355",
"0.6387762",
"0.6090469",
"0.60641974",
"0.5989545",
"0.5955621",
"0.59304565",
"0.591822",
"0.58444196",
"0.5841969",
"0.5807256",
"0.5790679",
"0.5630977",
"0.5562243",
"0.5379452",
"0.5352015",
"0.52384615",
"0.5235957",
"0.516909",
"0.51581156",
"0.5147197",... | 0.8213595 | 0 |
Counts the amount of expired invoices for the contact. | def expired_invoices_count(self):
return self.get_expired_invoices().count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_no_of_invoices(self):\n for record in self:\n record.invoice_count = len(record.invoice_ids)",
"def get_expired_invoices(self):\n return self.invoice_set.filter(\n expiration_date__lte=date.today(),\n paid=False,\n debited=False,\n ... | [
"0.6492827",
"0.63781244",
"0.56678087",
"0.56478906",
"0.5508277",
"0.54931414",
"0.54583615",
"0.54224503",
"0.5404585",
"0.5396429",
"0.5373567",
"0.53188616",
"0.5313624",
"0.523742",
"0.5208584",
"0.51858103",
"0.51830447",
"0.51752496",
"0.5167114",
"0.5158963",
"0.5089... | 0.84319055 | 0 |
Adds a contact to a campaign. If the contact is already in that campaign this will raise an exception. | def add_to_campaign(self, campaign_id):
campaign = Campaign.objects.get(pk=campaign_id)
if not ContactCampaignStatus.objects.filter(
contact=self, campaign=campaign
).exists():
# We first create the big object that will hold the status for the campaign
Contact... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddContact(self, contact):\n\t\tcontact.group_membership_info = [gdata.contacts.data.GroupMembershipInfo(href=self.GetFirstGroupId())]\n\t\ttry:\n\t\t\tself.client.CreateContact(contact)\n\t\texcept gdata.client.RequestError:\n\t\t\tpass",
"def add_contact(self, contact):\n self.db.insert_contact(cont... | [
"0.7627295",
"0.7424115",
"0.68625385",
"0.68550974",
"0.68319404",
"0.6752613",
"0.66253865",
"0.64495605",
"0.643185",
"0.64214087",
"0.6403436",
"0.63824666",
"0.6353236",
"0.63223153",
"0.6272251",
"0.6199567",
"0.61656684",
"0.60307956",
"0.5995998",
"0.5977701",
"0.5914... | 0.7699542 | 0 |
Checks if the contact has any active subscription. If count is passed through this, it will instead return how many of these they have. | def has_active_subscription(self, count=False):
subs = self.subscriptions.filter(active=True)
return subs.exists() if count is False else subs.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_subscribers(self):\n return self.request(\"count:Contact\", [ None ])",
"def contacts_in_route_count(self):\n subprods = SubscriptionProduct.objects.filter(route=self).distinct('subscription__contact')\n return subprods.count",
"def get_subscribed_users(self, obj):\n retur... | [
"0.75198597",
"0.6862191",
"0.66709375",
"0.628151",
"0.6169264",
"0.60658246",
"0.6064264",
"0.60293543",
"0.589479",
"0.58911204",
"0.5842869",
"0.57893777",
"0.57746965",
"0.57657087",
"0.5731054",
"0.57261413",
"0.5724176",
"0.5717416",
"0.5708131",
"0.5706865",
"0.570610... | 0.7511574 | 1 |
Returns a queryset with the subscriptions of this contact. | def get_subscriptions(self):
return self.subscriptions.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriptions(self):\r\n return subs.AccountSubscriptions(self)",
"def subscriptions(self):\r\n return v3.Subscriptions(self)",
"def get_subscriptions(self):\n url = '{}/v2/subscriptions'.format(self.url)\n r = requests.get(url, headers=self.headers_v2)\n return r.json()"... | [
"0.75429577",
"0.7530589",
"0.7323063",
"0.7279339",
"0.7275472",
"0.72422016",
"0.7151664",
"0.7102055",
"0.7097441",
"0.6876215",
"0.68351597",
"0.66983294",
"0.66664577",
"0.66407704",
"0.66184616",
"0.654786",
"0.64856887",
"0.64463097",
"0.64458936",
"0.6443956",
"0.6442... | 0.8102227 | 0 |
Returns a list with the distinct subscriptions that have expired invoices | def get_subscriptions_with_expired_invoices(self):
subscriptions = []
for invoice in self.get_expired_invoices():
for invoice_item in invoice.invoiceitem_set.all():
if (
invoice_item.subscription
and invoice_item.subscription not in sub... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_expired_invoices(self):\n return self.invoice_set.filter(\n expiration_date__lte=date.today(),\n paid=False,\n debited=False,\n canceled=False,\n uncollectible=False,\n )",
"def expired_invoices_count(self):\n return self.get_exp... | [
"0.78037703",
"0.6684304",
"0.6344531",
"0.6057695",
"0.6041876",
"0.58982563",
"0.5830548",
"0.5798724",
"0.5777036",
"0.57421863",
"0.5709596",
"0.5693749",
"0.5611359",
"0.5611255",
"0.558637",
"0.55561835",
"0.5468073",
"0.54159164",
"0.5400865",
"0.53974116",
"0.53971344... | 0.8587474 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.