_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q48600
Repository.use_plenary_asset_view
train
def use_plenary_asset_view(self): """Pass through to provider AssetLookupSession.use_plenary_asset_view""" self._object_views['asset'] = PLENARY # self._get_provider_session('asset_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions(): ...
python
{ "resource": "" }
q48601
Repository.use_federated_repository_view
train
def use_federated_repository_view(self): """Pass through to provider AssetLookupSession.use_federated_repository_view""" self._repository_view = FEDERATED # self._get_provider_session('asset_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions...
python
{ "resource": "" }
q48602
Repository.use_isolated_repository_view
train
def use_isolated_repository_view(self): """Pass through to provider AssetLookupSession.use_isolated_repository_view""" self._repository_view = ISOLATED # self._get_provider_session('asset_lookup_session') # To make sure the session is tracked for session in self._get_provider_sessions():...
python
{ "resource": "" }
q48603
Repository.get_asset_form
train
def get_asset_form(self, *args, **kwargs): """Pass through to provider AssetAdminSession.get_asset_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. ...
python
{ "resource": "" }
q48604
Repository.save_asset
train
def save_asset(self, asset_form, *args, **kwargs): """Pass through to provider AssetAdminSession.update_asset""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if asset_form.is_for_update(): return self.update_asset(asset_form, ...
python
{ "resource": "" }
q48605
Repository.use_comparative_asset_composition_view
train
def use_comparative_asset_composition_view(self): """Pass through to provider AssetCompositionSession.use_comparative_asset_composition_view""" self._object_views['asset_composition'] = COMPARATIVE # self._get_provider_session('asset_composition_session') # To make sure the session is tracked ...
python
{ "resource": "" }
q48606
Repository.use_plenary_asset_composition_view
train
def use_plenary_asset_composition_view(self): """Pass through to provider AssetCompositionSession.use_plenary_asset_composition_view""" self._object_views['asset_composition'] = PLENARY # self._get_provider_session('asset_composition_session') # To make sure the session is tracked for se...
python
{ "resource": "" }
q48607
Repository.use_comparative_composition_view
train
def use_comparative_composition_view(self): """Pass through to provider CompositionLookupSession.use_comparative_composition_view""" self._object_views['composition'] = COMPARATIVE # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked for sessio...
python
{ "resource": "" }
q48608
Repository.use_plenary_composition_view
train
def use_plenary_composition_view(self): """Pass through to provider CompositionLookupSession.use_plenary_composition_view""" self._object_views['composition'] = PLENARY # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked for session in self._g...
python
{ "resource": "" }
q48609
Repository.use_active_composition_view
train
def use_active_composition_view(self): """Pass through to provider CompositionLookupSession.use_active_composition_view""" self._operable_views['composition'] = ACTIVE # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked for session in self._g...
python
{ "resource": "" }
q48610
Repository.use_any_status_composition_view
train
def use_any_status_composition_view(self): """Pass through to provider CompositionLookupSession.use_any_status_composition_view""" self._operable_views['composition'] = ANY_STATUS # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked for sessio...
python
{ "resource": "" }
q48611
Repository.use_sequestered_composition_view
train
def use_sequestered_composition_view(self): """Pass through to provider CompositionLookupSession.use_sequestered_composition_view""" self._containable_views['composition'] = SEQUESTERED # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked for ...
python
{ "resource": "" }
q48612
Repository.use_unsequestered_composition_view
train
def use_unsequestered_composition_view(self): """Pass through to provider CompositionLookupSession.use_unsequestered_composition_view""" self._containable_views['composition'] = UNSEQUESTERED # self._get_provider_session('composition_lookup_session') # To make sure the session is tracked ...
python
{ "resource": "" }
q48613
Repository.get_composition_form
train
def get_composition_form(self, *args, **kwargs): """Pass through to provider CompositionAdminSession.get_composition_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time w...
python
{ "resource": "" }
q48614
Repository.save_composition
train
def save_composition(self, composition_form, *args, **kwargs): """Pass through to provider CompositionAdminSession.update_composition""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.update_resource if composition_form.is_for_update(): return ...
python
{ "resource": "" }
q48615
AbstractActor._run
train
def _run(self): '''The actor's main work loop''' while self._is_running: yield from self._task() # Signal that the loop has finished. self._run_complete.set_result(True)
python
{ "resource": "" }
q48616
AssetAdminSession._update_asset_content_filename_on_disk_to_match_id
train
def _update_asset_content_filename_on_disk_to_match_id(self, ac): """Because we want the asset content filename to match the ac.ident, here we manipulate the saved file on disk after creating the asset content""" def has_secondary_storage(): return 'secondary_data_store_path'...
python
{ "resource": "" }
q48617
AssetAdminSession._update_asset_content_url_to_match_id
train
def _update_asset_content_url_to_match_id(self, ac): """update the ac URL value to match the ident""" mgr = self._provider_session._get_provider_manager('REPOSITORY') aas = mgr.get_asset_admin_session_for_repository(self._provider_session._catalog_id, ...
python
{ "resource": "" }
q48618
retrieve_net
train
def retrieve_net(wrnt_path): '''Rerieves a dumped Network and generates WordNet instance. @Args: -- wrnt_path : file_path to the '.wrnt' network dumped file. @returns: -- word_net : dict of Word() entities generated from the input file. ''' # Exception Handling of wrong format. ...
python
{ "resource": "" }
q48619
return_net
train
def return_net(word,word_net,depth=1): '''Creates a list of unique words that are at a provided depth from root word. @Args: -- word : root word from which the linked words should be returned. word_net : word network (dictionary of word instances)to be refered in this process. depth : ...
python
{ "resource": "" }
q48620
ConfigurationSetup.load_config
train
def load_config(self, name=None, path=None, home=False, ext='ini'): """Return the full path to a configuration file. This will look for configuration files in the ``full_path``, in the users home folder, or in a config directory in "/etc". If you set `home=True`, the system will look f...
python
{ "resource": "" }
q48621
ConfigurationSetup._find_config
train
def _find_config(self, config_file): """This method will check if the configuration file "exist" If it does NOT then the method will bail calling an IOError. :param config_file: ``str`` :return: ``str`` """ msg = ('Configuration file [ %s ] was not found.' % self.filena...
python
{ "resource": "" }
q48622
ConfigurationSetup.check_perms
train
def check_perms(self, perms='0600,0400'): """Check and enforce the permissions of the config file. Enforce permission on a provided configuration file. This will check and see if the permission are set based on the permission octet as set in the ``perms`` value. ``perms`` is a comma sep...
python
{ "resource": "" }
q48623
ConfigurationSetup.config_args
train
def config_args(self, section='default'): """Loop through the configuration file and set all of our values. Note: that anything can be set as a "section" in the argument file. If a section does not exist an empty dict will be returned. :param section: ``str`` :retu...
python
{ "resource": "" }
q48624
RepositoryManager.get_asset_content_lookup_session_for_repository
train
def get_asset_content_lookup_session_for_repository(self, repository_id): """Pass through to provider get_asset_content_lookup_session_for_repository""" return getattr(sessions, 'AssetContentLookupSession')( provider_session=self._provider_manager.get_asset_content_lookup_session_for_reposit...
python
{ "resource": "" }
q48625
FuzzyTranscript._rngs
train
def _rngs(self): """This is where we should also enforce evidence requirements""" outputs = [] if len(self._exon_groups)==1: return [self._exon_groups.consensus('single')] z = 0 #output count begin = 0 meeting_criteria = [i for i in range(0,len(self._exon_groups)) if len(se...
python
{ "resource": "" }
q48626
FuzzyTranscript.add_transcripts
train
def add_transcripts(self,txs): """We traverse through the other transcripts and try to add to these groups """ passed = [] for tx2 in txs: for tx1 in self._initial: jov = tx1.junction_overlap(tx2,self._tolerance) sub = jov.is_subset() if sub == 1 or s...
python
{ "resource": "" }
q48627
FuzzyTranscript.add_transcript
train
def add_transcript(self,tx): """add a single transcript""" candidates = tx.junctions targets = self.junctions matches = [] for i in range(0,len(targets)): for j in range(0,len(candidates)): if targets[i].overlaps(candidates[j],self._tolerance): matches.a...
python
{ "resource": "" }
q48628
Deconvolution.parse
train
def parse(self,tolerance=0,downsample=None,evidence=2,use_gene_names=False): """Divide out the transcripts. allow junction tolerance if wanted""" g = Graph() nodes = [Node(x) for x in self._transcripts] for n in nodes: g.add_node(n) for i in range(0,len(nodes)): for j in range(0,...
python
{ "resource": "" }
q48629
LocusStream.read_entry
train
def read_entry(self): """As long as entires overlap keep putting them together in a list that is the payload for a range that describes the bounds of the list :return: range with payload list of elements :rtype: GenomicRange """ if not self._current_range: return None ...
python
{ "resource": "" }
q48630
get_start_stops
train
def get_start_stops(transcript_sequence, start_codons=None, stop_codons=None): """Return start and stop positions for all frames in the given transcript. """ transcript_sequence = transcript_sequence.upper() # for comparison with codons below if not start_codons: st...
python
{ "resource": "" }
q48631
get_rna_counts
train
def get_rna_counts(rna_file, transcript_name): """Get coverage for a given RNA BAM file, return read counts. """ # check if the RNA file exists if not os.path.exists(rna_file): msg = 'RNA-Seq BAM file "{}" does not exist'.format(rna_file) logging.error(msg) raise OSError(msg) rna...
python
{ "resource": "" }
q48632
get_color_palette
train
def get_color_palette(scheme): """Return colors for a given scheme. Default colors are returned for an item if undefined in scheme. """ color_schemes = { 'default': { 'frames': ['tomato', 'limegreen', 'deepskyblue'], 'background': '#ffffff', 'color': '#616161', 'ticks': ...
python
{ "resource": "" }
q48633
create_parser
train
def create_parser(): """Argument parser. """ parser = argparse.ArgumentParser( prog='riboplot.py', description='Plot and output read counts for a single transcript') required = parser.add_argument_group('required arguments') required.add_argument('-b', '--ribo_file', help='Ribo-Seq alignment fi...
python
{ "resource": "" }
q48634
data
train
def data(place): """get forecast data.""" lat, lon = place url = "https://api.forecast.io/forecast/%s/%s,%s?solar" % (APIKEY, lat, lon) w_data = json.loads(urllib2.urlopen(url).read()) return w_data
python
{ "resource": "" }
q48635
mangle
train
def mangle(data_point): """mangle data into expected format.""" temp_dict = {} temp_dict.update(data_point) temp_dict['utc_datetime'] = \ datetime.datetime.utcfromtimestamp(temp_dict['time']) if 'solar' in data_point: temp_dict['GHI (W/m^2)'] = data_point['solar']['ghi'] temp...
python
{ "resource": "" }
q48636
read_stack
train
def read_stack(stack, plyt=None, laminaprop=None, rho=None, plyts=None, laminaprops=None, rhos=None, offset=0., calc_scf=True): """Read a laminate stacking sequence data. An ``Laminate`` object is returned based on the inputs given. Parameters ---------- stack : list Angles of the ...
python
{ "resource": "" }
q48637
read_lamination_parameters
train
def read_lamination_parameters(thickness, laminaprop, rho, xiA1, xiA2, xiA3, xiA4, xiB1, xiB2, xiB3, xiB4, xiD1, xiD2, xiD3, xiD4, xiE1, xiE2, xiE3, xiE4): r"""Calculates a laminate based on t...
python
{ "resource": "" }
q48638
Laminate.calc_equivalent_modulus
train
def calc_equivalent_modulus(self): """Calculates the equivalent laminate properties. The following attributes are calculated: e1, e2, g12, nu12, nu21 """ AI = np.matrix(self.ABD, dtype=np.float64).I a11, a12, a22, a33 = AI[0,0], AI[0,1], AI[1,1], AI[2,2] sel...
python
{ "resource": "" }
q48639
Laminate.calc_lamination_parameters
train
def calc_lamination_parameters(self): """Calculate the lamination parameters. The following attributes are calculated: xiA, xiB, xiD, xiE """ if len(self.plies) == 0: if self.xiA is None: raise ValueError('Laminate with 0 plies!') els...
python
{ "resource": "" }
q48640
Laminate.calc_constitutive_matrix
train
def calc_constitutive_matrix(self): """Calculates the laminate constitutive matrix This is the commonly called ``ABD`` matrix with ``shape=(6, 6)`` when the classical laminated plate theory is used, or the ``ABDE`` matrix when the first-order shear deformation theory is used, containing...
python
{ "resource": "" }
q48641
Laminate.force_balanced_LP
train
def force_balanced_LP(self): r"""Force balanced lamination parameters The lamination parameters `\xi_{A2}` and `\xi_{A4}` are set to null to force a balanced laminate. """ dummy, xiA1, xiA2, xiA3, xiA4 = self.xiA self.xiA = np.array([1, xiA1, 0, xiA3, 0], dtype=np.float...
python
{ "resource": "" }
q48642
Laminate.force_orthotropic
train
def force_orthotropic(self): r"""Force an orthotropic laminate The terms `A_{13}`, `A_{23}`, `A_{31}`, `A_{32}`, `B_{13}`, `B_{23}`, `B_{31}`, `B_{32}`, `D_{13}`, `D_{23}`, `D_{31}`, `D_{32}` are set to zero to force an orthotropic laminate. """ if self....
python
{ "resource": "" }
q48643
Laminate.force_symmetric
train
def force_symmetric(self): """Force a symmetric laminate The `B` terms of the constitutive matrix are set to zero. """ if self.offset != 0.: raise RuntimeError( 'Laminates with offset cannot be forced symmetric!') self.B = np.zeros((3,3)) ...
python
{ "resource": "" }
q48644
GradeList.get_next_grade
train
def get_next_grade(self): """Gets the next ``Grade`` in this list. return: (osid.grading.Grade) - the next ``Grade`` in this list. The ``has_next()`` method should be used to test that a next ``Grade`` is available before calling this method. raise: IllegalState...
python
{ "resource": "" }
q48645
Task.depends
train
def depends(self, *tasks): """ Interfaces the GraphNode `depends` method """ nodes = [x.node for x in tasks] self.node.depends(*nodes) return self
python
{ "resource": "" }
q48646
Task.then
train
def then(self, *tasks): """ Interfaces the GraphNode `then` method """ nodes = [x.node for x in tasks] self.node.then(*nodes) return self
python
{ "resource": "" }
q48647
Task.add
train
def add(self, *tasks): """ Interfaces the GraphNode `add` method """ nodes = [x.node for x in tasks] self.node.add(*nodes) return self
python
{ "resource": "" }
q48648
Task._run
train
def _run(self): """ Run the task respecting dependencies """ for node in self.node.relatives: launch_node_task(node) for node in self.node.relatives: self.wait_and_join(node.task) if self.node.parent: while not self.node.parent.task.siblings_pe...
python
{ "resource": "" }
q48649
read_version
train
def read_version(): """Read version from the first line starting with digit """ regex = re.compile('^(?P<number>\d.*?) .*$') with open('../CHANGELOG.rst') as f: for line in f: match = regex.match(line) if match: return match.group('number')
python
{ "resource": "" }
q48650
ResourceProfile.get_resource_record_types
train
def get_resource_record_types(self): """Gets all the resource record types supported. return: (osid.type.TypeList) - the list of supported resource record types *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for ...
python
{ "resource": "" }
q48651
ResourceManager.get_resource_search_session_for_bin
train
def get_resource_search_session_for_bin(self, bin_id): """Gets a resource search session for the given bin. arg: bin_id (osid.id.Id): the ``Id`` of the bin return: (osid.resource.ResourceSearchSession) - ``a ResourceSearchSession`` raise: NotFound - ``bin_id`` not fo...
python
{ "resource": "" }
q48652
ResourceManager.get_resource_agent_session
train
def get_resource_agent_session(self): """Gets the session for retrieving resource agent mappings. return: (osid.resource.ResourceAgentSession) - a ``ResourceAgentSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_resource_ag...
python
{ "resource": "" }
q48653
ResourceManager.get_bin_admin_session
train
def get_bin_admin_session(self): """Gets the bin administrative session for creating, updating and deleteing bins. return: (osid.resource.BinAdminSession) - a ``BinAdminSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bin_admin()`` is ``f...
python
{ "resource": "" }
q48654
ResourceManager.get_bin_hierarchy_session
train
def get_bin_hierarchy_session(self): """Gets the bin hierarchy traversal session. return: (osid.resource.BinHierarchySession) - ``a BinHierarchySession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bin_hierarchy()`` is ...
python
{ "resource": "" }
q48655
ResourceManager.get_bin_hierarchy_design_session
train
def get_bin_hierarchy_design_session(self): """Gets the bin hierarchy design session. return: (osid.resource.BinHierarchyDesignSession) - a ``BinHierarchyDesignSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_bin_hierarchy...
python
{ "resource": "" }
q48656
ResourceProxyManager.get_resource_lookup_session
train
def get_resource_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the resource lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceLookupSession) - ``a ResourceLookupSession`` raise: NullArgument - ``proxy`` i...
python
{ "resource": "" }
q48657
ResourceProxyManager.get_resource_lookup_session_for_bin
train
def get_resource_lookup_session_for_bin(self, bin_id, proxy): """Gets the ``OsidSession`` associated with the resource lookup service for the given bin. arg: bin_id (osid.id.Id): the ``Id`` of the bin arg: proxy (osid.proxy.Proxy): ``a proxy`` return: (osid.resource.ResourceLookup...
python
{ "resource": "" }
q48658
ResourceProxyManager.get_resource_query_session
train
def get_resource_query_session(self, proxy): """Gets a resource query session. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceQuerySession) - ``a ResourceQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed...
python
{ "resource": "" }
q48659
ResourceProxyManager.get_resource_query_session_for_bin
train
def get_resource_query_session_for_bin(self, bin_id, proxy): """Gets a resource query session for the given bin. arg: bin_id (osid.id.Id): the ``Id`` of the bin arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceQuerySession) - ``a ResourceQueryS...
python
{ "resource": "" }
q48660
ResourceProxyManager.get_resource_search_session
train
def get_resource_search_session(self, proxy): """Gets a resource search session. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceSearchSession) - ``a ResourceSearchSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFa...
python
{ "resource": "" }
q48661
ResourceProxyManager.get_resource_admin_session
train
def get_resource_admin_session(self, proxy): """Gets a resource administration session for creating, updating and deleting resources. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceAdminSession) - ``a ResourceAdminSession`` raise: NullArgument ...
python
{ "resource": "" }
q48662
ResourceProxyManager.get_resource_admin_session_for_bin
train
def get_resource_admin_session_for_bin(self, bin_id, proxy): """Gets a resource administration session for the given bin. arg: bin_id (osid.id.Id): the ``Id`` of the bin arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceAdminSession) - ``a Resou...
python
{ "resource": "" }
q48663
ResourceProxyManager.get_resource_bin_session
train
def get_resource_bin_session(self, proxy): """Gets the session for retrieving resource to bin mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceBinSession) - a ``ResourceBinSession`` raise: NullArgument - ``proxy`` is ``null`` ra...
python
{ "resource": "" }
q48664
ResourceProxyManager.get_resource_bin_assignment_session
train
def get_resource_bin_assignment_session(self, proxy): """Gets the session for assigning resource to bin mappings. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceBinAssignmentSession) - a ``ResourceBinAssignmentSession`` raise: NullArgument - ``...
python
{ "resource": "" }
q48665
ResourceProxyManager.get_group_hierarchy_session
train
def get_group_hierarchy_session(self, proxy): """Gets the group hierarchy traversal session for the given resource group. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.BinHierarchySession) - ``a GroupHierarchySession`` raise: NullArgument - ``proxy`` ...
python
{ "resource": "" }
q48666
ResourceProxyManager.get_resource_agent_assignment_session
train
def get_resource_agent_assignment_session(self, proxy): """Gets the session for assigning agents to resources. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.ResourceAgentAssignmentSession) - a ``ResourceAgentAssignmentSession`` raise: NullArgument - `...
python
{ "resource": "" }
q48667
ResourceProxyManager.get_bin_lookup_session
train
def get_bin_lookup_session(self, proxy): """Gets the bin lookup session. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.BinLookupSession) - a ``BinLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to c...
python
{ "resource": "" }
q48668
ResourceProxyManager.get_bin_query_session
train
def get_bin_query_session(self, proxy): """Gets the bin query session. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.resource.BinQuerySession) - a ``BinQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable to complete request ...
python
{ "resource": "" }
q48669
register
train
def register(klass): "Register a class into the agnocomplete registry." logger.info("registering {}".format(klass.__name__)) AGNOCOMPLETE_REGISTRY[klass.slug] = klass
python
{ "resource": "" }
q48670
NormalClosure._compute_one_closed_central_moment
train
def _compute_one_closed_central_moment(self, moment, covariance_matrix): r""" Compute each row of closed central moment based on Isserlis' Theorem of calculating higher order moments of multivariate normal distribution in terms of covariance matrix :param moment: moment matrix :...
python
{ "resource": "" }
q48671
Wind.cardinal_direction
train
def cardinal_direction(self): """ Returns the cardinal direction of the wind as a string. Possible returned values are N, E, S, W, and None. 315 degrees to 45 degrees exclusive -> N 45 degrees to 135 degrees exclusive -> E 135 degrees to 225 degrees exclusive -> S ...
python
{ "resource": "" }
q48672
image_name_spec.normalise_filled
train
def normalise_filled(self, meta, val): """Only care about valid image names""" available = list(meta.everything["images"].keys()) val = sb.formatted(sb.string_spec(), formatter=MergedOptionStringFormatter).normalise(meta, val) if val not in available: raise BadConfiguration("...
python
{ "resource": "" }
q48673
env_spec.create_result
train
def create_result(self, env_name, other_val, meta, val, dividers): """Set default_val and set_val depending on the seperator""" args = [env_name] if other_val is NotSpecified: other_val = None if not dividers: args.extend([None, None]) elif dividers[0] == ...
python
{ "resource": "" }
q48674
link_spec.determine_2
train
def determine_2(self, container_name, container_alias, meta, val): """"Default the alias to the name of the container""" if container_alias is not NotSpecified: return container_alias return container_name[container_name.rfind(":")+1:].replace('/', '-')
python
{ "resource": "" }
q48675
link_spec.alter_1
train
def alter_1(self, given_container_name, container_name, meta, val): """Get the container_name of the container if a container is specified""" meta.container = None if not isinstance(container_name, six.string_types): meta.container = container_name container_name = contai...
python
{ "resource": "" }
q48676
catch_no_credentials
train
def catch_no_credentials(message, **info): """Turn a NoCredentialsError into a BadAmazon""" try: yield except NoCredentialsError as error: if hasattr(error, "response"): info['error_code'] = error.response["ResponseMetadata"]["HTTPStatusCode"] info['error_message'] = ...
python
{ "resource": "" }
q48677
check_effective
train
def check_effective(func): """decorator, tests if an Assessment or Section is effective, raises error if not Side benefit: raised NotFound on AssessmentSections and AssessmentTakens """ def wrapper(*args, **kwargs): if ('assessment_section_id' in kwargs or args and 'Section' in...
python
{ "resource": "" }
q48678
get_first_part_id_for_assessment
train
def get_first_part_id_for_assessment(assessment_id, runtime=None, proxy=None, create=False, bank_id=None): """Gets the first part id, which represents the first section, of assessment""" if create and bank_id is None: raise NullArgument('Bank Id must be provided for create option') try: retu...
python
{ "resource": "" }
q48679
get_assessment_part_lookup_session
train
def get_assessment_part_lookup_session(runtime, proxy, section=None): """returns an assessment part lookup session, perhaps even a magic one""" # This appears to share code with get_item_lookup_session try: config = runtime.get_configuration() parameter_id = Id('parameter:magicAssessmentPart...
python
{ "resource": "" }
q48680
get_assessment_section
train
def get_assessment_section(section_id, runtime=None, proxy=None): """Gets a Section given a section_id""" from .mixins import LoadedSection collection = JSONClientValidated('assessment', collection='AssessmentSection', runtime=runtime...
python
{ "resource": "" }
q48681
update_parent_sequence_map
train
def update_parent_sequence_map(child_part, delete=False): """Updates the child map of a simple sequence assessment assessment part""" if child_part.has_parent_part(): object_map = child_part.get_assessment_part()._my_map database = 'assessment_authoring' collection_type = 'AssessmentPart...
python
{ "resource": "" }
q48682
remove_from_parent_sequence_map
train
def remove_from_parent_sequence_map(assessment_part_admin_session, assessment_part_id): """Updates the child map of a simple sequence assessment assessment part to remove child part""" apls = get_assessment_part_lookup_session(runtime=assessment_part_admin_session._runtime, ...
python
{ "resource": "" }
q48683
raise_null_argument
train
def raise_null_argument(func): """decorator, to intercept num argument TypeError and raise as NullArgument""" def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except TypeError as ex: if any(statement in ex.args[0] for statement in ['takes exactly', ...
python
{ "resource": "" }
q48684
run_dot
train
def run_dot(dot): """Converts a graph in DOT format into an IPython displayable object.""" global impl if impl is None: impl = guess_impl() if impl == "dot": return run_dot_dot(dot) elif impl == "js": return run_dot_js(dot) else: raise ValueError("unknown implemen...
python
{ "resource": "" }
q48685
OsidSession._get_agent_key
train
def _get_agent_key(self, proxy=None): """Gets an agent key for session management. Side effect of setting a new proxy if one is sent along, and initializing the provider session map if agent key has not been seen before """ if self._proxy is None: self._prox...
python
{ "resource": "" }
q48686
OsidSession._get_provider_sessions
train
def _get_provider_sessions(self): """Gets list of all known provider sessions.""" agent_key = self._get_agent_key() sessions = [] for session_name in self._provider_sessions[agent_key]: sessions.append(self._provider_sessions[agent_key][session_name]) return sessions
python
{ "resource": "" }
q48687
ModelMultipleDomainField.extra_create_kwargs
train
def extra_create_kwargs(self): """ Inject the domain of the current user in the new model instances. """ user = self.get_agnocomplete_context() if user: _, domain = user.email.split('@') return { 'domain': domain } retur...
python
{ "resource": "" }
q48688
salt_hash_from_plaintext
train
def salt_hash_from_plaintext(password): """ Create a XOR encrypted PBKDF2 salted checksum from a plaintext password. >>> seed_generator.DEBUG=True # Generate always the same seed for tests >>> salt, data = salt_hash_from_plaintext("test") >>> salt == 'DEBUG' True >>> data =='pbkdf2_sha1$5$...
python
{ "resource": "" }
q48689
_simulate_client
train
def _simulate_client(plaintext_password, init_pbkdf2_salt, cnonce, server_challenge): """ A implementation of the JavaScript client part. Needful for finding bugs. """ # log.debug("_simulate_client(plaintext_password='%s', init_pbkdf2_salt='%s', cnonce='%s', server_challenge='%s')", # plaint...
python
{ "resource": "" }
q48690
XorCryptor.encrypt
train
def encrypt(self, txt, key): """ XOR ciphering with a PBKDF2 checksum """ # log.debug("encrypt(txt='%s', key='%s')", txt, key) assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt) assert isinstance(key, six.text_type), "key: %s is not text type!"...
python
{ "resource": "" }
q48691
XorCryptor.decrypt
train
def decrypt(self, txt, key): """ 1. Decrypt a XOR crypted String. 2. Compare the inserted SHA salt-hash checksum. """ # log.debug("decrypt(txt='%s', key='%s')", txt, key) assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt) assert isinsta...
python
{ "resource": "" }
q48692
forecast
train
def forecast(place, series=True): """NOAA weather forecast for a location""" lat, lon = place url = "http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?" + \ "whichClient=NDFDgen&" + "lat=%s&lon=%s&" % (lat, lon) + \ "Unit=e&temp=temp&wspd=wspd&sky=sky&wx=wx&rh=rh&" + \ ...
python
{ "resource": "" }
q48693
_cast_float
train
def _cast_float(temp_dt): """returns utc timestamp""" if type(temp_dt) == str: fmt = '%Y-%m-%dT%H:%M:00' base_dt = temp_dt[0:19] tz_offset = eval(temp_dt[19:22]) temp_dt = datetime.datetime.strptime(base_dt, fmt) - \ datetime.timedelta(hours=tz_offset) return ...
python
{ "resource": "" }
q48694
AuthenticationManager.get_agent_lookup_session
train
def get_agent_lookup_session(self): """Gets the ``OsidSession`` associated with the agent lookup service. return: (osid.authentication.AgentLookupSession) - an ``AgentLookupSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_...
python
{ "resource": "" }
q48695
AuthenticationManager.get_agent_lookup_session_for_agency
train
def get_agent_lookup_session_for_agency(self, agency_id): """Gets the ``OsidSession`` associated with the agent lookup service for the given agency. arg: agency_id (osid.id.Id): the ``Id`` of the agency return: (osid.authentication.AgentLookupSession) - ``an _agent_lookup_ses...
python
{ "resource": "" }
q48696
BAMIndex.check_ordered
train
def check_ordered(self): """ True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false :return: is it ordered? :rtype: bool """ sys.stderr.write("error unimplemented check_ordered\n") sys.exit() seen_chrs = set() curr_chr ...
python
{ "resource": "" }
q48697
BAMIndex.get_longest_target_alignment_coords_by_name
train
def get_longest_target_alignment_coords_by_name(self,name): """For a name get the best alignment :return: [filebyte,innerbyte] describing the to distance the zipped block start, and the distance within the unzipped block :rtype: list """ longest = -1 coord = None #for x in self._queries[sel...
python
{ "resource": "" }
q48698
BAMIndex.get_index_line
train
def get_index_line(self,lnum): """ Take the 1-indexed line number and return its index information""" if lnum < 1: sys.stderr.write("ERROR: line number should be greater than zero\n") sys.exit() elif lnum > len(self._lines): sys.stderr.write("ERROR: too far this line nuber is not in index\...
python
{ "resource": "" }
q48699
BAMIndex.get_coord_line_number
train
def get_coord_line_number(self,coord): """return the one-indexed line number given the coordinates""" if coord[0] in self._coords: if coord[1] in self._coords[coord[0]]: return self._coords[coord[0]][coord[1]] return None
python
{ "resource": "" }