_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21500 | get_mapped_permissions_for | train | def get_mapped_permissions_for(brain_or_object):
"""Get the mapped permissions for the given object
A mapped permission is one that is used in the object.
Each permission string, e.g. "senaite.core: Field: Edit Analysis Remarks" is
translated by the function `AccessControl.Permission.pname` to a valid... | python | {
"resource": ""
} |
q21501 | get_allowed_permissions_for | train | def get_allowed_permissions_for(brain_or_object, user=None):
"""Get the allowed permissions for the given object
Code extracted from `IRoleManager.manage_getUserRolesAndPermissions`
:param brain_or_object: Catalog brain or object
:param user: A user ID, user object or None (for the current user)
:... | python | {
"resource": ""
} |
q21502 | get_disallowed_permissions_for | train | def get_disallowed_permissions_for(brain_or_object, user=None):
"""Get the disallowed permissions for the given object
Code extracted from `IRoleManager.manage_getUserRolesAndPermissions`
:brain_or_object: Catalog brain or object
:param user: A user ID, user object or None (for the current user)
:... | python | {
"resource": ""
} |
q21503 | check_permission | train | def check_permission(permission, brain_or_object):
"""Check whether the security context allows the given permission on
the given brain or object.
N.B.: This includes also acquired permissions
:param permission: Permission name
:brain_or_object: Catalog brain or object
:returns: True if the... | python | {
"resource": ""
} |
q21504 | get_permissions_for_role | train | def get_permissions_for_role(role, brain_or_object):
"""Return the permissions of the role which are granted on the object
Code extracted from `IRoleManager.permissionsOfRole`
:param role: The role to check the permission
:param brain_or_object: Catalog brain or object
:returns: List of permission... | python | {
"resource": ""
} |
q21505 | get_roles_for_permission | train | def get_roles_for_permission(permission, brain_or_object):
"""Return the roles of the permission that is granted on the object
Code extracted from `IRoleManager.rolesOfPermission`
:param permission: The permission to get the roles
:param brain_or_object: Catalog brain or object
:returns: List of r... | python | {
"resource": ""
} |
q21506 | get_local_roles_for | train | def get_local_roles_for(brain_or_object, user=None):
"""Get the local defined roles on the context
Code extracted from `IRoleManager.get_local_roles_for_userid`
:param brain_or_object: Catalog brain or object
:param user: A user ID, user object or None (for the current user)
:returns: List of gran... | python | {
"resource": ""
} |
q21507 | grant_local_roles_for | train | def grant_local_roles_for(brain_or_object, roles, user=None):
"""Grant local roles for the object
Code extracted from `IRoleManager.manage_addLocalRoles`
:param brain_or_object: Catalog brain or object
:param user: A user ID, user object or None (for the current user)
:param roles: The local roles... | python | {
"resource": ""
} |
q21508 | revoke_local_roles_for | train | def revoke_local_roles_for(brain_or_object, roles, user=None):
"""Revoke local roles for the object
Code extracted from `IRoleManager.manage_setLocalRoles`
:param brain_or_object: Catalog brain or object
:param roles: The local roles to revoke for the current user
:param user: A user ID, user obje... | python | {
"resource": ""
} |
q21509 | grant_permission_for | train | def grant_permission_for(brain_or_object, permission, roles, acquire=0):
"""Grant the permission for the object to the defined roles
Code extracted from `IRoleManager.manage_permission`
:param brain_or_object: Catalog brain or object
:param permission: The permission to be granted
:param roles: Th... | python | {
"resource": ""
} |
q21510 | manage_permission_for | train | def manage_permission_for(brain_or_object, permission, roles, acquire=0):
"""Change the settings for the given permission.
Code extracted from `IRoleManager.manage_permission`
:param brain_or_object: Catalog brain or object
:param permission: The permission to be granted
:param roles: The roles th... | python | {
"resource": ""
} |
q21511 | PrintForm.getCSS | train | def getCSS(self):
""" Returns the css style to be used for the current template.
If the selected template is 'default.pt', this method will
return the content from 'default.css'. If no css file found
for the current template, returns empty string
"""
template ... | python | {
"resource": ""
} |
q21512 | PrintForm.pdfFromPOST | train | def pdfFromPOST(self):
"""
It returns the pdf for the sampling rounds printed
"""
html = self.request.form.get('html')
style = self.request.form.get('style')
reporthtml = "<html><head>%s</head><body><div id='report'>%s</body></html>" % (style, html)
return self.pr... | python | {
"resource": ""
} |
q21513 | BikaSetup.getAnalysisServicesVocabulary | train | def getAnalysisServicesVocabulary(self):
"""
Get all active Analysis Services from Bika Setup and return them as Display List.
"""
bsc = getToolByName(self, 'bika_setup_catalog')
brains = bsc(portal_type='AnalysisService',
is_active=True)
items = [(b.... | python | {
"resource": ""
} |
q21514 | BikaSetup.getPrefixFor | train | def getPrefixFor(self, portal_type):
"""Return the prefix for a portal_type.
If not found, simply uses the portal_type itself
"""
prefix = [p for p in self.getIDFormatting() if p['portal_type'] == portal_type]
if prefix:
return prefix[0]['prefix']
else:
... | python | {
"resource": ""
} |
q21515 | BikaSetup.getRejectionReasonsItems | train | def getRejectionReasonsItems(self):
"""Return the list of predefined rejection reasons
"""
reasons = self.getRejectionReasons()
if not reasons:
return []
reasons = reasons[0]
keys = filter(lambda key: key != "checkbox", reasons.keys())
return map(lambd... | python | {
"resource": ""
} |
q21516 | AnalysisRequestRejectBase.get_rejection_reasons | train | def get_rejection_reasons(self, keyword=None):
"""
Returns a list with the rejection reasons as strings
:param keyword: set of rejection reasons to be retrieved.
Possible values are:
- 'selected': Get, amongst the set of predefined reasons, the ones selected
- 'o... | python | {
"resource": ""
} |
q21517 | BikaCatalogTool.softClearFindAndRebuild | train | def softClearFindAndRebuild(self):
"""
Empties catalog, then finds all contentish objects quering over
uid_catalog and reindexes them.
This may take a long time and will not care about missing
objects in uid_catalog.
"""
logger.info('Soft cleaning ... | python | {
"resource": ""
} |
q21518 | ARResultsInterpretationView.get_text | train | def get_text(self, department, mode="raw"):
"""Returns the text saved for the selected department
"""
row = self.context.getResultsInterpretationByDepartment(department)
rt = RichTextValue(row.get("richtext", ""), "text/plain", "text/html")
if mode == "output":
return... | python | {
"resource": ""
} |
q21519 | Client.getContactUIDForUser | train | def getContactUIDForUser(self):
"""Get the UID of the user associated with the authenticated user
"""
membership_tool = api.get_tool("portal_membership")
member = membership_tool.getAuthenticatedMember()
username = member.getUserName()
r = self.portal_catalog(
... | python | {
"resource": ""
} |
q21520 | Client.getAnalysisCategories | train | def getAnalysisCategories(self):
"""Return all available analysis categories
"""
bsc = api.get_tool("bika_setup_catalog")
cats = []
for st in bsc(portal_type="AnalysisCategory",
is_active=True,
sort_on="sortable_title"):
cat... | python | {
"resource": ""
} |
q21521 | Client.getContacts | train | def getContacts(self, only_active=True):
"""Return an array containing the contacts from this Client
"""
contacts = self.objectValues("Contact")
if only_active:
contacts = filter(api.is_active, contacts)
return contacts | python | {
"resource": ""
} |
q21522 | Client.getDecimalMark | train | def getDecimalMark(self):
"""Return the decimal mark to be used on reports for this client
If the client has DefaultDecimalMark selected, the Default value from
the LIMS Setup will be returned.
Otherwise, will return the value of DecimalMark.
"""
if self.getDefaultDecim... | python | {
"resource": ""
} |
q21523 | Client.getCountry | train | def getCountry(self, default=None):
"""Return the Country from the Physical or Postal Address
"""
physical_address = self.getPhysicalAddress().get("country", default)
postal_address = self.getPostalAddress().get("country", default)
return physical_address or postal_address | python | {
"resource": ""
} |
q21524 | WorksheetImporter.get_rows | train | def get_rows(self, startrow=3, worksheet=None):
"""Returns a generator for all rows in a sheet.
Each row contains a dictionary where the key is the value of the
first row of the sheet for each column.
The data values are returned in utf-8 format.
Starts to consume dat... | python | {
"resource": ""
} |
q21525 | WorksheetImporter.to_bool | train | def to_bool(self, value):
""" Converts a sheet string value to a boolean value.
Needed because of utf-8 conversions
"""
try:
value = value.lower()
except:
pass
try:
value = value.encode('utf-8')
except:
pass
... | python | {
"resource": ""
} |
q21526 | WorksheetImporter.get_object | train | def get_object(self, catalog, portal_type, title=None, **kwargs):
"""This will return an object from the catalog.
Logs a message and returns None if no object or multiple objects found.
All keyword arguments are passed verbatim to the contentFilter
"""
if not title and not kwargs... | python | {
"resource": ""
} |
q21527 | Analysis_Services.get_relations | train | def get_relations(self, service_title, default_obj, obj_type, catalog_name, sheet_name, column):
""" Return an array of objects of the specified type in accordance to
the object titles defined in the sheet specified in 'sheet_name' and
service set in the paramenter 'service_title'.
... | python | {
"resource": ""
} |
q21528 | fix_workflow_transitions | train | def fix_workflow_transitions(portal):
"""
Replace target states from some workflow statuses
"""
logger.info("Fixing workflow transitions...")
tochange = [
{'wfid': 'bika_duplicateanalysis_workflow',
'trid': 'submit',
'changes': {
'new_state_id': 'to_be_verified... | python | {
"resource": ""
} |
q21529 | GetSampleStickers.get_default_sticker_id | train | def get_default_sticker_id(self):
"""
Gets the default sticker for that content type depending on the
requested size.
:return: An sticker ID as string
"""
size = self.request.get('size', '')
if size == 'small':
return self.sample_type.getDefaultSmallS... | python | {
"resource": ""
} |
q21530 | IdentifiersIndexer | train | def IdentifiersIndexer(instance):
"""Return a list of unique Identifier strings
This populates the Identifiers Keyword index, but with some
replacements to prevent the word-splitter etc from taking effect.
"""
identifiers = instance.Schema()['Identifiers'].get(instance)
return [safe_unicode(i['I... | python | {
"resource": ""
} |
q21531 | IHaveIdentifiersSchemaExtender.getOrder | train | def getOrder(self, schematas):
"""Return modified order of field schemats.
"""
schemata = self.context.schema['description'].schemata
fields = schematas[schemata]
fields.insert(fields.index('description') + 1,
'Identifiers')
return schematas | python | {
"resource": ""
} |
q21532 | AbstractAnalysis.getVerificators | train | def getVerificators(self):
"""Returns the user ids of the users that verified this analysis
"""
verifiers = list()
actions = ["verify", "multi_verify"]
for event in wf.getReviewHistory(self):
if event['action'] in actions:
verifiers.append(event['actor... | python | {
"resource": ""
} |
q21533 | AbstractAnalysis.getDefaultUncertainty | train | def getDefaultUncertainty(self, result=None):
"""Return the uncertainty value, if the result falls within
specified ranges for the service from which this analysis was derived.
"""
if result is None:
result = self.getResult()
uncertainties = self.getUncertainties()
... | python | {
"resource": ""
} |
q21534 | AbstractAnalysis.setUncertainty | train | def setUncertainty(self, unc):
"""Sets the uncertainty for this analysis. If the result is a
Detection Limit or the value is below LDL or upper UDL, sets the
uncertainty value to 0
"""
# Uncertainty calculation on DL
# https://jira.bikalabs.com/browse/LIMS-1808
if... | python | {
"resource": ""
} |
q21535 | AbstractAnalysis.isBelowLowerDetectionLimit | train | def isBelowLowerDetectionLimit(self):
"""Returns True if the result is below the Lower Detection Limit or
if Lower Detection Limit has been manually set
"""
if self.isLowerDetectionLimit():
return True
result = self.getResult()
if result and str(result).strip... | python | {
"resource": ""
} |
q21536 | AbstractAnalysis.isAboveUpperDetectionLimit | train | def isAboveUpperDetectionLimit(self):
"""Returns True if the result is above the Upper Detection Limit or
if Upper Detection Limit has been manually set
"""
if self.isUpperDetectionLimit():
return True
result = self.getResult()
if result and str(result).strip... | python | {
"resource": ""
} |
q21537 | AbstractAnalysis.getExponentialFormatPrecision | train | def getExponentialFormatPrecision(self, result=None):
""" Returns the precision for the Analysis Service and result
provided. Results with a precision value above this exponential
format precision should be formatted as scientific notation.
If the Calculate Precision according to Uncert... | python | {
"resource": ""
} |
q21538 | AbstractAnalysis.getPrecision | train | def getPrecision(self, result=None):
"""Returns the precision for the Analysis.
- If ManualUncertainty is set, calculates the precision of the result
in accordance with the manual uncertainty set.
- If Calculate Precision from Uncertainty is set in Analysis Service,
calcula... | python | {
"resource": ""
} |
q21539 | AbstractAnalysis.getAnalyst | train | def getAnalyst(self):
"""Returns the stored Analyst or the user who submitted the result
"""
analyst = self.getField("Analyst").get(self)
if not analyst:
analyst = self.getSubmittedBy()
return analyst or "" | python | {
"resource": ""
} |
q21540 | AbstractAnalysis.getWorksheet | train | def getWorksheet(self):
"""Returns the Worksheet to which this analysis belongs to, or None
"""
worksheet = self.getBackReferences('WorksheetAnalysis')
if not worksheet:
return None
if len(worksheet) > 1:
logger.error(
"Analysis %s is assig... | python | {
"resource": ""
} |
q21541 | AbstractAnalysis.getAttachmentUIDs | train | def getAttachmentUIDs(self):
"""Used to populate metadata, so that we don't need full objects of
analyses when working with their attachments.
"""
attachments = self.getAttachment()
uids = [att.UID() for att in attachments]
return uids | python | {
"resource": ""
} |
q21542 | AbstractAnalysis.remove_duplicates | train | def remove_duplicates(self, ws):
"""When this analysis is unassigned from a worksheet, this function
is responsible for deleting DuplicateAnalysis objects from the ws.
"""
for analysis in ws.objectValues():
if IDuplicateAnalysis.providedBy(analysis) \
and ... | python | {
"resource": ""
} |
q21543 | AbstractAnalysis.getInterimValue | train | def getInterimValue(self, keyword):
"""Returns the value of an interim of this analysis
"""
interims = filter(lambda item: item["keyword"] == keyword,
self.getInterimFields())
if not interims:
logger.warning("Interim '{}' for analysis '{}' not found"... | python | {
"resource": ""
} |
q21544 | checkUserAccess | train | def checkUserAccess(worksheet, request, redirect=True):
""" Checks if the current user has granted access to the worksheet.
If the user is an analyst without LabManager, LabClerk and
RegulatoryInspector roles and the option 'Allow analysts
only to access to the Worksheets on which they are a... | python | {
"resource": ""
} |
q21545 | showRejectionMessage | train | def showRejectionMessage(worksheet):
""" Adds a portalMessage if
a) the worksheet has been rejected and replaced by another or
b) if the worksheet is the replacement of a rejected worksheet.
Otherwise, does nothing.
"""
if hasattr(worksheet, 'replaced_by'):
uc = getToolByName... | python | {
"resource": ""
} |
q21546 | get_date | train | def get_date(context, value):
"""Tries to return a DateTime.DateTime object
"""
if not value:
return None
if isinstance(value, DateTime):
return value
if isinstance(value, datetime):
return dt2DT(value)
if not isinstance(value, basestring):
return None
def tr... | python | {
"resource": ""
} |
q21547 | ulocalized_time | train | def ulocalized_time(time, long_format=None, time_only=None, context=None,
request=None):
"""
This function gets ans string as time or a DateTime objects and returns a
string with the time formatted
:param time: The time to process
:type time: str/DateTime
:param long_format:... | python | {
"resource": ""
} |
q21548 | BrowserView.python_date_format | train | def python_date_format(self, long_format=None, time_only=False):
"""This convert bika domain date format msgstrs to Python
strftime format strings, by the same rules as ulocalized_time.
XXX i18nl10n.py may change, and that is where this code is taken from.
"""
# get msgid
... | python | {
"resource": ""
} |
q21549 | AbstractBaseAnalysis.getVATAmount | train | def getVATAmount(self):
"""Compute VAT Amount from the Price and system configured VAT
"""
price, vat = self.getPrice(), self.getVAT()
return float(price) * (float(vat) / 100) | python | {
"resource": ""
} |
q21550 | AbstractBaseAnalysis.getDiscountedPrice | train | def getDiscountedPrice(self):
"""Compute discounted price excl. VAT
"""
price = self.getPrice()
price = price and price or 0
discount = self.bika_setup.getMemberDiscount()
discount = discount and discount or 0
return float(price) - (float(price) * float(discount))... | python | {
"resource": ""
} |
q21551 | AbstractBaseAnalysis.getDiscountedBulkPrice | train | def getDiscountedBulkPrice(self):
"""Compute discounted bulk discount excl. VAT
"""
price = self.getBulkPrice()
price = price and price or 0
discount = self.bika_setup.getMemberDiscount()
discount = discount and discount or 0
return float(price) - (float(price) * ... | python | {
"resource": ""
} |
q21552 | AbstractBaseAnalysis.getTotalPrice | train | def getTotalPrice(self):
"""Compute total price including VAT
"""
price = self.getPrice()
vat = self.getVAT()
price = price and price or 0
vat = vat and vat or 0
return float(price) + (float(price) * float(vat)) / 100 | python | {
"resource": ""
} |
q21553 | AbstractBaseAnalysis.getTotalBulkPrice | train | def getTotalBulkPrice(self):
"""Compute total bulk price
"""
price = self.getBulkPrice()
vat = self.getVAT()
price = price and price or 0
vat = vat and vat or 0
return float(price) + (float(price) * float(vat)) / 100 | python | {
"resource": ""
} |
q21554 | AbstractBaseAnalysis.getTotalDiscountedPrice | train | def getTotalDiscountedPrice(self):
"""Compute total discounted price
"""
price = self.getDiscountedPrice()
vat = self.getVAT()
price = price and price or 0
vat = vat and vat or 0
return float(price) + (float(price) * float(vat)) / 100 | python | {
"resource": ""
} |
q21555 | AbstractBaseAnalysis.getTotalDiscountedBulkPrice | train | def getTotalDiscountedBulkPrice(self):
"""Compute total discounted corporate bulk price
"""
price = self.getDiscountedCorporatePrice()
vat = self.getVAT()
price = price and price or 0
vat = vat and vat or 0
return float(price) + (float(price) * float(vat)) / 100 | python | {
"resource": ""
} |
q21556 | AbstractBaseAnalysis.getLowerDetectionLimit | train | def getLowerDetectionLimit(self):
"""Returns the Lower Detection Limit for this service as a floatable
"""
ldl = self.getField('LowerDetectionLimit').get(self)
try:
return float(ldl)
except ValueError:
return 0 | python | {
"resource": ""
} |
q21557 | AbstractBaseAnalysis.getUpperDetectionLimit | train | def getUpperDetectionLimit(self):
"""Returns the Upper Detection Limit for this service as a floatable
"""
udl = self.getField('UpperDetectionLimit').get(self)
try:
return float(udl)
except ValueError:
return 0 | python | {
"resource": ""
} |
q21558 | WorkflowActionSubmitAdapter.get_interims_data | train | def get_interims_data(self):
"""Returns a dictionary with the interims data
"""
form = self.request.form
if 'item_data' not in form:
return {}
item_data = {}
if type(form['item_data']) == list:
for i_d in form['item_data']:
for i, ... | python | {
"resource": ""
} |
q21559 | get_calculation_dependants_for | train | def get_calculation_dependants_for(service):
"""Collect all services which depend on this service
:param service: Analysis Service Object/ZCatalog Brain
:returns: List of services that depend on this service
"""
def calc_dependants_gen(service, collector=None):
"""Generator for recursive r... | python | {
"resource": ""
} |
q21560 | get_service_dependencies_for | train | def get_service_dependencies_for(service):
"""Calculate the dependencies for the given service.
"""
dependants = get_calculation_dependants_for(service)
dependencies = get_calculation_dependencies_for(service)
return {
"dependencies": dependencies.values(),
"dependants": dependants... | python | {
"resource": ""
} |
q21561 | InstrumentQCFailuresViewlet.get_failed_instruments | train | def get_failed_instruments(self):
"""Find invalid instruments
- instruments who have failed QC tests
- instruments whose certificate is out of date
- instruments which are disposed until next calibration test
Return a dictionary with all info about expired/invalid instruments
... | python | {
"resource": ""
} |
q21562 | InstrumentQCFailuresViewlet.available | train | def available(self):
"""Control availability of the viewlet
"""
url = api.get_url(self.context)
# render on the portal root
if self.context == api.get_portal():
return True
# render on the front-page
if url.endswith("/front-page"):
return T... | python | {
"resource": ""
} |
q21563 | InstrumentQCFailuresViewlet.render | train | def render(self):
"""Render the viewlet
"""
if not self.available():
return ""
mtool = api.get_tool("portal_membership")
member = mtool.getAuthenticatedMember()
roles = member.getRoles()
allowed = "LabManager" in roles or "Manager" in roles
s... | python | {
"resource": ""
} |
q21564 | AuditLogView.get_widget_for | train | def get_widget_for(self, fieldname):
"""Lookup the widget
"""
field = self.context.getField(fieldname)
if not field:
return None
return field.widget | python | {
"resource": ""
} |
q21565 | AuditLogView.get_widget_label_for | train | def get_widget_label_for(self, fieldname, default=None):
"""Lookup the widget of the field and return the label
"""
widget = self.get_widget_for(fieldname)
if widget is None:
return default
return widget.label | python | {
"resource": ""
} |
q21566 | AuditLogView.translate_state | train | def translate_state(self, s):
"""Translate the given state string
"""
if not isinstance(s, basestring):
return s
s = s.capitalize().replace("_", " ")
return t(_(s)) | python | {
"resource": ""
} |
q21567 | AuditLogView.folderitems | train | def folderitems(self):
"""Generate folderitems for each version
"""
items = []
# get the snapshots
snapshots = get_snapshots(self.context)
# reverse the order to get the most recent change first
snapshots = list(reversed(snapshots))
# set the total number ... | python | {
"resource": ""
} |
q21568 | InstrumentResultsFileParser._addRawResult | train | def _addRawResult(self, resid, values={}, override=False):
""" Adds a set of raw results for an object with id=resid
resid is usually an Analysis Request ID or Worksheet's Reference
Analysis ID. The values are a dictionary in which the keys are
analysis service keywords and t... | python | {
"resource": ""
} |
q21569 | InstrumentResultsFileParser.getResultsTotalCount | train | def getResultsTotalCount(self):
""" The total number of analysis results parsed
"""
count = 0
for val in self.getRawResults().values():
count += len(val)
return count | python | {
"resource": ""
} |
q21570 | InstrumentResultsFileParser.getAnalysisKeywords | train | def getAnalysisKeywords(self):
""" The analysis service keywords found
"""
analyses = []
for rows in self.getRawResults().values():
for row in rows:
analyses = list(set(analyses + row.keys()))
return analyses | python | {
"resource": ""
} |
q21571 | InstrumentTXTResultsFileParser.read_file | train | def read_file(self, infile):
"""Given an input file read its contents, strip whitespace from the
beginning and end of each line and return a list of the preprocessed
lines read.
:param infile: file that contains the data to be read
:return: list of the read lines with stripped... | python | {
"resource": ""
} |
q21572 | AnalysisResultsImporter.attach_attachment | train | def attach_attachment(self, analysis, attachment):
"""
Attach a file or a given set of files to an analysis
:param analysis: analysis where the files are to be attached
:param attachment: files to be attached. This can be either a
single file or a list of files
:return: ... | python | {
"resource": ""
} |
q21573 | format_numeric_result | train | def format_numeric_result(analysis, result, decimalmark='.', sciformat=1):
"""
Returns the formatted number part of a results value. This is
responsible for deciding the precision, and notation of numeric
values in accordance to the uncertainty. If a non-numeric
result value is given, the value wil... | python | {
"resource": ""
} |
q21574 | ReferenceResultsWidget._get_spec_value | train | def _get_spec_value(self, form, uid, key, default=''):
"""Returns the value assigned to the passed in key for the analysis
service uid from the passed in form.
If check_floatable is true, will return the passed in default if the
obtained value is not floatable
:param form: form ... | python | {
"resource": ""
} |
q21575 | ReferenceResultsWidget.ReferenceResults | train | def ReferenceResults(self, field, allow_edit=False):
"""Render Reference Results Table
"""
instance = getattr(self, "instance", field.aq_parent)
table = api.get_view("table_reference_results",
context=instance,
request=self.REQUES... | python | {
"resource": ""
} |
q21576 | RemarksField.set | train | def set(self, instance, value, **kwargs):
"""Adds the value to the existing text stored in the field,
along with a small divider showing username and date of this entry.
"""
if not value:
return
value = value.strip()
date = DateTime().rfc822()
user = g... | python | {
"resource": ""
} |
q21577 | setup_handler | train | def setup_handler(context):
"""SENAITE setup handler
"""
if context.readDataFile("bika.lims_various.txt") is None:
return
logger.info("SENAITE setup handler [BEGIN]")
portal = context.getSite()
# Run Installers
remove_default_content(portal)
hide_navbar_items(portal)
rein... | python | {
"resource": ""
} |
q21578 | remove_default_content | train | def remove_default_content(portal):
"""Remove default Plone contents
"""
logger.info("*** Delete Default Content ***")
# Get the list of object ids for portal
object_ids = portal.objectIds()
delete_ids = filter(lambda id: id in object_ids, CONTENTS_TO_DELETE)
portal.manage_delObjects(ids=de... | python | {
"resource": ""
} |
q21579 | hide_navbar_items | train | def hide_navbar_items(portal):
"""Hide root items in navigation
"""
logger.info("*** Hide Navigation Items ***")
# Get the list of object ids for portal
object_ids = portal.objectIds()
object_ids = filter(lambda id: id in object_ids, NAV_BAR_ITEMS_TO_HIDE)
for object_id in object_ids:
... | python | {
"resource": ""
} |
q21580 | reindex_content_structure | train | def reindex_content_structure(portal):
"""Reindex contents generated by Generic Setup
"""
logger.info("*** Reindex content structure ***")
def reindex(obj, recurse=False):
# skip catalog tools etc.
if api.is_object(obj):
obj.reindexObject()
if recurse and hasattr(aq_... | python | {
"resource": ""
} |
q21581 | setup_groups | train | def setup_groups(portal):
"""Setup roles and groups for BECHEM
"""
logger.info("*** Setup Roles and Groups ***")
portal_groups = api.get_tool("portal_groups")
for gdata in GROUPS:
group_id = gdata["id"]
# create the group and grant the roles
if group_id not in portal_groups... | python | {
"resource": ""
} |
q21582 | setup_catalog_mappings | train | def setup_catalog_mappings(portal):
"""Setup portal_type -> catalog mappings
"""
logger.info("*** Setup Catalog Mappings ***")
at = api.get_tool("archetype_tool")
for portal_type, catalogs in CATALOG_MAPPINGS:
at.setCatalogsByType(portal_type, catalogs) | python | {
"resource": ""
} |
q21583 | setup_core_catalogs | train | def setup_core_catalogs(portal):
"""Setup core catalogs
"""
logger.info("*** Setup Core Catalogs ***")
to_reindex = []
for catalog, name, attribute, meta_type in INDEXES:
c = api.get_tool(catalog)
indexes = c.indexes()
if name in indexes:
logger.info("*** Index '... | python | {
"resource": ""
} |
q21584 | setup_auditlog_catalog | train | def setup_auditlog_catalog(portal):
"""Setup auditlog catalog
"""
logger.info("*** Setup Audit Log Catalog ***")
catalog_id = auditlog_catalog.CATALOG_AUDITLOG
catalog = api.get_tool(catalog_id)
for name, meta_type in auditlog_catalog._indexes.iteritems():
indexes = catalog.indexes()
... | python | {
"resource": ""
} |
q21585 | _createWorksheet | train | def _createWorksheet(base, worksheettemplate, analyst):
"""
This function creates a new worksheet takeing advantatge of the analyst
variable. If there isn't an analyst definet, the system will puck up the
the first one obtained in a query.
"""
if not(analyst):
# Get any analyst
a... | python | {
"resource": ""
} |
q21586 | doWorksheetLogic | train | def doWorksheetLogic(base, action, analysis):
"""
This function checks if the actions contains worksheet actions.
There is a selection list in each action section. This select has the
following options and consequence.
1) "To the current worksheet" (selected by default)
2) "To another workshee... | python | {
"resource": ""
} |
q21587 | ARImport.workflow_before_validate | train | def workflow_before_validate(self):
"""This function transposes values from the provided file into the
ARImport object's fields, and checks for invalid values.
If errors are found:
- Validation transition is aborted.
- Errors are stored on object and displayed to user.
... | python | {
"resource": ""
} |
q21588 | ARImport.workflow_script_import | train | def workflow_script_import(self):
"""Create objects from valid ARImport
"""
bsc = getToolByName(self, 'bika_setup_catalog')
client = self.aq_parent
title = _('Submitting Sample Import')
description = _('Creating and initialising objects')
bar = ProgressBar(self, ... | python | {
"resource": ""
} |
q21589 | ARImport.get_header_values | train | def get_header_values(self):
"""Scrape the "Header" values from the original input file
"""
lines = self.getOriginalFile().data.splitlines()
reader = csv.reader(lines)
header_fields = header_data = []
for row in reader:
if not any(row):
continu... | python | {
"resource": ""
} |
q21590 | ARImport.save_header_data | train | def save_header_data(self):
"""Save values from the file's header row into their schema fields.
"""
client = self.aq_parent
headers = self.get_header_values()
if not headers:
return False
# Plain header fields that can be set into plain schema fields:
... | python | {
"resource": ""
} |
q21591 | ARImport.get_sample_values | train | def get_sample_values(self):
"""Read the rows specifying Samples and return a dictionary with
related data.
keys are:
headers - row with "Samples" in column 0. These headers are
used as dictionary keys in the rows below.
prices - Row with "Analysis Price"... | python | {
"resource": ""
} |
q21592 | ARImport.get_batch_header_values | train | def get_batch_header_values(self):
"""Scrape the "Batch Header" values from the original input file
"""
lines = self.getOriginalFile().data.splitlines()
reader = csv.reader(lines)
batch_headers = batch_data = []
for row in reader:
if not any(row):
... | python | {
"resource": ""
} |
q21593 | ARImport.create_or_reference_batch | train | def create_or_reference_batch(self):
"""Save reference to batch, if existing batch specified
Create new batch, if possible with specified values
"""
client = self.aq_parent
batch_headers = self.get_batch_header_values()
if not batch_headers:
return False
... | python | {
"resource": ""
} |
q21594 | ARImport.validate_headers | train | def validate_headers(self):
"""Validate headers fields from schema
"""
pc = getToolByName(self, 'portal_catalog')
pu = getToolByName(self, "plone_utils")
client = self.aq_parent
# Verify Client Name
if self.getClientName() != client.Title():
self.er... | python | {
"resource": ""
} |
q21595 | ARImport.validate_samples | train | def validate_samples(self):
"""Scan through the SampleData values and make sure
that each one is correct
"""
bsc = getToolByName(self, 'bika_setup_catalog')
keywords = bsc.uniqueValuesFor('getKeyword')
profiles = []
for p in bsc(portal_type='AnalysisProfile'):
... | python | {
"resource": ""
} |
q21596 | ARImport.get_row_services | train | def get_row_services(self, row):
"""Return a list of services which are referenced in Analyses.
values may be UID, Title or Keyword.
"""
bsc = getToolByName(self, 'bika_setup_catalog')
services = set()
for val in row.get('Analyses', []):
brains = bsc(portal_ty... | python | {
"resource": ""
} |
q21597 | ARImport.get_row_profile_services | train | def get_row_profile_services(self, row):
"""Return a list of services which are referenced in profiles
values may be UID, Title or ProfileKey.
"""
bsc = getToolByName(self, 'bika_setup_catalog')
services = set()
profiles = [x.getObject() for x in bsc(portal_type='Analysis... | python | {
"resource": ""
} |
q21598 | ARImport.get_row_container | train | def get_row_container(self, row):
"""Return a sample container
"""
bsc = getToolByName(self, 'bika_setup_catalog')
val = row.get('Container', False)
if val:
brains = bsc(portal_type='Container', UID=row['Container'])
if brains:
brains[0].ge... | python | {
"resource": ""
} |
q21599 | t | train | def t(i18n_msg):
"""Safely translate and convert to UTF8, any zope i18n msgid returned from
a bikaMessageFactory _
"""
text = to_unicode(i18n_msg)
try:
request = api.get_request()
domain = getattr(i18n_msg, "domain", "senaite.core")
text = translate(text, domain=domain, conte... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.