

def _folderRecurse(self, structCache, dbcl, path):
    hash = None
    existingRecord = [x for x in structCache if (x['Path'] == path)]
    children = [x for x in structCache if (x['Path'].startswith(path) and (x['Path'] != path))]
    existingRecord = (existingRecord[0] if len(existingRecord) else None)
    if existingRecord:
        hash = existingRecord['Hash']
    try:
        dirmetadata = dbcl.metadata(path, hash=hash)
    except rest.ErrorResponse as e:
        if (e.status == 304):
            for child in children:
                self._folderRecurse(structCache, dbcl, child['Path'])
            return
        if (e.status == 404):
            structCache[:] = (x for x in structCache if ((x != existingRecord) and (x not in children)))
            return
        self._raiseDbException(e)
    if (not existingRecord):
        existingRecord = {
            'Files': [],
            'Path': dirmetadata['path'],
        }
        structCache.append(existingRecord)
    existingRecord['Hash'] = dirmetadata['hash']
    existingRecord['Files'] = []
    curDirs = []
    for file in dirmetadata['contents']:
        if file['is_dir']:
            curDirs.append(file['path'])
            self._folderRecurse(structCache, dbcl, file['path'])
        else:
            if ((not file['path'].lower().endswith('.gpx')) and (not file['path'].lower().endswith('.tcx'))):
                continue
            existingRecord['Files'].append({
                'Rev': file['rev'],
                'Path': file['path'],
            })
    structCache[:] = (x for x in structCache if ((x['Path'] in curDirs) or (x not in dbcl)))

dataset/ETHPy150Open cpfair/tapiriik/tapiriik/services/Dropbox/dropbox.py DropboxService._folderRecurse/VarMisuse@416/542 `children`->`dbcl`