ndio/remote/neuroRemote.py
def create_channels(self, dataset, token, new_channels_data):
        """
        Creates channels given a dictionary in 'new_channels_data'
        , 'dataset' name, and 'token' (project) name.

        Arguments:
            token (str): Token to identify project
            dataset (str): Dataset name to identify dataset to download from
            new_channels_data (dict): New channel data to upload into new
                channels

        Returns:
            bool: Process completed succesfully or not
        """
        channels = {}
        for channel_new in new_channels_data:

            self._check_channel(channel_new.name)

            if channel_new.channel_type not in ['image', 'annotation']:
                raise ValueError('Channel type must be ' +
                                 'neuroRemote.IMAGE or ' +
                                 'neuroRemote.ANNOTATION.')

            if channel_new.readonly * 1 not in [0, 1]:
                raise ValueError("readonly must be 0 (False) or 1 (True).")

            channels[channel_new.name] = {
                "channel_name": channel_new.name,
                "channel_type": channel_new.channel_type,
                "datatype": channel_new.dtype,
                "readonly": channel_new.readonly * 1
            }
        req = requests.post(self.url("/{}/project/".format(dataset) +
                                     "{}".format(token)),
                            json={"channels": {channels}}, verify=False)

        if req.status_code is not 201:
            raise RemoteDataUploadError('Could not upload {}'.format(req.text))
        else:
            return True
def create_channels(self, dataset, token, new_channels_data):
        """
        Creates channels given a dictionary in 'new_channels_data'
        , 'dataset' name, and 'token' (project) name.

        Arguments:
            token (str): Token to identify project
            dataset (str): Dataset name to identify dataset to download from
            new_channels_data (dict): New channel data to upload into new
                channels

        Returns:
            bool: Process completed succesfully or not
        """
        channels = {}
        for channel_new in new_channels_data:

            self._check_channel(channel_new.name)

            if channel_new.channel_type not in ['image', 'annotation']:
                raise ValueError('Channel type must be ' +
                                 'neuroRemote.IMAGE or ' +
                                 'neuroRemote.ANNOTATION.')

            if channel_new.readonly * 1 not in [0, 1]:
                raise ValueError("readonly must be 0 (False) or 1 (True).")

            channels[channel_new.name] = {
                "channel_name": channel_new.name,
                "channel_type": channel_new.channel_type,
                "datatype": channel_new.dtype,
                "readonly": channel_new.readonly * 1
            }
        req = requests.post(self.url("/{}/project/".format(dataset) +
                                     "{}".format(token)),
                            json={"channels": {channels}}, verify=False)

        if req.status_code is not 201:
            raise RemoteDataUploadError('Could not upload {}'.format(req.text))
        else:
            return True
Creates channels given a dictionary in 'new_channels_data'
        , 'dataset' name, and 'token' (project) name.

        Arguments:
            token (str): Token to identify project
            dataset (str): Dataset name to identify dataset to download from
            new_channels_data (dict): New channel data to upload into new
                channels

        Returns:
            bool: Process completed succesfully or not