Save channel groups to file.
167241
def save_channels(self, checked=False, test_name=None):
        """"""
        self.read_group_info()

        if self.filename is not None:
            filename = self.filename
        elif self.parent.info.filename is not None:
            filename = (splitext(self.parent.info.filename)[0] +
                        '_channels.json')
        else:
            filename = None

        if test_name is None:
            filename, _ = QFileDialog.getSaveFileName(self,
                                                      'Save Channels Montage',
                                                      filename,
                                                      'Channels File (*.json)')
        else:
            filename = test_name

        if filename == '':
            return

        self.filename = filename

        groups = deepcopy(self.groups)
        for one_grp in groups:
            one_grp['color'] = one_grp['color'].rgba()

        with open(filename, 'w') as outfile:
            dump(groups, outfile, indent=' ')
831467
def save_keywords(filename, xml):
    """"""
    tmp_dir = os.path.dirname(filename)
    if not os.path.isdir(tmp_dir):
        os.mkdir(tmp_dir)

    file_desc = open(filename, "w")
    file_desc.write(xml)
    file_desc.close()
1203230
def join(self, channel):
        
        
        if channel not in self.channels:
            channel.users.add(self.nick)
            self.channels.append(channel)
1107038
def save_new_channel(self):
        
        form_info = self.input['form']
        channel = Channel(typ=15, name=form_info['name'],
                          description=form_info['description'],
                          owner_id=form_info['owner_id'])
        channel.blocking_save()
        self.current.task_data['target_channel_key'] = channel.key
592110
def read_channel_list_file(*source):
    
    # read file(s)
    config = configparser.ConfigParser(dict_type=OrderedDict)
    source = file_list(source)
    success_ = config.read(*source)
    if len(success_) != len(source):
        raise IOError("Failed to read one or more CLF files")
    # create channel list
    out = ChannelList()
    out.source = source
    append = out.append
    # loop over all groups and channels
    for group in config.sections():
        params = OrderedDict(config.items(group))
        channels = params.pop('channels').strip('\n').split('\n')
        if 'flow' in params or 'fhigh' in params:
            low = params.pop('flow', 0)
            high = params.pop('fhigh', inf)
            if isinstance(high, string_types) and high.lower() == 'nyquist':
                high = inf
            frange = float(low), float(high)
        else:
            frange = None
        for channel in channels:
            try:
                match = CHANNEL_DEFINITION.match(channel).groupdict()
            except AttributeError as exc:
                exc.args = ('Cannot parse %r as channel list entry' % channel,)
                raise
            # remove Nones from match
            match = dict((k, v) for k, v in match.items() if v is not None)
            match.setdefault('safe', 'safe')
            match.setdefault('fidelity', 'clean')
            # create channel and copy group params
            safe = match.get('safe', 'safe').lower() != 'unsafe'
            channel = Channel(match.pop('name'), frequency_range=frange,
                              safe=safe, sample_rate=match.pop('sample_rate'))
            channel.params = params.copy()
            channel.params.update(match)
            channel.group = group
            # extract those params for which the Channel has an attribute
            for key in ['frametype']:
                setattr(channel, key, channel.params.pop(key, None))
            append(channel)
    return out
990428
def save(output_filename, labels, palette, dpi, options):

    '''

    '''

    if not options.quiet:
        print('  saving {}...'.format(output_filename))

    if options.saturate:
        palette = palette.astype(np.float32)
        pmin = palette.min()
        pmax = palette.max()
        palette = 255 * (palette - pmin)/(pmax-pmin)
        palette = palette.astype(np.uint8)

    if options.white_bg:
        palette = palette.copy()
        palette[0] = (255, 255, 255)

    output_img = Image.fromarray(labels, 'P')
    output_img.putpalette(palette.flatten())
    output_img.save(output_filename, dpi=dpi)
738756
private function SaveGroups()
    {
        $assignedIDs = $this->AssignedGroupIDs();
        $selectedIDs = Request::PostArray('Group');
        $this->ClearMembergroups($selectedIDs);
        foreach ($selectedIDs as $selectedID)
        {
            if (!in_array($selectedID, $assignedIDs))
            {
                $confirmGroup = new RegisterConfirmMembergroup();
                $confirmGroup->SetConfirm($this->confirm);
                $confirmGroup->SetMemberGroup(Membergroup::Schema()->ByID($selectedID));
                $confirmGroup->Save();
            }
        }
    }
657809
def bind_channel(self, channel, callback):
        """"""

        # Remove the following list when deprecation time expires
        if channel in self.CHANNELS:
            warning = (
                "The event name '{}' will soon be deprecated. Use "
                "the real event name '{}' instead."
            ).format(channel, self.CHANNELS[channel])

            self.handle_error(warning)
            channel = self.CHANNELS[channel]
        # -------------------------------------------------------

        if channel == self.EVENT_NAME_ERROR:
            self.error_callback = callback
        elif channel == self.EVENT_NAME_RESULTS:
            self.socketIO.on(channel, partial(self.unpack_results, callback))
        else:
            self.socketIO.on(channel, callback)
1325910
def clip(self, channels=True):
        """"""
        if not isinstance(channels, (tuple, list)):
            channels = [channels] * len(self.channels)

        for i in range(len(self.channels)):
            if channels[i]:
                self.channels[i] = np.ma.clip(self.channels[i], 0.0, 1.0)
1342089
public void saveWaveAsFile(String filename) {

        WaveHeader waveHeader = wave.getWaveHeader();

        int byteRate = waveHeader.getByteRate();
        int audioFormat = waveHeader.getAudioFormat();
        int sampleRate = waveHeader.getSampleRate();
        int bitsPerSample = waveHeader.getBitsPerSample();
        int channels = waveHeader.getChannels();
        long chunkSize = waveHeader.getChunkSize();
        long subChunk1Size = waveHeader.getSubChunk1Size();
        long subChunk2Size = waveHeader.getSubChunk2Size();
        int blockAlign = waveHeader.getBlockAlign();

        try {
            FileOutputStream fos = new FileOutputStream(filename);
            fos.write(WaveHeader.RIFF_HEADER.getBytes());
            // little endian
            fos.write(new byte[] {(byte) (chunkSize), (byte) (chunkSize >> 8), (byte) (chunkSize >> 16),
                            (byte) (chunkSize >> 24)});
            fos.write(WaveHeader.WAVE_HEADER.getBytes());
            fos.write(WaveHeader.FMT_HEADER.getBytes());
            fos.write(new byte[] {(byte) (subChunk1Size), (byte) (subChunk1Size >> 8), (byte) (subChunk1Size >> 16),
                            (byte) (subChunk1Size >> 24)});
            fos.write(new byte[] {(byte) (audioFormat), (byte) (audioFormat >> 8)});
            fos.write(new byte[] {(byte) (channels), (byte) (channels >> 8)});
            fos.write(new byte[] {(byte) (sampleRate), (byte) (sampleRate >> 8), (byte) (sampleRate >> 16),
                            (byte) (sampleRate >> 24)});
            fos.write(new byte[] {(byte) (byteRate), (byte) (byteRate >> 8), (byte) (byteRate >> 16),
                            (byte) (byteRate >> 24)});
            fos.write(new byte[] {(byte) (blockAlign), (byte) (blockAlign >> 8)});
            fos.write(new byte[] {(byte) (bitsPerSample), (byte) (bitsPerSample >> 8)});
            fos.write(WaveHeader.DATA_HEADER.getBytes());
            fos.write(new byte[] {(byte) (subChunk2Size), (byte) (subChunk2Size >> 8), (byte) (subChunk2Size >> 16),
                            (byte) (subChunk2Size >> 24)});
            fos.write(wave.getBytes());
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
987427
def dump_ckan(m):
    """"""

    doc = MetapackDoc(cache=m.cache)
    doc.new_section('Groups',        'Title Description Id Image_url'.split())
    doc.new_section('Organizations', 'Title Description Id Image_url'.split())

    c = RemoteCKAN(m.ckan_url, apikey=m.api_key)

    for g in c.action.group_list(all_fields=True):
        print(g.keys())

    for o in c.action.organization_list(all_fields=True):
        print(g.keys())
30754
private void buildChannel() {
      FileLookup fileLookup = FileLookupFactory.newInstance();

      // in order of preference - we first look for an external JGroups file, then a set of XML
      // properties, and
      // finally the legacy JGroups String properties.
      String cfg;
      if (props != null) {
         if (props.containsKey(CHANNEL_LOOKUP)) {
            String channelLookupClassName = props.getProperty(CHANNEL_LOOKUP);

            try {
               JGroupsChannelLookup lookup = Util.getInstance(channelLookupClassName, configuration.classLoader());
               channel = lookup.getJGroupsChannel(props);
               connectChannel = lookup.shouldConnect();
               disconnectChannel = lookup.shouldDisconnect();
               closeChannel = lookup.shouldClose();
            } catch (ClassCastException e) {
               log.wrongTypeForJGroupsChannelLookup(channelLookupClassName, e);
               throw new CacheException(e);
            } catch (Exception e) {
               log.errorInstantiatingJGroupsChannelLookup(channelLookupClassName, e);
               throw new CacheException(e);
            }
         }

         if (channel == null && props.containsKey(CHANNEL_CONFIGURATOR)) {
            JGroupsChannelConfigurator configurator = (JGroupsChannelConfigurator) props.get(CHANNEL_CONFIGURATOR);
            try {
               channel = configurator.createChannel();
            } catch (Exception e) {
               throw log.errorCreatingChannelFromConfigurator(configurator.getProtocolStackString(), e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_FILE)) {
            cfg = props.getProperty(CONFIGURATION_FILE);
            Collection<URL> confs = Collections.emptyList();
            try {
               confs = fileLookup.lookupFileLocations(cfg, configuration.classLoader());
            } catch (IOException io) {
               //ignore, we check confs later for various states
            }
            if (confs.isEmpty()) {
               throw log.jgroupsConfigurationNotFound(cfg);
            } else if (confs.size() > 1) {
               log.ambiguousConfigurationFiles(Util.toStr(confs));
            }
            try {
               channel = new JChannel(confs.iterator().next());
            } catch (Exception e) {
               throw log.errorCreatingChannelFromConfigFile(cfg, e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_XML)) {
            cfg = props.getProperty(CONFIGURATION_XML);
            try {
               channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
            } catch (Exception e) {
               throw log.errorCreatingChannelFromXML(cfg, e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_STRING)) {
            cfg = props.getProperty(CONFIGURATION_STRING);
            try {
               channel = new JChannel(new ByteArrayInputStream(cfg.getBytes()));
            } catch (Exception e) {
               throw log.errorCreatingChannelFromConfigString(cfg, e);
            }
         }
      }

      if (channel == null) {
         log.unableToUseJGroupsPropertiesProvided(props);
         try {
            channel = new JChannel(
                  fileLookup.lookupFileLocation(DEFAULT_JGROUPS_CONFIGURATION_FILE, configuration.classLoader()));
         } catch (Exception e) {
            throw log.errorCreatingChannelFromConfigFile(DEFAULT_JGROUPS_CONFIGURATION_FILE, e);
         }
      }
   }
1298596
def to_array(self, channels=2):
        """"""
        if self.fade_type == "linear":
            return np.linspace(self.in_volume, self.out_volume,
                self.duration * channels)\
                .reshape(self.duration, channels)
        elif self.fade_type == "exponential":
            if self.in_volume < self.out_volume:
                return (np.logspace(8, 1, self.duration * channels,
                    base=.5) * (
                        self.out_volume - self.in_volume) / 0.5 + 
                        self.in_volume).reshape(self.duration, channels)
            else:
                return (np.logspace(1, 8, self.duration * channels, base=.5
                    ) * (self.in_volume - self.out_volume) / 0.5 + 
                    self.out_volume).reshape(self.duration, channels)
        elif self.fade_type == "cosine":
            return
594150
def saveShp(self, target):
        """"""
        if not hasattr(target, "write"):
            target = os.path.splitext(target)[0] + '.shp'
        if not self.shapeType:
            self.shapeType = self._shapes[0].shapeType
        self.shp = self.__getFileObj(target)
        self.__shapefileHeader(self.shp, headerType='shp')
        self.__shpRecords()
701089
def _fmto_groups(self):
        """"""
        ret = defaultdict(set)
        for key in self:
            ret[getattr(self, key).group].add(getattr(self, key))
        return dict(ret)
892720
def channels_create(self, name, **kwargs):
        """"""
        return self.__call_api_post('channels.create', name=name, kwargs=kwargs)
71660
def save_to_file(self, filename_prefix):
    """"""
    # Wrap in single quotes to make it easier to see the full subword when
    # it has spaces and make it easier to search with ctrl+f.
    filename = self._filename(filename_prefix)
    lines = ["'%s'" % s for s in self._subwords]
    self._write_lines_to_file(filename, lines)