_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q47100
AssetContentForm.get_data_metadata
train
def get_data_metadata(self): """Gets the metadata for the content data. return: (osid.Metadata) - metadata for the content data *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template...
python
{ "resource": "" }
q47101
AssetContentForm.get_url_metadata
train
def get_url_metadata(self): """Gets the metadata for the url. return: (osid.Metadata) - metadata for the url *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template metadata =...
python
{ "resource": "" }
q47102
AssetContentForm.clear_url
train
def clear_url(self): """Removes the url. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.repository.AssetConten...
python
{ "resource": "" }
q47103
Composition.get_children
train
def get_children(self): """Gets the children of this composition. return: (osid.repository.CompositionList) - the composition children raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* """ # ...
python
{ "resource": "" }
q47104
CompositionForm.get_children_metadata
train
def get_children_metadata(self): """Gets the metadata for children. return: (osid.Metadata) - metadata for the children *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._mdata['children']) metadata.update({'existing_children_values': ...
python
{ "resource": "" }
q47105
CompositionForm.set_children
train
def set_children(self, child_ids): """Sets the children. arg: child_ids (osid.id.Id[]): the children``Ids`` raise: InvalidArgument - ``child_ids`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* ...
python
{ "resource": "" }
q47106
CompositionForm.clear_children
train
def clear_children(self): """Clears the children. raise: NoAccess - ``Metadata.isRequired()`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_children_metadata().is_read_only() or ...
python
{ "resource": "" }
q47107
RepositoryNode.get_repository
train
def get_repository(self): """Gets the ``Repository`` at this node. return: (osid.repository.Repository) - the repository represented by this node *compliance: mandatory -- This method must be implemented.* """ if self._lookup_session is None: mgr = g...
python
{ "resource": "" }
q47108
RepositoryNode.get_parent_repository_nodes
train
def get_parent_repository_nodes(self): """Gets the parents of this repository. return: (osid.repository.RepositoryNodeList) - the parents of the ``id`` *compliance: mandatory -- This method must be implemented.* """ parent_repository_nodes = [] for node ...
python
{ "resource": "" }
q47109
EdXCompositionQueryRecord.match_any_learning_objective
train
def match_any_learning_objective(self, match): """Matches an item with any objective. arg: match (boolean): ``true`` to match items with any learning objective, ``false`` to match items with no learning objectives *compliance: mandatory -- This method must be ...
python
{ "resource": "" }
q47110
EdXCompositionRecord.get_group_id_to_child
train
def get_group_id_to_child(self): """ At a minimum need a course composition parent and two children to the split test course composition | split_test composition | | vertical vertical And the expected output is a URL...
python
{ "resource": "" }
q47111
EdXCompositionRecord.export_olx
train
def export_olx(self, tarball, root_path): """if sequestered, only export the assets""" def append_asset_to_soup_and_export(asset_): if isinstance(asset_, Item): try: unique_url = asset_.export_olx(tarball, root_path) except AttributeError: ...
python
{ "resource": "" }
q47112
long_encode
train
def long_encode(input, errors='strict'): """Transliterate to 8 bit using as many letters as needed. For example, \u00e4 LATIN SMALL LETTER A WITH DIAERESIS ``ä`` will be replaced with ``ae``. """ if not isinstance(input, text_type): input = text_type(input, sys.getdefaultencoding(), errors...
python
{ "resource": "" }
q47113
short_encode
train
def short_encode(input, errors='strict'): """Transliterate to 8 bit using as few letters as possible. For example, \u00e4 LATIN SMALL LETTER A WITH DIAERESIS ``ä`` will be replaced with ``a``. """ if not isinstance(input, text_type): input = text_type(input, sys.getdefaultencoding(), error...
python
{ "resource": "" }
q47114
single_encode
train
def single_encode(input, errors='strict'): """Transliterate to 8 bit using only single letter replacements. For example, \u2639 WHITE FROWNING FACE ``☹`` will be passed through unchanged. """ if not isinstance(input, text_type): input = text_type(input, sys.getdefaultencoding(), errors) ...
python
{ "resource": "" }
q47115
_double_encoding_factory
train
def _double_encoding_factory(encoder, byte_encoder, byte_encoding): """Send the transliterated output to another codec.""" def dbl_encode(input, errors='strict'): uni, length = encoder(input, errors) return byte_encoder(uni, errors)[0], length dbl_encode.__name__ = '%s_%s' % (encoder.__name_...
python
{ "resource": "" }
q47116
trans_search
train
def trans_search(encoding): """Lookup transliterating codecs.""" if encoding == 'transliterate': return codecs.CodecInfo(long_encode, no_decode) # translit/long/utf8 # translit/one # translit/short/ascii if encoding.startswith('translit/'): parts = encoding.split('/') i...
python
{ "resource": "" }
q47117
NodeVisitor.visit
train
def visit(self, node): """Returns a generator that walks all children recursively.""" for child in node: yield child for subchild in self.visit(child): yield subchild
python
{ "resource": "" }
q47118
get_objective_mdata
train
def get_objective_mdata(): """Return default mdata map for Objective""" return { 'cognitive_process': { 'element_label': { 'text': 'cognitive process', 'languageTypeId': str(DEFAULT_LANGUAGE_TYPE), 'scriptTypeId': str(DEFAULT_SCRIPT_TYPE), ...
python
{ "resource": "" }
q47119
get_activity_mdata
train
def get_activity_mdata(): """Return default mdata map for Activity""" return { 'courses': { 'element_label': { 'text': 'courses', 'languageTypeId': str(DEFAULT_LANGUAGE_TYPE), 'scriptTypeId': str(DEFAULT_SCRIPT_TYPE), 'formatTyp...
python
{ "resource": "" }
q47120
get_proficiency_mdata
train
def get_proficiency_mdata(): """Return default mdata map for Proficiency""" return { 'completion': { 'element_label': { 'text': 'completion', 'languageTypeId': str(DEFAULT_LANGUAGE_TYPE), 'scriptTypeId': str(DEFAULT_SCRIPT_TYPE), ...
python
{ "resource": "" }
q47121
getLogger
train
def getLogger(name): """Return a logger from a given name. If the name does not have a log handler, this will create one for it based on the module name which will log everything to a log file in a location the executing user will have access to. :param name: ``str`` :return: ``object`` ""...
python
{ "resource": "" }
q47122
ColorLogRecord.getMessage
train
def getMessage(self): """Returns a colorized log message based on the log level. If the platform is windows the original message will be returned without colorization windows escape codes are crazy. :returns: ``str`` """ msg = str(self.msg) if self.args: ...
python
{ "resource": "" }
q47123
LogSetup.default_logger
train
def default_logger(self, name=__name__, enable_stream=False, enable_file=True): """Default Logger. This is set to use a rotating File handler and a stream handler. If you use this logger all logged output that is INFO and above will be logged, unless debug_logging...
python
{ "resource": "" }
q47124
LogSetup.set_handler
train
def set_handler(self, log, handler): """Set the logging level as well as the handlers. :param log: ``object`` :param handler: ``object`` """ if self.debug_logging is True: log.setLevel(logging.DEBUG) handler.setLevel(logging.DEBUG) else: ...
python
{ "resource": "" }
q47125
LogSetup.return_logfile
train
def return_logfile(filename, log_dir='/var/log'): """Return a path for logging file. If ``log_dir`` exists and the userID is 0 the log file will be written to the provided log directory. If the UserID is not 0 or log_dir does not exist the log file will be written to the users home fold...
python
{ "resource": "" }
q47126
text_coords
train
def text_coords(string, position): r""" Transform a simple index into a human-readable position in a string. This function accepts a string and an index, and will return a triple of `(lineno, columnno, line)` representing the position through the text. It's useful for displaying a string index in a...
python
{ "resource": "" }
q47127
get_regex
train
def get_regex(regex): """ Ensure we have a compiled regular expression object. >>> import re >>> get_regex('string') # doctest: +ELLIPSIS <_sre.SRE_Pattern object at 0x...> >>> pattern = re.compile(r'string') >>> get_regex(pattern) is pattern True >>> get...
python
{ "resource": "" }
q47128
Scanner.beginning_of_line
train
def beginning_of_line(self): r""" Return true if the scan pointer is at the beginning of a line. >>> s = Scanner("test\ntest\n") >>> s.beginning_of_line() True >>> s.skip(r'te') 2 >>> s.beginning_of_line() False ...
python
{ "resource": "" }
q47129
Scanner.getch
train
def getch(self): """ Get a single character and advance the scan pointer. >>> s = Scanner("abc") >>> s.getch() 'a' >>> s.getch() 'b' >>> s.getch() 'c' >>> s.pos 3 """ self.pos += ...
python
{ "resource": "" }
q47130
Scanner.peek
train
def peek(self, length): """ Get a number of characters without advancing the scan pointer. >>> s = Scanner("test string") >>> s.peek(7) 'test st' >>> s.peek(7) 'test st' """ return self.string[self.pos:self.pos + length]
python
{ "resource": "" }
q47131
Scanner.unscan
train
def unscan(self): """ Undo the last scan, resetting the position and match registers. >>> s = Scanner('test string') >>> s.pos 0 >>> s.skip(r'te') 2 >>> s.rest 'st string' >>> s.unscan() >>> s.po...
python
{ "resource": "" }
q47132
Scanner.scan_full
train
def scan_full(self, regex, return_string=True, advance_pointer=True): """ Match from the current position. If `return_string` is false and a match is found, returns the number of characters matched. >>> s = Scanner("test string") >>> s.scan_full(r' ') ...
python
{ "resource": "" }
q47133
Scanner.search_full
train
def search_full(self, regex, return_string=True, advance_pointer=True): """ Search from the current position. If `return_string` is false and a match is found, returns the number of characters matched (from the current position *up to* the end of the match). >>> s =...
python
{ "resource": "" }
q47134
Scanner.scan
train
def scan(self, regex): """ Match a pattern from the current position. If a match is found, advances the scan pointer and returns the matched string. Otherwise returns ``None``. >>> s = Scanner("test string") >>> s.pos 0 >>> s.scan(r'foo')...
python
{ "resource": "" }
q47135
Scanner.scan_until
train
def scan_until(self, regex): """ Search for a pattern from the current position. If a match is found, advances the scan pointer and returns the matched string, from the current position *up to* the end of the match. Otherwise returns ``None``. >>> s = Scanner("test ...
python
{ "resource": "" }
q47136
Scanner.scan_upto
train
def scan_upto(self, regex): """ Scan up to, but not including, the given regex. >>> s = Scanner("test string") >>> s.scan('t') 't' >>> s.scan_upto(r' ') 'est' >>> s.pos 4 >>> s.pos_history [0, 1,...
python
{ "resource": "" }
q47137
parse
train
def parse(requirements): """ Parses given requirements line-by-line. """ transformer = RTransformer() return map(transformer.transform, filter(None, map(_parse, requirements.splitlines())))
python
{ "resource": "" }
q47138
Authenticator.authenticate
train
def authenticate(self, transport, account_name, password): """ Authenticates account, if no password given tries to pre-authenticate. @param transport: transport to use for method calls @param account_name: account name @param password: account password @return: AuthToken...
python
{ "resource": "" }
q47139
SSASimulation.simulate_system
train
def simulate_system(self, parameters, initial_conditions, timepoints, max_moment_order=1, number_of_processes=1): """ Perform Gillespie SSA simulations and returns trajectories for of each species. Each trajectory is interpolated at the given time points. By defau...
python
{ "resource": "" }
q47140
requirements
train
def requirements(): """Build the requirements list for this project""" requirements_list = [] with open('requirements.txt') as requirements: for install in requirements: requirements_list.append(install.strip()) return requirements_list
python
{ "resource": "" }
q47141
Statistic.do_run
train
def do_run(self, count=1): '''Roll count dice, store results. Does all stats so might be slower than specific doFoo methods. But, it is proly faster than running each of those seperately to get same stats. Sets the following properties: - stats.bucket - stats.sum ...
python
{ "resource": "" }
q47142
get_distr
train
def get_distr(center=0.0, stdev=default_stdev, length=50): "Returns a PDF of a given length. " # distr = np.random.random(length) # sticking to normal distibution to easily control separability distr = rng.normal(center, stdev, size=[length, 1]) return distr
python
{ "resource": "" }
q47143
Syncer.pull
train
def pull(self, conf, ignore_missing=False): """Push this image""" with Builder().remove_replaced_images(conf): self.push_or_pull(conf, "pull", ignore_missing=ignore_missing)
python
{ "resource": "" }
q47144
Syncer.push_or_pull
train
def push_or_pull(self, conf, action=None, ignore_missing=False): """Push or pull this image""" if action not in ("push", "pull"): raise ProgrammerError("Should have called push_or_pull with action to either push or pull, got {0}".format(action)) if not conf.image_index: ...
python
{ "resource": "" }
q47145
GradebookColumnQuery.match_grade_system_id
train
def match_grade_system_id(self, grade_system_id, match): """Sets the grade system ``Id`` for this query. arg: grade_system_id (osid.id.Id): a grade system ``Id`` arg: match (boolean): ``true`` for a positive match, ``false`` for a negative match raise: NullArgumen...
python
{ "resource": "" }
q47146
AggregateReleaser.releasers
train
def releasers(cls): """ Returns all of the supported releasers. """ return [ HookReleaser, VersionFileReleaser, PythonReleaser, CocoaPodsReleaser, NPMReleaser, CReleaser, ChangelogReleaser, G...
python
{ "resource": "" }
q47147
AggregateReleaser.detected_releasers
train
def detected_releasers(cls, config): """ Returns all of the releasers that are compatible with the project. """ def get_config(releaser): if config: return config.get(releaser.config_name(), {}) return {} releasers = [] for rele...
python
{ "resource": "" }
q47148
AggregateReleaser.check_version_consistency
train
def check_version_consistency(self): """ Determine if any releasers have inconsistent versions """ version = None releaser_name = None for releaser in self.releasers: try: next_version = releaser.determine_current_version() except...
python
{ "resource": "" }
q47149
get_aws_s3_handle
train
def get_aws_s3_handle(config_map): """Convenience function for getting AWS S3 objects Added by cjshaw@mit.edu, Jan 9, 2015 Added to aws_adapter build by birdland@mit.edu, Jan 25, 2015, and added support for Configuration May 25, 2017: Switch to boto3 """ url = 'https://' + config_map['s3_b...
python
{ "resource": "" }
q47150
get_signed_url
train
def get_signed_url(url, config_map): """ Convenience function for getting cloudfront signed URL given a saved URL cjshaw, Jan 7, 2015 Follows: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ private-content-creating-signed-url-canned-policy.html#private- ...
python
{ "resource": "" }
q47151
remove_file
train
def remove_file(config_map, file_key): """Convenience function for removing objects from AWS S3 Added by cjshaw@mit.edu, Apr 28, 2015 May 25, 2017: Switch to boto3 """ # for boto3, need to remove any leading / if file_key[0] == '/': file_key = file_key[1::] client = boto3.client( ...
python
{ "resource": "" }
q47152
GradeSystemSearchResults.get_grade_systems
train
def get_grade_systems(self): """Gets the grade system list resulting from the search. return: (osid.grading.GradeSystemList) - the grade system list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.ret...
python
{ "resource": "" }
q47153
GradeEntrySearchResults.get_grade_entries
train
def get_grade_entries(self): """Gets the package list resulting from the search. return: (osid.grading.GradeEntryList) - the grade entry list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved:...
python
{ "resource": "" }
q47154
GradebookColumnSearchResults.get_gradebook_columns
train
def get_gradebook_columns(self): """Gets the gradebook column list resulting from the search. return: (osid.grading.GradebookColumnList) - the gradebook column list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* ...
python
{ "resource": "" }
q47155
GradebookSearchResults.get_gradebooks
train
def get_gradebooks(self): """Gets the gradebook list resulting from the search. return: (osid.grading.GradebookList) - the gradebook list raise: IllegalState - list already retrieved *compliance: mandatory -- This method must be implemented.* """ if self.retrieved: ...
python
{ "resource": "" }
q47156
RelationshipProxyManager.get_relationship_search_session
train
def get_relationship_search_session(self, proxy=None): """Gets the ``OsidSession`` associated with the relationship search service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.RelationshipSearchSession) - a ``RelationshipSearchSession`` raise: N...
python
{ "resource": "" }
q47157
RelationshipProxyManager.get_relationship_search_session_for_family
train
def get_relationship_search_session_for_family(self, family_id=None, proxy=None): """Gets the ``OsidSession`` associated with the relationship search service for the given family. arg: family_id (osid.id.Id): the ``Id`` of the family arg: proxy (osid.proxy.Proxy): a proxy return: ...
python
{ "resource": "" }
q47158
RelationshipProxyManager.get_relationship_family_assignment_session
train
def get_relationship_family_assignment_session(self, proxy=None): """Gets the ``OsidSession`` associated with assigning relationships to families. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.RelationshipFamilyAssignmentSession) - a ``RelationshipFamilyAs...
python
{ "resource": "" }
q47159
RelationshipProxyManager.get_family_query_session
train
def get_family_query_session(self, proxy=None): """Gets the ``OsidSession`` associated with the family query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilyQuerySession) - a ``FamilyQuerySession`` raise: NullArgument - ``proxy`` is `...
python
{ "resource": "" }
q47160
RelationshipProxyManager.get_family_search_session
train
def get_family_search_session(self, proxy=None): """Gets the ``OsidSession`` associated with the family search service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.relationship.FamilySearchSession) - a ``FamilySearchSession`` raise: NullArgument - ``proxy`` ...
python
{ "resource": "" }
q47161
TemporalRecord.get_end_date
train
def get_end_date(self): """Gets the end date. return: (osid.calendaring.DateTime) - the end date *compliance: mandatory -- This method must be implemented.* """ edate = self.my_osid_object._my_map['endDate'] return DateTime( edate.year, edate.mon...
python
{ "resource": "" }
q47162
SourceableFormRecord.clear_branding
train
def clear_branding(self): """Removes the branding. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if (self.get_branding_metadata().is_read_only() o...
python
{ "resource": "" }
q47163
SourceableRecord.get_branding
train
def get_branding(self): """Gets a branding, such as an image or logo, expressed using the ``Asset`` interface. return: (osid.repository.AssetList) - a list of assets raise: OperationFailed - unable to complete request *compliance: mandatory -- This method must be implemented.* ...
python
{ "resource": "" }
q47164
MultiLanguageFormRecord.get_display_names_metadata
train
def get_display_names_metadata(self): """Gets the metadata for all display_names. return: (osid.Metadata) - metadata for the display_names *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._display_names_metadata) metadata.update({'exi...
python
{ "resource": "" }
q47165
MultiLanguageFormRecord.get_descriptions_metadata
train
def get_descriptions_metadata(self): """Gets the metadata for all descriptions. return: (osid.Metadata) - metadata for the descriptions *compliance: mandatory -- This method must be implemented.* """ metadata = dict(self._descriptions_metadata) metadata.update({'existin...
python
{ "resource": "" }
q47166
MultiLanguageFormRecord.add_display_name
train
def add_display_name(self, display_name): """Adds a display_name. arg: display_name (displayText): the new display name raise: InvalidArgument - ``display_name`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``display_name`` is ``...
python
{ "resource": "" }
q47167
MultiLanguageFormRecord.remove_display_name_by_language
train
def remove_display_name_by_language(self, language_type): """Removes the specified display_name. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if ...
python
{ "resource": "" }
q47168
MultiLanguageFormRecord.add_description
train
def add_description(self, description): """Adds a description. arg: description (displayText): the new description raise: InvalidArgument - ``description`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` raise: NullArgument - ``description`` is ``null`` ...
python
{ "resource": "" }
q47169
MultiLanguageFormRecord.remove_description_by_language
train
def remove_description_by_language(self, language_type): """Removes the specified description. raise: NoAccess - ``Metadata.isRequired()`` is ``true`` or ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.* """ if se...
python
{ "resource": "" }
q47170
Locus.add_member
train
def add_member(self,grange): """Add a genomic range to the locus :param grange: :type grange: GenomicRange """ if self.use_direction and not grange.direction: sys.stderr.write("ERROR if using direction then direction of input members must be set\n") sys.exit() # Get range set proper...
python
{ "resource": "" }
q47171
Loci.add_locus
train
def add_locus(self,inlocus): """ Adds a locus to our loci, but does not go through an update our locus sets yet""" if self.use_direction == True and inlocus.use_direction == False: sys.stderr.write("ERROR if using the direction in Loci, then every locus added needs use_direction to be True\n") sys.e...
python
{ "resource": "" }
q47172
Loci.update_loci
train
def update_loci(self): """Goes through and combines loci until we have one set meeting our overlap definition""" # Create sub-loci for each chromosome lbc = {} chroms = sorted([x.range.chr for x in self.loci]) for chrom in chroms: lbc[chrom] = Loci() for x in self.loci: lbc[x.range.chr].add_locu...
python
{ "resource": "" }
q47173
Loci.merge_down_loci
train
def merge_down_loci(self): """Called internally to make loci overlapping into one set""" old_locus_size = -1 z = 0 while len(self.loci) != old_locus_size: z+=1 old_locus_size = len(self.loci) locus_size = len(self.loci) if self.verbose: sys.stderr.write(str(locus_size)+" ...
python
{ "resource": "" }
q47174
push
train
def push(collector, image, **kwargs): """Push an image""" if not image.image_index: raise BadOption("The chosen image does not have a image_index configuration", wanted=image.name) tag = kwargs["artifact"] if tag is NotSpecified: tag = collector.configuration["harpoon"].tag if tag is...
python
{ "resource": "" }
q47175
push_all
train
def push_all(collector, **kwargs): """Push all the images""" configuration = collector.configuration configuration["harpoon"].do_push = True configuration["harpoon"].only_pushable = True make_all(collector, **kwargs)
python
{ "resource": "" }
q47176
pull_arbitrary
train
def pull_arbitrary(collector, image, **kwargs): """Pull an arbitrary image""" image_index_of = lambda image: urlparse("https://{0}".format(image)).netloc if image.startswith("file://"): parsed = urlparse(image) filename = parsed.netloc + parsed.path if not os.path.exists(filename): ...
python
{ "resource": "" }
q47177
pull
train
def pull(collector, image, **kwargs): """Pull an image""" if not image.image_index: raise BadOption("The chosen image does not have a image_index configuration", wanted=image.name) tag = kwargs["artifact"] if tag is NotSpecified: collector.configuration["harpoon"].tag if tag is not N...
python
{ "resource": "" }
q47178
pull_dependencies
train
def pull_dependencies(collector, image, **kwargs): """Pull an image's dependent images""" for dep in image.commands.dependent_images: kwargs["image"] = dep pull_arbitrary(collector, **kwargs)
python
{ "resource": "" }
q47179
pull_parent
train
def pull_parent(collector, image, **kwargs): """DEPRECATED - use pull_dependencies instead""" log.warning("DEPRECATED - use pull_dependencies instead") pull_dependencies(collector, image, **kwargs)
python
{ "resource": "" }
q47180
pull_all
train
def pull_all(collector, image, **kwargs): """Pull all the images""" images = collector.configuration["images"] for layer in Builder().layered(images, only_pushable=True): for image_name, image in layer: log.info("Pulling %s", image_name) pull(collector, image, **kwargs)
python
{ "resource": "" }
q47181
pull_all_external
train
def pull_all_external(collector, **kwargs): """Pull all the external dependencies of all the images""" deps = set() images = collector.configuration["images"] for layer in Builder().layered(images): for image_name, image in layer: for dep in image.commands.external_dependencies: ...
python
{ "resource": "" }
q47182
make
train
def make(collector, image, **kwargs): """Just create an image""" tag = kwargs.get("artifact", NotSpecified) if tag is NotSpecified: tag = collector.configuration["harpoon"].tag if tag is not NotSpecified: image.tag = tag Builder().make_image(image, collector.configuration["images"]...
python
{ "resource": "" }
q47183
make_all
train
def make_all(collector, **kwargs): """Creates all the images in layered order""" configuration = collector.configuration push = configuration["harpoon"].do_push only_pushable = configuration["harpoon"].only_pushable if push: only_pushable = True tag = kwargs.get("artifact", NotSpecified...
python
{ "resource": "" }
q47184
make_pushable
train
def make_pushable(collector, **kwargs): """Make only the pushable images and their dependencies""" configuration = collector.configuration configuration["harpoon"].do_push = True configuration["harpoon"].only_pushable = True make_all(collector, **kwargs)
python
{ "resource": "" }
q47185
delete_untagged
train
def delete_untagged(collector, **kwargs): """Find the untagged images and remove them""" configuration = collector.configuration docker_api = configuration["harpoon"].docker_api images = docker_api.images() found = False for image in images: if image["RepoTags"] == ["<none>:<none>"]: ...
python
{ "resource": "" }
q47186
print_all_dockerfiles
train
def print_all_dockerfiles(collector, **kwargs): """Print all the dockerfiles""" for name, image in collector.configuration["images"].items(): print("{0}".format(name)) print("-" * len(name)) kwargs["image"] = image print_dockerfile(collector, **kwargs)
python
{ "resource": "" }
q47187
read_login
train
def read_login(collector, image, **kwargs): """Login to a docker registry with read permissions""" docker_api = collector.configuration["harpoon"].docker_api collector.configuration["authentication"].login(docker_api, image, is_pushing=False, global_docker=True)
python
{ "resource": "" }
q47188
write_login
train
def write_login(collector, image, **kwargs): """Login to a docker registry with write permissions""" docker_api = collector.configuration["harpoon"].docker_api collector.configuration["authentication"].login(docker_api, image, is_pushing=True, global_docker=True)
python
{ "resource": "" }
q47189
get_salt
train
def get_salt(request): """ return the user password salt. If the user doesn't exist return a pseudo salt. """ try: username = request.POST["username"] except KeyError: # log.error("No 'username' in POST data?!?") return HttpResponseBadRequest() try: request.s...
python
{ "resource": "" }
q47190
display_login_info
train
def display_login_info(sender, user, request, **kwargs): """ Create a message, after login. Because this signal receiver will be called **after** auth.models.update_last_login(), the user.last_login information was updated before! As a work-a-round, we add **user.previous_login** in forms.SecureLo...
python
{ "resource": "" }
q47191
throttle_login
train
def throttle_login(request): """Throttles a client by keeping track of the number of failed login attempts. If the user succeeds at a login before the max attempts has been reached, the attempts are reset. """ email = request.POST['email'] password = request.POST['password'] # if the form i...
python
{ "resource": "" }
q47192
list_js_files
train
def list_js_files(dir): """ Generator for all JavaScript files in the directory, recursively >>> 'examples/module.js' in list(list_js_files('examples')) True """ for dirpath, dirnames, filenames in os.walk(dir): for filename in filenames: if is_js_file(filename): ...
python
{ "resource": "" }
q47193
split_delimited
train
def split_delimited(delimiters, split_by, text): """ Generator that walks the ``text`` and splits it into an array on ``split_by``, being careful not to break inside a delimiter pair. ``delimiters`` should be an even-length string with each pair of matching delimiters listed together, open first. ...
python
{ "resource": "" }
q47194
get_doc_comments
train
def get_doc_comments(text): r""" Return a list of all documentation comments in the file text. Each comment is a pair, with the first element being the comment text and the second element being the line after it, which may be needed to guess function & arguments. >>> get_doc_comments(read_file...
python
{ "resource": "" }
q47195
split_tag
train
def split_tag(section): """ Split the JSDoc tag text (everything following the @) at the first whitespace. Returns a tuple of (tagname, body). """ splitval = re.split('\s+', section, 1) tag, body = len(splitval) > 1 and splitval or (splitval[0], '') return tag.strip(), body.strip()
python
{ "resource": "" }
q47196
guess_function_name
train
def guess_function_name(next_line, regexps=FUNCTION_REGEXPS): """ Attempt to determine the function name from the first code line following the comment. The patterns recognized are described by `regexps`, which defaults to FUNCTION_REGEXPS. If a match is successful, returns the function name. Ot...
python
{ "resource": "" }
q47197
guess_parameters
train
def guess_parameters(next_line): """ Attempt to guess parameters based on the presence of a parenthesized group of identifiers. If successful, returns a list of parameter names; otherwise, returns None. """ match = re.search('\(([\w\s,]+)\)', next_line) if match: return [arg.strip()...
python
{ "resource": "" }
q47198
parse_comment
train
def parse_comment(doc_comment, next_line): r""" Split the raw comment text into a dictionary of tags. The main comment body is included as 'doc'. >>> comment = get_doc_comments(read_file('examples/module.js'))[4][0] >>> parse_comment(strip_stars(comment), '')['doc'] 'This is the documentation ...
python
{ "resource": "" }
q47199
parse_comments_for_file
train
def parse_comments_for_file(filename): """ Return a list of all parsed comments in a file. Mostly for testing & interactive use. """ return [parse_comment(strip_stars(comment), next_line) for comment, next_line in get_doc_comments(read_file(filename))]
python
{ "resource": "" }