original_docstring: 
          Save any outstanding items. This returns a Deferred which will
          errback if Tor was unhappy with anything, or callback with
          this TorConfig object on success.
          
docstring: Save any outstanding items. This returns a Deferred which will
  errback if Tor was unhappy with anything, or callback with
  this TorConfig object on success.
docstring_tokens: Save any outstanding items . This returns a Deferred which will errback if Tor was unhappy with anything or callback with this TorConfig object on success .
code: def save(self):
          """
          Save any outstanding items. This returns a Deferred which will
          errback if Tor was unhappy with anything, or callback with
          this TorConfig object on success.
          """
  
          if not self.needs_save():
              return defer.succeed(self)
  
          args = []
          directories = []
          for (key, value) in self.unsaved.items():
              if key == 'HiddenServices':
                  self.config['HiddenServices'] = value
                  for hs in value:
                      for (k, v) in hs.config_attributes():
                          if k == 'HiddenServiceDir':
                              if v not in directories:
                                  directories.append(v)
                                  args.append(k)
                                  args.append(v)
                              else:
                                  raise RuntimeError("Trying to add hidden service with same HiddenServiceDir: %s" % v)
                          else:
                              args.append(k)
                              args.append(v)
                  continue
  
              if isinstance(value, list):
                  for x in value:
                      # FIXME XXX
                      if x is not DEFAULT_VALUE:
                          args.append(key)
                          args.append(str(x))
  
              else:
                  args.append(key)
                  args.append(value)
  
              # FIXME in future we should wait for CONF_CHANGED and
              # update then, right?
              real_name = self._find_real_name(key)
              if not isinstance(value, list) and real_name in self.parsers:
                  value = self.parsers[real_name].parse(value)
              self.config[real_name] = value
  
          # FIXME might want to re-think this, but currently there's no
          # way to put things into a config and get them out again
          # nicely...unless you just don't assign a protocol
          if self.protocol:
              d = self.protocol.set_conf(*args)
              d.addCallback(self._save_completed)
              return d
  
          else:
              self._save_completed()
              return defer.succeed(self)
code_tokens: def save ( self ) : if not self . needs_save ( ) : return defer . succeed ( self ) args = [ ] directories = [ ] for ( key , value ) in self . unsaved . items ( ) : if key == 'HiddenServices' : self . config [ 'HiddenServices' ] = value for hs in value : for ( k , v ) in hs . config_attributes ( ) : if k == 'HiddenServiceDir' : if v not in directories : directories . append ( v ) args . append ( k ) args . append ( v ) else : raise RuntimeError ( "Trying to add hidden service with same HiddenServiceDir: %s" % v ) else : args . append ( k ) args . append ( v ) continue if isinstance ( value , list ) : for x in value : if x is not DEFAULT_VALUE : args . append ( key ) args . append ( str ( x ) ) else : args . append ( key ) args . append ( value ) real_name = self . _find_real_name ( key ) if not isinstance ( value , list ) and real_name in self . parsers : value = self . parsers [ real_name ] . parse ( value ) self . config [ real_name ] = value if self . protocol : d = self . protocol . set_conf ( * args ) d . addCallback ( self . _save_completed ) return d else : self . _save_completed ( ) return defer . succeed ( self )
short_docstring: Save any outstanding items.
short_docstring_tokens: Save any outstanding items .
comment: """
          Save any outstanding items. This returns a Deferred which will
          errback if Tor was unhappy with anything, or callback with
          this TorConfig object on success.
          """$SEP$# FIXME XXX$SEP$# FIXME in future we should wait for CONF_CHANGED and$SEP$# update then, right?$SEP$# FIXME might want to re-think this, but currently there's no$SEP$# way to put things into a config and get them out again$SEP$# nicely...unless you just don't assign a protocol