Return a standard formatting of a Task serialization.
968281
def _task_to_text(self, task):
        

        started = self._format_date(task.get('started_at', None))
        completed = self._format_date(task.get('completed_at', None))

        success = task.get('success', None)
        success_lu = {None: 'Not executed', True: 'Success',
                      False: 'Failed'}

        run_log = task.get('run_log', {})
        return '\n'.join(['Task: %s' % task.get('name', None),
                          'Command: %s' % task.get('command', None),
                          'Result: %s' % success_lu[success],
                          'Started at: %s' % started,
                          'Completed at: %s' % completed,
                          'Return Code: %s' % run_log.get('return_code', None),
                          'Stdout: %s' % run_log.get('stdout', None),
                          'Stderr: %s' % run_log.get('stderr', None)])
764557
def _stub_task(self, description, tags=None, **kw):
        

        # If whitespace is not removed here, TW will do it when we pass the
        # task to it.
        task = {"description": description.strip()}

        # Allow passing "tags" in as part of kw.
        if 'tags' in kw and tags is None:
            task['tags'] = tags
            del(kw['tags'])

        if tags is not None:
            task['tags'] = tags

        task.update(kw)

        # Only UNIX timestamps are currently supported.
        if 'due' in kw:
            task['due'] = str(task['due'])

        return task
1012835
def dump(self,format='ttl'):

		'''
		
		'''

		return self.rdf.graph.serialize(format=format).decode('utf-8')
918111
def task2ics():
    """"""
    from argparse import ArgumentParser, FileType
    from sys import stdout

    parser = ArgumentParser(description='Converter from Taskwarrior to iCalendar syntax.')
    parser.add_argument('indir', nargs='?', help='Input Taskwarrior directory (default to ~/.task)', default=expanduser('~/.task'))
    parser.add_argument('outfile', nargs='?', type=FileType('w'), default=stdout,
                        help='Output iCalendar file (default: stdout)')
    args = parser.parse_args()

    task = IcsTask(args.indir)
    args.outfile.write(task.to_vobject().serialize())
162367
def serialize(self):
        """"""
        res = {}
        if self.query:
            if isinstance(self.query, dict):
                res["query"] = self.query
            elif isinstance(self.query, Query):
                res["query"] = self.query.serialize()
            else:
                raise InvalidQuery("Invalid query")
        if self.filter:
            res['filter'] = self.filter.serialize()
        if self.facet.facets:
            res['facets'] = self.facet.serialize()
        if self.agg.aggs:
            res['aggs'] = self.agg.serialize()
        if self.rescore:
            res['rescore'] = self.rescore.serialize()
        if self.window_size:
            res['window_size'] = self.window_size
        if self.fields is not None: #Deal properly with self.fields = []
            res['fields'] = self.fields
        if self.size is not None:
            res['size'] = self.size
        if self.start is not None:
            res['from'] = self.start
        if self._highlight:
            res['highlight'] = self._highlight.serialize()
        if self.sort:
            if isinstance(self.sort, SortFactory):
                sort = self.sort.serialize()
                if sort:
                    res['sort'] = sort
            else:
                res['sort'] = self.sort
        if self.explain:
            res['explain'] = self.explain
        if self.version:
            res['version'] = self.version
        if self.track_scores:
            res['track_scores'] = self.track_scores
        if self._script_fields:
            if isinstance(self.script_fields, ScriptFields):
                res['script_fields'] = self.script_fields.serialize()
            elif isinstance(self.script_fields, dict):
                res['script_fields'] = self.script_fields
            else:
                raise ScriptFieldsError("Parameter script_fields should of type ScriptFields or dict")
        if self.index_boost:
            res['indices_boost'] = self.index_boost
        if self.min_score:
            res['min_score'] = self.min_score
        if self.stats:
            res['stats'] = self.stats
        if self.partial_fields:
            res['partial_fields'] = self.partial_fields
        if self._source:
            res['_source'] = self._source
        if self.timeout:
            res['timeout'] = self.timeout
        return res
343771
def contents(self):
        
        return self._logged_dict.discard(TIMESTAMP_FIELD).discard(
            TASK_UUID_FIELD
        ).discard(TASK_LEVEL_FIELD)
1091757
def serialize(self):
        """"""
        api_metadata = OrderedDict()
        # $ char makes this come first in sort ordering
        api_metadata['$version'] = self.current_version
        locations = {}

        for svc_name, group in self.groups():
            group_apis = OrderedDict()
            group_metadata = OrderedDict()
            group_metadata['apis'] = group_apis
            group_metadata['title'] = group.title
            api_metadata[group.name] = group_metadata

            if group.docs is not None:
                group_metadata['docs'] = group.docs

            for name, api in group.items():
                group_apis[name] = OrderedDict()
                group_apis[name]['service'] = svc_name
                group_apis[name]['api_group'] = group.name
                group_apis[name]['api_name'] = api.name
                group_apis[name]['introduced_at'] = api.introduced_at
                group_apis[name]['methods'] = api.methods
                group_apis[name]['request_schema'] = api.request_schema
                group_apis[name]['response_schema'] = api.response_schema
                group_apis[name]['doc'] = api.docs
                group_apis[name]['changelog'] = api._changelog
                if api.title:
                    group_apis[name]['title'] = api.title
                else:
                    title = name.replace('-', ' ').replace('_', ' ').title()
                    group_apis[name]['title'] = title

                group_apis[name]['url'] = api.resolve_url()

                if api.undocumented:
                    group_apis[name]['undocumented'] = True
                if api.deprecated_at is not None:
                    group_apis[name]['deprecated_at'] = api.deprecated_at

                locations[name] = {
                    'api': api.location,
                    'request_schema': api._request_schema_location,
                    'response_schema': api._response_schema_location,
                    'changelog': api._changelog_locations,
                    'view': api.view_fn_location,
                }

        return api_metadata, locations
154882
def docs(root_url, path):
    """"""
    root_url = root_url.rstrip('/')
    path = path.lstrip('/')
    if root_url == OLD_ROOT_URL:
        return 'https://docs.taskcluster.net/{}'.format(path)
    else:
        return '{}/docs/{}'.format(root_url, path)
444625
def _serialize(self, value, *args, **kwargs):
        """"""
        if value is not None:
            value = super(MSTimestamp, self)._serialize(value, *args) * 1e3
        return value
614234
def _serialize_input_list(input_value):
        """"""
        input_list = []
        for item in input_value:
            if isinstance(item, list):
                input_list.append(Task._serialize_input_list(item))
            else:
                if isinstance(item, File):
                    item = Task._to_api_file_format(item)
                input_list.append(item)
        return input_list
966349
def _serialize_inputs(inputs):
        """"""
        serialized_inputs = {}
        for input_id, input_value in inputs.items():
            if isinstance(input_value, list):
                serialized_list = Task._serialize_input_list(input_value)
                serialized_inputs[input_id] = serialized_list
            else:
                if isinstance(input_value, File):
                    input_value = Task._to_api_file_format(input_value)
                serialized_inputs[input_id] = input_value
        return serialized_inputs
546911
def as_serializable(self):
        """"""
        other = MeanStdFilter(self.shape)
        other.sync(self)
        return other
106523
def pretty_format(message):
    
    skip = {
        TIMESTAMP_FIELD, TASK_UUID_FIELD, TASK_LEVEL_FIELD, MESSAGE_TYPE_FIELD,
        ACTION_TYPE_FIELD, ACTION_STATUS_FIELD}

    def add_field(previous, key, value):
        value = unicode(pprint.pformat(value, width=40)).replace(
            "\\n", "\n ").replace("\\t", "\t")
        # Reindent second line and later to match up with first line's
        # indentation:
        lines = value.split("\n")
        # indent lines are "  <key length>|  <value>"
        indent = "{}| ".format(" " * (2 + len(key)))
        value = "\n".join([lines[0]] + [indent + l for l in lines[1:]])
        return "  %s: %s\n" % (key, value)

    remaining = ""
    for field in [ACTION_TYPE_FIELD, MESSAGE_TYPE_FIELD, ACTION_STATUS_FIELD]:
        if field in message:
            remaining += add_field(remaining, field, message[field])
    for (key, value) in sorted(message.items()):
        if key not in skip:
            remaining += add_field(remaining, key, value)

    level = "/" + "/".join(map(unicode, message[TASK_LEVEL_FIELD]))
    return "%s -> %s\n%sZ\n%s" % (
        message[TASK_UUID_FIELD],
        level,
        # If we were returning or storing the datetime we'd want to use an
        # explicit timezone instead of a naive datetime, but since we're
        # just using it for formatting we needn't bother.
        datetime.utcfromtimestamp(message[TIMESTAMP_FIELD]).isoformat(
            sep=str(" ")),
        remaining, )
574399
def serialized(self, prepend_date=True):
        """"""
        name = self.serialized_name()
        datetime = self.serialized_time(prepend_date)
        return "%s %s" % (datetime, name)
1200998
public String prettyPrint() {
        StringBuilder sb = new StringBuilder(shortSummary());
        sb.append('\n');
        sb.append("-----------------------------------------\n");
        sb.append("ms     %     Task name\n");
        sb.append("-----------------------------------------\n");
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMinimumIntegerDigits(5);
        nf.setGroupingUsed(false);
        NumberFormat pf = NumberFormat.getPercentInstance();
        pf.setMinimumIntegerDigits(3);
        pf.setGroupingUsed(false);
        final TaskInfo[] taskInfos = getTaskInfo();
        Arrays.sort(taskInfos, new Comparator<TaskInfo>() {
            @Override
            public int compare(TaskInfo o1, TaskInfo o2) {
                return Long.compare(o1.getTimeMillis(), o2.getTimeMillis());
            }
        });
        for (TaskInfo task : taskInfos) {
            sb.append(nf.format(task.getTimeMillis())).append("  ");
            sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append("  ");
            sb.append(task.getTaskName()).append("\n");
        }
        return sb.toString();
    }
411598
def _ToString(x):
    """"""
    # Some cross-language values for primitives.  This is tested in
    # jsontemplate_test.py.
    if x is None:
        return 'null'
    if isinstance(x, six.string_types):
        return x
    return pprint.pformat(x)
979826
def get_formatter_report(f: logging.Formatter) -> Optional[Dict[str, str]]:
    
    if f is None:
        return None
    return {
        '_fmt': f._fmt,
        'datefmt': f.datefmt,
        '_style': str(f._style),
    }