_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20900 | generateUniqueId | train | def generateUniqueId(context, **kw):
""" Generate pretty content IDs.
"""
# get the config for this portal type from the system setup
config = get_config(context, **kw)
# get the variables map for later string interpolation
variables = get_variables(context, **kw)
# The new generate sequence number
number = 0
# get the sequence type from the global config
sequence_type = config.get("sequence_type", "generated")
# Sequence Type is "Counter", so we use the length of the backreferences or
# contained objects of the evaluated "context" defined in the config
if sequence_type in ["counter"]:
number = get_counted_number(context, config, variables, **kw)
# Sequence Type is "Generated", so the ID is constructed according to the
# configured split length
if sequence_type in ["generated"]:
number = get_generated_number(context, config, variables, **kw)
# store the new sequence number | python | {
"resource": ""
} |
q20901 | ObjectTransitionedEventHandler | train | def ObjectTransitionedEventHandler(obj, event):
"""Object has been transitioned to an new state
"""
# only snapshot supported objects
if not supports_snapshots(obj):
return
# default transition entry
entry = {
"modified": DateTime().ISO(),
"action": event.action,
| python | {
"resource": ""
} |
q20902 | ObjectModifiedEventHandler | train | def ObjectModifiedEventHandler(obj, event):
"""Object has been modified
"""
# only snapshot supported objects
if not supports_snapshots(obj):
return
| python | {
"resource": ""
} |
q20903 | ObjectInitializedEventHandler | train | def ObjectInitializedEventHandler(obj, event):
"""Object has been created
"""
# only snapshot supported objects
if not supports_snapshots(obj):
return
# | python | {
"resource": ""
} |
q20904 | AnalysisSpec.Title | train | def Title(self):
""" Return the title if possible, else return the Sample type.
Fall back on the instance's ID if there's no sample type or title.
"""
title = ''
if self.title:
title = self.title | python | {
"resource": ""
} |
q20905 | AnalysisSpec.getSampleTypes | train | def getSampleTypes(self, active_only=True):
"""Return all sampletypes
"""
catalog = api.get_tool("bika_setup_catalog")
query = {
"portal_type": "SampleType",
# N.B. The `sortable_title` index sorts case sensitive. Since there
# is no sort key for sample types, it makes more sense to sort
# them alphabetically in the selection
"sort_on": "title",
"sort_order": "ascending"
| python | {
"resource": ""
} |
q20906 | _objectdata_cache_key | train | def _objectdata_cache_key(func, obj):
"""Cache Key for object data
"""
uid = api.get_uid(obj)
modified = api.get_modification_date(obj).millis()
| python | {
"resource": ""
} |
q20907 | get_storage | train | def get_storage(obj):
"""Get or create the audit log storage for the given object
:param obj: Content object
:returns: PersistentList
"""
annotation = IAnnotations(obj)
if annotation.get(SNAPSHOT_STORAGE) | python | {
"resource": ""
} |
q20908 | get_snapshot_count | train | def get_snapshot_count(obj):
"""Returns the number of snapsots
:param obj: Content object
:returns: Current snapshots in the storage
"""
try:
| python | {
"resource": ""
} |
q20909 | get_snapshot_by_version | train | def get_snapshot_by_version(obj, version=0):
"""Get a snapshot by version
Snapshot versions begin with `0`, because this is the first index of the
storage, which is a list.
:param obj: Content object
:param version: The index position of the snapshot in the storage
:returns: Snapshot at the given index position
"""
| python | {
"resource": ""
} |
q20910 | get_object_data | train | def get_object_data(obj):
"""Get object schema data
NOTE: We RAM cache this data because it should only change when the object
was modified!
XXX: We need to set at least the modification date when we set fields in
Ajax Listing when we take a snapshot there!
:param obj: Content object
:returns: Dictionary of extracted schema data
"""
model | python | {
"resource": ""
} |
q20911 | get_object_metadata | train | def get_object_metadata(obj, **kw):
"""Get object metadata
:param obj: Content object
:returns: Dictionary of extracted object metadata
"""
# inject metadata of volatile data
metadata = {
"actor": get_user_id(),
"roles": get_roles(),
"action": "",
"review_state": api.get_review_status(obj),
"active": api.is_active(obj),
"snapshot_created": DateTime().ISO(),
| python | {
"resource": ""
} |
q20912 | compare_last_two_snapshots | train | def compare_last_two_snapshots(obj, raw=False):
"""Helper to compare the last two snapshots directly
"""
if get_snapshot_count(obj) < 2:
return {}
version | python | {
"resource": ""
} |
q20913 | diff_values | train | def diff_values(value_a, value_b, raw=False):
"""Returns a human-readable diff between two values
:param value_a: First value to compare
:param value_b: Second value to compare
:param raw: True to compare the raw values, e.g. UIDs
:returns a list of diff tuples
"""
if not raw:
value_a = _process_value(value_a)
value_b = _process_value(value_b)
# No changes
if value_a == value_b:
return None
diffs = []
| python | {
"resource": ""
} |
q20914 | _process_value | train | def _process_value(value):
"""Convert the value into a human readable diff string
"""
if not value:
value = _("Not set")
# XXX: bad data, e.g. in AS Method field
elif value == "None":
value = _("Not set")
# 0 is detected as the portal UID
elif value == "0":
pass
elif api.is_uid(value):
value = _get_title_or_id_from_uid(value)
elif isinstance(value, (dict)):
| python | {
"resource": ""
} |
q20915 | Batch.Title | train | def Title(self):
"""Return the Batch ID if title is not defined
"""
titlefield = self.Schema().getField('title')
if titlefield.widget.visible:
| python | {
"resource": ""
} |
q20916 | Batch.getClient | train | def getClient(self):
"""Retrieves the Client for which the current Batch is attached to
Tries to retrieve the Client from the Schema property, but if not
found, searches for linked ARs and retrieve the Client from the
first one. If the Batch has no client, returns None.
| python | {
"resource": ""
} |
q20917 | Batch.BatchLabelVocabulary | train | def BatchLabelVocabulary(self):
"""Return all batch labels as a display list
"""
bsc = getToolByName(self, 'bika_setup_catalog')
ret = []
for p in bsc(portal_type='BatchLabel',
| python | {
"resource": ""
} |
q20918 | Batch.getAnalysisRequestsBrains | train | def getAnalysisRequestsBrains(self, **kwargs):
"""Return all the Analysis Requests brains linked to the Batch
kargs are passed directly to | python | {
"resource": ""
} |
q20919 | Batch.getAnalysisRequests | train | def getAnalysisRequests(self, **kwargs):
"""Return all the Analysis Requests objects linked to the Batch kargs
| python | {
"resource": ""
} |
q20920 | Instrument.getValidCertifications | train | def getValidCertifications(self):
""" Returns the certifications fully valid
"""
certs = []
today = date.today()
for c in self.getCertifications():
validfrom = c.getValidFrom() if c else None
| python | {
"resource": ""
} |
q20921 | Instrument.isValid | train | def isValid(self):
""" Returns if the current instrument is not out for verification, calibration,
out-of-date regards to its certificates and if the latest QC succeed
"""
return self.isOutOfDate() is False \
and self.isQCValid() is True \ | python | {
"resource": ""
} |
q20922 | Instrument.isQCValid | train | def isQCValid(self):
""" Returns True if the results of the last batch of QC Analyses
performed against this instrument was within the valid range.
For a given Reference Sample, more than one Reference Analyses assigned
to this same instrument can be performed and the Results Capture Date
might slightly differ amongst them. Thus, this function gets the latest
QC Analysis performed, looks for siblings (through RefAnalysisGroupID)
and if the results for all them are valid, then returns True. If there
is one single Reference Analysis from the group with an out-of-range
result, the function returns False
"""
query = {"portal_type": "ReferenceAnalysis",
"getInstrumentUID": self.UID(),
"sort_on": "getResultCaptureDate",
"sort_order": "reverse",
"sort_limit": 1,}
brains = api.search(query, CATALOG_ANALYSIS_LISTING)
if len(brains) == 0:
# There are no Reference Analyses assigned to this instrument yet
return True
# Look for siblings. These are the QC Analyses that were created
# together with this last ReferenceAnalysis and for the same Reference | python | {
"resource": ""
} |
q20923 | Instrument.addReferences | train | def addReferences(self, reference, service_uids):
""" Add reference analyses to reference
"""
# TODO Workflow - Analyses. Assignment of refanalysis to Instrument
addedanalyses = []
wf = getToolByName(self, 'portal_workflow')
bsc = getToolByName(self, 'bika_setup_catalog')
bac = getToolByName(self, 'bika_analysis_catalog')
ref_type = reference.getBlank() and 'b' or 'c'
ref_uid = reference.UID()
postfix = 1
for refa in reference.getReferenceAnalyses():
grid = refa.getReferenceAnalysesGroupID()
try:
cand = int(grid.split('-')[2])
if cand >= postfix:
postfix = cand + 1
except:
pass
postfix = str(postfix).zfill(int(3))
refgid = 'I%s-%s' % (reference.id, postfix)
for service_uid in service_uids:
# services with dependents don't belong in references
service = bsc(portal_type='AnalysisService', UID=service_uid)[0].getObject()
calc = service.getCalculation()
if calc and calc.getDependentServices():
continue | python | {
"resource": ""
} |
q20924 | Instrument.setImportDataInterface | train | def setImportDataInterface(self, values):
""" Return the current list of import data interfaces
"""
exims = self.getImportDataInterfacesList()
new_values = [value for value in values if value in exims]
if len(new_values) < len(values):
| python | {
"resource": ""
} |
q20925 | AttachmentsViewlet.show | train | def show(self):
"""Controls if the viewlet should be rendered
"""
url = self.request.getURL()
# XXX: Hack to show the viewlet only on the AR base_view
if not any(map(url.endswith, ["base_view", "manage_results"])):
return False
| python | {
"resource": ""
} |
q20926 | Import | train | def Import(context, request):
""" Read analysis results from an XML string
"""
errors = []
logs = []
# Do import stuff here
logs.append("Generic XML | python | {
"resource": ""
} |
q20927 | get_storage_location | train | def get_storage_location():
""" get the portal with the plone.api
"""
location | python | {
"resource": ""
} |
q20928 | NumberGenerator.storage | train | def storage(self):
""" get the counter storage
"""
annotation = get_portal_annotation()
if annotation.get(NUMBER_STORAGE) is None:
| python | {
"resource": ""
} |
q20929 | NumberGenerator.get_number | train | def get_number(self, key):
""" get the next consecutive number
"""
storage = self.storage
logger.debug("NUMBER before => %s" % storage.get(key, '-'))
try:
logger.debug("*** consecutive number lock acquire ***")
lock.acquire()
try:
counter = storage[key]
storage[key] = counter + 1
except KeyError:
| python | {
"resource": ""
} |
q20930 | NumberGenerator.set_number | train | def set_number(self, key, value):
""" set a key's value
"""
storage = self.storage
if not isinstance(value, int):
logger.error("set_number: Value must be an integer")
return
try:
| python | {
"resource": ""
} |
q20931 | SampleType.getJSMinimumVolume | train | def getJSMinimumVolume(self, **kw):
"""Try convert the MinimumVolume to 'ml' or 'g' so that JS has an
easier time working with it. If conversion fails, return raw value.
"""
default = self.Schema()['MinimumVolume'].get(self)
try:
mgdefault = default.split(' ', 1)
mgdefault = mg(float(mgdefault[0]), mgdefault[1])
except:
mgdefault = mg(0, 'ml')
| python | {
"resource": ""
} |
q20932 | SampleType._sticker_templates_vocabularies | train | def _sticker_templates_vocabularies(self):
"""
Returns the vocabulary to be used in
AdmittedStickerTemplates.small_default
If the object has saved not AdmittedStickerTemplates.admitted stickers,
this method will return an empty DisplayList. Otherwise it returns
the stickers selected in admitted.
:return: A DisplayList
"""
admitted = self.getAdmittedStickers()
if not admitted:
return DisplayList()
| python | {
"resource": ""
} |
q20933 | EmailView.fail | train | def fail(self, message, status=500, **kw):
"""Set a JSON error object and a status to the response
"""
self.request.response.setStatus(status)
| python | {
"resource": ""
} |
q20934 | EmailView.handle_ajax_request | train | def handle_ajax_request(self):
"""Handle requests ajax routes
"""
# check if the method exists
func_arg = self.traverse_subpath[0]
func_name = "ajax_{}".format(func_arg)
func = getattr(self, func_name, None)
if func is None:
return self.fail("Invalid function", status=400)
# Additional provided path segments after | python | {
"resource": ""
} |
q20935 | EmailView.parse_email | train | def parse_email(self, email):
"""parse an email to an unicode name, email tuple
"""
splitted = safe_unicode(email).rsplit(",", 1)
if len(splitted) == 1:
return (False, splitted[0])
elif len(splitted) == 2: | python | {
"resource": ""
} |
q20936 | EmailView.to_email_attachment | train | def to_email_attachment(self, filename, filedata, **kw):
"""Create a new MIME Attachment
The Content-Type: header is build from the maintype and subtype of the
guessed filename mimetype. Additional parameters for this header are
taken from the keyword arguments.
"""
maintype = "application"
| python | {
"resource": ""
} |
q20937 | EmailView.send_email | train | def send_email(self, recipients, subject, body, attachments=None):
"""Prepare and send email to the recipients
:param recipients: a list of email or name,email strings
:param subject: the email subject
:param body: the email body
:param attachments: list of email attachments
:returns: True if all emails were sent, else false
"""
recipient_pairs = map(self.parse_email, recipients)
template_context = {
"recipients": "\n".join(
map(lambda p: formataddr(p), recipient_pairs))
}
body_template = Template(safe_unicode(body)).safe_substitute(
**template_context)
_preamble = "This is a multi-part message in MIME format.\n"
_from = formataddr((self.email_from_name, self.email_from_address))
_subject = Header(s=safe_unicode(subject), charset="utf8")
_body = MIMEText(body_template, _subtype="plain", _charset="utf8")
# Create the enclosing message
mime_msg = MIMEMultipart()
mime_msg.preamble = _preamble
mime_msg["Subject"] = _subject
mime_msg["From"] = _from
mime_msg.attach(_body)
# Attach attachments
for attachment in attachments:
mime_msg.attach(attachment)
success = []
# Send one email per recipient
| python | {
"resource": ""
} |
q20938 | EmailView.send | train | def send(self, msg_string, immediate=True):
"""Send the email via the MailHost tool
"""
try:
mailhost = api.get_tool("MailHost")
mailhost.send(msg_string, immediate=immediate)
except SMTPException as e:
logger.error(e) | python | {
"resource": ""
} |
q20939 | EmailView.add_status_message | train | def add_status_message(self, message, level="info"):
"""Set a portal status message
"""
| python | {
"resource": ""
} |
q20940 | EmailView.get_report_data | train | def get_report_data(self, report):
"""Report data to be used in the template
"""
ar = report.getAnalysisRequest()
attachments = map(self.get_attachment_data, ar.getAttachment())
pdf = self.get_pdf(report)
filesize = "{} Kb".format(self.get_filesize(pdf))
filename = "{}.pdf".format(ar.getId())
return {
| python | {
"resource": ""
} |
q20941 | EmailView.get_recipients_data | train | def get_recipients_data(self, reports):
"""Recipients data to be used in the template
"""
if not reports:
return []
recipients = []
recipient_names = []
for num, report in enumerate(reports):
# get the linked AR of this ARReport
ar = report.getAnalysisRequest()
# recipient names of this report
report_recipient_names = []
for recipient in self.get_recipients(ar):
name = recipient.get("Fullname")
email = recipient.get("EmailAddress")
record = {
"name": name,
"email": email,
"valid": True,
}
if record not in recipients:
| python | {
"resource": ""
} |
q20942 | EmailView.get_responsibles_data | train | def get_responsibles_data(self, reports):
"""Responsibles data to be used in the template
"""
if not reports:
return []
recipients = []
recipient_names = []
for num, report in enumerate(reports):
# get the linked AR of this ARReport
ar = report.getAnalysisRequest()
# recipient names of this report
report_recipient_names = []
responsibles = ar.getResponsible()
for manager_id in responsibles.get("ids", []):
responsible = responsibles["dict"][manager_id]
name = responsible.get("name")
email = responsible.get("email")
record = {
"name": name,
"email": email,
"valid": True,
}
| python | {
"resource": ""
} |
q20943 | EmailView.email_from_name | train | def email_from_name(self):
"""Portal email name
"""
lab_from_name = self.laboratory.getName()
| python | {
"resource": ""
} |
q20944 | EmailView.get_total_size | train | def get_total_size(self, *files):
"""Calculate the total size of the given files
"""
# Recursive unpack an eventual list of lists
def iterate(item):
if isinstance(item, (list, tuple)):
for i in item:
for ii in iterate(i):
yield ii
| python | {
"resource": ""
} |
q20945 | EmailView.get_object_by_uid | train | def get_object_by_uid(self, uid):
"""Get the object by UID
"""
logger.debug("get_object_by_uid::UID={}".format(uid))
obj = api.get_object_by_uid(uid, None)
| python | {
"resource": ""
} |
q20946 | EmailView.get_filesize | train | def get_filesize(self, f):
"""Return the filesize of the PDF as a float
"""
try:
filesize = float(f.get_size())
| python | {
"resource": ""
} |
q20947 | EmailView.get_recipients | train | def get_recipients(self, ar):
"""Return the AR recipients in the same format like the AR Report
expects in the records field `Recipients`
"""
plone_utils = api.get_tool("plone_utils")
def is_email(email):
if not plone_utils.validateSingleEmailAddress(email):
return False
return True
def recipient_from_contact(contact):
if not contact:
return None
email = contact.getEmailAddress()
return {
"UID": api.get_uid(contact),
"Username": contact.getUsername(),
"Fullname": to_utf8(contact.Title()),
"EmailAddress": email,
}
def recipient_from_email(email):
if not is_email(email):
return None
return {
"UID": "",
| python | {
"resource": ""
} |
q20948 | EmailView.ajax_recalculate_size | train | def ajax_recalculate_size(self):
"""Recalculate the total size of the selected attachments
"""
reports = self.get_reports()
attachments = self.get_attachments()
total_size = self.get_total_size(reports, attachments)
return {
"files": len(reports) | python | {
"resource": ""
} |
q20949 | is_worksheet_context | train | def is_worksheet_context():
"""Returns whether the current context from the request is a Worksheet
"""
request = api.get_request()
parents = request.get("PARENTS", [])
portal_types_names = map(lambda p: getattr(p, "portal_type", None), parents)
if "Worksheet" in portal_types_names:
return True
# Check if the worksheet is declared in | python | {
"resource": ""
} |
q20950 | guard_assign | train | def guard_assign(analysis):
"""Return whether the transition "assign" can be performed or not
"""
# Only if the request was done from worksheet context.
if not is_worksheet_context():
return False
# Cannot assign if the Sample has not been received
if not analysis.isSampleReceived():
return False
# Cannot assign if the analysis | python | {
"resource": ""
} |
q20951 | guard_submit | train | def guard_submit(analysis):
"""Return whether the transition "submit" can be performed or not
"""
# Cannot submit without a result
if not analysis.getResult():
return False
# Cannot submit with interims without value
for interim in analysis.getInterimFields():
if not interim.get("value", ""):
return False
# Cannot submit if attachment not set, but is required
if not analysis.getAttachment():
if analysis.getAttachmentOption() == 'r':
return False
# Check if can submit based on the Analysis Request state
if IRequestAnalysis.providedBy(analysis):
point_of_capture = analysis.getPointOfCapture()
| python | {
"resource": ""
} |
q20952 | guard_multi_verify | train | def guard_multi_verify(analysis):
"""Return whether the transition "multi_verify" can be performed or not
The transition multi_verify will only take place if multi-verification of
results is enabled.
"""
# Cannot multiverify if there is only one remaining verification
remaining_verifications = analysis.getNumberOfRemainingVerifications()
if remaining_verifications <= 1:
return False
# Cannot verify if the user submitted and self-verification is not allowed
if was_submitted_by_current_user(analysis):
if not analysis.isSelfVerificationEnabled():
return False
# Cannot verify if the user verified and multi verification is not allowed
if was_verified_by_current_user(analysis):
if not is_multi_verification_allowed(analysis):
return | python | {
"resource": ""
} |
q20953 | guard_retract | train | def guard_retract(analysis):
""" Return whether the transition "retract" can be performed or not
"""
# Cannot retract if there are dependents that cannot be retracted
if not is_transition_allowed(analysis.getDependents(), "retract"):
return False
dependencies = analysis.getDependencies()
if not dependencies:
return True | python | {
"resource": ""
} |
q20954 | user_has_super_roles | train | def user_has_super_roles():
"""Return whether the current belongs to superuser roles
"""
member = api.get_current_user() | python | {
"resource": ""
} |
q20955 | current_user_was_last_verifier | train | def current_user_was_last_verifier(analysis):
"""Returns whether the current user was the last verifier | python | {
"resource": ""
} |
q20956 | is_transition_allowed | train | def is_transition_allowed(analyses, transition_id):
"""Returns whether all analyses can be transitioned or not
"""
if not analyses:
return True
if not isinstance(analyses, list):
return is_transition_allowed([analyses], | python | {
"resource": ""
} |
q20957 | is_submitted_or_submittable | train | def is_submitted_or_submittable(analysis):
"""Returns whether the analysis is submittable or has already been submitted
"""
if ISubmitted.providedBy(analysis):
| python | {
"resource": ""
} |
q20958 | is_verified_or_verifiable | train | def is_verified_or_verifiable(analysis):
"""Returns whether the analysis is verifiable or has already been verified
"""
if IVerified.providedBy(analysis):
return True
if wf.isTransitionAllowed(analysis, "verify"):
| python | {
"resource": ""
} |
q20959 | InstrumentValidation.isValidationInProgress | train | def isValidationInProgress(self):
"""Checks if the date is beteween a validation period
"""
today = DateTime()
| python | {
"resource": ""
} |
q20960 | InstrumentValidation.getRemainingDaysInValidation | train | def getRemainingDaysInValidation(self):
"""Returns the days until the instrument returns from validation
"""
delta = 0
today = DateTime()
down_from = self.getDownFrom() or today
down_to = self.getDownTo()
# one of the fields is not set, return 0 days
if not down_from or not down_to:
return 0
# down_from comes after down_to?
if down_from > down_to:
| python | {
"resource": ""
} |
q20961 | LabContact.hasUser | train | def hasUser(self):
"""Check if contact has user
"""
username = self.getUsername()
if not username:
| python | {
"resource": ""
} |
q20962 | LabContact._departmentsVoc | train | def _departmentsVoc(self):
"""Vocabulary of available departments
"""
query = {
"portal_type": "Department",
"is_active": True
}
results = api.search(query, "bika_setup_catalog")
items = map(lambda dept: (api.get_uid(dept), api.get_title(dept)),
results)
| python | {
"resource": ""
} |
q20963 | LabContact._defaultDepsVoc | train | def _defaultDepsVoc(self):
"""Vocabulary of all departments
"""
# Getting the assigned departments
deps = self.getDepartments()
items = []
for d in deps:
| python | {
"resource": ""
} |
q20964 | LabContact.addDepartment | train | def addDepartment(self, dep):
"""Adds a department
:param dep: UID or department object
:returns: True when the department was added
"""
if api.is_uid(dep):
dep = api.get_object_by_uid(dep)
deps | python | {
"resource": ""
} |
q20965 | LabContact.removeDepartment | train | def removeDepartment(self, dep):
"""Removes a department
:param dep: UID or department object
:returns: True when the department was removed
"""
if api.is_uid(dep):
dep = api.get_object_by_uid(dep)
| python | {
"resource": ""
} |
q20966 | rename_bika_setup | train | def rename_bika_setup():
"""
Rename Bika Setup to just Setup to avoid naming confusions for new users
"""
logger.info("Renaming Bika Setup...")
bika_setup = api.get_bika_setup()
bika_setup.setTitle("Setup")
bika_setup.reindexObject()
| python | {
"resource": ""
} |
q20967 | guard_retract | train | def guard_retract(worksheet):
"""Return whether the transition retract can be performed or not to the
worksheet passed in. Since the retract transition from worksheet is a
shortcut to retract transitions from all analyses the worksheet contains,
this guard only returns True if retract transition is allowed for all
analyses the worksheet contains
"""
analyses = worksheet.getAnalyses()
detached = ['rejected', 'retracted']
| python | {
"resource": ""
} |
q20968 | guard_rollback_to_open | train | def guard_rollback_to_open(worksheet):
"""Return whether 'rollback_to_receive' transition can be performed or not
"""
for analysis in worksheet.getAnalyses():
| python | {
"resource": ""
} |
q20969 | ContainerType.getContainers | train | def getContainers(self):
"""Return a list of all containers of this type
"""
_containers = []
for container in self.bika_setup.bika_containers.objectValues():
containertype = container.getContainerType()
| python | {
"resource": ""
} |
q20970 | Calculation.setFormula | train | def setFormula(self, Formula=None):
"""Set the Dependent Services from the text of the calculation Formula
"""
bsc = getToolByName(self, 'bika_setup_catalog')
if Formula is None:
self.setDependentServices(None)
self.getField('Formula').set(self, Formula)
| python | {
"resource": ""
} |
q20971 | Calculation.getCalculationDependants | train | def getCalculationDependants(self, deps=None):
"""Return a flat list of services who depend on this calculation.
This refers only to services who's Calculation UIDReferenceField have
the value set to point to this calculation.
It has nothing to do with the services referenced in the calculation's
Formula.
"""
if deps is None:
deps = []
backrefs = get_backreferences(self, 'AnalysisServiceCalculation')
services = map(get_object_by_uid, backrefs)
| python | {
"resource": ""
} |
q20972 | Calculation._getGlobals | train | def _getGlobals(self, **kwargs):
"""Return the globals dictionary for the formula calculation
"""
# Default globals
globs = {
"__builtins__": None,
"all": all,
"any": any,
"bool": bool,
"chr": chr,
"cmp": cmp,
"complex": complex,
"divmod": divmod,
"enumerate": enumerate,
"float": float,
"format": format,
"frozenset": frozenset,
"hex": hex,
"int": int,
"len": len,
"list": list,
"long": long,
"math": math,
"max": max,
"min": min,
"oct": oct,
"ord": ord,
"pow": pow,
"range": range,
"reversed": reversed,
"round": round,
| python | {
"resource": ""
} |
q20973 | Calculation._getModuleMember | train | def _getModuleMember(self, dotted_name, member):
"""Get the member object of a module.
:param dotted_name: The dotted name of the module, e.g. 'scipy.special'
:type dotted_name: string
:param member: The name of the | python | {
"resource": ""
} |
q20974 | after_unassign | train | def after_unassign(reference_analysis):
"""Removes the reference analysis from the system
"""
analysis_events.after_unassign(reference_analysis)
| python | {
"resource": ""
} |
q20975 | after_retract | train | def after_retract(reference_analysis):
"""Function triggered after a 'retract' transition for the reference
analysis passed in is performed. The reference analysis transitions to
"retracted" state and a new copy of the reference analysis is created
"""
reference = reference_analysis.getSample()
service = reference_analysis.getAnalysisService()
worksheet = reference_analysis.getWorksheet()
instrument = reference_analysis.getInstrument()
if worksheet:
# This a reference analysis in a worksheet
slot = worksheet.get_slot_position_for(reference_analysis)
refgid = reference_analysis.getReferenceAnalysesGroupID()
ref = worksheet.add_reference_analysis(reference, service, slot, refgid)
if not ref:
logger.warn("Cannot add a retest for reference analysis {} into {}"
| python | {
"resource": ""
} |
q20976 | Update.require | train | def require(self, fieldname, allow_blank=False):
"""fieldname is required"""
if self.request.form and fieldname not in self.request.form.keys():
| python | {
"resource": ""
} |
q20977 | Update.used | train | def used(self, fieldname):
"""fieldname is used, remove from list | python | {
"resource": ""
} |
q20978 | ReferenceResultsView.get_reference_results | train | def get_reference_results(self):
"""Return a mapping of Analysis Service -> Reference Results
"""
referenceresults | python | {
"resource": ""
} |
q20979 | is_import_interface | train | def is_import_interface(instrument_interface):
"""Returns whether the instrument interface passed in is for results import
"""
if IInstrumentImportInterface.providedBy(instrument_interface):
return True
| python | {
"resource": ""
} |
q20980 | is_export_interface | train | def is_export_interface(instrument_interface):
"""Returns whether the instrument interface passed in is for results export
"""
if IInstrumentExportInterface.providedBy(instrument_interface):
return True
| python | {
"resource": ""
} |
q20981 | getExim | train | def getExim(exim_id):
"""Returns the instrument interface for the exim_id passed in
"""
interfaces = | python | {
"resource": ""
} |
q20982 | get_automatic_parser | train | def get_automatic_parser(exim_id, infile):
"""Returns the parser to be used by default for the instrument id interface
and results file passed in.
"""
adapter = getExim(exim_id)
if IInstrumentAutoImportInterface.providedBy(adapter):
return adapter.get_automatic_parser(infile) | python | {
"resource": ""
} |
q20983 | ReferenceSamplesView.is_manage_allowed | train | def is_manage_allowed(self):
"""Check if manage is allowed
"""
| python | {
"resource": ""
} |
q20984 | ReferenceSamplesView.get_assigned_services | train | def get_assigned_services(self):
"""Get the current assigned services of this Worksheet
"""
analyses = self.context.getAnalyses()
routine_analyses = filter(
| python | {
"resource": ""
} |
q20985 | ReferenceSamplesView.get_assigned_services_uids | train | def get_assigned_services_uids(self):
"""Get the current assigned services UIDs of this Worksheet
"""
| python | {
"resource": ""
} |
q20986 | ReferenceSamplesView.get_supported_services_uids | train | def get_supported_services_uids(self, referencesample):
"""Get the supported services of the reference sample
"""
| python | {
"resource": ""
} |
q20987 | ReferenceSamplesView.make_supported_services_choices | train | def make_supported_services_choices(self, referencesample):
"""Create choices for supported services
"""
choices = []
assigned_services = self.get_assigned_services_uids()
for uid in self.get_supported_services_uids(referencesample):
service = api.get_object(uid)
title = api.get_title(service)
| python | {
"resource": ""
} |
q20988 | ReferenceSamplesView.make_position_choices | train | def make_position_choices(self):
"""Create choices for available positions
"""
choices = []
| python | {
"resource": ""
} |
q20989 | ReferenceSamplesView.get_available_positions | train | def get_available_positions(self):
"""Return a list of empty slot numbers
"""
available_positions = ["new"]
layout = self.context.getLayout()
used_positions = [int(slot["position"]) for slot in layout]
if used_positions:
used = [
| python | {
"resource": ""
} |
q20990 | AnalysesView.isItemAllowed | train | def isItemAllowed(self, obj):
"""Returns true if the current analysis to be rendered has a slot
assigned for the current layout.
:param obj: analysis to be rendered as a row in the list
:type obj: ATContentType/DexterityContentType
:return: True if the obj has an slot assigned. Otherwise, False.
:rtype: bool
| python | {
"resource": ""
} |
q20991 | AnalysesView.folderitems | train | def folderitems(self):
"""Returns an array of dictionaries, each dictionary represents an
analysis row to be rendered in the list. The array returned is sorted
in accordance with the layout positions set for the analyses this
worksheet contains when the analyses were added in the worksheet.
:returns: list of dicts with the items to be rendered in the list
"""
items = BaseView.folderitems(self)
# Fill empty positions from the layout with fake rows. The worksheet
# can be generated by making use of a WorksheetTemplate, so there is
# the chance that some slots of this worksheet being empty. We need to
# render a row still, at lest to display the slot number (Pos)
| python | {
"resource": ""
} |
q20992 | AnalysesView.get_item_position | train | def get_item_position(self, analysis_uid):
"""Returns a list with the position for the analysis_uid passed in
within the current worksheet in accordance with the current layout,
where the first item from the list returned is the slot and the second
is the position of the analysis within the slot.
:param analysis_uid: uid of the analysis the position is requested
:return: the position | python | {
"resource": ""
} |
q20993 | AnalysesView.fill_empty_slots | train | def fill_empty_slots(self, items):
"""Append dicts to the items passed in for those slots that don't have
any analysis assigned but the row needs to be rendered still.
:param items: dictionary with the items to be rendered in the list
"""
for pos in self.get_empty_slots():
item = {
"obj": self.context,
"id": self.context.id,
"uid": self.context.UID(),
"title": self.context.Title(),
"type_class": "blank-worksheet-row",
"url": self.context.absolute_url(),
"relative_url": self.context.absolute_url(),
"view_url": self.context.absolute_url(),
"path": "/".join(self.context.getPhysicalPath()),
"before": {},
"after": {},
"replace": {
"Pos": "<span class='badge'>{}</span> {}".format(
| python | {
"resource": ""
} |
q20994 | AnalysesView.fill_slots_headers | train | def fill_slots_headers(self, items):
"""Generates the header cell for each slot. For each slot, the first
cell displays information about the parent all analyses within that
given slot have in common, such as the AR Id, SampleType, etc.
:param items: dictionary with items to be rendered in the list
"""
prev_position = 0
for item in items:
item_position = item["Pos"]
| python | {
"resource": ""
} |
q20995 | AnalysesView.skip_item_key | train | def skip_item_key(self, item, key):
"""Add the key to the item's "skip" list
"""
if "skip" in item:
| python | {
"resource": ""
} |
q20996 | AnalysesView.render_remarks_tag | train | def render_remarks_tag(self, ar):
"""Renders a remarks image icon
"""
if not ar.getRemarks():
return ""
uid = api.get_uid(ar)
url = ar.absolute_url()
title = ar.Title()
tooltip = _("Remarks of {}").format(title)
| python | {
"resource": ""
} |
q20997 | AnalysisRequest.Description | train | def Description(self):
"""Returns searchable data as Description"""
descr = | python | {
"resource": ""
} |
q20998 | AnalysisRequest.getDefaultMemberDiscount | train | def getDefaultMemberDiscount(self):
"""Compute default member discount if it applies
"""
if hasattr(self, 'getMemberDiscountApplies'):
| python | {
"resource": ""
} |
q20999 | AnalysisRequest.getResponsible | train | def getResponsible(self):
"""Return all manager info of responsible departments
"""
managers = {}
for department in self.getDepartments():
manager = department.getManager()
if manager is None:
continue
manager_id = manager.getId()
if manager_id not in managers:
managers[manager_id] = {}
managers[manager_id]['salutation'] = safe_unicode(
manager.getSalutation())
managers[manager_id]['name'] = safe_unicode(
manager.getFullname())
managers[manager_id]['email'] = safe_unicode(
manager.getEmailAddress())
managers[manager_id]['phone'] = safe_unicode(
manager.getBusinessPhone())
managers[manager_id]['job_title'] = safe_unicode(
manager.getJobTitle())
if manager.getSignature():
managers[manager_id]['signature'] = \
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.