Uploads all the local views from :attr:`VIEW_PATHS` directory
        to CouchBase server

        This method **over-writes** all the server-side views with the same
        named ones coming from :attr:`VIEW_PATHS` folder.

def upload(cls):
        """Uploads all the local views from :attr:`VIEW_PATHS` directory
        to CouchBase server

        This method **over-writes** all the server-side views with the same
        named ones coming from :attr:`VIEW_PATHS` folder.
        """
        cls._check_folder()
        os.chdir(cls.VIEWS_PATH)
        buckets = dict()
        # iterate local folders
        for bucket_name in os.listdir(cls.VIEWS_PATH):
            if not os.path.isdir(bucket_name):
                continue
            # get bucket object
            if bucket_name not in buckets:
                try:
                    bucket = Connection.bucket(bucket_name)
                except BucketNotFoundError as why:
                    print("[WARNING] %s" % str(why))
                    continue
                else:
                    buckets[bucket_name] = bucket
            else:
                bucket = buckets[bucket_name]
            # go through design docs
            for ddoc_name in os.listdir(bucket_name):
                views_path = '%s/%s/views' % (bucket_name, ddoc_name)
                spatial_path = '%s/%s/spatial' % (bucket_name, ddoc_name)
                if not (os.path.exists(views_path) and os.path.isdir(views_path)) and \
                   not (os.path.exists(spatial_path) and os.path.isdir(spatial_path)):
                    continue
                # initialize design doc
                new_ddoc = {
                    'views': {},
                    'spatial': {},
                }
                # map and reduces
                if os.path.exists(views_path) and os.path.isdir(views_path):
                    for filename in os.listdir(views_path):
                        if not os.path.isfile('%s/%s' % (views_path, filename)) or \
                           not filename.endswith(('.map.js', '.reduce.js')):
                            continue
                        view_name, view_type, js = filename.rsplit('.', 2)
                        if view_name not in new_ddoc['views']:
                            new_ddoc['views'][view_name] = {}
                        with open('%s/%s' % (views_path, filename), 'r') as f:
                            new_ddoc['views'][view_name][view_type] = f.read()
                # spatial views
                if os.path.exists(spatial_path) and os.path.isdir(spatial_path):
                    for filename in os.listdir(spatial_path):
                        if not os.path.isfile('%s/%s' % (spatial_path, filename)) or \
                           not filename.endswith('.spatial.js'):
                            continue
                        view_name = filename.rsplit('.', 2)[0]
                        with open('%s/%s' % (spatial_path, filename), 'r') as f:
                            new_ddoc['spatial'][view_name] = f.read()
                bucket['_design/%s' % ddoc_name] = new_ddoc
                print('Uploaded design document: %s' % ddoc_name)
        pass