Guesses a container from the current object.
19505
def OpenAsContainer(self):
    """"""
    if self.IsDirectory():
      return self

    # TODO(user): Add support for more containers here (e.g. registries, zip
    # files etc).
    else:  # For now just guess TSK.
      tsk_handler = self._handlers[rdf_paths.PathSpec.PathType.TSK]
      tsk_pathspec = rdf_paths.PathSpec(
          path="/", pathtype=rdf_paths.PathSpec.PathType.TSK)
      return tsk_handler(
          base_fd=self,
          handlers=self._handlers,
          pathspec=tsk_pathspec,
          progress_callback=self.progress_callback)
1115104
function getContainer() {

  if (container) {
    return container;
  }

  body.insertAdjacentHTML('afterbegin', mustache.render(containerTemplate));
  container = document.querySelector('.js-feedback-queue');
  return container;
}
1013294
def from_info(cls, container, info_obj):
        """"""
        create_fn = cls.from_subdir if 'subdir' in info_obj \
            else cls.from_file_info
        return create_fn(container, info_obj)
144573
def guess_width(self):
        """"""
        if len(self.header) <= 4:
            nspace = 6
        elif len(self.header) <= 6:
            nspace = 5
        else:
            nspace = 4
        ncol = len(self.header)
        self._width = [nspace] * ncol
        width = [0] * ncol

        # set initial width from header
        for idx, item in enumerate(self.header):
            width[idx] = len(str(item))

        # guess width of each column from first 10 lines of data
        samples = min(len(self.data), 10)
        for col in range(ncol):
            for idx in range(samples):
                data = self.data[idx][col]
                if not isinstance(data, (float, int)):
                    temp = len(data)
                else:
                    temp = 10
                if temp > width[col]:
                    width[col] = temp

        for col in range(ncol):
            self._width[col] += width[col]
106173
def guesser(types=GUESS_TYPES, strict=False):
    """"""
    return TypeGuesser(types=types, strict=strict)
816579
def _inspect(self,obj,objtype=None):
        """"""
        gen=super(Dynamic,self).__get__(obj,objtype)

        if hasattr(gen,'_Dynamic_last'):
            return gen._Dynamic_last
        else:
            return gen
1138566
def from_result(cls, container, result):
        """"""
        if result is None:
            raise errors.NoObjectException

        elif cls.is_prefix(result):
            return cls.from_prefix(container, result)

        elif cls.is_key(result):
            return cls.from_key(container, result)

        raise errors.CloudException("Unknown boto result type: %s" %
                                    type(result))
270231
def _guess_type(val):
        """"""
        if isinstance(val, bool):
            return "choice"
        elif isinstance(val, int):
            return "number"
        elif isinstance(val, float):
            return "number"
        elif isinstance(val, str):
            return "text"
        elif hasattr(val, 'read'):
            return "file"
        else:
            return "text"
1054860
def _parse_container(tokens, index, for_or_if=None):
    """"""

    # Store the opening bracket.
    items = [Atom(Token(*tokens[index]))]
    index += 1

    num_tokens = len(tokens)
    while index < num_tokens:
        tok = Token(*tokens[index])

        if tok.token_string in ',)]}':
            # First check if we're at the end of a list comprehension or
            # if-expression. Don't add the ending token as part of the list
            # comprehension or if-expression, because they aren't part of those
            # constructs.
            if for_or_if == 'for':
                return (ListComprehension(items), index - 1)

            elif for_or_if == 'if':
                return (IfExpression(items), index - 1)

            # We've reached the end of a container.
            items.append(Atom(tok))

            # If not, then we are at the end of a container.
            if tok.token_string == ')':
                # The end of a tuple.
                return (Tuple(items), index)

            elif tok.token_string == ']':
                # The end of a list.
                return (List(items), index)

            elif tok.token_string == '}':
                # The end of a dictionary or set.
                return (DictOrSet(items), index)

        elif tok.token_string in '([{':
            # A sub-container is being defined.
            (container, index) = _parse_container(tokens, index)
            items.append(container)

        elif tok.token_string == 'for':
            (container, index) = _parse_container(tokens, index, 'for')
            items.append(container)

        elif tok.token_string == 'if':
            (container, index) = _parse_container(tokens, index, 'if')
            items.append(container)

        else:
            items.append(Atom(tok))

        index += 1

    return (None, None)
1113274
function(cid) {

    // Find and bind container.
    return findContainerThrows(cid)
    .bind({})
    .then(function(container) {
      this.container = container;
    })
    // Check if container is running.
    .then(function() {
      return isRunning(cid);
    })
    // Stop container if it is running.
    .then(function(isRunning) {
      var self = this;
      if (isRunning) {
        return Promise.fromNode(function(cb) {
          self.container.stop(cb);
        });
      }
    })
    // Wrap errors.
    .catch(function(err) {
      throw new VError(err, 'Error stopping container %s.', cid);
    });

  }
733128
async def container(self, container=None, container_type=None, params=None):
        
        # Container versioning is a bit tricky, primitive type containers are not versioned.
        elem_type = x.container_elem_type(container_type, params)
        raw_container = container_is_raw(container_type, params)
        elem_elementary = TypeWrapper.is_elementary_type(elem_type)
        is_versioned = not elem_elementary and not raw_container
        version = None

        if is_versioned:
            version = await self.version(container_type, params, elem=container)
            if self.is_tracked():
                return self.get_tracked()

        if hasattr(container_type, 'boost_serialize'):
            container = container_type() if container is None else container
            self.pop_track(is_versioned)
            return await container.boost_serialize(self, elem=container, elem_type=container_type, params=params, version=version)

        # Container entry version + container
        if self.writing:
            self.pop_track(is_versioned)
            return await self.container_dump(container, container_type, params)
        else:
            obj = await self.container_load(container_type, params=params, container=container)
            return self.track_obj(obj, is_versioned)
545541
def get_container_at(self, slot):
        

        # ensure we have an integer
        slot = to_int(slot)

        if slot < 1:
            return None

        layout = self.getLayout()

        for pos in layout:
            layout_slot = to_int(pos['position'])
            uid = pos['container_uid']
            if layout_slot != slot or not uid:
                continue
            return api.get_object_by_uid(uid)

        return None
1147837
def get_objects_by_offset(self, start):
        

        _, container = self._get_container(start)
        if container is None:
            return set()
        else:
            return container.internal_objects
1163963
def from_prefix(cls, container, prefix):
        """"""
        if prefix is None:
            raise errors.NoObjectException

        return cls(container,
                   name=prefix.name,
                   obj_type=cls.type_cls.SUBDIR)
1056328
def identify(self, obj):
    """"""
    hash_ = hash(obj)
    type_id = self.to_id(type(obj))
    return (hash_, TypeId(type_id))
1125654
def evaluate_object(obj, cls=None, cache=False, **kwargs):
        """"""
        old_obj = obj
        if isinstance(obj, Element):
            if cache:
                obj = obj.evaluate_cached(**kwargs)
            else:
                obj = obj.evaluate(cache=cache, **kwargs)

        if cls is not None and type(obj) != cls:
            obj = cls(obj)

        for attr in ('string', 'location', 'tokens'):
            if hasattr(old_obj, attr):
                setattr(obj, attr, getattr(old_obj, attr))

        return obj
1117001
def guess_filename(obj):
    """"""
    name = getattr(obj, 'name', None)
    if name and name[0] != '<' and name[-1] != '>':
        return os.path.basename(name)