Code Duplication    Length = 28-28 lines in 2 locations

client-ai/ai_client.py 1 location

@@ 133-160 (lines=28) @@
130
131
## Basic functions
132
133
def get(objID, forceUpdate = 0, noUpdate = 0, canBePublic = 1, publicOnly = 0):
134
    global nonexistingObj
135
    if nonexistingObj.has_key(objID) and not forceUpdate:
136
        return None
137
    if noUpdate:
138
        return db.get(objID, None)
139
    if (db.needsUpdate(objID) or forceUpdate) and not publicOnly:
140
        try:
141
            db[objID] = cmdProxy.getInfo(objID)
142
        except ige.SecurityException:
143
            if canBePublic:
144
                db[objID] = cmdProxy.getPublicInfo(objID)
145
            else:
146
                return db.get(objID, None)
147
        except ige.NoSuchObjectException:
148
            if db.has_key(objID):
149
                del db[objID]
150
            nonexistingObj[objID] = None
151
            return None
152
    if (db.needsUpdate(objID) or forceUpdate) and publicOnly: #for when the data you need is never anything but public
153
        try:
154
            db[objID] = cmdProxy.getPublicInfo(objID)
155
        except ige.NoSuchObjectException:
156
            if db.has_key(objID):
157
                del db[objID]
158
            nonexistingObj[objID] = None
159
            return None
160
    return db[objID]
161
162
def updateIDs(objIDs):
163
    delete = objIDs[:]

client/osci/client.py 1 location

@@ 233-260 (lines=28) @@
230
        except ige.NoAccountException:
231
            pass
232
233
def get(objID, forceUpdate = 0, noUpdate = 0, canBePublic = 1, publicOnly = 0):
234
    global nonexistingObj
235
    if nonexistingObj.has_key(objID) and not forceUpdate:
236
        return None
237
    if noUpdate:
238
        return db.get(objID, None)
239
    if (db.needsUpdate(objID) or forceUpdate) and not publicOnly:
240
        try:
241
            db[objID] = cmdProxy.getInfo(objID)
242
        except ige.SecurityException:
243
            if canBePublic:
244
                db[objID] = cmdProxy.getPublicInfo(objID)
245
            else:
246
                return db.get(objID, None)
247
        except ige.NoSuchObjectException:
248
            if db.has_key(objID):
249
                del db[objID]
250
            nonexistingObj[objID] = None
251
            return None
252
    if (db.needsUpdate(objID) or forceUpdate) and publicOnly: #for when the data you need is never anything but public
253
        try:
254
            db[objID] = cmdProxy.getPublicInfo(objID)
255
        except ige.NoSuchObjectException:
256
            if db.has_key(objID):
257
                del db[objID]
258
            nonexistingObj[objID] = None
259
            return None
260
    return db[objID]
261
262
def updateIDs(objIDs):
263
    delete = objIDs[:]