This file is indexed.

/usr/share/pyshared/whyteboard/lib/pubsubconf.py is in whyteboard 0.41.1-4build1.

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
138
139
140
"""
Allows user to configure pubsub. Most important:

- setVersion(N): State which version of pubsub should be used (N=1, 2 or 3; 
  defaults to latest). E.g. to use version 1 of pubsub:
    
    # in your main script only:
    import pubsubconf
    pubsubconf.setVersion(1)
    
    # in main script and all other modules imported:
    from pubsub import pub # usual line
    
- Several functions specific to version 3:

  - setListenerExcHandler(handler): set handling of exceptions 
    raised in listeners (default: None). 
    
  - setTopicUnspecifiedFatal(val=True): state whether unspecified 
    topics should be creatable (default: False). 
    
  - setNotificationhandler(notificationhandler): what class to instantiate for 
    processing notification events (default: None).
  
  - transitionV1ToV3(commonName, stage=1): set policies that support 
    migrating an application from pubsub version 1 to version 3.
     
"""


packageImported = False


class Version:
    DEFAULT = 3
    value  = None
    output = None
        

def setVersion(val, output=None):
    '''Set the version of package to be used when imported. If 
    output is set to a file object (has write() method), a message
    will be written to that file indicating which version of pubsub 
    has been imported. E.g. setVersion(2, sys.stdout).'''
    if val < 1 or val > 3:
        raise ValueError('val = %s invalid, need 1 <= val <= 3' % val)
    Version.value  = val
    Version.output = output

def getVersion():
    '''Get version number selected for import (via setVersion, 
    or default version if setVersion not called).'''
    return Version.value or Version.DEFAULT

def isVersionChosen():
    '''Return True if setVersion() was called at least once.'''
    return Version.value is not None
    
def getDefaultVersion():
    '''Get version number imported by default.'''
    return Version.default
    
def getVersionOutput():
    '''Return the file object to be used for messaging about imported version'''
    return Version.output


class Policies:
    '''
    Define the policies used by pubsub, when several alternatives 
    exist. 
    '''
    
    _notificationHandler     = None
    _listenerExcHandler      = None
    _raiseOnTopicUnspecified = False
    _msgDataProtocol         = 'kwargs'
    _msgDataArgName          = None
    

def setTopicUnspecifiedFatal(val=True):
    '''When called with val=True (default), causes pubsub to 
    raise an UnspecifiedTopicError when attempting to create
    a topic that has no specification. This happens when 
    pub.addTopicDefnProvider() was never called, or none of 
    the given providers specify the topic (or a super topic of 
    it) that was given to pub.subscribe(). If True, the topic 
    will be created with argument specification inferred from 
    first listener subscribed. '''
    Policies._raiseOnTopicUnspecified = val
    
    
def setNotificationHandler(notificationHandler):
    '''The notifier should be a class that follows the API of  
    pubsub.utils.INotificationHandler. If no notifier is set, then 
    the default will be used. '''
    Policies._notificationHandler = notificationHandler
    

def setListenerExcHandler(handler):
    '''Set the handler to call when a listener raises an exception
    during a sendMessage(). Without a handler, the send operation
    aborts, whereas with one, the exception information is sent to 
    it (where it can be logged, printed, whatever), and 
    sendMessage() continues to send messages
    to remaining listeners. '''
    Policies._listenerExcHandler = handler


def isPackageImported():
    '''Can be used to determine if pubsub package has been imported 
    by your application (or by any modules imported by it). '''
    return packageImported


def setMsgProtocol(protocol):
    '''Messaging protocol defaults to 'kwargs'. It can be set to 
    'dataArg' to support legacy code or simple pub-sub architectures. '''
    if protocol not in ('dataArg', 'kwargs'):
        raise NotImplementedError('The protocol "%s" is not supported' % protocol)
    
    Policies._msgDataProtocol = protocol

    
def transitionV1ToV3(commonName, stage=1):
    '''Use this to help with migrating code from protocol DATA_ARG to 
    KW_ARGS. This only makes sense in an application that has been using 
    setMsgProtocol('dataArg') and wants to move to the more robust 'kwargs'. 
    This function is designed to support a three-stage process: 
    (stage 1) make all listeners use the same argument name (commonName); 
    (stage 2) make all senders use the kwargs protocol and all listeners
    use kwargs rather than Message.data. The third stage, for which you 
    don't use this function, consists in splitting up your message data
    into more kwargs and further refining your topic specification tree. 
    See the docs for more info. 
    '''
    
    Policies._msgDataArgName = commonName
    if stage <= 1:
        Policies._msgDataProtocol = 'dataArg'