_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q21000
AnalysisRequest.getManagers
train
def getManagers(self): """Return all managers of responsible departments """ manager_ids = [] manager_list = [] for department in self.getDepartments(): manager = department.getManager() if manager is None: continue manager_id =...
python
{ "resource": "" }
q21001
AnalysisRequest.getDueDate
train
def getDueDate(self): """Returns the earliest due date of the analyses this Analysis Request contains.""" due_dates = map(lambda an: an.getDueDate, self.getAnalyses()) return due_dates and min(due_dates) or None
python
{ "resource": "" }
q21002
AnalysisRequest.getLate
train
def getLate(self): """Return True if there is at least one late analysis in this Request """ for analysis in self.getAnalyses(): if analysis.review_state == "retracted": continue analysis_obj = api.get_object(analysis) if analysis_obj.isLateAna...
python
{ "resource": "" }
q21003
AnalysisRequest.getPrinted
train
def getPrinted(self): """ returns "0", "1" or "2" to indicate Printed state. 0 -> Never printed. 1 -> Printed after last publish 2 -> Printed but republished afterwards. """ workflow = getToolByName(self, 'portal_workflow') review_state = workflow.getI...
python
{ "resource": "" }
q21004
AnalysisRequest.getBillableItems
train
def getBillableItems(self): """Returns the items to be billed """ # Assigned profiles profiles = self.getProfiles() # Billable profiles which have a fixed price set billable_profiles = filter( lambda pr: pr.getUseAnalysisProfilePrice(), profiles) # All...
python
{ "resource": "" }
q21005
AnalysisRequest.getDiscountAmount
train
def getDiscountAmount(self): """It computes and returns the analysis service's discount amount without VAT """ has_client_discount = self.aq_parent.getMemberDiscountApplies() if has_client_discount: discount = Decimal(self.getDefaultMemberDiscount()) retur...
python
{ "resource": "" }
q21006
AnalysisRequest.getTotalPrice
train
def getTotalPrice(self): """It gets the discounted price from analyses and profiles to obtain the total value with the VAT and the discount applied :returns: analysis request's total price including VATs and discounts """ price = (self.getSubtotal() - self.getDiscountAmount() + ...
python
{ "resource": "" }
q21007
AnalysisRequest.getVerifier
train
def getVerifier(self): """Returns the user that verified the whole Analysis Request. Since the verification is done automatically as soon as all the analyses it contains are verified, this function returns the user that verified the last analysis pending. """ wtool = getT...
python
{ "resource": "" }
q21008
AnalysisRequest.getVerifiersIDs
train
def getVerifiersIDs(self): """Returns the ids from users that have verified at least one analysis from this Analysis Request """ verifiers_ids = list() for brain in self.getAnalyses(): verifiers_ids += brain.getVerificators return list(set(verifiers_ids))
python
{ "resource": "" }
q21009
AnalysisRequest.getVerifiers
train
def getVerifiers(self): """Returns the list of lab contacts that have verified at least one analysis from this Analysis Request """ contacts = list() for verifier in self.getVerifiersIDs(): user = api.get_user(verifier) contact = api.get_user_contact(user,...
python
{ "resource": "" }
q21010
AnalysisRequest.getQCAnalyses
train
def getQCAnalyses(self, qctype=None, review_state=None): """return the QC analyses performed in the worksheet in which, at least, one sample of this AR is present. Depending on qctype value, returns the analyses of: - 'b': all Blank Reference Samples used in related worksheet/s ...
python
{ "resource": "" }
q21011
AnalysisRequest.getResultsRange
train
def getResultsRange(self): """Returns the valid result ranges for the analyses this Analysis Request contains. By default uses the result ranges defined in the Analysis Specification set in "Specification" field if any. Values manually set through `ResultsRange` field for any gi...
python
{ "resource": "" }
q21012
AnalysisRequest.getSamplingWorkflowEnabled
train
def getSamplingWorkflowEnabled(self): """Returns True if the sample of this Analysis Request has to be collected by the laboratory personnel """ template = self.getTemplate() if template: return template.getSamplingRequired() return self.bika_setup.getSampling...
python
{ "resource": "" }
q21013
AnalysisRequest.getDepartments
train
def getDepartments(self): """Returns a list of the departments assigned to the Analyses from this Analysis Request """ departments = list() for analysis in self.getAnalyses(full_objects=True): department = analysis.getDepartment() if department and departm...
python
{ "resource": "" }
q21014
AnalysisRequest.getResultsInterpretationByDepartment
train
def getResultsInterpretationByDepartment(self, department=None): """Returns the results interpretation for this Analysis Request and department. If department not set, returns the results interpretation tagged as 'General'. :returns: a dict with the following keys: {'u...
python
{ "resource": "" }
q21015
AnalysisRequest.getPartitions
train
def getPartitions(self): """This functions returns the partitions from the analysis request's analyses. :returns: a list with the full partition objects """ partitions = [] for analysis in self.getAnalyses(full_objects=True): if analysis.getSamplePartition() ...
python
{ "resource": "" }
q21016
AnalysisRequest.isAnalysisServiceHidden
train
def isAnalysisServiceHidden(self, uid): """Checks if the analysis service that match with the uid provided must be hidden in results. If no hidden assignment has been set for the analysis in this request, returns the visibility set to the analysis itself. Raise a TypeError if th...
python
{ "resource": "" }
q21017
AnalysisRequest.getRejecter
train
def getRejecter(self): """If the Analysis Request has been rejected, returns the user who did the rejection. If it was not rejected or the current user has not enough privileges to access to this information, returns None. """ wtool = getToolByName(self, 'portal_workflow') ...
python
{ "resource": "" }
q21018
AnalysisRequest.getDescendants
train
def getDescendants(self, all_descendants=False): """Returns the descendant Analysis Requests :param all_descendants: recursively include all descendants """ # N.B. full objects returned here from # `Products.Archetypes.Referenceable.getBRefs` # -> don't add th...
python
{ "resource": "" }
q21019
AnalysisRequest.getDescendantsUIDs
train
def getDescendantsUIDs(self, all_descendants=False): """Returns the UIDs of the descendant Analysis Requests This method is used as metadata """ descendants = self.getDescendants(all_descendants=all_descendants) return map(api.get_uid, descendants)
python
{ "resource": "" }
q21020
AnalysisRequest.setParentAnalysisRequest
train
def setParentAnalysisRequest(self, value): """Sets a parent analysis request, making the current a partition """ self.Schema().getField("ParentAnalysisRequest").set(self, value) if not value: noLongerProvides(self, IAnalysisRequestPartition) else: alsoProv...
python
{ "resource": "" }
q21021
AnalysisRequest.setDateReceived
train
def setDateReceived(self, value): """Sets the date received to this analysis request and to secondary analysis requests """ self.Schema().getField('DateReceived').set(self, value) for secondary in self.getSecondaryAnalysisRequests(): secondary.setDateReceived(value) ...
python
{ "resource": "" }
q21022
AnalysisRequest.addAttachment
train
def addAttachment(self, attachment): """Adds an attachment or a list of attachments to the Analysis Request """ if not isinstance(attachment, (list, tuple)): attachment = [attachment] original = self.getAttachment() or [] # Function addAttachment can accept brain, o...
python
{ "resource": "" }
q21023
AddDuplicateView.get_container_mapping
train
def get_container_mapping(self): """Returns a mapping of container -> postition """ layout = self.context.getLayout() container_mapping = {} for slot in layout: if slot["type"] != "a": continue position = slot["position"] contai...
python
{ "resource": "" }
q21024
AddDuplicateView.folderitems
train
def folderitems(self): """Custom folderitems for Worksheet ARs """ items = [] for ar, pos in self.get_container_mapping().items(): ar = api.get_object_by_uid(ar) ar_id = api.get_id(ar) ar_uid = api.get_uid(ar) ar_url = api.get_url(ar) ...
python
{ "resource": "" }
q21025
IDServerView.get_next_id_for
train
def get_next_id_for(self, key): """Get a preview of the next number """ portal_type = key.split("-")[0] config = get_config(None, portal_type=portal_type) id_template = config.get("form", "") number = self.storage.get(key) + 1 spec = { "seq": number, ...
python
{ "resource": "" }
q21026
IDServerView.to_int
train
def to_int(self, number, default=0): """Returns an integer """ try: return int(number) except (KeyError, ValueError): return self.to_int(default, 0)
python
{ "resource": "" }
q21027
IDServerView.set_seed
train
def set_seed(self, key, value): """Set a number of the number generator """ number_generator = getUtility(INumberGenerator) return number_generator.set_number(key, self.to_int(value))
python
{ "resource": "" }
q21028
IDServerView.seed
train
def seed(self): """ Reset the number from which the next generated sequence start. If you seed at 100, next seed will be 101 """ form = self.request.form prefix = form.get('prefix', None) if prefix is None: return 'No prefix provided' seed = form.g...
python
{ "resource": "" }
q21029
DashboardView.check_dashboard_cookie
train
def check_dashboard_cookie(self): """ Check if the dashboard cookie should exist through bikasetup configuration. If it should exist but doesn't exist yet, the function creates it with all values as default. If it should exist and already exists, it returns the value. ...
python
{ "resource": "" }
q21030
DashboardView.is_filter_selected
train
def is_filter_selected(self, selection_id, value): """ Compares whether the 'selection_id' parameter value saved in the cookie is the same value as the "value" parameter. :param selection_id: a string as a dashboard_cookie key. :param value: The value to compare against the valu...
python
{ "resource": "" }
q21031
DashboardView._create_raw_data
train
def _create_raw_data(self): """ Gathers the different sections ids and creates a string as first cookie data. :return: A dictionary like: {'analyses':'all','analysisrequest':'all','worksheets':'all'} """ result = {} for section in self.get_sections():...
python
{ "resource": "" }
q21032
DashboardView._fill_dates_evo
train
def _fill_dates_evo(self, query_json, catalog_name, periodicity): """Returns an array of dictionaries, where each dictionary contains the amount of items created at a given date and grouped by review_state, based on the passed in periodicity. This is an expensive function that will not ...
python
{ "resource": "" }
q21033
DashboardView._update_criteria_with_filters
train
def _update_criteria_with_filters(self, query, section_name): """ This method updates the 'query' dictionary with the criteria stored in dashboard cookie. :param query: A dictionary with search criteria. :param section_name: The dashboard section name :return: The 'query...
python
{ "resource": "" }
q21034
ReferenceSample.getReferenceAnalysesService
train
def getReferenceAnalysesService(self, service_uid): """ return all analyses linked to this reference sample for a service """ analyses = [] for analysis in self.objectValues('ReferenceAnalysis'): if analysis.getServiceUID() == service_uid: analyses.append(analysis) ...
python
{ "resource": "" }
q21035
ReferenceSample.addReferenceAnalysis
train
def addReferenceAnalysis(self, service): """ Creates a new Reference Analysis object based on this Sample Reference, with the type passed in and associates the newly created object to the Analysis Service passed in. :param service: Object, brain or UID of the Analysis Service ...
python
{ "resource": "" }
q21036
ReferenceSample.getServices
train
def getServices(self): """ get all services for this Sample """ tool = getToolByName(self, REFERENCE_CATALOG) services = [] for spec in self.getReferenceResults(): service = tool.lookupObject(spec['uid']) services.append(service) return services
python
{ "resource": "" }
q21037
ReferenceSample.isValid
train
def isValid(self): """ Returns if the current Reference Sample is valid. This is, the sample hasn't neither been expired nor disposed. """ today = DateTime() expiry_date = self.getExpiryDate() if expiry_date and today > expiry_date: return False ...
python
{ "resource": "" }
q21038
after_submit
train
def after_submit(analysis): """Method triggered after a 'submit' transition for the analysis passed in is performed. Promotes the submit transition to the Worksheet to which the analysis belongs to. Note that for the worksheet there is already a guard that assures the transition to the worksheet will on...
python
{ "resource": "" }
q21039
after_retract
train
def after_retract(analysis): """Function triggered after a 'retract' transition for the analysis passed in is performed. The analysis transitions to "retracted" state and a new copy of the analysis is created. The copy initial state is "unassigned", unless the the retracted analysis was assigned to a wo...
python
{ "resource": "" }
q21040
after_reject
train
def after_reject(analysis): """Function triggered after the "reject" transition for the analysis passed in is performed.""" # Remove from the worksheet remove_analysis_from_worksheet(analysis) # Reject our dependents (analyses that depend on this analysis) cascade_to_dependents(analysis, "rejec...
python
{ "resource": "" }
q21041
reindex_request
train
def reindex_request(analysis, idxs=None): """Reindex the Analysis Request the analysis belongs to, as well as the ancestors recursively """ if not IRequestAnalysis.providedBy(analysis) or \ IDuplicateAnalysis.providedBy(analysis): # Analysis not directly bound to an Analysis Request....
python
{ "resource": "" }
q21042
remove_analysis_from_worksheet
train
def remove_analysis_from_worksheet(analysis): """Removes the analysis passed in from the worksheet, if assigned to any """ worksheet = analysis.getWorksheet() if not worksheet: return analyses = filter(lambda an: an != analysis, worksheet.getAnalyses()) worksheet.setAnalyses(analyses) ...
python
{ "resource": "" }
q21043
remove_qc_reports
train
def remove_qc_reports(portal): """Removes the action Quality Control from Reports """ logger.info("Removing Reports > Quality Control ...") ti = portal.reports.getTypeInfo() actions = map(lambda action: action.id, ti._actions) for index, action in enumerate(actions, start=0): if action =...
python
{ "resource": "" }
q21044
purge_portlets
train
def purge_portlets(portal): """Remove old portlets. Leave the Navigation portlet only """ logger.info("Purging portlets ...") def remove_portlets(context_portlet): mapping = portal.restrictedTraverse(context_portlet) for key in mapping.keys(): if key not in PORTLETS_TO_PURGE...
python
{ "resource": "" }
q21045
setup_partitioning
train
def setup_partitioning(portal): """Setups the enhanced partitioning system """ logger.info("Setting up the enhanced partitioning system") # Add "Create partition" transition add_create_partition_transition(portal) # Add getAncestorsUIDs index in analyses catalog add_partitioning_indexes(po...
python
{ "resource": "" }
q21046
add_partitioning_metadata
train
def add_partitioning_metadata(portal): """Add metadata columns required for partitioning machinery """ logger.info("Adding partitioning metadata") add_metadata(portal, CATALOG_ANALYSIS_REQUEST_LISTING, 'getRawParentAnalysisRequest') add_metadata(portal, CATALOG_ANALYSIS_REQUEST_LI...
python
{ "resource": "" }
q21047
remove_sample_prep_workflow
train
def remove_sample_prep_workflow(portal): """Removes sample_prep and sample_prep_complete transitions """ # There is no need to walk through objects because of: # https://github.com/senaite/senaite.core/blob/master/bika/lims/upgrade/v01_02_008.py#L187 logger.info("Removing 'sample_prep' related state...
python
{ "resource": "" }
q21048
reindex_multifiles
train
def reindex_multifiles(portal): """Reindex Multifiles to be searchable by the catalog """ logger.info("Reindexing Multifiles ...") brains = api.search(dict(portal_type="Multifile"), "bika_setup_catalog") total = len(brains) for num, brain in enumerate(brains): if num % 100 == 0: ...
python
{ "resource": "" }
q21049
remove_not_requested_analyses_view
train
def remove_not_requested_analyses_view(portal): """Remove the view 'Not requested analyses" from inside AR """ logger.info("Removing 'Analyses not requested' view ...") ar_ptype = portal.portal_types.AnalysisRequest ar_ptype._actions = filter(lambda act: act.id != "analyses_not_requested", ...
python
{ "resource": "" }
q21050
get_catalogs
train
def get_catalogs(portal): """Returns the catalogs from the site """ res = [] for object in portal.objectValues(): if ICatalogTool.providedBy(object): res.append(object) elif IZCatalog.providedBy(object): res.append(object) res.sort() return res
python
{ "resource": "" }
q21051
add_worksheet_indexes
train
def add_worksheet_indexes(portal): """Add indexes for better worksheet handling """ logger.info("Adding worksheet indexes") add_index(portal, catalog_id="bika_analysis_catalog", index_name="getCategoryTitle", index_attribute="getCategoryTitle", index_metatype="...
python
{ "resource": "" }
q21052
remove_bika_listing_resources
train
def remove_bika_listing_resources(portal): """Remove all bika_listing resources """ logger.info("Removing bika_listing resouces") REMOVE_JS = [ "++resource++bika.lims.js/bika.lims.bikalisting.js", "++resource++bika.lims.js/bika.lims.bikalistingfilterbar.js", ] REMOVE_CSS = [ ...
python
{ "resource": "" }
q21053
hide_samples
train
def hide_samples(portal): """Removes samples views from everywhere, related indexes, etc. """ logger.info("Removing Samples from navbar ...") if "samples" in portal: portal.manage_delObjects(["samples"]) def remove_samples_action(content_type): type_info = content_type.getTypeInfo()...
python
{ "resource": "" }
q21054
fix_ar_analyses_inconsistencies
train
def fix_ar_analyses_inconsistencies(portal): """Fixes inconsistencies between analyses and the ARs they belong to when the AR is in a "cancelled", "invalidated" or "rejected state """ def fix_analyses(request, status): wf_id = "bika_analysis_workflow" workflow = api.get_tool("portal_work...
python
{ "resource": "" }
q21055
add_worksheet_progress_percentage
train
def add_worksheet_progress_percentage(portal): """Adds getProgressPercentage metadata to worksheets catalog """ add_metadata(portal, CATALOG_WORKSHEET_LISTING, "getProgressPercentage") logger.info("Reindexing Worksheets ...") query = dict(portal_type="Worksheet") brains = api.search(query, CATAL...
python
{ "resource": "" }
q21056
remove_get_department_uids
train
def remove_get_department_uids(portal): """Removes getDepartmentUIDs indexes and metadata """ logger.info("Removing filtering by department ...") del_index(portal, "bika_catalog", "getDepartmentUIDs") del_index(portal, "bika_setup_catalog", "getDepartmentUID") del_index(portal, CATALOG_ANALYSIS_...
python
{ "resource": "" }
q21057
change_analysis_requests_id_formatting
train
def change_analysis_requests_id_formatting(portal, p_type="AnalysisRequest"): """Applies the system's Sample ID Formatting to Analysis Request """ ar_id_format = dict( form='{sampleType}-{seq:04d}', portal_type='AnalysisRequest', prefix='analysisrequest', sequence_type='gener...
python
{ "resource": "" }
q21058
set_id_format
train
def set_id_format(portal, format): """Sets the id formatting in setup for the format provided """ bs = portal.bika_setup if 'portal_type' not in format: return logger.info("Applying format {} for {}".format(format.get('form', ''), format.get...
python
{ "resource": "" }
q21059
remove_stale_javascripts
train
def remove_stale_javascripts(portal): """Removes stale javascripts """ logger.info("Removing stale javascripts ...") for js in JAVASCRIPTS_TO_REMOVE: logger.info("Unregistering JS %s" % js) portal.portal_javascripts.unregisterResource(js)
python
{ "resource": "" }
q21060
remove_stale_css
train
def remove_stale_css(portal): """Removes stale CSS """ logger.info("Removing stale css ...") for css in CSS_TO_REMOVE: logger.info("Unregistering CSS %s" % css) portal.portal_css.unregisterResource(css)
python
{ "resource": "" }
q21061
remove_stale_indexes_from_bika_catalog
train
def remove_stale_indexes_from_bika_catalog(portal): """Removes stale indexes and metadata from bika_catalog. Most of these indexes and metadata were used for Samples, but they are no longer used. """ logger.info("Removing stale indexes and metadata from bika_catalog ...") cat_id = "bika_catalog" ...
python
{ "resource": "" }
q21062
fix_worksheet_status_inconsistencies
train
def fix_worksheet_status_inconsistencies(portal): """Walks through open worksheets and transition them to 'verified' or 'to_be_verified' if all their analyses are not in an open status """ logger.info("Fixing worksheet inconsistencies ...") query = dict(portal_type="Worksheet", revi...
python
{ "resource": "" }
q21063
apply_analysis_request_partition_interface
train
def apply_analysis_request_partition_interface(portal): """Walks trhough all AR-like partitions registered in the system and applies the IAnalysisRequestPartition marker interface to them """ logger.info("Applying 'IAnalysisRequestPartition' marker interface ...") query = dict(portal_type="AnalysisR...
python
{ "resource": "" }
q21064
update_notify_on_sample_invalidation
train
def update_notify_on_sample_invalidation(portal): """The name of the Setup field was NotifyOnARRetract, so it was confusing. There was also two fields "NotifyOnRejection" """ setup = api.get_setup() # NotifyOnARRetract --> NotifyOnSampleInvalidation old_value = setup.__dict__.get("NotifyOnARRet...
python
{ "resource": "" }
q21065
set_secondary_id_formatting
train
def set_secondary_id_formatting(portal): """Sets the default id formatting for secondary ARs """ secondary_id_format = dict( form="{parent_ar_id}-S{secondary_count:02d}", portal_type="AnalysisRequestSecondary", prefix="analysisrequestsecondary", sequence_type="") set_id_f...
python
{ "resource": "" }
q21066
reindex_submitted_analyses
train
def reindex_submitted_analyses(portal): """Reindex submitted analyses """ logger.info("Reindex submitted analyses") brains = api.search({}, "bika_analysis_catalog") total = len(brains) logger.info("Processing {} analyses".format(total)) for num, brain in enumerate(brains): # skip a...
python
{ "resource": "" }
q21067
remove_invoices
train
def remove_invoices(portal): """Moves all existing invoices inside the client and removes the invoices folder with the invoice batches """ logger.info("Unlink Invoices") invoices = portal.get("invoices") if invoices is None: return for batch in invoices.objectValues(): for ...
python
{ "resource": "" }
q21068
get_workflow_ids_for
train
def get_workflow_ids_for(brain_or_object): """Returns a list with the workflow ids bound to the type of the object passed in """ portal_type = api.get_portal_type(brain_or_object) wf_ids = workflow_ids_by_type.get(portal_type, None) if wf_ids: return wf_ids workflow_ids_by_type[port...
python
{ "resource": "" }
q21069
get_workflow_states_for
train
def get_workflow_states_for(brain_or_object): """Returns a list with the states supported by the workflows the object passed in is bound to """ portal_type = api.get_portal_type(brain_or_object) states = states_by_type.get(portal_type, None) if states: return states # Retrieve the s...
python
{ "resource": "" }
q21070
restore_review_history_for
train
def restore_review_history_for(brain_or_object): """Restores the review history for the given brain or object """ # Get the review history. Note this comes sorted from oldest to newest review_history = get_purged_review_history_for(brain_or_object) obj = api.get_object(brain_or_object) wf_tool ...
python
{ "resource": "" }
q21071
cache_affected_objects_review_history
train
def cache_affected_objects_review_history(portal): """Fills the review_history_cache dict. The keys are the uids of the objects to be bound to new workflow and the values are their current review_history """ logger.info("Caching review_history ...") query = dict(portal_type=NEW_SENAITE_WORKFLOW_BIND...
python
{ "resource": "" }
q21072
get_review_history_for
train
def get_review_history_for(brain_or_object): """Returns the review history list for the given object. If there is no review history for the object, it returns a default review history """ workflow_history = api.get_object(brain_or_object).workflow_history if not workflow_history: # No review...
python
{ "resource": "" }
q21073
create_initial_review_history
train
def create_initial_review_history(brain_or_object): """Creates a new review history for the given object """ obj = api.get_object(brain_or_object) # It shouldn't be necessary to walk-through all workflows from this object, # cause there are no objects with more than one workflow bound in 1.3. #...
python
{ "resource": "" }
q21074
resort_client_actions
train
def resort_client_actions(portal): """Resorts client action views """ sorted_actions = [ "edit", "contacts", "view", # this redirects to analysisrequests "analysisrequests", "batches", "samplepoints", "profiles", "templates", "specs", ...
python
{ "resource": "" }
q21075
init_auditlog
train
def init_auditlog(portal): """Initialize the contents for the audit log """ # reindex the auditlog folder to display the icon right in the setup portal.bika_setup.auditlog.reindexObject() # Initialize contents for audit logging start = time.time() uid_catalog = api.get_tool("uid_catalog") ...
python
{ "resource": "" }
q21076
remove_log_action
train
def remove_log_action(portal): """Removes the old Log action from types """ logger.info("Removing Log Tab ...") portal_types = api.get_tool("portal_types") for name in portal_types.listContentTypes(): ti = portal_types[name] actions = map(lambda action: action.id, ti._actions) ...
python
{ "resource": "" }
q21077
reindex_sortable_title
train
def reindex_sortable_title(portal): """Reindex sortable_title from some catalogs """ catalogs = [ "bika_catalog", "bika_setup_catalog", "portal_catalog", ] for catalog_name in catalogs: logger.info("Reindexing sortable_title for {} ...".format(catalog_name)) h...
python
{ "resource": "" }
q21078
DateTimeWidget.ulocalized_time
train
def ulocalized_time(self, time, context, request): """Returns the localized time in string format """ value = ut(time, long_format=self.show_time, time_only=False, context=context, request=request) return value or ""
python
{ "resource": "" }
q21079
DateTimeWidget.ulocalized_gmt0_time
train
def ulocalized_gmt0_time(self, time, context, request): """Returns the localized time in string format, but in GMT+0 """ value = get_date(context, time) if not value: return "" # DateTime is stored with TimeZone, but DateTimeWidget omits TZ value = value.toZon...
python
{ "resource": "" }
q21080
AnalysisServicesView.get_currency_symbol
train
def get_currency_symbol(self): """Returns the locale currency symbol """ currency = self.context.bika_setup.getCurrency() locale = locales.getLocale("en") locale_currency = locale.numbers.currencies.get(currency) if locale_currency is None: return "$" ...
python
{ "resource": "" }
q21081
AnalysisServicesView.format_maxtime
train
def format_maxtime(self, maxtime): """Formats the max time record to a days, hours, minutes string """ minutes = maxtime.get("minutes", "0") hours = maxtime.get("hours", "0") days = maxtime.get("days", "0") # days, hours, minutes return u"{}: {} {}: {} {}: {}".for...
python
{ "resource": "" }
q21082
AnalysisServicesView.folderitems
train
def folderitems(self, full_objects=False, classic=True): """Sort by Categories """ bsc = getToolByName(self.context, "bika_setup_catalog") self.an_cats = bsc( portal_type="AnalysisCategory", sort_on="sortable_title") self.an_cats_order = dict([ ...
python
{ "resource": "" }
q21083
Sticker.get_items
train
def get_items(self): """Returns a list of SuperModel items """ uids = self.get_uids() if not uids: return [SuperModel(self.context)] items = map(lambda uid: SuperModel(uid), uids) return self._resolve_number_of_copies(items)
python
{ "resource": "" }
q21084
Sticker.getAvailableTemplates
train
def getAvailableTemplates(self): """Returns an array with the templates of stickers available. Each array item is a dictionary with the following structure: {'id': <template_id>, 'title': <teamplate_title>, 'selected: True/False'} """ # Getting adapt...
python
{ "resource": "" }
q21085
Sticker.getSelectedTemplate
train
def getSelectedTemplate(self, default="Code_39_40x20mm.pt"): """Returns the id of the sticker template selected. If no specific template found in the request (parameter template), returns the default template set in Setup > Stickers. If the template doesn't exist, uses the default temp...
python
{ "resource": "" }
q21086
Sticker.getSelectedTemplateCSS
train
def getSelectedTemplateCSS(self): """Looks for the CSS file from the selected template and return its contents. If the selected template is default.pt, looks for a file named default.css in the stickers path and return its contents. If no CSS file found, retrns an empty strin...
python
{ "resource": "" }
q21087
Sticker.renderItem
train
def renderItem(self, item): """Renders the next available sticker. Uses the template specified in the request ('template' parameter) by default. If no template defined in the request, uses the default template set by default in Setup > Stickers. If the template specified doesn'...
python
{ "resource": "" }
q21088
Sticker.getItemsURL
train
def getItemsURL(self): """Used in stickers_preview.pt """ req_items = self.get_uids() req_items = req_items or [api.get_uid(self.context)] req = "{}?items={}".format(self.request.URL, ",".join(req_items)) return req
python
{ "resource": "" }
q21089
Sticker._getStickersTemplatesDirectory
train
def _getStickersTemplatesDirectory(self, resource_name): """Returns the paths for the directory containing the css and pt files for the stickers deppending on the filter_by_type. :param resource_name: The name of the resource folder. :type resource_name: string :returns: a strin...
python
{ "resource": "" }
q21090
Sticker.pdf_from_post
train
def pdf_from_post(self): """Returns a pdf stream with the stickers """ html = self.request.form.get("html") style = self.request.form.get("style") reporthtml = "<html><head>{0}</head><body>{1}</body></html>" reporthtml = reporthtml.format(style, html) reporthtml =...
python
{ "resource": "" }
q21091
Sticker._resolve_number_of_copies
train
def _resolve_number_of_copies(self, items): """For the given objects generate as many copies as the desired number of stickers. :param items: list of objects whose stickers are going to be previewed. :type items: list :returns: list containing n copies of each object in the item...
python
{ "resource": "" }
q21092
Sticker.get_copies_count
train
def get_copies_count(self): """Return the copies_count number request parameter :returns: the number of copies for each sticker as stated in the request :rtype: int """ setup = api.get_setup() default_num = setup.getDefaultNumberOfCopies() request_num = s...
python
{ "resource": "" }
q21093
DuplicateAnalysis.getResultsRange
train
def getResultsRange(self): """Returns the valid result range for this analysis duplicate, based on both on the result and duplicate variation set in the original analysis A Duplicate will be out of range if its result does not match with the result for the parent analysis plus the dupli...
python
{ "resource": "" }
q21094
getCatalogDefinitions
train
def getCatalogDefinitions(): """ Returns a dictionary with catalogs definitions. """ final = {} analysis_request = bika_catalog_analysisrequest_listing_definition analysis = bika_catalog_analysis_listing_definition autoimportlogs = bika_catalog_autoimportlogs_listing_definition worksheet...
python
{ "resource": "" }
q21095
getCatalog
train
def getCatalog(instance, field='UID'): """ Returns the catalog that stores objects of instance passed in type. If an object is indexed by more than one catalog, the first match will be returned. :param instance: A single object :type instance: ATContentType :returns: The first catalog that ...
python
{ "resource": "" }
q21096
PrintView.download
train
def download(self, data, filename, content_type="application/pdf"): """Download the PDF """ self.request.response.setHeader( "Content-Disposition", "inline; filename=%s" % filename) self.request.response.setHeader("Content-Type", content_type) self.request.response.se...
python
{ "resource": "" }
q21097
upgradestep
train
def upgradestep(upgrade_product, version): """ Decorator for updating the QuickInstaller of a upgrade """ def wrap_func(fn): def wrap_func_args(context, *args): p = getToolByName(context, 'portal_quickinstaller').get(upgrade_product) setattr(p, 'installedversion', version) ...
python
{ "resource": "" }
q21098
HoribaJobinYvonCSVParser.parse_data_line
train
def parse_data_line(self, line): """ Parses the data line into a dictionary for the importer """ it = self._generate(line) reader = csv.DictReader(it, fieldnames=self.headers) values = reader.next() values['DefaultResult'] = 'ResidualError' ...
python
{ "resource": "" }
q21099
AnalysisSpecificationWidget.process_form
train
def process_form(self, instance, field, form, empty_marker=None, emptyReturnsMarker=False): """Return a list of dictionaries fit for AnalysisSpecsResultsField consumption. If neither hidemin nor hidemax are specified, only services which have float()able entries ...
python
{ "resource": "" }