:param from_value: string like "image:tag" or "image:tag AS name"
    :return: tuple of the image and stage name, e.g. ("image:tag", None)
4220
def image_from(from_value):
    
    regex = re.compile(r"""(?xi)     # readable, case-insensitive regex
        \s*                          # ignore leading whitespace
        (?P<image> \S+ )             # image and optional tag
        (?:                          # optional "AS name" clause for stage
            \s+ AS \s+
            (?P<name> \S+ )
        )?
        """)
    match = re.match(regex, from_value)
    return match.group('image', 'name') if match else (None, None)
198235
def payload(self, value):
        
        if isinstance(value, tuple):
            content_type, payload = value
            self.content_type = content_type
            self._payload = payload
        else:
            self._payload = value
118040
def from_bid(cls, value):
        
        if not isinstance(value, bytes):
            raise TypeError("value must be an instance of bytes")
        if len(value) != 16:
            raise ValueError("value must be exactly 16 bytes")
        return cls((_UNPACK_64(value[8:])[0], _UNPACK_64(value[:8])[0]))
1019975
def _fromstring(value):
    '''
    '''

    if not value:
        return None
    std_value = value.strip().lower()
    if std_value == 'true':
        return 'true'
    elif std_value == 'false':
        return 'false'
#     try:
#         return int(std_value)
#     except ValueError:
#         pass
#     try:
#         return float(std_value)
#     except ValueError:
#         pass
    return value
1286209
def from_value(cls, value, size=None, fmt='Q', **kwargs):
        '''
        
        '''
        bl = cls(**kwargs)  # size is 0 by default
        bl.fromvalue(value=value, size=size, fmt=fmt)
        return bl
398908
def as_name(value)
      case true
      when value.tag?
        element(value).name
      when value.dicom_name?
        @methods_from_names.has_key?(value) ? value.to_s : nil
      when value.dicom_method?
        @names_from_methods[value.to_sym]
      else
        nil
      end
    end
1081362
function (fromString) {
                    var matches = fromString.match(/(\${.*?})/g);
                    if (matches != null) {
                        for (var i = 0; i < matches.length; i++) {
                            var val = values[matches[i].substring(2, matches[i].length - 1)] || "";
                            if (val != null) {
                                fromString = fromString.replace(matches[i], val);
                            }
                        }
                    }
                    return fromString;
                }
1293862
def label(self, value):
        
        return self._labels.get(value) or text.pretty(self(value))
196679
def create_option_from_value(tag, value):
    
    dhcp_option.parser()
    fake_opt = dhcp_option(tag = tag)
    for c in dhcp_option.subclasses:
        if c.criteria(fake_opt):
            if hasattr(c, '_parse_from_value'):
                return c(tag = tag, value = c._parse_from_value(value))
            else:
                raise ValueError('Invalid DHCP option ' + str(tag) + ": " + repr(value))
    else:
        fake_opt._setextra(_tobytes(value))
        return fake_opt
761270
def to_internal_value(self, value):
        """"""

        if "id" in value:
            tag = Tag.objects.get(id=value["id"])
        else:
            if "name" not in value:
                raise ValidationError("Tags must include an ID or a name.")
            if len(slugify(value["name"])) > 50:
                raise ValidationError("Maximum tag length is 50 characters.")

            name = value["name"]
            slug = value.get("slug", slugify(name))
            try:
                tag = Tag.objects.get(slug=slug)
            except Tag.DoesNotExist:
                tag, created = Tag.objects.get_or_create(name=name, slug=slug)
        return tag
1003536
def normalizeToTag(val):
    
    try:
        val = val.upper()
    except AttributeError:
        raise KeyError("{} is not a tag or name string".format(val))
    if val not in tagsAndNameSetUpper:
        raise KeyError("{} is not a tag or name string".format(val))
    else:
        try:
            return fullToTagDictUpper[val]
        except KeyError:
            return val
1263246
def source(self, value):
        
        if not isinstance(value, tuple) or len(value) != 2:
            raise AttributeError
        self._source = value
651628
def from_dict(raw_data):
        """"""
        try:
            definition = raw_data['definition']
            term_id = raw_data['id']
            image = Image.from_dict(raw_data['image'])
            rank = raw_data['rank']
            term = raw_data['term']
            return Term(definition, term_id, image, rank, term)
        except KeyError:
            raise ValueError('Unexpected term json structure')
1300348
private static String getTagValueAsString(final ITag tag, final byte[] value) {
		StringBuilder buf = new StringBuilder();

		switch (tag.getTagValueType()) {
		case TEXT:
			buf.append("=");
			buf.append(new String(value));
			break;
		case NUMERIC:
			buf.append("NUMERIC");
			break;
		case BINARY:
			buf.append("BINARY");
			break;
		case MIXED:
			buf.append("=");
			buf.append(getSafePrintChars(value));
			break;
		case DOL:
			buf.append("");
			break;
		default:
			break;
		}

		return buf.toString();
	}
1204853
def get_imagestreamtag_from_image(image):
    
    ret = image

    # Remove the registry part
    ret = strip_registry_from_image(image)

    # ImageStream names cannot contain '/'
    ret = ret.replace('/', '-')

    # If there is no ':' suffix value, add one
    if ret.find(':') == -1:
        ret += ":latest"

    return ret
179542
function (val) {
        var color, mode;
        if (arguments.length > 1) color = arguments[1];
        if (arguments.length > 2) mode = arguments[2];

        return {
            is: 'tag',
            val: val,
            color: color,
            mode: mode,
            toString: function(env) {
                var attr = {};

                _.set(attr, 'value', val.ev(env).toString());
                if (color) {
                    _.set(attr, 'color', color.ev(env).toString());
                }
                if (mode) {
                    _.set(attr, 'mode', mode.ev(env).toString());
                }
                return {
                    '_name': 'stop',
                    '_attributes': attr
                };
            }
        };
    }
10646
def property_label_text(property)
      case property.to_sym
      when :image_default then t(:image_url)
      when :web_default then t(:website_url)
      when :web_blog then t(:blog_url)
      else t(property.to_sym)
      end
    end