code stringlengths 4 4.48k | docstring stringlengths 1 6.45k | _id stringlengths 24 24 |
|---|---|---|
@command <NEW_LINE> def deploy(args): <NEW_LINE> <INDENT> build_root = '/tmp/build' <NEW_LINE> build_dest = '/tmp/build-dest' <NEW_LINE> os.mkdir(build_root) <NEW_LINE> os.mkdir(build_dest) <NEW_LINE> vcs_client = vcstools.get_vcs_client('git', build_root) <NEW_LINE> vcs_client.checkout('source-url', version='1.2.3') o... | (re)build and deploy the application | 625941e04e696a04525c97cd |
def has_permission(self, request, view): <NEW_LINE> <INDENT> if request.method in SAFE_METHODS: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return request.user.is_staff | Checks if the request belongs to SAFE_METHODS
Prevents any request other than SAFE_METHODS to be executed by Admin only | 625941e050485f2cf553d11b |
def testListBackoffIteratorAsTuple(self): <NEW_LINE> <INDENT> rc = RetryingCall(lambda: defer.fail(Exception())) <NEW_LINE> d = rc.start(backoffIterator=(0.01, 0.01, 0.01)) <NEW_LINE> self.failUnlessFailure(d, Exception) <NEW_LINE> return d | Pass a back-off iterator that is a C{tuple} and make sure the
function is called without incident until the list is exhausted. | 625941e091f36d47f21ac876 |
def DisableAutoScalingGroup(self, request): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> params = request._serialize() <NEW_LINE> body = self.call("DisableAutoScalingGroup", params) <NEW_LINE> response = json.loads(body) <NEW_LINE> if "Error" not in response["Response"]: <NEW_LINE> <INDENT> model = models.DisableAutoSc... | 本接口(DisableAutoScalingGroup)用于停用指定伸缩组。
:param request: 调用DisableAutoScalingGroup所需参数的结构体。
:type request: :class:`tencentcloud.autoscaling.v20180419.models.DisableAutoScalingGroupRequest`
:rtype: :class:`tencentcloud.autoscaling.v20180419.models.DisableAutoScalingGroupResponse` | 625941e0566aa707497f48e4 |
def test_read_namespaced_ingress_status(self): <NEW_LINE> <INDENT> pass | Test case for read_namespaced_ingress_status | 625941e0ec188e330fd5ab19 |
def __checkValues(obj): <NEW_LINE> <INDENT> elements=vars(obj) <NEW_LINE> allValues=True <NEW_LINE> for element in elements: <NEW_LINE> <INDENT> if elements[element]==None: <NEW_LINE> <INDENT> allValues=False <NEW_LINE> logging.warning(element+" does not have a value.") <NEW_LINE> <DEDENT> <DEDENT> return allValues | Checks that all the needed values are filled and creates a warning if not | 625941e0d53ae8145f87a5ea |
def execute(self): <NEW_LINE> <INDENT> tmp_dir = tempfile.mkdtemp() <NEW_LINE> print >>sys.stderr, 'Temporary directory is %s' % (tmp_dir,) <NEW_LINE> build_dir = os.path.join(tmp_dir, os.path.basename(self.svn_url)) <NEW_LINE> print >>sys.stderr, 'Creating checkout in %s' % build_dir <NEW_LINE> svn = MinisculeSvnWrapp... | Execute build step. | 625941e032920d7e50b28553 |
def set_install_url(self, url): <NEW_LINE> <INDENT> self.install_url = url | Set install URL to other_config field
:param url:
:return: | 625941e0a8370b7717052c1e |
def ConvertBoolop(self, tree): <NEW_LINE> <INDENT> return N.Expression(position = self.gc.GC(tree), operator = BINARY_OPERATOR_CONVERSIONS[GetClassName(tree.op)], children = self.ConvertListOfStatements(tree.values)) | Convert the BoolOp(boolop op, expr* values) node. (And | Or) | 625941e007d97122c4178c13 |
def _Offset(self, leftwards_value): <NEW_LINE> <INDENT> if (math.fabs(leftwards_value) < geom.tolerance) or len(self.vertices) < 2: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> RollDir = l if leftwards_value < 0 else -1 <NEW_LINE> kOffset = Curve() <NEW_LINE> kOffset_started = False <NEW_LINE> spans = self.GetSp... | offset the curve using Geoff's method | 625941e0090684286d50f06a |
def add_numbers(num1, num2, num3): <NEW_LINE> <INDENT> sum = num1 + num2 + num3 <NEW_LINE> return sum | This function accept three
argument please make sure
you pass three numbers | 625941e02eb69b55b151cc34 |
@toolkit.dummy <NEW_LINE> def transform_phone_movement(kchain_id, movement): <NEW_LINE> <INDENT> return movement | Transform the phone's movement to something sensible for the robot.
It currently does nothing; the phone and robot move on a 1:1 scale. | 625941e0090684286d50f06b |
def stop_moving(self): <NEW_LINE> <INDENT> self._keys_pressed -= 1 <NEW_LINE> if self._keys_pressed == 0: <NEW_LINE> <INDENT> self._turn = 0 <NEW_LINE> self._forward = 0 <NEW_LINE> self.callback(self._start_joystick_position) | Start and stop moving functions:
-start_moving function increases number of currently pressed keys used to navigate car.
-stop_moving function decreases this number, and returns joystick to start position if there is no pressed key.
:return: None | 625941e08e05c05ec3eea6f8 |
def part_1(input_file_name): <NEW_LINE> <INDENT> with open(input_file_name) as f: <NEW_LINE> <INDENT> ret_sum = 0 <NEW_LINE> for line in f: <NEW_LINE> <INDENT> line_list = [int(n) for n in line.split()] <NEW_LINE> max_number = max(line_list) <NEW_LINE> min_number = min(line_list) <NEW_LINE> ret_sum += max_number - min_... | Part 1 | 625941e0d7e4931a7ee9e29f |
def isAnagram(self, s, t): <NEW_LINE> <INDENT> cnt = [0] * 26 <NEW_LINE> for c in s: <NEW_LINE> <INDENT> cnt[ord(c) - ord('a')] += 1 <NEW_LINE> <DEDENT> for c in t: <NEW_LINE> <INDENT> cnt[ord(c) - ord('a')] -= 1 <NEW_LINE> <DEDENT> for i in cnt: <NEW_LINE> <INDENT> if i != 0: <NEW_LINE> <INDENT> return False <NEW_LINE... | :type s: str
:type t: str
:rtype: bool | 625941e026068e7796caf064 |
def isVoiceCompressionEnabled(self): <NEW_LINE> <INDENT> pass | Is voice compression enabled? Returns 1 if true otherwise returns 0. | 625941e0de87d2750b860116 |
def parse_page(self, response): <NEW_LINE> <INDENT> item = CrawlerItem() <NEW_LINE> item['url'] = response.url.encode('utf-8') <NEW_LINE> item['visited'] = datetime.datetime.now().isoformat().encode('utf-8') <NEW_LINE> item['published'] = get_first(response.selector.xpath('//meta[@name="date"]/@content').extract()) <NE... | Scrapes information from pages into items | 625941e029b78933be1e5a28 |
def find_max(lst): <NEW_LINE> <INDENT> index = len(lst) - 1 <NEW_LINE> x = lst[index].length <NEW_LINE> return x | Precon: Takes
lst-list sorted by length
Postcon: Returns largest length | 625941e096565a6dacc8fa4b |
def test_tenant_absent(self): <NEW_LINE> <INDENT> name = 'nova' <NEW_LINE> ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Tenant / project "{0}" is already absent'.format(name)} <NEW_LINE> mock_lst = MagicMock(side_effect=[['Error'], []]) <NEW_LINE> with patch.dict(keystone.__salt__, {'keystone.tenant_... | Test to ensure that the keystone tenant is absent. | 625941e0aad79263cf390dc7 |
def test_immunization_1(base_settings): <NEW_LINE> <INDENT> filename = base_settings["unittest_data_dir"] / "immunization-example.json" <NEW_LINE> inst = immunization.Immunization.parse_file( filename, content_type="application/json", encoding="utf-8" ) <NEW_LINE> assert "Immunization" == inst.resource_type <NEW_LINE> ... | No. 1 tests collection for Immunization.
Test File: immunization-example.json | 625941e015baa723493c42f9 |
def _set_prevent_teardown(self, v, load=False): <NEW_LINE> <INDENT> if hasattr(v, "_utype"): <NEW_LINE> <INDENT> v = v._utype(v) <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> t = YANGDynClass( v, base=YANGBool, default=YANGBool("false"), is_leaf=True, yang_name="prevent-teardown", parent=self, path_helper=self._path_hel... | Setter method for prevent_teardown, mapped from YANG variable /network_instances/network_instance/protocols/protocol/bgp/global/afi_safis/afi_safi/l3vpn_ipv6_unicast/prefix_limit/state/prevent_teardown (boolean)
If this variable is read-only (config: false) in the
source YANG file, then _set_prevent_teardow... | 625941e076e4537e8c3519f6 |
def end_subroutine(self): <NEW_LINE> <INDENT> if self.opcode & 0x000F == 0xE: <NEW_LINE> <INDENT> self.registers['pc'] = self.registers['stack'][self.registers['sp']] <NEW_LINE> self.registers['sp'] = self.registers['sp'] - 1 <NEW_LINE> <DEDENT> mnemonic = "RET" <NEW_LINE> human = "PC <= " + str(self.registers['stack']... | Limpia la pantalla
El flujo del programa se devuelve a la instrucción que llamó a la subrutina | 625941e0d486a94d0b98e4c7 |
def post(self, step_id): <NEW_LINE> <INDENT> step = JobStep.query.get(step_id) <NEW_LINE> if step is None: <NEW_LINE> <INDENT> return '', 404 <NEW_LINE> <DEDENT> if step.result == Result.aborted: <NEW_LINE> <INDENT> return '', 410 <NEW_LINE> <DEDENT> args = self.parser.parse_args() <NEW_LINE> artifact = Artifact( name=... | Create a new artifact with the given name. | 625941e0287bf620b61d3de2 |
def dump_commands(cf): <NEW_LINE> <INDENT> walk(cf, '') | dump a tree of all the known API commands | 625941e08a349b6b435e84f3 |
def video_id(value): <NEW_LINE> <INDENT> query = urlparse(value) <NEW_LINE> if query.hostname == 'youtu.be': <NEW_LINE> <INDENT> return query.path[1:] <NEW_LINE> <DEDENT> if query.hostname in ('www.youtube.com', 'youtube.com'): <NEW_LINE> <INDENT> if query.path == '/watch': <NEW_LINE> <INDENT> p = parse_qs(query.query)... | Examples:
- http://youtu.be/SA2iWivDJiE
- http://www.youtube.com/watch?v=_oPAwA_Udwc&feature=feedu
- http://www.youtube.com/embed/SA2iWivDJiE
- http://www.youtube.com/v/SA2iWivDJiE?version=3&hl=en_US | 625941e030bbd722463cc148 |
def draw_wall(self, cell, side): <NEW_LINE> <INDENT> start = None <NEW_LINE> heading = None <NEW_LINE> if side == Heading.NORTH: <NEW_LINE> <INDENT> start = (self.origin + self.square_size * cell[0], self.origin + self.square_size * (cell[1] + 1)) <NEW_LINE> heading = Heading.EAST <NEW_LINE> <DEDENT> elif side == Headi... | Draws a wall for a cell.
Arguments:
cell -- the position of the cell.
side -- the heading of the wall. | 625941e0dc8b845886cb58b7 |
def test_auth_register(self): <NEW_LINE> <INDENT> user = User.objects.get(username=self.login_credentials['username']) <NEW_LINE> self.client.force_login(user) <NEW_LINE> response_post = self.client.post(reverse_lazy('booking:register'), self.register_details, follow=True) <NEW_LINE> self.assertNotEquals(response_post.... | Dont Post Registration Details if User is Logged In | 625941e03eb6a72ae02ec867 |
def generate_metadata( build_env, setup_py_path, source_dir, isolated, details, ): <NEW_LINE> <INDENT> logger.debug( 'Running setup.py (path:%s) egg_info for package %s', setup_py_path, details, ) <NEW_LINE> egg_info_dir = TempDirectory( kind="pip-egg-info", globally_managed=True ).path <NEW_LINE> args = make_setuptool... | Generate metadata using setup.py-based defacto mechanisms.
Returns the generated metadata directory. | 625941e007f4c71912b11805 |
def precios_grupos_view(request): <NEW_LINE> <INDENT> grupos = Grupo.objects.all() <NEW_LINE> return render(request, 'precios-grupos.html', {'grupos': grupos}) | List available Grupo objects. | 625941e06e29344779a62991 |
def isIndexHidden(self, QModelIndex): <NEW_LINE> <INDENT> return False | QListView.isIndexHidden(QModelIndex) -> bool | 625941e010dbd63aa1bd2f23 |
@login_required(login_url="/login/") <NEW_LINE> def visualizar_mensaje_view(request,id_mensaje): <NEW_LINE> <INDENT> mensaje_obj = Mensaje.objects.get(pk=id_mensaje) <NEW_LINE> mensaje_obj.leido = True; <NEW_LINE> mensaje_obj.save() <NEW_LINE> usuario = Usuario.objects.get(id=request.user.id) <NEW_LINE> usuario.notific... | Permite visualizar el contenido de un mensaje seleccionado
:param
request:
:param id_mensaje:
:return: | 625941e00c0af96317bb8569 |
def computeArea(self, A, B, C, D, E, F, G, H): <NEW_LINE> <INDENT> a1 = (C-A) * (D-B) <NEW_LINE> a2 = (G-E) * (H-F) <NEW_LINE> if E < A: <NEW_LINE> <INDENT> (A,B,C,D), (E,F,G,H) = (E,F,G,H), (A,B,C,D) <NEW_LINE> <DEDENT> if C <= E or (D <= F or B >= H): <NEW_LINE> <INDENT> return a1 + a2 <NEW_LINE> <DEDENT> overlapX = ... | :type A: int
:type B: int
:type C: int
:type D: int
:type E: int
:type F: int
:type G: int
:type H: int
:rtype: int | 625941e0b7558d58953c528e |
def get_draw_support(self): <NEW_LINE> <INDENT> return bool(issubclass(self.__basedoc, DrawDoc)) | Check if the plugin supports the :class:`.DrawDoc` interface.
:return: bool: True if :class:`.DrawDoc` is supported; False if
:class:`.DrawDoc` is not supported. | 625941e0711fe17d825426e4 |
@pytest.fixture(autouse=True) <NEW_LINE> def setup_config(hass): <NEW_LINE> <INDENT> hass.loop.run_until_complete( register_auth_provider(hass, {"type": "homeassistant"}) ) <NEW_LINE> hass.loop.run_until_complete(auth_ha.async_setup(hass)) | Fixture that sets up the auth provider homeassistant module. | 625941e0d8ef3951e32438bf |
def get_apic_config(self): <NEW_LINE> <INDENT> return self._apic_policy | Get the apic configuration
:return: Instance of ApicPolicy or None if no apic policy configured. | 625941e030dc7b7665901ce3 |
def get_ticks(): <NEW_LINE> <INDENT> if not _get_init(): <NEW_LINE> <INDENT> return 0 <NEW_LINE> <DEDENT> return sdl.SDL_GetTicks() | get_ticks() -> milliseconds
get the time in milliseconds | 625941e0be8e80087fb20fbf |
def configure_mail(): <NEW_LINE> <INDENT> conf_file = '/etc/exim4/update-exim4.conf.conf' <NEW_LINE> put('templates%s' % conf_file, '/tmp/') <NEW_LINE> sudo('mv /tmp/update-exim4.conf.conf %s' % conf_file) <NEW_LINE> sudo('update-exim4.conf') | Setup an SMTP server only accessible to localhost | 625941e0fb3f5b602dac3a18 |
def round_up_to_multiple(n, x): <NEW_LINE> <INDENT> return n - n % -x | Round `n` up to the next multiple of `x` | 625941e071ff763f4b549a13 |
def distanceK(self, root, target, K): <NEW_LINE> <INDENT> con = collections.defaultdict(list); <NEW_LINE> def dfs(parent, child): <NEW_LINE> <INDENT> if parent and child: <NEW_LINE> <INDENT> con[parent.val].append(child.val) <NEW_LINE> con[child.val].append(parent.val) <NEW_LINE> <DEDENT> if child.left: dfs(child, chil... | :type root: TreeNode
:type target: TreeNode
:type K: int
:rtype: List[int] | 625941e076d4e153a657eeb3 |
def parse_path(command,cur_dir): <NEW_LINE> <INDENT> cur_dir = cur_dir[:] <NEW_LINE> exp = re.compile("(\.\.)|(\/)|\s") <NEW_LINE> for i in filter(lambda x: x, exp.split(command)): <NEW_LINE> <INDENT> if i == '..': <NEW_LINE> <INDENT> u.weak_pop(cur_dir) <NEW_LINE> <DEDENT> elif i == '/': <NEW_LINE> <INDENT> cur_dir = ... | makes path, relative to cur_dir | 625941e0851cf427c661a88d |
def can_create_log_entry_with_record_types(self, log_entry_record_types): <NEW_LINE> <INDENT> return | Tests if this user can create a single ``LogEntry`` using the desired record types.
While ``LoggingManager.getLogEntryRecordTypes()`` can be used to
examine which records are supported, this method tests which
record(s) are required for creating a specific ``LogEntry``.
Providing an empty array tests if a ``LogEntry``... | 625941e0b5575c28eb68e384 |
def pdf_page_count(filelike): <NEW_LINE> <INDENT> filelike.seek(0) <NEW_LINE> parser = PDFParser(filelike) <NEW_LINE> doc = PDFDocument() <NEW_LINE> parser.set_document(doc) <NEW_LINE> doc.set_parser(parser) <NEW_LINE> doc.initialize('') <NEW_LINE> pages = sum(1 for _ in doc.get_pages()) <NEW_LINE> filelike.seek(0) <NE... | returns number of pages of an pdf document | 625941e032920d7e50b28554 |
def get_vc(self): <NEW_LINE> <INDENT> url = "https://ssl.captcha.qq.com/cap_union_prehandle?aid=549000912&captype=&curenv=inner&protocol=https&clientype=2&disturblevel=&apptype=2&noheader=&color=&showtype=embed&fb=1&theme=&lang=2052&ua=" + self._UA + "&grayscale=1&cap_cd=" + self._cap_cd + "&uid=" + self._uin + "&wxLan... | 获取滑块验证参数
:return: | 625941e0099cdd3c635f0fda |
def build_relational(op, lhs, rhs): <NEW_LINE> <INDENT> return irt.FunCall(op, [lhs, rhs], type_hint=ctx.evaluator.bool) | Generate a function call to the given binary relational operator
between the two given expressions.
:param object op: The operator to call.
:param irt.Expr lhs: The left-hand side.
:param irt.Expr rhs: The right-hand side.
:rtype: irt.Expr | 625941e021a7993f00bc8077 |
def load_articles_to_redis_cron(): <NEW_LINE> <INDENT> site_articles, articles, sites_lastids = {}, [], [] <NEW_LINE> for article in Article.objects.filter(status='active', is_recent=True).order_by('-id').iterator(): <NEW_LINE> <INDENT> articles.append(article.uindex) <NEW_LINE> if not site_articles.get(article.site_id... | 扫描一遍数据库 | 625941e04e4d5625662d4754 |
def __init__(self, filename=None): <NEW_LINE> <INDENT> if filename is None: <NEW_LINE> <INDENT> from sage.misc.temporary_file import tmp_filename <NEW_LINE> self._filename = tmp_filename(ext='.perf') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self._filename = filename | Interface to the gperftools profiler
INPUT:
- ``filename`` -- string or ``None`` (default). The file name
to log to. By default, a new temporary file is created.
EXAMPLES::
sage: from sage.misc.gperftools import Profiler
sage: Profiler()
Profiler logging to ... | 625941e0287bf620b61d3de3 |
def map_omop_domain_to_blm_class(domain: str, concept_class: Optional[str] = None, desired_blm_categories: Iterable[str] = None ) -> str: <NEW_LINE> <INDENT> default_type = 'biolink:NamedThing' <NEW_LINE> if DomainClass(domain, concept_class) in map_omop_domain_to_blm_class.mappings_domain_class: <NEW_LINE> <INDENT> bi... | Maps the OMOP domain_id to Biolink Model class, e.g., 'Condition' to 'biolink:Disease'
Parameters
----------
domain - OMOP domain, e.g., 'Condition'
concept_class - [optional] OMOP concept class ID, e.g., 'Ingredient'
desired_blm_categories - [optional] desired Biolink categories to choose from (e.g., if a query node ... | 625941e0bd1bec0571d909b0 |
def get_field(record, field): <NEW_LINE> <INDENT> value = record[field.start-1:field.start+field.length-1].decode('utf-8') <NEW_LINE> if field.just == 'l': <NEW_LINE> <INDENT> return value.rstrip() <NEW_LINE> <DEDENT> elif field.just == 'r': <NEW_LINE> <INDENT> return value.lstrip() <NEW_LINE> <DEDENT> else: <NEW_LINE>... | Return the contents of a field from the record as a string. | 625941e00fa83653e465733a |
def loss_function(logits, labels, aux_logits): <NEW_LINE> <INDENT> with tf.name_scope('xentropy'): <NEW_LINE> <INDENT> cross_entropy = tf.losses.sparse_softmax_cross_entropy( logits=logits, labels=labels) <NEW_LINE> loss = tf.reduce_mean(cross_entropy, name='xentropy_mean') <NEW_LINE> <DEDENT> if aux_logits is not None... | Loss function. | 625941e0d486a94d0b98e4c8 |
def __init__( self, rollback_manager, cancellation_manager, ssh_actions, resource_group_name, storage_account_name, private_key, ): <NEW_LINE> <INDENT> super().__init__( rollback_manager=rollback_manager, cancellation_manager=cancellation_manager ) <NEW_LINE> self._ssh_actions = ssh_actions <NEW_LINE> self._resource_gr... | Init command.
:param rollback_manager:
:param cancellation_manager:
:param ssh_actions:
:param resource_group_name:
:param storage_account_name:
:param private_key: | 625941e0f548e778e58cd900 |
def fetchTweets(): <NEW_LINE> <INDENT> query = 'SELECT * FROM tweets' <NEW_LINE> return executeQuery(query, output=True) | Fetches all tweets the bot has tweeted. | 625941e05fc7496912cc3cff |
def random_run_until_control_side_changed(agg_wrap_base,itermax = 1000): <NEW_LINE> <INDENT> control_side = agg_wrap_base.control_side() <NEW_LINE> agg_wrap = agg_wrap_base.copy() <NEW_LINE> for i in range(itermax): <NEW_LINE> <INDENT> if agg_wrap.control_side() != control_side: <NEW_LINE> <INDENT> return agg_wrap <NEW... | 让AI控制(随机乱走)直到控制方变动 | 625941e0796e427e537b0949 |
def difference_update(self, other): <NEW_LINE> <INDENT> data = self._data <NEW_LINE> if not isinstance(other, BaseSet): <NEW_LINE> <INDENT> other = Set(other) <NEW_LINE> <DEDENT> if self is other: <NEW_LINE> <INDENT> self.clear() <NEW_LINE> <DEDENT> for elt in ifilter(data.has_key, other): <NEW_LINE> <INDENT> del data[... | Remove all elements of another set from this set. | 625941e030dc7b7665901ce4 |
def Run(benchmark_spec): <NEW_LINE> <INDENT> vm = benchmark_spec.vms[0] <NEW_LINE> _SetAndConfirmGpuClocks(vm) <NEW_LINE> num_iterations = FLAGS.gpu_pcie_bandwidth_iterations <NEW_LINE> raw_results = [] <NEW_LINE> metadata = {} <NEW_LINE> metadata['num_iterations'] = num_iterations <NEW_LINE> metadata['memory_clock_MHz... | Sets the GPU clock speed and runs the CUDA PCIe benchmark.
Args:
benchmark_spec: The benchmark specification. Contains all data that is
required to run the benchmark.
Returns:
A list of sample.Sample objects. | 625941e0dd821e528d63b527 |
def rule_low_registers(self, arg): <NEW_LINE> <INDENT> r_num = self.check_register(arg) <NEW_LINE> if r_num > 7: <NEW_LINE> <INDENT> raise iarm.exceptions.RuleError( "Register {} is not a low register".format(arg)) | Low registers are R0 - R7 | 625941e0e76e3b2f99f3ab88 |
def zip(filename): <NEW_LINE> <INDENT> filename_ziped = '{}_{}.zip'.format(filename[:-4], date.today().strftime('%Y%m%d')) <NEW_LINE> print('Gerando arquivo {}...'.format(filename_ziped)) <NEW_LINE> FNULL = open(os.devnull, 'w') <NEW_LINE> subprocess.call(['7z', 'a', '-y', filename_ziped, filename], stdout=FNULL, stder... | Cria o arquivo de backup do outlook.
Um arquivo .zip com a data que o arquivo foi gerado
Retorna: Nome do arquivo de backup | 625941e0a8370b7717052c1f |
def set_AppID(self, value): <NEW_LINE> <INDENT> super(GetTerritoryInputSet, self)._set_input('AppID', value) | Set the value of the AppID input for this Choreo. ((conditional, string) The App ID provided by Genability.) | 625941e09c8ee82313fbbaf7 |
def get_connection(conn_id=None): <NEW_LINE> <INDENT> return Connection( conn_id=conn_id, conn_type='http', schema='https', host='testhost',) | Can be used as patch for hook.get_connection. | 625941e055399d3f05588a37 |
def retrievedata(self, uid, deleteafteruse=True): <NEW_LINE> <INDENT> LOGGER.debug("Retrieving file %s", uid) <NEW_LINE> kwargs = self.FILENAME_RX.match(uid).groupdict() <NEW_LINE> with open(os.path.join(self.folder, uid), 'rb') as fin: <NEW_LINE> <INDENT> data = pickle.load(fin) <NEW_LINE> <DEDENT> if deleteafteruse: ... | Retrieve some data.
@param uid: the uid as returned by checkfordata
@return a tuple (kwargs, data) | 625941e044b2445a33932415 |
def t200450_x14(val2=10, val3=12): <NEW_LINE> <INDENT> assert GetDistanceToPlayer() < val2 <NEW_LINE> call = t200450_x23() <NEW_LINE> if call.Done(): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> elif GetDistanceToPlayer() > val3: <NEW_LINE> <INDENT> assert t200450_x2() <NEW_LINE> <DEDENT> """State 4""" <NEW_LINE> retur... | State 0,1 | 625941e07047854f462a1787 |
def _update_tooltip(self, event): <NEW_LINE> <INDENT> markup = None <NEW_LINE> if event: <NEW_LINE> <INDENT> if not event.xdata: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> if self._offset is not None: <NEW_LINE> <INDENT> xdata = self._offset <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> xdata = max(self._line_xs[0]... | Sets or clears the tooltip showing info about the hovered line. | 625941e0e8904600ed9f22b3 |
def simple_message(message_type, text_1, text_2): <NEW_LINE> <INDENT> message_dialog = Gtk.MessageDialog( None, 0, message_type, Gtk.ButtonsType.OK, text_1 ) <NEW_LINE> message_dialog.format_secondary_text(text_2) <NEW_LINE> content_area = message_dialog.get_content_area() <NEW_LINE> content_area.set_property('margin-l... | Show simple message box | 625941e05fcc89381b1e1a42 |
@contextlib.contextmanager <NEW_LINE> def use_store(store_or_path): <NEW_LINE> <INDENT> global store, db, layout, root, unpadded_root <NEW_LINE> temporary_store = store_or_path <NEW_LINE> if not isinstance(store_or_path, Store): <NEW_LINE> <INDENT> temporary_store = Store(store_or_path) <NEW_LINE> <DEDENT> _ = store.db... | Use the store passed as argument within the context manager.
Args:
store_or_path: either a Store object ot a path to where the store resides
Returns:
Store object associated with the context manager's store | 625941e0e1aae11d1e74a03c |
def _any_is_descendant(selection, target): <NEW_LINE> <INDENT> for index in selection: <NEW_LINE> <INDENT> if _is_descendant(index, target): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> <DEDENT> return False | Return true if any index in selection is a parent of target. | 625941e0187af65679ca54a1 |
def plot(self, data_types): <NEW_LINE> <INDENT> logging.info("Plotting most liked and most retweeted tweet") <NEW_LINE> if not data_types: <NEW_LINE> <INDENT> self.logger.warning("data_types list is empty. Valid data_types are favorite_count and retweet_count. " "Plotting both favorite and retweet count") <NEW_LINE> da... | Plot likes or retweets over time
:param data_type (String): Allowed valued: "favorite_count"/"retweet_count"
:return None: | 625941e0d268445f265b51f0 |
def test_successful_image_update(self): <NEW_LINE> <INDENT> config = CourseOverviewImageConfig.current() <NEW_LINE> course_image = 'src_course_image.png' <NEW_LINE> updated_course_image = 'src_course_image1.png' <NEW_LINE> course = CourseFactory.create(course_image=course_image) <NEW_LINE> self._create_course_image(cou... | Test the successful image set re-creation on updating
the course overview. | 625941e0b5575c28eb68e385 |
def test_read_step_file(self): <NEW_LINE> <INDENT> h_doc = Handle_TDocStd_Document() <NEW_LINE> app = XCAFApp_Application.GetApplication().GetObject() <NEW_LINE> app.NewDocument(TCollection_ExtendedString("MDTV-CAF"), h_doc) <NEW_LINE> doc = h_doc.GetObject() <NEW_LINE> h_shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc... | Reads the previous step file | 625941e03617ad0b5ed68278 |
def search(request, terms): <NEW_LINE> <INDENT> results = DocEntry.objects.search(terms.split(',')) <NEW_LINE> current_rank = 0 <NEW_LINE> ordered = {} <NEW_LINE> for r in results: <NEW_LINE> <INDENT> if r.rank == 0: <NEW_LINE> <INDENT> ordered[r] = [] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if r.parent in ordere... | Show a list of search results for a list of terms. | 625941e0d4950a0f3b08c6cc |
def render_template(self, template, context=None): <NEW_LINE> <INDENT> context = context or {} <NEW_LINE> extra_context = { 'constants': constants, 'csrf': self.csrf, 'current_account': self.get_current_account(), 'current_profile': self.get_current_profile(), 'request': self.request, 'session': self.session, 'uri_for'... | Renders the template with the provided context (optional). | 625941e0a934411ee3751a16 |
def create_test_image(): <NEW_LINE> <INDENT> image_file = StringIO() <NEW_LINE> image = Image.new('RGBA', size=(500, 500), color=(256, 0, 0)) <NEW_LINE> image.save(image_file, 'png') <NEW_LINE> image_file.seek(0) <NEW_LINE> return ContentFile(image_file.read(), 'test.png') | Create a 500x500px image for use in tests.
:returns: :class:`django.core.files.base.ContentFile` | 625941e0ac7a0e7691ed4448 |
def unregister(self, fd): <NEW_LINE> <INDENT> if self._epfd < 0: <NEW_LINE> <INDENT> _err_closed() <NEW_LINE> <DEDENT> ev = epoll_event() <NEW_LINE> try: <NEW_LINE> <INDENT> epoll_ctl(self._epfd, EPOLL_CTL_DEL, fd, byref(ev)) <NEW_LINE> <DEDENT> except OSError as exc: <NEW_LINE> <INDENT> if exc.errno != EBADF: <NEW_LIN... | Unregister a previously registered descriptor
:param fd:
The descriptor to unregister
:raises ValueError:
If :meth:`closed()` is True
:raises OSError:
If the underlying ``epoll_ctl(2)`` fails. The error message matches
those found in the manual page.
.. note::
For feature parity with Python 3.4, u... | 625941e0adb09d7d5db6cb0f |
def addDecodedOrigin(self,name,functions,nodeOrigin): <NEW_LINE> <INDENT> origins=[n.addDecodedOrigin(name,functions,nodeOrigin) for n in self._nodes] <NEW_LINE> self.createEnsembleOrigin(name) <NEW_LINE> return self.getOrigin(name) | Create a new Origin. A new origin is created on each of the
ensembles, and these are grouped together to create an output.
This method uses the same signature as ca.nengo.model.nef.NEFEnsemble.addDecodedOrigin()
:param string name: the name of the newly created origin
:param functions: the functions to approximate ... | 625941e03d592f4c4ed1d3e6 |
def getInboundMessages(self): <NEW_LINE> <INDENT> results = [] <NEW_LINE> messages = self._getInboundMessages() <NEW_LINE> for message in messages: <NEW_LINE> <INDENT> if not message.DeliveryReceipt(): <NEW_LINE> <INDENT> results.append(message) <NEW_LINE> <DEDENT> <DEDENT> if(len(results) > 0): <NEW_LINE> <INDENT> sel... | Returns an array of inbound messages and automatically acknowledges their receipt | 625941e010dbd63aa1bd2f24 |
def get_search_term(self): <NEW_LINE> <INDENT> return(self.entry.get_text()) | Return the currently set search term | 625941e023849d37ff7b340e |
def test_check_full_true(self): <NEW_LINE> <INDENT> self.picker.fruit_count = 999999999 <NEW_LINE> self.assertTrue(self.picker.check_full()) | Test check_full method to see if it detects a full count | 625941e0baa26c4b54cb149e |
@contextlib.contextmanager <NEW_LINE> def temporary_seed(seed): <NEW_LINE> <INDENT> state = np.random.get_state() <NEW_LINE> np.random.seed(seed) <NEW_LINE> try: <NEW_LINE> <INDENT> yield <NEW_LINE> <DEDENT> finally: <NEW_LINE> <INDENT> np.random.set_state(state) | Context for temporarily setting a numpy seed. | 625941e0d99f1b3c44c6790b |
def load_small_datasets_names(): <NEW_LINE> <INDENT> big_datasets = load_big_datasets_names() <NEW_LINE> all_datasets = load_datasets_names() <NEW_LINE> return [item for item in all_datasets if item not in big_datasets] | :return: the names of the big datasets. (more than 1000 features) | 625941e07d43ff24873a3024 |
def _pend_msg(self, handler): <NEW_LINE> <INDENT> return lambda msg: PendingMsg(msg, handler).pend() | Wrap your incoming ROS message handlers with this method for thread
safety. Handler execution will be postponed until the next Blender
callback. | 625941e096565a6dacc8fa4c |
def generate_new_name(self, prefix_name, idx=0): <NEW_LINE> <INDENT> prefix_name=LocationName.from_object(prefix_name) <NEW_LINE> if idx is None: <NEW_LINE> <INDENT> if self.is_name_free(prefix_name): <NEW_LINE> <INDENT> return prefix_name <NEW_LINE> <DEDENT> idx=0 <NEW_LINE> <DEDENT> while True: <NEW_LINE> <INDENT> pa... | Generate a new name inside the location using the given prefix and starting index.
If `idx` is ``None``, check just the `prefix_name` first before starting to append indices. | 625941e0435de62698dfdfcf |
def __getitem__(self, index): <NEW_LINE> <INDENT> ID = self.indexes[index] <NEW_LINE> X = [] <NEW_LINE> if self.cached[ID] is not None: <NEW_LINE> <INDENT> X = self.cached[ID] <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> X = self.load_file(ID) <NEW_LINE> if self.cache: <NEW_LINE> <INDENT> self.cached[ID] = X <NEW_LINE... | Generate one batch of data | 625941e097e22403b379d31d |
def set_mode(self, mode): <NEW_LINE> <INDENT> self.mode = mode | Set the mode of the worker.
The mode SCRIPT_MODE should be used if this Worker is a driver that is
being run as a Python script or interactively in a shell. It will print
information about task failures.
The mode WORKER_MODE should be used if this Worker is not a driver. It
will not print information about tasks.
Th... | 625941e0711fe17d825426e5 |
def to_geodetic(x,y,z,a_axis=6378137.0,flat=1.0/298.257223563): <NEW_LINE> <INDENT> b_axis = (1.0 - flat)*a_axis <NEW_LINE> lin_ecc = np.sqrt((2.0*flat - flat**2)*a_axis**2) <NEW_LINE> ecc1 = lin_ecc/a_axis <NEW_LINE> e12 = ecc1**2 <NEW_LINE> dtr = np.pi/180.0 <NEW_LINE> w = np.sqrt(x**2 + y**2) <NEW_LINE> lon = np.arc... | Convert from cartesian coordinates to geodetic coordinates
using a closed form solution
Inputs:
x,y,z in cartesian coordinates
Options:
a_axis: semimajor axis of the ellipsoid (default: WGS84)
flat: ellipsoidal flattening (default: WGS84)
References:
J Zhu "Exact conversion of Earth-centered, Earth-f... | 625941e08a43f66fc4b543e3 |
def step(self, length, width, agent_locations): <NEW_LINE> <INDENT> tempx = self.loc_x + self.action.move_x <NEW_LINE> tempy = self.loc_y + self.action.move_y <NEW_LINE> if [tempx, tempy] not in agent_locations: <NEW_LINE> <INDENT> if tempx < 0 or tempx >= length: <NEW_LINE> <INDENT> self.loc_x = self.loc_x <NEW_LINE> ... | This part is to move the agent while checking
if it hits the boundary or other agents | 625941e0091ae356686672da |
def __eq__(self, other: Any) -> bool: <NEW_LINE> <INDENT> if isinstance(other, str): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> other = self.construct_from_string(other) <NEW_LINE> <DEDENT> except TypeError: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> <DEDENT> if isinstance(other, type(self)): <NEW_LINE> <IN... | Check whether 'other' is equal to self.
By default, 'other' is considered equal if either
* it's a string matching 'self.name'.
* it's an instance of this type and all of the
the attributes in ``self._metadata`` are equal between
`self` and `other`.
Parameters
----------
other : Any
Returns
-------
bool | 625941e08e71fb1e9831db2a |
def test_specific_peer_prefixes_announced(self): <NEW_LINE> <INDENT> announced_prefixes = self.pybird.get_peer_prefixes_announced("PS1") <NEW_LINE> assert len(announced_prefixes) == 2 | Test the retrieval of prefixes announced by a peer. | 625941e0507cdc57c6307064 |
def __init__(self, method_name='ocsvm', rate_of_outliers=0.01, gamma='auto', nu=0.5, n_neighbors=10, metric='minkowski', p=2): <NEW_LINE> <INDENT> if method_name != 'knn' and method_name != 'lof' and method_name != 'ocsvm': <NEW_LINE> <INDENT> sys.exit('There is no ad method named \'{0}\'. Please check the variable of ... | Applicability Domain (AD)
Parameters
----------
method_name: str, default 'ocsvm'
The name of method to set AD. 'knn', 'lof', or 'ocsvm'
rate_of_outliers: float, default 0.01
Rate of outlier samples. This is used to set threshold
gamma : (only for 'ocsvm') float, default ’auto’
Kernel coefficient for ‘rbf’... | 625941e0627d3e7fe0d691d3 |
def getLength(self): <NEW_LINE> <INDENT> return len(self.masses) | Returns the branch length (= number of R-odd masses).
:returns: length of branch (number of cascade decay steps) | 625941e0462c4b4f79d1da51 |
def test_page_loading(self): <NEW_LINE> <INDENT> assert self.page.content == PAGE_CONTENT | Assert that content is loaded correctly from disk. | 625941e0bde94217f368316f |
def test_locate_middle(): <NEW_LINE> <INDENT> ugrid = twenty_one_triangles() <NEW_LINE> assert ugrid.locate_nodes( (3.0000000001, 5) ) == 6 <NEW_LINE> assert ugrid.locate_nodes( (3, 5.00000000001) ) == 7 <NEW_LINE> assert ugrid.locate_nodes( (3, 4.99999999999) ) == 2 | see what happens the point is equidistant to two nodes | 625941e07d847024c06be641 |
def _get_bitbake_info(self): <NEW_LINE> <INDENT> bb_path = os.path.dirname(__file__) <NEW_LINE> bb_path = os.path.dirname(bb_path) <NEW_LINE> bb_path = os.path.dirname(bb_path) <NEW_LINE> bb_path = os.path.dirname(bb_path) <NEW_LINE> bb_path = self._run_command('git rev-parse --show-toplevel', os.path.dirname(__file__)... | Return a tuple of bitbake information | 625941e01d351010ab855e9d |
def check_type_keywords(self, schema, rule, path): <NEW_LINE> <INDENT> if not self.strict_rule_validation: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> global_keywords = ['type', 'desc', 'example', 'extensions', 'name', 'nullable', 'version', 'func', 'include'] <NEW_LINE> all_allowed_keywords = { 'str': global_keywor... | All supported keywords:
- allowempty_map
- assertion
- class
- date
- default
- desc
- enum
- example
- extensions
- func
- ident
- include_name
- map_regex_rule
- mapping
- matching
- matching_rule
- name
- nullable
- pattern
- pattern_regexp
- range
- regex_mappings
- required
- schema
- sequ... | 625941e04f88993c3716c3e6 |
def init(self, program_description=None, add_param_args=True, add_default_logging=True, additional_args=None, allow_extra_parameters=None, doDebug=False): <NEW_LINE> <INDENT> self.doDebug = doDebug <NEW_LINE> if allow_extra_parameters is not None: <NEW_LINE> <INDENT> self.allow_extra_parameters = allow_extra_parameters... | Parse command line arguments, and initialize parameter dictionary.
:param doDebug: Turn on ConfigMaster debugging
:param add_default_logging: This can be used to turn on/off the --debugString and --logPath options
:param allow_extra_parameters: If this is true, then ConfigMaster will merely warn and not exit if an ext... | 625941e04e696a04525c97cf |
def hideContainer(self): <NEW_LINE> <INDENT> if self.gui.isVisible(): <NEW_LINE> <INDENT> self.gui.hide() | Hide the container
@return: None | 625941e0cad5886f8bd2735b |
def was_deactivated(self) -> bool: <NEW_LINE> <INDENT> return dpgcore.is_item_deactivated(self.id) | Checks if an item just stopped being active (this frame?). | 625941e091f36d47f21ac878 |
def client_permissions_changed(client, roles): <NEW_LINE> <INDENT> has_changed = False <NEW_LINE> if not client: <NEW_LINE> <INDENT> return has_changed <NEW_LINE> <DEDENT> client = client.getObject() <NEW_LINE> perms = client.rolesOfPermission(AddClient) <NEW_LINE> labclerk = 'LabClerk' <NEW_LINE> for perm in perms: <N... | Checks if client permissions have been changed.
:param client: a client zcatalog brain
:param roles: a list of strings as role names
:return: Boolean | 625941e0bde94217f3683170 |
def test_06(self): <NEW_LINE> <INDENT> data = env_data.JSONV2_Request(self.NdeviceId) <NEW_LINE> deviceTime = data['deviceTime'] <NEW_LINE> data['pm10'] = "string" <NEW_LINE> data = json.dumps(data) <NEW_LINE> res = OpenAPI(method=self.method, data=data) <NEW_LINE> self.assertEqual(0, res.json()['code']) <NEW_LINE> elk... | 推送正式设备数据-字段类型不正确int->string | 625941e030c21e258bdfa822 |
def symmetric_mean_absolute_percentage_error(y_true, y_pred): <NEW_LINE> <INDENT> y_true, y_pred = np.array(y_true), np.array(y_pred) <NEW_LINE> return np.mean(np.abs(y_true - y_pred) / (y_true + y_pred + 1)) | Symmetric Mean Absolute Percentage Error (SMAPE)
:param y_true: array-like, true values
:param y_pred: array-like, predicted values
:return: SMAPE | 625941e0e8904600ed9f22b4 |
def __init__(self, config=None, path=None): <NEW_LINE> <INDENT> if self.parser is not None and config is None and path is None: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> Config.parser = configparser.ConfigParser(interpolation=None) <NEW_LINE> if config is not None: <NEW_LINE> <INDENT> log.info("Inspecting config f... | Read the config file
Parse config from given string (config) or file (path).
If no config or path given, default to "~/.did/config" which
can be overrided by the ``DID_DIR`` environment variable. | 625941e0090684286d50f06d |
def change_fleet_direction(ai_settings, alien_group): <NEW_LINE> <INDENT> for alien in alien_group.sprites(): <NEW_LINE> <INDENT> alien.rect.y += ai_settings.fleet_drop_speed <NEW_LINE> <DEDENT> ai_settings.fleet_direction *= -1 | Lowers the entire fleet and changes the direction of the fleet | 625941e0fb3f5b602dac3a19 |
def maxArea(self, height): <NEW_LINE> <INDENT> res = 0 <NEW_LINE> start = 0 <NEW_LINE> end = len(height) - 1 <NEW_LINE> while start < end: <NEW_LINE> <INDENT> tmp_res = (end - start) * (height[start] if height[start] < height[end] else height[end]) <NEW_LINE> if tmp_res > res: <NEW_LINE> <INDENT> res = tmp_res <NEW_LIN... | :type height: List[int]
:rtype: int | 625941e0de87d2750b860118 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.