/usr/share/pyshared/z3c/rml/occurence.py is in python-z3c.rml 2.0.0-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | ##############################################################################
#
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Condition Implementation
$Id: occurence.py 73959 2007-04-01 01:36:03Z srichter $
"""
__docformat__ = "reStructuredText"
import reportlab
import sys
import zope.interface
import zope.schema
from zope.schema import fieldproperty
class ICondition(zope.interface.Interface):
"""Condition that is checked before a directive is available."""
__doc__ = zope.schema.TextLine(
title=u'Description',
description=u'The description of the condition.',
required=True)
def __call__(directive):
"""Check whether the condition is fulfilled for the given directive."""
class IOccurence(zope.interface.Interface):
"""Description of the occurence of a sub-directive."""
__doc__ = zope.schema.TextLine(
title=u'Description',
description=u'The description of the occurence.',
required=True)
tag = zope.schema.BytesLine(
title=u'Tag',
description=u'The tag of the sub-directive within the directive',
required=True)
signature = zope.schema.Field(
title=u'Signature',
description=u'The signature of the sub-directive.',
required=True)
condition = zope.schema.Field(
title=u'Condition',
description=u'The condition that the directive is available.',
required=False)
@zope.interface.implementer(ICondition)
def laterThanReportlab21(directive):
"""The directive is only available in Reportlab 2.1 and higher."""
return [int(num) for num in reportlab.Version.split('.')] >= (2, 0)
def containing(*occurences):
frame = sys._getframe(1)
f_locals = frame.f_locals
f_globals = frame.f_globals
if not (f_locals is not f_globals
and f_locals.get('__module__')
and f_locals.get('__module__') == f_globals.get('__name__')
):
raise TypeError("contains not called from signature interface")
f_locals['__interface_tagged_values__'] = {'directives': occurences}
class Occurence(object):
zope.interface.implements(IOccurence)
tag = fieldproperty.FieldProperty(IOccurence['tag'])
signature = fieldproperty.FieldProperty(IOccurence['signature'])
condition = fieldproperty.FieldProperty(IOccurence['condition'])
def __init__(self, tag, signature, condition=None):
self.tag = tag
self.signature = signature
self.condition = condition
class ZeroOrMore(Occurence):
"""Zero or More
This sub-directive can occur zero or more times.
"""
class ZeroOrOne(Occurence):
"""Zero or one
This sub-directive can occur zero or one time.
"""
class OneOrMore(Occurence):
"""One or More
This sub-directive can occur one or more times.
"""
class One(Occurence):
"""One
This sub-directive must occur exactly one time.
"""
|