Serialize task input dictionary
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
438528
def byteify(input_object):
    
    if isinstance(input_object, dict):
        return {byteify(key): byteify(value)
                for key, value in list(input_object.items())}
    elif isinstance(input_object, list):
        return [byteify(element) for element in input_object]
    elif isinstance(input_object, str):
        return input_object.encode('utf-8')
    else:
        return input_object
152283
def serialize_task_id(self):
        
        return "{}@{}".format(
            self._identification[TASK_UUID_FIELD],
            self._nextTaskLevel().toString()).encode("ascii")
298849
def encode_task_experimental(task):
    
    # First, clean the task:
    task = task.copy()
    if 'tags' in task:
        task['tags'] = ','.join(task['tags'])
    for k in task:
        task[k] = encode_task_value(k, task[k])

    # Then, format it as a string
    return [
        "%s:\"%s\"" % (k, v) if v else "%s:" % (k, )
        for k, v in sorted(task.items(), key=itemgetter(0))
    ]
269548
def _input_as_dict(self, data):
        
        # clear self._input; ready to receive new input and output files
        self._input = {}
        # Check that the arguments to the
        # subcommand-specific parameters are valid
        self.check_arguments()

        # Ensure that we have all required input (file I/O)
        for k in self._input_order:
            # N.B.: optional positional arguments begin with underscore (_)!
            # (e.g., see _mate_in for bwa bwasw)
            if k[0] != '_' and k not in data:
                raise MissingRequiredArgumentApplicationError("Missing "
                                                              "required "
                                                              "input %s" % k)

        # Set values for input and output files
        for k in data:
            # check for unexpected keys in the dict
            if k not in self._input_order:
                error_message = "Invalid input arguments (%s)\n" % k
                error_message += "Valid keys are: %s" % repr(self._input_order)
                raise InvalidArgumentApplicationError(error_message + '\n')

            # check for absolute paths
            if not isabs(data[k][0]):
                raise InvalidArgumentApplicationError("Only absolute paths "
                                                      "allowed.\n%s" %
                                                      repr(data))
            self._input[k] = data[k]

        # if there is a -f option to specify an output file, force the user to
        # use it (otherwise things to to stdout)
        if '-f' in self.Parameters and not self.Parameters['-f'].isOn():
            raise InvalidArgumentApplicationError("Please specify an output "
                                                  "file with -f")

        return ''
859753
def serialize(self):
    """"""
    return {
        'word': self.word,
        'pos': self.pos,
        'label': self.label,
        'dependency': self.dependency,
        'has_cjk': self.has_cjk(),
    }
834402
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'request') and self.request is not None:
            _dict['request'] = self.request._to_dict()
        if hasattr(self, 'response') and self.response is not None:
            _dict['response'] = self.response._to_dict()
        if hasattr(self, 'log_id') and self.log_id is not None:
            _dict['log_id'] = self.log_id
        if hasattr(self,
                   'request_timestamp') and self.request_timestamp is not None:
            _dict['request_timestamp'] = self.request_timestamp
        if hasattr(
                self,
                'response_timestamp') and self.response_timestamp is not None:
            _dict['response_timestamp'] = self.response_timestamp
        if hasattr(self, 'workspace_id') and self.workspace_id is not None:
            _dict['workspace_id'] = self.workspace_id
        if hasattr(self, 'language') and self.language is not None:
            _dict['language'] = self.language
        return _dict
1212451
def serialize(self):
        """"""
        # Serialize fields to a dict
        data = {}
        for field_name in self:
            value = self._values.get(field_name)
            field = self.fields.get(field_name)
            if value is not None:
                if field.all:
                    value = [field.serialize(v) for v in value]
                else:
                    value = field.serialize(value)
            # Skip empty fields unless field.null
            if not field.null and ((field.all and value == []) or (not field.all and value in {None, ''})):
                continue
            data[field.name] = value
        return data
1161867
def dump_json(model, batch_len=200000, use_natural_keys=True, verbosity=1):
    
    model = get_model(model)

    N = model.objects.count()

    if verbosity > 0:
        widgets = [pb.Counter(), '/%d rows: ' % (N,), pb.Percentage(), ' ', pb.RotatingMarker(), ' ', pb.Bar(),' ', pb.ETA()]
        i, pbar = 0, pb.ProgressBar(widgets=widgets, maxval=N).start()

    JSONSerializer = serializers.get_serializer("json")
    jser = JSONSerializer()

    if verbosity > 0:
        pbar.update(0)
    for i, partial_qs in enumerate(util.generate_slices(model.objects.all(), batch_len=batch_len)):
        with open(model._meta.app_label.lower() + '--' + model._meta.object_name.lower() + '--%04d.json' % i, 'w') as fpout:
            if verbosity > 0:
                pbar.update(i*batch_len)
            jser.serialize(partial_qs, indent=1, stream=fpout, use_natural_keys=use_natural_keys)
    if verbosity > 0:
        pbar.finish()
723014
def serialize(self):
        
        return {'day': self.day, 'other': self.other,
                'timeranges': [t.serialize() for t in self.timeranges]}
478303
def getTaskHelp(_Task):
  
  """
  Ret = []

  for k in ['name', 'desc']:
    v = _Task.Config.get(k)

    if v is not None:
      Ret.append('%s: %s' % (k, v))

  Args = _Task.Args

  if Args:
    Ret.append('\nArgs:')

    for argName, Arg in Args.items():
      Ret.append('  %s: %s' % (argName, Arg.get('desc', Arg['type_str'])))

    Ret.append('')

  return '\n'.join(Ret).rstrip()
870120
def serialize_to_dict(dictionary):
    ''''''
    retval = {}
    
    for k, v in dictionary.items():
        if isinstance(v, dict):
            retval[k] = serialize_to_dict(v)
        else:
            # This is when custom serialization happens
            if isinstance(v, np.ndarray):
                if v.dtype == 'float64':
                    # We don't support float64 on js side
                    v = v.astype('float32')

                retval[k] = encode_numpy(v)
            else:
                retval[k] = v
    
    return retval
498839
def serialize
      {
        "job_class"  => self.class.name,
        "job_id"     => job_id,
        "provider_job_id" => provider_job_id,
        "queue_name" => queue_name,
        "priority"   => priority,
        "arguments"  => serialize_arguments_if_needed(arguments),
        "executions" => executions,
        "exception_executions" => exception_executions,
        "locale"     => I18n.locale.to_s,
        "timezone"   => Time.zone.try(:name),
        "enqueued_at" => Time.now.utc.iso8601
      }
    end
334298
def run_task_json(task_cls, task_data):
    
    # TODO what does set_skipping_json do?
    task = instantiate(task_cls)
    task_callable = get_callable(task)
    td = TaskData(task_data)
    td.set_skipping_json(True)
    return task_callable(td)
956002
def serialize(self):
        
        return {"hstart": self.hstart, "mstart": self.mstart,
                "hend": self.hend, "mend": self.mend,
                "is_valid": self.is_valid}
343771
def contents(self):
        
        return self._logged_dict.discard(TIMESTAMP_FIELD).discard(
            TASK_UUID_FIELD
        ).discard(TASK_LEVEL_FIELD)
1328387
def to_json(self, *args, **kwargs):
        
        return json.dumps(self.serialized, *args, **kwargs)