<commit_before>## Script (Python) "guard_auto_preserve_sample"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=type_name=None
##title=
##

from DateTime import DateTime
workflow = context.portal_workflow

# Return TRUE if object advances to To Be Sampled
# Return FALSE if object advances to Sample Due
# We made it a seperate guard, so that ARs and Analyses can depend
# on Sample.getSamplingWorkflowEnabled setting

SamplingWorkflowEnabled = context.bika_setup.getSamplingWorkflowEnabled()

if context.portal_type == 'Sample':
    return SamplingWorkflowEnabled

elif context.portal_type == "AnalysisRequest":
    sample = context.getSample()
    if sample:
        return sample.getSamplingWorkflowEnabled()
    else:
        return SamplingWorkflowEnabled

elif context.portal_type == "Analysis":
    sample = context.aq_parent.getSample()
    if sample:
        return sample.getSamplingWorkflowEnabled()
    else:
        return SamplingWorkflowEnabled
<commit_msg>Auto-Sampling workflow guard applies to partitions<commit_after>## Script (Python) "guard_auto_preserve_sample"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=type_name=None
##title=
##

from DateTime import DateTime
workflow = context.portal_workflow

# Return TRUE if object advances to To Be Sampled
# Return FALSE if object advances to Sample Due
# We made it a seperate guard, so that ARs and Analyses can depend
# on Sample.getSamplingWorkflowEnabled setting

SamplingWorkflowEnabled = context.bika_setup.getSamplingWorkflowEnabled()

if context.portal_type == 'Sample':
    return SamplingWorkflowEnabled

elif context.portal_type == "AnalysisRequest":
    sample = context.getSample()
    if sample:
        return sample.getSamplingWorkflowEnabled()
    else:
        return SamplingWorkflowEnabled

elif context.portal_type == "Analysis":
    sample = context.aq_parent.getSample()
    if sample:
        return sample.getSamplingWorkflowEnabled()
    else:
        return SamplingWorkflowEnabled

elif context.portal_type == "SamplePartition":
    sample = context.aq_parent
    if sample:
        return sample.getSamplingWorkflowEnabled()
    else:
        return SamplingWorkflowEnabled
{'fraction_non_alphanumeric': 0.07679180887372014, 'fraction_numerical': 0.0, 'mean_word_length': 4.804455445544554, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7244281', 'n_tokens_mistral': 650, 'n_tokens_neox': 643, 'n_words': 189}