:param fields: ('bdate', 'domain')
        :return: 'bdate,domain'
770479
def _convert_list2str(self, fields):
        
        if isinstance(fields, tuple) or isinstance(fields, list):
            return ','.join(fields)
        return fields
677279
def map_value(self, field, value):
        

        if field == 'sids':
            # Site identifiers are returned as "[id] [auth_id]";
            # Map to auth name for easier usability
            ids = {}
            for idinfo in value:
                id, auth = idinfo.split(' ')
                auth = AUTHORITY_BY_ID[auth]
                ids[auth['name']] = id
            return ids

        if field == 'valid_daterange':
            # Date ranges for each element are returned in an array
            # (sorted by the order the elements were were requested);
            # Convert to dictionary with element id as key
            elems, complex = self.getlist('parameter')
            ranges = {}
            for elem, val in zip(elems, value):
                if val:
                    start, end = val
                    ranges[elem] = (parse_date(start), parse_date(end))
                else:
                    ranges[elem] = None, None
            return ranges
        return value
5292
def parse_field_options(self, *options):
        
        defaults = {}
        for option in options:
            if isinstance(option, six.text_type):
                tokens = [token.strip() for token in option.split(self.view.lookup_sep)]

                for token in tokens:
                    if not len(token.split(":")) == 2:
                        warnings.warn("The %s token is not properly formatted. Tokens need to be "
                                      "formatted as 'token:value' pairs." % token)
                        continue

                    param, value = token.split(":", 1)

                    if any([k == param for k in ("start_date", "end_date", "gap_amount")]):

                        if param in ("start_date", "end_date"):
                            value = parser.parse(value)

                        if param == "gap_amount":
                            value = int(value)

                    defaults[param] = value

        return defaults
529426
def __fix_field_date(self, item, attribute):
        """"""

        field_date = str_to_datetime(item[attribute])

        try:
            _ = int(field_date.strftime("%z")[0:3])
        except ValueError:
            logger.warning("%s in commit %s has a wrong format", attribute, item['commit'])
            item[attribute] = field_date.replace(tzinfo=None).isoformat()
969888
def field_datetime_to_json(self, dt):
        
        if isinstance(dt, six.string_types):
            dt = parse_datetime(dt)
        if not dt:
            return None
        ts = timegm(dt.utctimetuple())
        if dt.microsecond:
            return "{0}.{1:0>6d}".format(ts, dt.microsecond)
        else:
            return ts
888032
def format_field(self, value, format_spec):
        """"""
        if isinstance(value, datetime) and not format_spec:
            return super().format_field(value, '%Y-%m-%d_%H-%M-%S')
        if value is None:
            return ''
        return super().format_field(value, format_spec)
686756
def getDateFields(fc):
    
    if arcpyFound == False:
        raise Exception("ArcPy is required to use this function")
    return [field.name for field in arcpy.ListFields(fc, field_type="Date")]
498095
def get_field_value(obj, field):
    
    if isinstance(field, DateTimeField):
        # DateTimeFields are timezone-aware, so we need to convert the field
        # to its naive form before we can accuratly compare them for changes.
        try:
            value = field.to_python(getattr(obj, field.name, None))
            if value is not None and settings.USE_TZ and not timezone.is_naive(value):
                value = timezone.make_naive(value, timezone=timezone.utc)
        except ObjectDoesNotExist:
            value = field.default if field.default is not NOT_PROVIDED else None
    else:
        try:
            value = smart_text(getattr(obj, field.name, None))
        except ObjectDoesNotExist:
            value = field.default if field.default is not NOT_PROVIDED else None

    return value
963601
private StringBuffer format(Date date, StringBuffer toAppendTo,
                                FieldDelegate delegate) {
        // Convert input date to time field list
        calendar.setTime(date);

        boolean useDateFormatSymbols = useDateFormatSymbols();

        for (int i = 0; i < compiledPattern.length; ) {
            int tag = compiledPattern[i] >>> 8;
            int count = compiledPattern[i++] & 0xff;
            if (count == 255) {
                count = compiledPattern[i++] << 16;
                count |= compiledPattern[i++];
            }

            switch (tag) {
            case TAG_QUOTE_ASCII_CHAR:
                toAppendTo.append((char)count);
                break;

            case TAG_QUOTE_CHARS:
                toAppendTo.append(compiledPattern, i, count);
                i += count;
                break;

            default:
                subFormat(tag, count, delegate, toAppendTo, useDateFormatSymbols);
                break;
            }
        }
        return toAppendTo;
    }
232852
def encode_field(self, field, value):
        
        if isinstance(field, messages.BytesField):
            if field.repeated:
                value = [base64.b64encode(byte) for byte in value]
            else:
                value = base64.b64encode(value)
        elif isinstance(field, message_types.DateTimeField):
            # DateTimeField stores its data as a RFC 3339 compliant string.
            if field.repeated:
                value = [i.isoformat() for i in value]
            else:
                value = value.isoformat()
        return value
1318777
def encode_field(self, field, value):
        
        for encoder in _GetFieldCodecs(field, 'encoder'):
            result = encoder(field, value)
            value = result.value
            if result.complete:
                return value
        if isinstance(field, messages.EnumField):
            if field.repeated:
                remapped_value = [GetCustomJsonEnumMapping(
                    field.type, python_name=e.name) or e.name for e in value]
            else:
                remapped_value = GetCustomJsonEnumMapping(
                    field.type, python_name=value.name)
            if remapped_value:
                return remapped_value
        if (isinstance(field, messages.MessageField) and
                not isinstance(field, message_types.DateTimeField)):
            value = json.loads(self.encode_message(value))
        return super(_ProtoJsonApiTools, self).encode_field(field, value)
423495
def pretty_print_domain(rows, keyword, domain):
    
    if len(rows.get('records')) == 0:
        return None

    # six columns; priority, name, content, ttl, change_date, type
    header_l = ['prio', 'name', 'content',
                'ttl', 'change date', 'type']
    # 0->4, 1->0, 2->2, 3->3, 4->5, 5->1
    header_l_sorted = ['name', 'type', 'content',
                       'ttl', 'prio', 'change date']
    header_l_sorted.reverse()

    cols_width = [len(i) for i in header_l]

    """
    if key == 'change_date':
        value = datetime.fromtimestamp(
            int(row_d.get(key))).strftime("%Y%m%d-%H%M%S")
            """

    cw_, soa = get_columns_width(rows.get('records'),
                                 cols_width, True)

    # sorted as name, type, content, ttl, priority, change_date
    cols_width_sorted = [cw_[1], cw_[5], cw_[2],
                         cw_[3], cw_[0], cw_[4]]

    if isinstance(soa, dict):
        soa_s = ('zone:        ' + soa.get('name') + '\n' +
                 'SOA record:  ' + soa.get('content') + '\n' +
                 'ttl:         ' + soa.get('ttl') + '\n' +
                 'change date: ' + soa.get('change_date'))
        domain = soa.get('name')
        print(soa_s)

    print domain

    if keyword != 'SOA':
        print_header(cols_width_sorted, header_l_sorted, len(domain))
        str_value = ''
        for row in rows.get('records'):
            if row.get('type') == 'SOA':
                pass
            else:
                # name
                if row.get('name'):
                    str_value = get_row_s(row, 'name',
                                          cols_width_sorted[0],
                                          domain=domain)
                    sys.stdout.write("|%s" % str_value)
                # type
                if row.get('type'):
                    str_value = get_row_s(row, 'type',
                                          cols_width_sorted[1])
                    sys.stdout.write("|%s" % str_value)
                # content
                if row.get('content'):
                    str_value = get_row_s(row, 'content',
                                          cols_width_sorted[2])
                    sys.stdout.write("|%s" % str_value)
                # ttl
                if row.get('ttl'):
                    str_value = get_row_s(row, 'ttl',
                                          cols_width_sorted[3])
                    sys.stdout.write("|%s" % str_value)
                # priority
                if row.get('priority') is None:
                    val = {'priority': '-'}
                else:
                    val = row.copy()
                str_value = get_row_s(val, 'priority',
                                      cols_width_sorted[4])
                sys.stdout.write("|%s" % str_value)
                if row.get('change_date') is None:
                    val = {'change_date': '-'}
                else:
                    val = row.copy()
                str_value = get_row_s(val, 'change_date',
                                      cols_width_sorted[5])
                print("|%s|" % str_value)

        print_bottom(cols_width_sorted, len(domain))
888891
def b(field: str, kwargs: Dict[str, Any],
      present: Optional[Any] = None, missing: Any = '') -> str:
    
    if kwargs.get(field):
        return field if present is None else str(present)
    return str(missing)
762126
def _field_value_text(self, field):
        """"""
        if field in self.fields:
            return unicode(self.get(field))
        else:
            return self.get_timemachine_instance(field)._object_name_text()
1072813
def format_field(self, field):
        
        if field is None:
            return "NULL"
        elif isinstance(field, TypeError):
            return "TypeError"
        elif isinstance(field, Decimal):
            if field % 1 == 0:
                return str(int(field))
            return str(float(field))
        elif isinstance(field, set):
            return "(" + ", ".join([self.format_field(v) for v in field]) + ")"
        elif isinstance(field, datetime):
            return field.isoformat()
        elif isinstance(field, timedelta):
            rd = relativedelta(
                seconds=int(field.total_seconds()), microseconds=field.microseconds
            )
            return delta_to_str(rd)
        elif isinstance(field, Binary):
            return "<Binary %d>" % len(field.value)
        pretty = repr(field)
        if pretty.startswith("u'"):
            return pretty[1:]
        return pretty
388120
def _format_fields(cls, declared_fields: typing.List[tuple]):
        
        formatted_fields = []
        for declared_field in declared_fields:
            field_name = field_type = field_defn = None

            # Case when only (name), or "name", is specified
            if isinstance(declared_field, str) or len(declared_field) == 1:
                field_name = declared_field
                field_type = typing.Any
                field_defn = field(default=None)

            # Case when (name, type) are specified
            elif len(declared_field) == 2:
                field_name = declared_field[0]
                field_type = declared_field[1]
                field_defn = field(default=None)

            # Case when (name, type, field) are specified
            elif len(declared_field) == 3:
                field_name = declared_field[0]
                field_type = declared_field[1]

                # Process the definition and create a `field` object
                # Definition will be of the form `{'required': False, 'default': 'John'}`
                assert isinstance(declared_field[2], dict)
                metadata = default = None
                if 'required' in declared_field[2] and declared_field[2]['required']:
                    metadata = {'required': True}
                if 'default' in declared_field[2]:
                    default = declared_field[2]['default']
                field_defn = field(default=default, metadata=metadata)

            formatted_fields.append((field_name, field_type, field_defn))

        return formatted_fields
1205143
def _parse_fields_dns(self, *args, **kwargs):
        

        from warnings import warn
        warn('IPASN._parse_fields_dns() has been deprecated and will be '
             'removed. You should now use IPASN.parse_fields_dns().')
        return self.parse_fields_dns(*args, **kwargs)