Prints information about the store as human-readable text.

    Args:
      storage_reader (StorageReader): storage reader.
425258
def _PrintStorageInformationAsText(self, storage_reader):
    
    table_view = views.ViewsFactory.GetTableView(
        self._views_format_type, title='Plaso Storage Information')
    table_view.AddRow(['Filename', os.path.basename(self._storage_file_path)])
    table_view.AddRow(['Format version', storage_reader.format_version])
    table_view.AddRow(
        ['Serialization format', storage_reader.serialization_format])
    table_view.Write(self._output_writer)

    if storage_reader.storage_type == definitions.STORAGE_TYPE_SESSION:
      self._PrintSessionsOverview(storage_reader)
      self._PrintSessionsDetails(storage_reader)

      storage_counters = self._CalculateStorageCounters(storage_reader)

      if 'parsers' not in storage_counters:
        self._output_writer.Write(
            'Unable to determine number of events generated per parser.\n')
      else:
        self._PrintParsersCounter(storage_counters['parsers'])

      if 'analysis_reports' not in storage_counters:
        self._output_writer.Write(
            'Unable to determine number of reports generated per plugin.\n')
      else:
        self._PrintAnalysisReportCounter(storage_counters['analysis_reports'])

      if 'event_labels' not in storage_counters:
        self._output_writer.Write(
            'Unable to determine number of event tags generated per label.\n')
      else:
        self._PrintEventLabelsCounter(storage_counters['event_labels'])

      self._PrintWarningCounters(storage_counters)

      if self._verbose:
        self._PrintWarningsDetails(storage_reader)

      self._PrintAnalysisReportsDetails(storage_reader)

    elif storage_reader.storage_type == definitions.STORAGE_TYPE_TASK:
      self._PrintTasksInformation(storage_reader)
1007948
def _store_information(self):
        
        
        print '<<< Generating Information Storage >>>'

        # Stores information on Workbench commands and signatures
        for name, meth in inspect.getmembers(self, predicate=inspect.isroutine):
            if not name.startswith('_'):
                info = {'command': name, 'sig': str(funcsigs.signature(meth)), 'docstring': meth.__doc__}
                self.store_info(info, name, type_tag='command')

        # Stores help text into the workbench information system
        self.store_info({'help': '<<< Workbench Server Version %s >>>' % self.version}, 'version', type_tag='help')
        self.store_info({'help': self._help_workbench()}, 'workbench', type_tag='help')
        self.store_info({'help': self._help_basic()}, 'basic', type_tag='help')
        self.store_info({'help': self._help_commands()}, 'commands', type_tag='help')
        self.store_info({'help': self._help_workers()}, 'workers', type_tag='help')
600063
def _PrintWarningsDetails(self, storage):
    
    if not storage.HasWarnings():
      self._output_writer.Write('No warnings stored.\n\n')
      return

    for index, warning in enumerate(storage.GetWarnings()):
      title = 'Warning: {0:d}'.format(index)
      table_view = views.ViewsFactory.GetTableView(
          self._views_format_type, title=title)

      table_view.AddRow(['Message', warning.message])
      table_view.AddRow(['Parser chain', warning.parser_chain])

      path_specification = warning.path_spec.comparable
      for path_index, line in enumerate(path_specification.split('\n')):
        if not line:
          continue

        if path_index == 0:
          table_view.AddRow(['Path specification', line])
        else:
          table_view.AddRow(['', line])

      table_view.Write(self._output_writer)
114735
def thrift_print(structure, offset=0):
    
    if not is_thrift_item(structure):
        return str(structure)
    s = str(structure.__class__) + '\n'
    for key in dir(structure):
        if key.startswith('_') or key in ['thrift_spec', 'read', 'write',
                                          'default_spec', 'validate']:
            continue
        s = s + ' ' * offset + key + ': ' + thrift_print(getattr(structure, key)
                                                         , offset+2) + '\n'
    return s
483243
def get_storage_info(self, human=False):
        
        res = self._req_get_storage_info()
        if human:
            res['total'] = humanize.naturalsize(res['total'], binary=True)
            res['used'] = humanize.naturalsize(res['used'], binary=True)
        return res
609843
def custom_print(data_structure, indent):
    
    for key, value in data_structure.items():
        print("\n%s%s:" % (' ' * attribute_indent * indent, str(key)), end=' ')
        if isinstance(value, OrderedDict):
            custom_print(value, indent + 1)
        elif isinstance(value, dict):
            custom_print(value, indent + 1)
        else:
            print("%s" % (str(value)), end=' ')
477618
def display(self, sink=None, detail='phrase'):
        
        if not isinstance(detail, int):
            detail = detailNum[detail]

        if detail >= detailNum['line'] and self.size is not None:
            size = " (%s%s)" % (
                humanize(self.size),
                "" if self.exclusiveSize is None else (
                    " %s exclusive" % (humanize(self.exclusiveSize))
                )
            )
        else:
            size = ""

        vol = "%s %s" % (
            _printUUID(self._uuid, detail - 1),
            sink.getSendPath(self) if sink else "",
        )

        return vol + size
152305
def info():
    
    print()
    print('root directory         :', tasks.conf.APE_ROOT)
    print()
    print('active container       :', os.environ.get('CONTAINER_NAME', ''))
    print()
    print('active product         :', os.environ.get('PRODUCT_NAME', ''))
    print()
    print('ape feature selection  :', tasks.FEATURE_SELECTION)
    print()
    print('containers and products:')
    print('-' * 30)
    print()
    for container_name in tasks.get_containers():
        print(container_name)
        for product_name in tasks.get_products(container_name):
            print('    ' + product_name)
    print()
848931
def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
    

    print((colored(text, color, on_color, attrs)), **kwargs)
323174
def store_contents(self):
        

        string_buffer = os.linesep.join(
            map(
                lambda x: ",".join(x),
                map(
                    lambda x: map(
                        str,
                        x.values()
                    ),
                    self.rows
                )
            )
        )

        with open(self.name + ".csv", "w") as f:
            f.write(string_buffer)
562425
def show_description(self):
        

        def printit(c, v):
            underline = "-" * len(dr.get_name(c))
            resp = self.responses[v["type"]]
            name = "%s[%s] %s%s" % (resp.color, resp.label, dr.get_name(c), Style.RESET_ALL)
            print(name, file=self.stream)
            print(underline, file=self.stream)
            print(render(c, v), file=self.stream)
            print(file=self.stream)

        for c in sorted(self.broker.get_by_type(rule), key=dr.get_name):
            v = self.broker[c]
            _type = v.get('type')
            if _type in self.responses:
                self.counts[_type] += 1
            if (_type and ((self.fail_only and _type == 'rule') or
                           ((self.missing and _type == 'skip') or
                            (not self.fail_only and _type != 'skip')))):
                printit(c, v)
        print(file=self.stream)

        self.print_header("Rule Execution Summary", Fore.CYAN)
        for c in self.counts:
            print(self.responses[c].color + self.responses[c].title + str(self.counts[c]) + Style.RESET_ALL, file=self.stream)
1238758
def human_readable(self, dense_repr: Sequence[Sequence[int]]) -> List[List[str]]:
        

        transcripts = []
        for dense_r in dense_repr:
            non_empty_phonemes = [phn_i for phn_i in dense_r if phn_i != 0]
            transcript = self.corpus.indices_to_labels(non_empty_phonemes)
            transcripts.append(transcript)

        return transcripts
1133162
def save_to_store(self):
        
        if not self._store:
            raise AttributeError('No datastore defined!')
        saved_data = self.save_to_data(in_place=True)
        data = Serializer.serialize(saved_data)
        self._store.store_blob(data, 'all_keys_with_undefined')
987473
def formatted_description(self):
        
        desc = self.description

        if desc:
            return desc.replace("%s1", self.formatted_value)
        else:
            return None
358603
def print_object_attributes( thing, heading=None, file=None ):
    '''
    
    '''
    if heading : print( '==', heading, '==', file=file )
    print( '\n'.join( object_attributes( thing ) ), file=file )
841059
def _PrintAnalysisStatusHeader(self, processing_status):
    
    self._output_writer.Write(
        'Storage file\t\t: {0:s}\n'.format(self._storage_file_path))

    self._PrintProcessingTime(processing_status)

    if processing_status and processing_status.events_status:
      self._PrintEventsStatus(processing_status.events_status)

    self._output_writer.Write('\n')
719705
def dense_to_human_readable(dense_repr: Sequence[Sequence[int]], index_to_label: Dict[int, str]) -> List[List[str]]:
    

    transcripts = []
    for dense_r in dense_repr:
        non_empty_phonemes = [phn_i for phn_i in dense_r if phn_i != 0]
        transcript = [index_to_label[index] for index in non_empty_phonemes]
        transcripts.append(transcript)

    return transcripts