_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21200 | AnalysesView.get_instruments_vocabulary | train | def get_instruments_vocabulary(self, analysis_brain):
"""Returns a vocabulary with the valid and active instruments available
for the analysis passed in.
If the option "Allow instrument entry of results" for the Analysis
is disabled, the function returns an empty vocabulary.
If... | python | {
"resource": ""
} |
q21201 | AnalysesView._folder_item_category | train | def _folder_item_category(self, analysis_brain, item):
"""Sets the category to the item passed in
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
if not self.show_categories:
return
... | python | {
"resource": ""
} |
q21202 | AnalysesView._folder_item_duedate | train | def _folder_item_duedate(self, analysis_brain, item):
"""Set the analysis' due date to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
# Note that if the analysis is a Reference... | python | {
"resource": ""
} |
q21203 | AnalysesView._folder_item_result | train | def _folder_item_result(self, analysis_brain, item):
"""Set the analysis' result to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
item["Result"] = ""
if not self.has_... | python | {
"resource": ""
} |
q21204 | AnalysesView._folder_item_calculation | train | def _folder_item_calculation(self, analysis_brain, item):
"""Set the analysis' calculation and interims to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
is_editable = self.is_... | python | {
"resource": ""
} |
q21205 | AnalysesView._folder_item_method | train | def _folder_item_method(self, analysis_brain, item):
"""Fills the analysis' method to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
is_editable = self.is_analysis_edition_allo... | python | {
"resource": ""
} |
q21206 | AnalysesView._folder_item_instrument | train | def _folder_item_instrument(self, analysis_brain, item):
"""Fills the analysis' instrument to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
item['Instrument'] = ''
if n... | python | {
"resource": ""
} |
q21207 | AnalysesView._folder_item_uncertainty | train | def _folder_item_uncertainty(self, analysis_brain, item):
"""Fills the analysis' uncertainty to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
item["Uncertainty"] = ""
... | python | {
"resource": ""
} |
q21208 | AnalysesView._folder_item_detection_limits | train | def _folder_item_detection_limits(self, analysis_brain, item):
"""Fills the analysis' detection limits to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
item["DetectionLimitOper... | python | {
"resource": ""
} |
q21209 | AnalysesView._folder_item_specifications | train | def _folder_item_specifications(self, analysis_brain, item):
"""Set the results range to the item passed in"""
# Everyone can see valid-ranges
item['Specification'] = ''
results_range = analysis_brain.getResultsRange
if not results_range:
return
# Display the... | python | {
"resource": ""
} |
q21210 | AnalysesView._folder_item_verify_icons | train | def _folder_item_verify_icons(self, analysis_brain, item):
"""Set the analysis' verification icons to the item passed in.
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents a row
"""
submitter = analysis_brain.g... | python | {
"resource": ""
} |
q21211 | AnalysesView._folder_item_assigned_worksheet | train | def _folder_item_assigned_worksheet(self, analysis_brain, item):
"""Adds an icon to the item dict if the analysis is assigned to a
worksheet and if the icon is suitable for the current context
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary cou... | python | {
"resource": ""
} |
q21212 | AnalysesView._folder_item_reflex_icons | train | def _folder_item_reflex_icons(self, analysis_brain, item):
"""Adds an icon to the item dictionary if the analysis has been
automatically generated due to a reflex rule
:param analysis_brain: Brain that represents an analysis
:param item: analysis' dictionary counterpart that represents ... | python | {
"resource": ""
} |
q21213 | AnalysesView._folder_item_fieldicons | train | def _folder_item_fieldicons(self, analysis_brain):
"""Resolves if field-specific icons must be displayed for the object
passed in.
:param analysis_brain: Brain that represents an analysis
"""
full_obj = self.get_object(analysis_brain)
uid = api.get_uid(full_obj)
... | python | {
"resource": ""
} |
q21214 | AnalysesView._folder_item_remarks | train | def _folder_item_remarks(self, analysis_brain, item):
"""Renders the Remarks field for the passed in analysis
If the edition of the analysis is permitted, adds the field into the
list of editable fields.
:param analysis_brain: Brain that represents an analysis
:param item: anal... | python | {
"resource": ""
} |
q21215 | AnalysesView._append_html_element | train | def _append_html_element(self, item, element, html, glue=" ",
after=True):
"""Appends an html value after or before the element in the item dict
:param item: dictionary that represents an analysis row
:param element: id of the element the html must be added the... | python | {
"resource": ""
} |
q21216 | sortable_title | train | def sortable_title(instance):
"""Uses the default Plone sortable_text index lower-case
"""
title = plone_sortable_title(instance)
if safe_callable(title):
title = title()
return title.lower() | python | {
"resource": ""
} |
q21217 | sortable_sortkey_title | train | def sortable_sortkey_title(instance):
"""Returns a sortable title as a mxin of sortkey + lowercase sortable_title
"""
title = sortable_title(instance)
if safe_callable(title):
title = title()
sort_key = instance.getSortKey()
if sort_key is None:
sort_key = 999999
return "{:... | python | {
"resource": ""
} |
q21218 | ARTemplateAnalysesView.get_settings | train | def get_settings(self):
"""Returns a mapping of UID -> setting
"""
settings = self.context.getAnalysisServicesSettings()
mapping = dict(map(lambda s: (s.get("uid"), s), settings))
return mapping | python | {
"resource": ""
} |
q21219 | WorkflowActionAssignAdapter.sorted_analyses | train | def sorted_analyses(self, analyses):
"""Sort the analyses by AR ID ascending and subsorted by priority
sortkey within the AR they belong to
"""
analyses = sorted(analyses, key=lambda an: an.getRequestID())
def sorted_by_sortkey(objs):
return sorted(objs, key=lambda a... | python | {
"resource": ""
} |
q21220 | InstrumentMaintenanceTask.getMaintenanceTypes | train | def getMaintenanceTypes(self):
""" Return the current list of maintenance types
"""
types = [('Preventive',safe_unicode(_('Preventive')).encode('utf-8')),
('Repair', safe_unicode(_('Repair')).encode('utf-8')),
('Enhancement', safe_unicode(_('Enhancement')).encod... | python | {
"resource": ""
} |
q21221 | after_unassign | train | def after_unassign(duplicate_analysis):
"""Removes the duplicate from the system
"""
analysis_events.after_unassign(duplicate_analysis)
parent = duplicate_analysis.aq_parent
logger.info("Removing duplicate '{}' from '{}'"
.format(duplicate_analysis.getId(), parent.getId()))
paren... | python | {
"resource": ""
} |
q21222 | after_retract | train | def after_retract(duplicate_analysis):
"""Function triggered after a 'retract' transition for the duplicate passed
in is performed. The duplicate transitions to "retracted" state and a new
copy of the duplicate is created.
"""
# Rename the analysis to make way for it's successor.
# Support multi... | python | {
"resource": ""
} |
q21223 | MasshunterQuantCSVParser.parse_sequencetableline | train | def parse_sequencetableline(self, line):
""" Parses sequence table lines
Sequence Table example:
Sequence Table,,,,,,,,,,,,,,,,,
Data File,Sample Name,Position,Inj Vol,Level,Sample Type,Acq Method File,,,,,,,,,,,
prerunrespchk.d,prerunrespchk,Vial 3,-1.00,,Sample... | python | {
"resource": ""
} |
q21224 | JSONReadExtender.render_template_partitions | train | def render_template_partitions(self):
"""
Supplies a more detailed view of the Partitions for this
template. It's built to mimic the partitions that are stored in the
ar_add form state variable, so that when a partition is chosen, there
is no further translation necessary.
... | python | {
"resource": ""
} |
q21225 | ComboBoxWidget.process_form | train | def process_form(self, instance, field, form, empty_marker=None,
emptyReturnsMarker=False):
"""A typed in value takes precedence over a selected value.
"""
name = field.getName()
otherName = "%s_other" % name
value = form.get(otherName, empty_marker)
... | python | {
"resource": ""
} |
q21226 | searchResults | train | def searchResults(self, REQUEST=None, used=None, **kw):
"""Search the catalog
Search terms can be passed in the REQUEST or as keyword
arguments.
The used argument is now deprecated and ignored
"""
if REQUEST and REQUEST.get('getRequestUID') \
and self.id == CATALOG_ANALYSIS_LISTING... | python | {
"resource": ""
} |
q21227 | barcode_entry.handle_Sample | train | def handle_Sample(self, instance):
"""If this sample has a single AR, go there.
If the sample has 0 or >1 ARs, go to the sample's view URL.
"""
ars = instance.getAnalysisRequests()
if len(ars) == 1:
return self.handle_AnalysisRequest(ars[0])
else:
... | python | {
"resource": ""
} |
q21228 | set_sample_type_default_stickers | train | def set_sample_type_default_stickers(portal):
"""
Fills the admitted stickers and their default stickers to every sample
type.
"""
# Getting all sticker templates
stickers = getStickerTemplates()
sticker_ids = []
for sticker in stickers:
sticker_ids.append(sticker.get('id'))
... | python | {
"resource": ""
} |
q21229 | ARAnalysesField.get | train | def get(self, instance, **kwargs):
"""Returns a list of Analyses assigned to this AR
Return a list of catalog brains unless `full_objects=True` is passed.
Other keyword arguments are passed to bika_analysis_catalog
:param instance: Analysis Request object
:param kwargs: Keyword... | python | {
"resource": ""
} |
q21230 | ARAnalysesField._get_services | train | def _get_services(self, full_objects=False):
"""Fetch and return analysis service objects
"""
bsc = api.get_tool("bika_setup_catalog")
brains = bsc(portal_type="AnalysisService")
if full_objects:
return map(api.get_object, brains)
return brains | python | {
"resource": ""
} |
q21231 | ARAnalysesField._to_service | train | def _to_service(self, thing):
"""Convert to Analysis Service
:param thing: UID/Catalog Brain/Object/Something
:returns: Analysis Service object or None
"""
# Convert UIDs to objects
if api.is_uid(thing):
thing = api.get_object_by_uid(thing, None)
# ... | python | {
"resource": ""
} |
q21232 | ARAnalysesField._update_specs | train | def _update_specs(self, instance, specs):
"""Update AR specifications
:param instance: Analysis Request
:param specs: List of Specification Records
"""
if specs is None:
return
# N.B. we copy the records here, otherwise the spec will be written to
#... | python | {
"resource": ""
} |
q21233 | AnalysisProfile.getTotalPrice | train | def getTotalPrice(self):
"""
Computes the final price using the VATAmount and the subtotal price
"""
price, vat = self.getAnalysisProfilePrice(), self.getVATAmount()
return float(price) + float(vat) | python | {
"resource": ""
} |
q21234 | EasyQParser.xlsx_to_csv | train | def xlsx_to_csv(self, infile, worksheet=0, delimiter=","):
""" Convert xlsx to easier format first, since we want to use the
convenience of the CSV library
"""
wb = load_workbook(self.getInputFile())
sheet = wb.worksheets[worksheet]
buffer = StringIO()
# extract ... | python | {
"resource": ""
} |
q21235 | SamplePoint.getSampleTypeTitles | train | def getSampleTypeTitles(self):
"""Returns a list of sample type titles
"""
sample_types = self.getSampleTypes()
sample_type_titles = map(lambda obj: obj.Title(), sample_types)
# N.B. This is used only for search purpose, because the catalog does
# not add an entry t... | python | {
"resource": ""
} |
q21236 | contentmenu_factories_available | train | def contentmenu_factories_available(self):
"""These types will have their Add New... factories dropdown menu removed.
"""
if hasattr(self._addContext(), 'portal_type') \
and self._addContext().portal_type in [
'ARImport',
'Batch',
'Client',
'AnalysisRequest',
'Wor... | python | {
"resource": ""
} |
q21237 | ReportsListingView.get_filesize | train | def get_filesize(self, pdf):
"""Compute the filesize of the PDF
"""
try:
filesize = float(pdf.get_size())
return filesize / 1024
except (POSKeyError, TypeError):
return 0 | python | {
"resource": ""
} |
q21238 | TX1800iParser._submit_results | train | def _submit_results(self):
"""
Adding current values as a Raw Result and Resetting everything.
"""
if self._cur_res_id and self._cur_values:
# Setting DefaultResult just because it is obligatory.
self._addRawResult(self._cur_res_id, self._cur_values)
s... | python | {
"resource": ""
} |
q21239 | ThermoScientificMultiskanCSVParser.parse_data | train | def parse_data(self, sline):
"""This function builds the addRawResults dictionary using the header values of the labels section
as sample Ids.
"""
if sline[0] == '':
return 0
for idx, label in enumerate(self._labels_values[sline[0]]):
if label != '':
... | python | {
"resource": ""
} |
q21240 | ContactLoginDetailsView.get_users | train | def get_users(self):
"""Get all users of the portal
"""
# We make use of the existing controlpanel `@@usergroup-userprefs`
# view logic to make sure we get all users from all plugins (e.g. LDAP)
users_view = UsersOverviewControlPanel(self.context, self.request)
return use... | python | {
"resource": ""
} |
q21241 | ContactLoginDetailsView.get_user_properties | train | def get_user_properties(self):
"""Return the properties of the User
"""
user = self.context.getUser()
# No User linked, nothing to do
if user is None:
return {}
out = {}
plone_user = user.getUser()
userid = plone_user.getId()
for she... | python | {
"resource": ""
} |
q21242 | ContactLoginDetailsView.linkable_users | train | def linkable_users(self):
"""Search Plone users which are not linked to a contact or lab contact
"""
# Only users with at nost these roles are displayed
linkable_roles = {"Authenticated", "Member", "Client"}
out = []
for user in self.get_users():
userid = us... | python | {
"resource": ""
} |
q21243 | ContactLoginDetailsView._link_user | train | def _link_user(self, userid):
"""Link an existing user to the current Contact
"""
# check if we have a selected user from the search-list
if userid:
try:
self.context.setUser(userid)
self.add_status_message(
_("User linked t... | python | {
"resource": ""
} |
q21244 | ContactLoginDetailsView.add_status_message | train | def add_status_message(self, message, severity="info"):
"""Set a portal message
"""
self.context.plone_utils.addPortalMessage(message, severity) | python | {
"resource": ""
} |
q21245 | _cache_key_select_state | train | def _cache_key_select_state(method, self, workflow_id, field_id, field_title):
"""
This function returns the key used to decide if select_state has to be recomputed
"""
key = update_timer(), workflow_id, field_id, field_title
return key | python | {
"resource": ""
} |
q21246 | _cache_key_select_analysisservice | train | def _cache_key_select_analysisservice(method, self, allow_blank,
multiselect, style=None):
"""
This function returns the key used to decide if method select_analysisservice has to be recomputed
"""
key = update_timer(), allow_blank, multiselect, style
return key | python | {
"resource": ""
} |
q21247 | _cache_key_select_analyst | train | def _cache_key_select_analyst(method, self, allow_blank=False, style=None):
"""
This function returns the key used to decide if method select_analyst has to be recomputed
"""
key = update_timer(),allow_blank, style
return key | python | {
"resource": ""
} |
q21248 | _cache_key_select_user | train | def _cache_key_select_user(method, self, allow_blank=True, style=None):
"""
This function returns the key used to decide if method select_user has to be recomputed
"""
key = update_timer(), allow_blank, style
return key | python | {
"resource": ""
} |
q21249 | _cache_key_select_daterange | train | def _cache_key_select_daterange(method, self, field_id, field_title, style=None):
"""
This function returns the key used to decide if method select_daterange has to be recomputed
"""
key = update_timer(), field_id, field_title, style
return key | python | {
"resource": ""
} |
q21250 | _cache_key_select_sample_type | train | def _cache_key_select_sample_type(method, self, allow_blank=True, multiselect=False, style=None):
"""
This function returns the key used to decide if method select_sample_type has to be recomputed
"""
key = update_timer(), allow_blank, multiselect, style
return key | python | {
"resource": ""
} |
q21251 | ReferenceAnalysis.getResultsRange | train | def getResultsRange(self):
"""Returns the valid result range for this reference analysis based on
the results ranges defined in the Reference Sample from which this
analysis has been created.
A Reference Analysis (control or blank) will be considered out of range
if its results ... | python | {
"resource": ""
} |
q21252 | ServicesWidget.process_form | train | def process_form(self, instance, field, form, empty_marker=None,
emptyReturnsMarker=False, validating=True):
"""Return UIDs of the selected services
"""
service_uids = form.get("uids", [])
return service_uids, {} | python | {
"resource": ""
} |
q21253 | ServicesWidget.Services | train | def Services(self, field, show_select_column=True):
"""Render Analyses Services Listing Table
"""
instance = getattr(self, "instance", field.aq_parent)
table = api.get_view("table_analyses_services",
context=instance,
request=sel... | python | {
"resource": ""
} |
q21254 | get_user | train | def get_user(user=None):
"""Get the user object
:param user: A user id, memberdata object or None for the current user
:returns: Plone User (PlonePAS) / Propertied User (PluggableAuthService)
"""
if user is None:
# Return the current authenticated user
user = getSecurityManager().ge... | python | {
"resource": ""
} |
q21255 | get_group | train | def get_group(group):
"""Return the group
:param group: The group name/id
:returns: Group
"""
portal_groups = get_tool("portal_groups")
if isinstance(group, basestring):
group = portal_groups.getGroupById(group)
elif isinstance(group, GroupData):
group = group
return gro... | python | {
"resource": ""
} |
q21256 | get_groups | train | def get_groups(user=None):
"""Return the groups of the user
:param user: A user id, memberdata object or None for the current user
:returns: List of groups
"""
portal_groups = get_tool("portal_groups")
user = get_user(user)
if user is None:
return []
return portal_groups.getGrou... | python | {
"resource": ""
} |
q21257 | add_group | train | def add_group(group, user=None):
"""Add the user to the group
"""
user = get_user(user)
if user is None:
raise ValueError("User '{}' not found".format(repr(user)))
if isinstance(group, basestring):
group = [group]
elif isinstance(group, GroupData):
group = [group]
... | python | {
"resource": ""
} |
q21258 | fix_broken_calculations | train | def fix_broken_calculations():
"""Walks-through calculations associated to undergoing analyses and
resets the value for DependentServices field"""
logger.info("Fixing broken calculations (re-assignment of dependents)...")
# Fetch only the subset of analyses that are undergoing.
# Analyses that hav... | python | {
"resource": ""
} |
q21259 | UpgradeReferenceFields | train | def UpgradeReferenceFields():
"""Convert all ReferenceField's values into UIDReferenceFields.
These are not touched: HistoryAware to be removed:
- Analysis.Calculation: HistoryAwareReferenceField (rel=
AnalysisCalculation)
- DuplicateAnalysis.Calculation: HistoryAwareReferenceField (rel=
... | python | {
"resource": ""
} |
q21260 | get_uid | train | def get_uid(value):
"""Takes a brain or object and returns a valid UID.
In this case, the object may come from portal_archivist, so we will
need to do a catalog query to get the UID of the current version
"""
if not value:
return ''
# Is value a brain?
if ICatalogBrain.providedBy(val... | python | {
"resource": ""
} |
q21261 | migrateFileFields | train | def migrateFileFields(portal):
"""
This function walks over all attachment types and migrates their FileField
fields.
"""
portal_types = [
"Attachment",
"ARImport",
"Instrument",
"InstrumentCertification",
"Method",
"Multifile",
"Report",
... | python | {
"resource": ""
} |
q21262 | XXX_REMOVEME | train | def XXX_REMOVEME(func):
"""Decorator for dead code removal
"""
@wraps(func)
def decorator(self, *args, **kwargs):
msg = "~~~~~~~ XXX REMOVEME marked method called: {}.{}".format(
self.__class__.__name__, func.func_name)
raise RuntimeError(msg)
return func(self, *args,... | python | {
"resource": ""
} |
q21263 | returns_json | train | def returns_json(func):
"""Decorator for functions which return JSON
"""
def decorator(*args, **kwargs):
instance = args[0]
request = getattr(instance, 'request', None)
request.response.setHeader("Content-Type", "application/json")
result = func(*args, **kwargs)
retur... | python | {
"resource": ""
} |
q21264 | returns_super_model | train | def returns_super_model(func):
"""Decorator to return standard content objects as SuperModels
"""
def to_super_model(obj):
# avoid circular imports
from senaite.core.supermodel import SuperModel
# Object is already a SuperModel
if isinstance(obj, SuperModel):
ret... | python | {
"resource": ""
} |
q21265 | profileit | train | def profileit(path=None):
"""cProfile decorator to profile a function
:param path: output file path
:type path: str
:return: Function
"""
def inner(func):
@wraps(func)
def wrapper(*args, **kwargs):
prof = cProfile.Profile()
retval = prof.runcall(func, *a... | python | {
"resource": ""
} |
q21266 | timeit | train | def timeit(threshold=0):
"""Decorator to log the execution time of a function
"""
def inner(func):
@wraps(func)
def wrapper(*args, **kwargs):
start = time.time()
return_value = func(*args, **kwargs)
end = time.time()
duration = float(end-start... | python | {
"resource": ""
} |
q21267 | AttachmentsView.action_update | train | def action_update(self):
"""Form action enpoint to update the attachments
"""
order = []
form = self.request.form
attachments = form.get("attachments", [])
for attachment in attachments:
# attachment is a form mapping, not a dictionary -> convert
... | python | {
"resource": ""
} |
q21268 | AttachmentsView.action_add_to_ws | train | def action_add_to_ws(self):
"""Form action to add a new attachment in a worksheet
"""
ws = self.context
form = self.request.form
attachment_file = form.get('AttachmentFile_file', None)
analysis_uid = self.request.get('analysis_uid', None)
service_uid = self.reque... | python | {
"resource": ""
} |
q21269 | AttachmentsView.action_add | train | def action_add(self):
"""Form action to add a new attachment
Code taken from bika.lims.content.addARAttachment.
"""
form = self.request.form
parent = api.get_parent(self.context)
attachment_file = form.get('AttachmentFile_file', None)
AttachmentType = form.get('... | python | {
"resource": ""
} |
q21270 | AttachmentsView.create_attachment | train | def create_attachment(self, container, attachment_file, **kw):
"""Create an Attachment object in the given container
"""
filename = getattr(attachment_file, "filename", "Attachment")
attachment = api.create(container, "Attachment", title=filename)
attachment.edit(AttachmentFile=a... | python | {
"resource": ""
} |
q21271 | AttachmentsView.delete_attachment | train | def delete_attachment(self, attachment):
"""Delete attachment from the AR or Analysis
The attachment will be only deleted if it is not further referenced by
another AR/Analysis.
"""
# Get the holding parent of this attachment
parent = None
if attachment.getLinke... | python | {
"resource": ""
} |
q21272 | AttachmentsView.get_attachment_size | train | def get_attachment_size(self, attachment):
"""Get the human readable size of the attachment
"""
fsize = 0
file = attachment.getAttachmentFile()
if file:
fsize = file.get_size()
if fsize < 1024:
fsize = '%s b' % fsize
else:
fsize... | python | {
"resource": ""
} |
q21273 | AttachmentsView.get_attachment_info | train | def get_attachment_info(self, attachment):
"""Returns a dictionary of attachment information
"""
attachment_uid = api.get_uid(attachment)
attachment_file = attachment.getAttachmentFile()
attachment_type = attachment.getAttachmentType()
attachment_icon = attachment_file.i... | python | {
"resource": ""
} |
q21274 | AttachmentsView.get_attachments | train | def get_attachments(self):
"""Returns a list of attachments info dictionaries
Original code taken from bika.lims.analysisrequest.view
"""
attachments = []
# process AR attachments
for attachment in self.context.getAttachment():
attachment_info = self.get_at... | python | {
"resource": ""
} |
q21275 | AttachmentsView.get_sorted_attachments | train | def get_sorted_attachments(self):
"""Returns a sorted list of analysis info dictionaries
"""
inf = float("inf")
order = self.get_attachments_order()
attachments = self.get_attachments()
def att_cmp(att1, att2):
_n1 = att1.get('UID')
_n2 = att2.get... | python | {
"resource": ""
} |
q21276 | AttachmentsView.get_attachment_types | train | def get_attachment_types(self):
"""Returns a list of available attachment types
"""
bika_setup_catalog = api.get_tool("bika_setup_catalog")
attachment_types = bika_setup_catalog(portal_type='AttachmentType',
is_active=True,
... | python | {
"resource": ""
} |
q21277 | AttachmentsView.get_analyses | train | def get_analyses(self):
"""Returns a list of analyses from the AR
"""
analyses = self.context.getAnalyses(full_objects=True)
return filter(self.is_analysis_attachment_allowed, analyses) | python | {
"resource": ""
} |
q21278 | AttachmentsView.is_analysis_attachment_allowed | train | def is_analysis_attachment_allowed(self, analysis):
"""Checks if the analysis
"""
if analysis.getAttachmentOption() not in ["p", "r"]:
return False
if api.get_workflow_status_of(analysis) in ["retracted"]:
return False
return True | python | {
"resource": ""
} |
q21279 | AttachmentsView.user_can_add_attachments | train | def user_can_add_attachments(self):
"""Checks if the current logged in user is allowed to add attachments
"""
if not self.global_attachments_allowed():
return False
context = self.context
pm = api.get_tool("portal_membership")
return pm.checkPermission(AddAtta... | python | {
"resource": ""
} |
q21280 | AttachmentsView.user_can_update_attachments | train | def user_can_update_attachments(self):
"""Checks if the current logged in user is allowed to update attachments
"""
context = self.context
pm = api.get_tool("portal_membership")
return pm.checkPermission(EditResults, context) or \
pm.checkPermission(EditFieldResults, ... | python | {
"resource": ""
} |
q21281 | AttachmentsView.user_can_delete_attachments | train | def user_can_delete_attachments(self):
"""Checks if the current logged in user is allowed to delete attachments
"""
context = self.context
user = api.get_current_user()
if not self.is_ar_editable():
return False
return (self.user_can_add_attachments() and
... | python | {
"resource": ""
} |
q21282 | AttachmentsView.storage | train | def storage(self):
"""A storage which keeps configuration settings for attachments
"""
annotation = self.get_annotation()
if annotation.get(ATTACHMENTS_STORAGE) is None:
annotation[ATTACHMENTS_STORAGE] = OOBTree()
return annotation[ATTACHMENTS_STORAGE] | python | {
"resource": ""
} |
q21283 | AttachmentsView.flush | train | def flush(self):
"""Remove the whole storage
"""
annotation = self.get_annotation()
if annotation.get(ATTACHMENTS_STORAGE) is not None:
del annotation[ATTACHMENTS_STORAGE] | python | {
"resource": ""
} |
q21284 | AttachmentsView.set_attachments_order | train | def set_attachments_order(self, order):
"""Remember the attachments order
"""
# append single uids to the order
if isinstance(order, basestring):
new_order = self.storage.get("order", [])
new_order.append(order)
order = new_order
self.storage.u... | python | {
"resource": ""
} |
q21285 | ajaxAttachmentsView.ajax_delete_analysis_attachment | train | def ajax_delete_analysis_attachment(self):
"""Endpoint for attachment delete in WS
"""
form = self.request.form
attachment_uid = form.get("attachment_uid", None)
if not attachment_uid:
return "error"
attachment = api.get_object_by_uid(attachment_uid, None)
... | python | {
"resource": ""
} |
q21286 | get_backreferences | train | def get_backreferences(context, relationship=None, as_brains=None):
"""Return all objects which use a UIDReferenceField to reference context.
:param context: The object which is the target of references.
:param relationship: The relationship name of the UIDReferenceField.
:param as_brains: Requests tha... | python | {
"resource": ""
} |
q21287 | UIDReferenceField.get_relationship_key | train | def get_relationship_key(self, context):
"""Return the configured relationship key or generate a new one
"""
if not self.relationship:
return context.portal_type + self.getName()
return self.relationship | python | {
"resource": ""
} |
q21288 | UIDReferenceField.link_reference | train | def link_reference(self, source, target):
"""Link the target to the source
"""
target_uid = api.get_uid(target)
# get the annotation storage key
key = self.get_relationship_key(target)
# get all backreferences from the source
# N.B. only like this we get the persi... | python | {
"resource": ""
} |
q21289 | UIDReferenceField.unlink_reference | train | def unlink_reference(self, source, target):
"""Unlink the target from the source
"""
target_uid = api.get_uid(target)
# get the storage key
key = self.get_relationship_key(target)
# get all backreferences from the source
# N.B. only like this we get the persistent... | python | {
"resource": ""
} |
q21290 | UIDReferenceField.getRaw | train | def getRaw(self, context, aslist=False, **kwargs):
"""Grab the stored value, and return it directly as UIDs.
:param context: context is the object who's schema contains this field.
:type context: BaseContent
:param aslist: Forces a single-valued field to return a list type.
:typ... | python | {
"resource": ""
} |
q21291 | UIDReferenceField._set_backreferences | train | def _set_backreferences(self, context, items, **kwargs):
"""Set the back references on the linked items
This will set an annotation storage on the referenced items which point
to the current context.
"""
# Don't set any references during initialization.
# This might cau... | python | {
"resource": ""
} |
q21292 | DateReceivedFieldVisibility.isVisible | train | def isVisible(self, field, mode="view", default="visible"):
"""Returns whether the field is visible in a given mode
"""
if mode != "edit":
return default
# If this is a Secondary Analysis Request, this field is not editable
if IAnalysisRequestSecondary.providedBy(sel... | python | {
"resource": ""
} |
q21293 | format_keyword | train | def format_keyword(keyword):
"""
Removing special character from a keyword. Analysis Services must have
this kind of keywords. E.g. if assay name from the Instrument is
'HIV-1 2.0', an AS must be created on Bika with the keyword 'HIV120'
"""
import re
result = ''
if keyword:
resu... | python | {
"resource": ""
} |
q21294 | guard_activate | train | def guard_activate(analysis_service):
"""Returns whether the transition activate can be performed for the
analysis service passed in
"""
calculation = analysis_service.getCalculation()
if not calculation:
return True
# If the calculation is inactive, we cannot activate the service
i... | python | {
"resource": ""
} |
q21295 | guard_deactivate | train | def guard_deactivate(analysis_service):
"""Returns whether the transition deactivate can be performed for the
analysis service passed in
"""
for dependant in analysis_service.getServiceDependants():
status = api.get_workflow_status_of(dependant)
if status == "active":
return ... | python | {
"resource": ""
} |
q21296 | AnalysisRequestsView.get_progress_percentage | train | def get_progress_percentage(self, ar_brain):
"""Returns the percentage of completeness of the Analysis Request
"""
review_state = ar_brain.review_state
if review_state == "published":
return 100
numbers = ar_brain.getAnalysesNum
num_analyses = numbers[1] or ... | python | {
"resource": ""
} |
q21297 | RecordsWidget.process_form | train | def process_form(self, instance, field, form, empty_marker=None,
emptyReturnsMarker=False):
"""
Basic impl for form processing in a widget plus allowing empty
values to be saved
"""
# a poor workaround for Plone repeating itself.
# XXX this is import... | python | {
"resource": ""
} |
q21298 | ProxyField.get | train | def get(self, instance, **kwargs):
"""retrieves the value of the same named field on the proxy object
"""
# The default value
default = self.getDefault(instance)
# Retrieve the proxy object
proxy_object = self.get_proxy(instance)
# Return None if we could not fi... | python | {
"resource": ""
} |
q21299 | ProxyField.set | train | def set(self, instance, value, **kwargs):
"""writes the value to the same named field on the proxy object
"""
# Retrieve the proxy object
proxy_object = self.get_proxy(instance)
# Return None if we could not find a proxied object, e.g. through
# the proxy expression 'con... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.