This file is indexed.

/usr/share/pyshared/freshen/cuke.py is in python-freshen 0.2-2.

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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#-*- coding: utf8 -*-

# Experimental - a non-nose runner for tests, may end up being compatible
# with Cucumber commandline

import os
from freshen.context import *
from freshen.core import TagMatcher, StepsRunner, load_feature, load_language
from freshen.stepregistry import StepImplLoader, StepImplRegistry, UndefinedStepImpl, AmbiguousStepImpl

class FreshenHandler(object):
    
    def before_feature(self, feature):
        pass
    
    def after_feature(self, feature):
        pass
    
    def before_scenario(self, scenario):
        pass
    
    def after_scenario(self, scenario):
        pass

    def before_step(self, step):
        pass
    
    def step_failed(self, step, e):
        pass
    
    def step_ambiguous(self, step, e):
        pass
        
    def step_undefined(self, step, e):
        pass
    
    def step_exception(self, step, e):
        pass
    
    def after_step(self, step):
        pass


class FreshenHandlerProxy(object):
    """ Acts as a handler and proxies callback events to a list of actual handlers. """
        
    def __init__(self, handlers):
        self._handlers = handlers
    
    def __getattr__(self, attr):
        def proxy(*args, **kwargs):
            for h in self._handlers:
                method = getattr(h, attr)
                method(*args, **kwargs)
        return proxy


def run_scenario(step_registry, scenario, handler):
    handler.before_scenario(scenario)
    
    runner = StepsRunner(step_registry)
    scc.clear()
    
    # Run @Before hooks
    for hook_impl in step_registry.get_hooks('before', scenario.get_tags()):
        hook_impl.run(scenario)
    
    # Run all the steps
    for step in scenario.iter_steps():
        handler.before_step(step)
        
        called = False
        try:
            runner.run_step(step)
        except AssertionError, e:
            handler.step_failed(step, e)
            called = True
        except UndefinedStepImpl, e:
            handler.step_undefined(step, e)
            called = True
        except AmbiguousStepImpl, e:
            handler.step_ambiguous(step, e)
            called = True
        except Exception, e:
            handler.step_exception(step, e)
            called = True
        
        if not called:
            handler.after_step(step)
    
    # Run @After hooks
    for hook_impl in step_registry.get_hooks('after', scenario.get_tags()):
        hook_impl.run(scenario)    
    handler.after_scenario(scenario)

def run_feature(step_registry, feature, handler):
    handler.before_feature(feature)
    ftc.clear()
    for scenario in feature.iter_scenarios():
        run_scenario(step_registry, scenario, handler)
    handler.after_feature(feature)

def run_features(step_registry, features, handler):
    for feature in features:
        run_feature(step_registry, feature, handler)

def load_step_definitions(paths):
    loader = StepImplLoader()
    sr = StepImplRegistry(TagMatcher)
    for path in paths:
        loader.load_steps_impl(sr, path)
    return sr

def load_features(paths, language):
    result = []
    for path in paths:
        for (dirpath, dirnames, filenames) in os.walk(path):
            for feature_file in filenames:
                if feature_file.endswith(".feature"):
                    feature_file = os.path.join(dirpath, feature_file)
                    result.append(load_feature(feature_file, language))
    return result

if __name__ == "__main__":
    import sys
    import logging
    from freshen.handlers import ConsoleHandler
    
    logging.basicConfig(level=logging.DEBUG)
    
    paths = sys.argv[1:] or ["features"]
    
    language = load_language('en')
    registry = load_step_definitions(paths)
    features = load_features(paths, language)
    handler = FreshenHandlerProxy([ConsoleHandler()])
    run_features(registry, features, handler)