create a bytespace within a remote levelup instance TODO: remove ns from signature to align w/ sublevel
555615
function Bytespace(db, ns, opts) {
  if (!(this instanceof Bytespace))
    return new Bytespace(db, ns, opts)

  if (!(ns instanceof Namespace)) {

    // if db is a subspace mount as a nested subspace
    if (db.namespace instanceof Namespace)
      return db.sublevel(ns, opts)

    // otherwise it's a root subspace
    ns = new Namespace([ ns ], opts && opts.hexNamespace)
  }

  var space = this

  space.namespace = ns
  opts = space.options = xtend(Bytespace.options, db.options, opts)
  ns.codec = new Codec(opts)

  // use provided methods manifest in options or get from db
  // TODO: can we remove this?
  space.methods = xtend(opts.methods || db.methods)

  // sublevel@6-compatible-ish
  Object.defineProperty(db, 'version', {
    value: 6,
    configurable: true
  })

  // forward open and close events from base db w/o affecting listener count
  ;(function forwardOpen() {
    db.once('open', function () {
      space.emit('open', space)
      forwardOpen()
    })
  })()

  // TODO: level emits closed, multilevel emits close...damn...
  ;(function forwardClose() {
    var closeEvent = db.createRpcStream ? 'close' : 'closed'
    db.once(closeEvent, function () {
      // only emit 'close' for sanity's sake
      space.emit('close')
      forwardClose()
    })
  })()

  // proxy `isOpen` to underlying db
  space.isOpen = function () {
    return db.isOpen()
  }

  // set multilevel `isClient` boolean
  space.isClient = !!db.isClient

  // for sublevel api-compatibility
  space.sublevel = function (ns_, opts_) {
    var index = space.sublevels || (space.sublevels = {})

    // memoize the sublevels we create
    // TODO: memoize with bytewise-encoded hex string instead
    if (index[ns_]) return index[ns_]

    return index[ns_] = new Bytespace(db, ns.append(ns_), xtend(opts, opts_))
  }

  space.clone = function () {
    return new Bytespace(db, ns, opts)
  }

  function kOpts(initial) {
    return xtend(initial, { keyEncoding: ns.keyEncoding, keyAsBuffer: !ns.hex })
  }

  function vOpts(initial) {
    return xtend({ valueEncoding: opts.valueEncoding }, initial)
  }

  function kvOpts(initial) {
    return vOpts(kOpts(initial))
  }

  function addEncodings(op, db) {
    if (db && db.options) {
      op.keyEncoding || (op.keyEncoding = db.options.keyEncoding)
      op.valueEncoding || (op.valueEncoding = db.options.valueEncoding)
    }
    return op
  }

  // method proxy implementations
  if (typeof db.get === 'function') {
    space.get = function (k, opts, cb) {
      cb = getCallback(opts, cb)
      opts = getOptions(opts)

      try {
        db.get(ns.encode(k, opts), kvOpts(opts), handler)
      }
      catch (err) {
        process.nextTick(cb.bind(null, err))
      }

      function handler(err, v) {
        // sanitize full keypath for notFound errors
        if (err && err.notFound || NOT_FOUND.test(err)) {
          try {
            err = new NotFoundError('Key not found in database [' + k + ']')
          }
          catch (_) {}
        }

        cb(err, v)
      }
    }
  }

  // helper to register pre and post commit hooks
  function addHook(hooks, hook) {
    hooks.push(hook)
    return function () {
      var i = hooks.indexOf(hook)
      if (i >= 0) return hooks.splice(i, 1)
    }
  }

  if (typeof db.batch === 'function') {

    space.del = function (k, opts, cb) {
      // redirect to batch
      space.batch([{ type: 'del', key: k }], opts, cb)
    }

    space.put = function (k, v, opts, cb) {
      // redirect to batch
      space.batch([{ type: 'put', key: k, value: v }], opts, cb)
    }

    space.batch = function (ops, opts, cb) {
      if (!arguments.length) return new Batch(space)

      cb = getCallback(opts, cb)
      opts = getOptions(opts)

      function add(op) {
        if (op === false) {
          return delete ops[i]
        }
        ops.push(op)
      }

      try {
        // encode batch ops and apply precommit hooks
        for (var i = 0, len = ops.length; i < len; i++) {
          var op = ops[i]

          addEncodings(op, op.prefix)

          op.prefix || (op.prefix = space)

          var ns = op.prefix.namespace
          if (!(ns instanceof Namespace))
            return cb('Unknown prefix in batch commit')

          if (ns.prehooks.length) {
            ns.trigger(ns.prehooks, op.prefix, [ op, add, ops ])
          }
        }

        if (!ops.length) return cb()

        var encodedOps = ops.map(function (op) {
          return {
            type: op.type,
            key: op.prefix.namespace.encode(op.key, opts, op),
            keyEncoding: ns.keyEncoding,
            value: op.value,
            // TODO: multilevel json serialization issue?
            valueEncoding: op.valueEncoding,
            sync: op.sync
          }
        })

        db.batch(encodedOps, kvOpts(opts), function (err) {
          if (err) return cb(err)

          // apply postcommit hooks for ops, setting encoded keys to initial state
          try {
            ops.forEach(function (op) {
              var ns = op.prefix.namespace

              if (ns.posthooks.length) {
                ns.trigger(ns.posthooks, op.prefix, [ op ])
              }
            })
          }
          catch (err) {
            return cb(err)
          }

          cb()
        })
      }
      catch (err) {
        process.nextTick(cb.bind(null, err))
      }
    }

    space.pre = function (range, hook) {
      // range is not (yet) implemented but here for sublevel compatibility
      if (typeof range === 'function') hook = range
      return addHook(ns.prehooks, hook)
    }

    space.post = function (range, hook) {
      if (typeof range === 'function') hook = range
      return addHook(ns.posthooks, hook)
    }
  }

  // if no batch available on db, replace write methods individually
  else {
    if (typeof db.del === 'function') {
      space.del = function (k, opts, cb) {
        cb = getCallback(opts, cb)
        opts = getOptions(opts)

        try {
          db.del(ns.encode(k, opts), kOpts(opts), cb)
        }
        catch (err) {
          process.nextTick(cb.bind(null, err))
        }
      }
    }

    if (typeof db.put === 'function') {
      space.put = function (k, v, opts, cb) {
        cb = getCallback(opts, cb)
        opts = getOptions(opts)

        try {
          db.put(ns.encode(k, opts), v, kvOpts(opts), cb)
        }
        catch (err) {
          process.nextTick(cb.bind(null, err))
        }
      }
    }
  }

  // transform stream to decode data keys
  function decodeStream(opts) {
    opts || (opts = {})
    var stream = Transform({ objectMode: true })

    stream._transform = function (data, _, cb) {
      try {
        // decode keys even when keys or values aren't requested specifically
        if ((opts.keys && opts.values) || (!opts.keys && !opts.values)) {
          data.key = ns.decode(data.key, opts)
        }
        else if (opts.keys) {
          data = ns.decode(data, opts)
        }
      }
      catch (err) {
        return cb(err)
      }
      cb(null, data)
    }

    return stream
  }

  // add read stream proxy methods if createReadStream is available
  // TODO: clean all this duplication up
  function readStream(opts) {
    return db.createReadStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }

  function liveStream(opts) {
    return db.createLiveStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }

  if (typeof db.createReadStream === 'function') {
    space.createReadStream = space.readStream = function (opts) {
      return readStream(xtend({ keys: true, values: true }, vOpts(opts)))
    }
    if (db.readStream) space.readStream = space.createReadStream
  }

  if (typeof db.createKeyStream === 'function') {
    space.createKeyStream = function (opts) {
      return readStream(xtend(vOpts(opts), { keys: true, values: false }))
    }
    if (db.keyStream) space.keyStream = space.createKeyStream
  }

  if (typeof db.createValueStream === 'function') {
    space.createValueStream = function (opts) {
      return readStream(xtend(vOpts(opts), { keys: false, values: true }))
    }
    if (db.valueStream) space.valueStream = space.createValueStream
  }

  // add createLiveStream proxy if available
  if (typeof db.createLiveStream === 'function') {
    space.createLiveStream = function (opts) {
      var o = xtend(vOpts(opts), ns.encodeRange(opts))
      return db.createLiveStream(o).pipe(decodeStream(opts))
    }
    if (db.liveStream) space.liveStream = space.createLiveStream
  }
}
516411
async function startTransfer(rawContent, localName, remoteName, progressCb){
    // convert buffer to hex or base64
    const content = rawContent.toString(_transferEncoding);

    // get absolute filesize
    const absoluteFilesize = content.length;

    // split file content into chunks
    const chunks = content.match(/[\s\S]{1,232}/g) || [];

    // command response buffer
    let response = null;

    // current upload size in bytes
    let currentUploadSize = 0;

    // open remote file for write
    try{
        ({response} = await _virtualTerminal.executeCommand(_luaCommandBuilder.prepare('fileOpen', [remoteName, 'w+'])));

        // valid handle ?
        if (response == 'nil'){
            throw new Error('i/o error - cannot open nodemcu file-handle for write');
        }
    }catch(e){
        _logger.debug(e);
        throw new Error('Cannot open remote file "' + remoteName + '" for write');
    }

    // initial progress update
    progressCb.apply(progressCb, [0, absoluteFilesize]);

    // internal helper to write chunks
    async function writeChunk(){
        if (chunks.length > 0){
            // get first element
            const l = chunks.shift();

            // increment size counter
            currentUploadSize += l.length;

            // write first element to file
            try{
                await _virtualTerminal.executeCommand('__nmtwrite("' + l + '")');
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot write chunk to remote file');
            }

            // run progress callback
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // write next
            await writeChunk();

        }else{
            // ensure that the progress callback is called, even for empty files
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // send file close command
            try{
                await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fileCloseFlush);
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot flush/close remote file');
            }
        }
    }

    // start transfer
    return writeChunk();
}
73531
void saveNamespace(boolean force, boolean uncompressed)
  throws AccessControlException, IOException {
    try {
      if (namenodeProtocolProxy == null) {
        versionBasedSaveNamespace(force, uncompressed);
      } else {
        methodBasedSaveNamespace(force, uncompressed);
      }
    } catch(RemoteException re) {
      throw re.unwrapRemoteException(AccessControlException.class);
    }
  }
502155
public static Keyspace createKeyspace(String keyspace, Cluster cluster,
      ConsistencyLevelPolicy consistencyLevelPolicy) {
    return createKeyspace(keyspace, cluster, consistencyLevelPolicy,
        FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE);
  }
319785
public void createKeyspace(String keyspace) {
        Map<String, String> replicationSimpleOneExtra = new HashMap<>();
        replicationSimpleOneExtra.put("'class'", "'SimpleStrategy'");
        replicationSimpleOneExtra.put("'replication_factor'", "1");
        String query = this.cassandraqueryUtils.createKeyspaceQuery(true,
                keyspace, this.cassandraqueryUtils
                        .createKeyspaceReplication(replicationSimpleOneExtra),
                "");
        LOGGER.debug(query);
        executeQuery(query);
    }
1095746
def create(name, level = ::Logger::INFO)
      dir = "#{Bitcoin.base_dir}/log"
      FileUtils.mkdir_p(dir)
      logger = ::Logger.new(dir + "/#{name}.log", 10)
      logger.level = level
      logger.formatter =  proc do |severity, datetime, progname, msg|
        Format % [severity[0..0], format_datetime(datetime), $$,
                  Thread.current.object_id, severity, progname, msg2str(msg)]
      end
      logger
    end
989794
def from_bytes(VarInt, byte_string):
        '''
        
        '''
        num = byte_string
        if num[0] <= 0xfc:
            num = num[0:1]
            non_compact = False
        elif num[0] == 0xfd:
            num = num[1:3]
            non_compact = (num[-1:] == b'\x00')
        elif num[0] == 0xfe:
            num = num[1:5]
            non_compact = (num[-2:] == b'\x00\x00')
        elif num[0] == 0xff:
            num = num[1:9]
            non_compact = (num[-4:] == b'\x00\x00\x00\x00')
        if len(num) not in [1, 2, 4, 8]:
            raise ValueError('Malformed VarInt. Got: {}'
                             .format(byte_string.hex()))

        if (non_compact
            and ('overwinter' in riemann.get_current_network_name()
                 or 'sapling' in riemann.get_current_network_name())):
            raise ValueError('VarInt must be compact. Got: {}'
                             .format(byte_string.hex()))

        ret = VarInt(
            utils.le2i(num),
            length=len(num) + 1 if non_compact else 0)

        return ret
426428
function serializeField(prop, value, dimension, spaceDimension) {
    var line;
    var propNRRD = mapJavascriptToNRRD(prop);
    switch(prop) {
    // nrrd-js stuff: skip
    case 'data':
    case 'buffer':
    case 'keys':
    case 'version':
        break;
    // Literal (uninterpreted) fields
    case 'content':
    case 'number':
    case 'sampleUnits':
    case 'space':
        line = propNRRD + ": " + value;
        break;
    // Integers (no infinity or whatever, just a plain integer, so the default serialization is good enough)
    case 'blockSize':
    case 'lineSkip':
    case 'byteSkip':
    case 'dimension':
    case 'spaceDimension':
        assert((typeof value) == "number" || value instanceof Number, "Field " + prop + " should at least contain a number!");
        line = propNRRD + ": " + value;
        break;
    // Floats (default serialization is good enough, as NaN contains nan, ignoring case, and similarly for Infinity inf)
    case 'min':
    case 'max':
    case 'oldMin':
    case 'oldMax':
        assert((typeof value) == "number" || value instanceof Number, "Field " + prop + " should contain a number!");
        line = propNRRD + ": " + value;
        break;
    // Vectors
    case 'spaceOrigin':
        assert(value.length === spaceDimension, "Field " + prop + " should be a list with length equal to the space dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": (" + value.join(",") + ")";
        break;
    // Lists of strings
    case 'labels':
    case 'units':
    case 'spaceUnits':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "string" || val instanceof String, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.map(serializeNRRDQuotedString).join(" ");
        break;
    // Lists of integers
    case 'sizes':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.join(" ");
        break;
    // Lists of floats
    case 'spacings':
    case 'thicknesses':
    case 'axisMins':
    case 'axisMaxs':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.join(" ");
        break;
    // Lists of vectors (dimension sized)
    case 'spaceDirections':
        assert(value.length !== undefined && value.length === dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (vec) {
          assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!");
          if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); });
        });
        line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" ");
        break;
    // Lists of vectors (space dimension sized)
    case 'measurementFrame':
        assert(value.length !== undefined && value.length === spaceDimension, "Field " + prop + " should be a list with length equal to the space dimension!");
        value.forEach(function (vec) {
          assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!");
          if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); });
        });
        line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" ");
        break;
    // One-of-a-kind fields
    case 'type':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'encoding':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'endian':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'dataFile':
        if (value.length || (value.files && 'subdim' in value)) {
            // List of data files: skip for now
        } else {
            line = propNRRD + ": " + serializeNRRDDataFile(value);
        }
        break;
    case 'centers':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        line = propNRRD + ": " + value.map(serializeNRRDOptional).join(" ");
        break;
    case 'kinds':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        line = propNRRD + ": " + value.map(serializeNRRDOptional).join(" ");
        break;
    // Something unknown
    default:
        console.warn("Unrecognized NRRD field: " + prop + ", skipping.");
    }
    return line;
}
1360401
@Override
    public void createNamespace() {
        // Use a temporary, no-keyspace session
        try (DBConn dbConn = createAndConnectConn(null)) {
            synchronized (m_schemaLock) {
                if (!m_schemaMgr.keyspaceExists(dbConn, m_keyspace)) {
                    m_schemaMgr.createKeyspace(dbConn, m_keyspace);
                }
            }
        }
    }
1113322
def create_space(self):
        ''''''
        cur = self._conn.cursor()
        cur.executescript(SQL_MODEL)
        self._conn.commit()
        cur.close()
        return
803309
def make_ns(self, ns):
        '''
        
        '''
        if self.namespace:
            val = {}
            val.update(self.namespace)
            val.update(ns)
            return val
        else:
            return ns
442961
def create_from_ll(cls, lls:LabelLists, bs:int=64, val_bs:int=None, ds_tfms:Optional[TfmList]=None,
                num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None, device:torch.device=None,
                test:Optional[PathOrStr]=None, collate_fn:Callable=data_collate, size:int=None, no_check:bool=False,
                resize_method:ResizeMethod=None, mult:int=None, padding_mode:str='reflection',
                mode:str='bilinear', tfm_y:bool=False)->'ImageDataBunch':
        ""
        lls = lls.transform(tfms=ds_tfms, size=size, resize_method=resize_method, mult=mult, padding_mode=padding_mode,
                            mode=mode, tfm_y=tfm_y)
        if test is not None: lls.add_test_folder(test)
        return lls.databunch(bs=bs, val_bs=val_bs, dl_tfms=dl_tfms, num_workers=num_workers, collate_fn=collate_fn,
                             device=device, no_check=no_check)
918903
function makeWhiteSpace(n) {
  var buffer = [], nb = true;
  for (; n > 0; n--) {
    buffer.push((nb || n == 1) ? nbsp : " ");
    nb = !nb;
  }
  return buffer.join("");
}
556465
def depthtospace(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'})

    return "depth_to_space", new_attrs, inputs
190142
def put(self, local, remote, contents=None, quiet=False):
        
        remote_dir = os.path.dirname(remote)
        remote_file = os.path.basename(local)\
            if remote.endswith('/') else os.path.basename(remote)

        if contents:
            # local is ignored if contents is set
            local_file = buffer_type(contents)
        elif isinstance(local, file_type):
            local_file = local
        else:
            local_file = open(local, 'rb')
        current = self.conn.pwd()
        self.descend(remote_dir, force=True)

        size = 0
        try:
            self.conn.storbinary('STOR %s' % remote_file, local_file)
            size = self.conn.size(remote_file)
        except:
            if not quiet:
                raise
        finally:
            local_file.close()
            self.conn.cwd(current)
        return size
403687
def create_server_rackspace(connection,
                            distribution,
                            disk_name,
                            disk_size,
                            ami,
                            region,
                            key_pair,
                            instance_type,
                            instance_name,
                            tags={},
                            security_groups=None):
    

    log_yellow("Creating Rackspace instance...")

    flavor = connection.flavors.find(name=instance_type)
    image = connection.images.find(name=ami)

    server = connection.servers.create(name=instance_name,
                                       flavor=flavor.id,
                                       image=image.id,
                                       region=region,
                                       availability_zone=region,
                                       key_name=key_pair)

    while server.status == 'BUILD':
        log_yellow("Waiting for build to finish...")
        sleep(5)
        server = connection.servers.get(server.id)

    # check for errors
    if server.status != 'ACTIVE':
        log_red("Error creating rackspace instance")
        exit(1)

    # the server was assigned IPv4 and IPv6 addresses, locate the IPv4 address
    ip_address = server.accessIPv4

    if ip_address is None:
        log_red('No IP address assigned')
        exit(1)

    wait_for_ssh(ip_address)
    log_green('New server with IP address {0}.'.format(ip_address))
    return server
1355829
def create(cls, uri, tlp_level=0, tags=[]):
        
        return cls._create(uri=uri, tlp_level=tlp_level, tags=tags)