prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Validation error in CodeCommit Trigger
  It appears that the validation for the CodeCommit Trigger class does not currently allow the use of any intrinsic functions for the `Events` property, and only accepts a list of hard coded values.
  
  https://github.com/cloudtools/troposphere/blob/45582eb1d21a6cc9cfa608f626d8acbf0317f37f/troposphere/codecommit.py#L18-L32
  
  We are trying to allow for the dynamic selection of  the values with a  parameter, but encounter errors when attempting to use a `Ref`.  A snippet of our trigger definition, and the error encountered is below:
  
  ```
  repo_trigger1 = codecommit.Trigger(
              Name = Ref(trigger_1_name),
              CustomData = Ref(trigger_1_custom_data),
              DestinationArn = Ref(trigger_1_destination_arn),
              Branches = Ref(trigger_1_branches),
              Events = Ref(trigger_1_events),
          )
  ```
  We are able to successfully generate the template when changing the `Events` assignment to:
  
  ```Events = ["all"],```
  
  I believe we just need to check if the value is one of the Helper functions before iterating through the events.  I will try to get a fix pushed up for review.
  
  </issue>
  <code>
  [start of troposphere/codecommit.py]
  1 # Copyright (c) 2016, Mark Peek <mark@peek.org>
  2 # All rights reserved.
  3 #
  4 # See LICENSE file for full license.
  5 
  6 from . import AWSObject, AWSProperty
  7 
  8 
  9 class Trigger(AWSProperty):
  10     props = {
  11         'Branches': ([basestring], False),
  12         'CustomData': (basestring, False),
  13         'DestinationArn': (basestring, False),
  14         'Events': ([basestring], False),
  15         'Name': (basestring, False),
  16     }
  17 
  18     def validate(self):
  19         valid = [
  20             'all',
  21             'createReference',
  22             'deleteReference',
  23             'updateReference',
  24         ]
  25         events = self.properties.get('Events')
  26         if events:
  27             if 'all' in events and len(events) != 1:
  28                 raise ValueError('Trigger events: all must be used alone')
  29             else:
  30                 for e in events:
  31                     if e not in valid:
  32                         raise ValueError('Trigger: invalid event %s' % e)
  33 
  34 
  35 class Repository(AWSObject):
  36     resource_type = "AWS::CodeCommit::Repository"
  37 
  38     props = {
  39         'RepositoryDescription': (basestring, False),
  40         'RepositoryName': (basestring, True),
  41         'Triggers': ([Trigger], False),
  42     }
  43
  [end of troposphere/codecommit.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/troposphere/codecommit.py b/troposphere/codecommit.py
  --- a/troposphere/codecommit.py
  +++ b/troposphere/codecommit.py
  @@ -3,7 +3,7 @@
   #
   # See LICENSE file for full license.
   
  -from . import AWSObject, AWSProperty
  +from . import AWSHelperFn, AWSObject, AWSProperty
   
   
   class Trigger(AWSProperty):
  @@ -23,12 +23,12 @@
               'updateReference',
           ]
           events = self.properties.get('Events')
  -        if events:
  +        if events and not isinstance(events, AWSHelperFn):
               if 'all' in events and len(events) != 1:
                   raise ValueError('Trigger events: all must be used alone')
               else:
                   for e in events:
  -                    if e not in valid:
  +                    if e not in valid and not isinstance(e, AWSHelperFn):
                           raise ValueError('Trigger: invalid event %s' % e)
  
verification_info: {"golden_diff": "diff --git a/troposphere/codecommit.py b/troposphere/codecommit.py\n--- a/troposphere/codecommit.py\n+++ b/troposphere/codecommit.py\n@@ -3,7 +3,7 @@\n #\n # See LICENSE file for full license.\n \n-from . import AWSObject, AWSProperty\n+from . import AWSHelperFn, AWSObject, AWSProperty\n \n \n class Trigger(AWSProperty):\n@@ -23,12 +23,12 @@\n             'updateReference',\n         ]\n         events = self.properties.get('Events')\n-        if events:\n+        if events and not isinstance(events, AWSHelperFn):\n             if 'all' in events and len(events) != 1:\n                 raise ValueError('Trigger events: all must be used alone')\n             else:\n                 for e in events:\n-                    if e not in valid:\n+                    if e not in valid and not isinstance(e, AWSHelperFn):\n                         raise ValueError('Trigger: invalid event %s' % e)\n", "issue": "Validation error in CodeCommit Trigger\nIt appears that the validation for the CodeCommit Trigger class does not currently allow the use of any intrinsic functions for the `Events` property, and only accepts a list of hard coded values.\r\n\r\nhttps://github.com/cloudtools/troposphere/blob/45582eb1d21a6cc9cfa608f626d8acbf0317f37f/troposphere/codecommit.py#L18-L32\r\n\r\nWe are trying to allow for the dynamic selection of  the values with a  parameter, but encounter errors when attempting to use a `Ref`.  A snippet of our trigger definition, and the error encountered is below:\r\n\r\n```\r\nrepo_trigger1 = codecommit.Trigger(\r\n            Name = Ref(trigger_1_name),\r\n            CustomData = Ref(trigger_1_custom_data),\r\n            DestinationArn = Ref(trigger_1_destination_arn),\r\n            Branches = Ref(trigger_1_branches),\r\n            Events = Ref(trigger_1_events),\r\n        )\r\n```\r\nWe are able to successfully generate the template when changing the `Events` assignment to:\r\n\r\n```Events = [\"all\"],```\r\n\r\nI believe we just need to check if the value is one of the Helper functions before iterating through the events.  I will try to get a fix pushed up for review.\n", "before_files": [{"content": "# Copyright (c) 2016, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSObject, AWSProperty\n\n\nclass Trigger(AWSProperty):\n    props = {\n        'Branches': ([basestring], False),\n        'CustomData': (basestring, False),\n        'DestinationArn': (basestring, False),\n        'Events': ([basestring], False),\n        'Name': (basestring, False),\n    }\n\n    def validate(self):\n        valid = [\n            'all',\n            'createReference',\n            'deleteReference',\n            'updateReference',\n        ]\n        events = self.properties.get('Events')\n        if events:\n            if 'all' in events and len(events) != 1:\n                raise ValueError('Trigger events: all must be used alone')\n            else:\n                for e in events:\n                    if e not in valid:\n                        raise ValueError('Trigger: invalid event %s' % e)\n\n\nclass Repository(AWSObject):\n    resource_type = \"AWS::CodeCommit::Repository\"\n\n    props = {\n        'RepositoryDescription': (basestring, False),\n        'RepositoryName': (basestring, True),\n        'Triggers': ([Trigger], False),\n    }\n", "path": "troposphere/codecommit.py"}]}