Convert a mopidy artist to a mopidy ref.
438272
def artist_to_ref(artist):
    """"""
    if artist.name:
        name = artist.name
    else:
        name = 'Unknown artist'
    return Ref.directory(uri=artist.uri, name=name)
266524
def convert_result(converter):
    """"""

    def decorate(fn):
        @inspection.wraps(fn)
        def new_fn(*args, **kwargs):
            return converter(fn(*args, **kwargs))

        return new_fn

    return decorate
1231305
def add_artwork_item(self, instance, item):
        
        if 'interface' in self.old_top[instance][item]:
            pass
        else:
            (item_type, item_id) = item.split(' ')
            self.artwork[item_type][item_id] = {}
            for s_item in sorted(self.old_top[instance][item]):
                if self.old_top[instance][item][s_item] is not None:
                    s_detail = self.old_top[instance][item][s_item]
                    s_type = type(s_detail)

                    if item_type == 'NOTE' and s_type == str:
                        # Fix any escaped newline characters
                        s_detail = s_detail.replace('\\n', '\n')

                    if s_type == str and len(s_detail) > 1 \
                            and s_detail[0] == '"' and s_detail[-1] == '"':
                        s_detail = s_detail[1:-1]

                    if item_type == 'SHAPE' and s_item == 'fill_color':
                        s_item = 'color'
                    elif s_item == 'rotate':
                        s_item = 'rotation'
                        s_detail = float(s_detail)

                    self.artwork[item_type][item_id][s_item] = s_detail

            if item_type == 'SHAPE' and \
                    'color' not in self.artwork[item_type][item_id]:
                self.artwork[item_type][item_id]['color'] = '#ffffff'
                self.artwork[item_type][item_id]['transparency'] = 0
1037971
def to_refs(value):
    """"""
    from mongoframes.frames import Frame, SubFrame

    # Frame
    if isinstance(value, Frame):
        return value._id

    # SubFrame
    elif isinstance(value, SubFrame):
        return to_refs(value._document)

    # Lists
    elif isinstance(value, (list, tuple)):
        return [to_refs(v) for v in value]

    # Dictionaries
    elif isinstance(value, dict):
        return {k: to_refs(v) for k, v in value.items()}

    return value
284125
def alter(self, operation, timeout=None, metadata=None, credentials=None):
        """"""
        return self.stub.Alter(operation, timeout=timeout, metadata=metadata,
                               credentials=credentials)
1007271
def _convert(self, image, output=None):
        """"""
        with Image.open(image) as im:
            width, height = im.size

            co = CanvasObjects()
            co.add(CanvasImg(image, 1.0, w=width, h=height))

            return WatermarkDraw(co, tempdir=self.tempdir, pagesize=(width, height)).write(output)
1190372
def refs(obj, **opts):
    '''
    '''
    v = _typedefof(obj, **opts)
    if v:
        v = v.refs
        if v and _callable(v):
            v = v(obj, False)
    return v
882675
function buildFriendmojiUrl (comicId, avatarId1, avatarId2, transparent, scale) {
  return `${baseCpanelUrl}${comicId}-${avatarId1}-${avatarId2}-v3.png?transparent=${transparent}&scale=${scale}`;
}
1027529
def _mor_to_pobject(self, mo_ref):
        """"""
        kls = classmapper(mo_ref._type)
        new_object = kls(mo_ref, self)
        return new_object
581441
def convert_field(self, value, conversion):
        """"""
        if isinstance(value, MissingField):
            if conversion is not None:
                value.conversion = conversion
            return value

        return super(FormatterWrapper, self).convert_field(value, conversion)
802134
function mix(self, ref) {
	if (ref === undefined) return self;
	if ((typeof(ref) != 'object') || (typeof(self) != 'object') || isValueObject(self)) return ref;
	Object.keys(ref).forEach(function(key) { self[key] = mix(self[key], ref[key]) });
	return self;
}
7524
def track_to_ref(track, with_track_no=False):
    """"""
    if with_track_no and track.track_no > 0:
        name = '%d - ' % track.track_no
    else:
        name = ''
    for artist in track.artists:
        if len(name) > 0:
            name += ', '
        name += artist.name
    if (len(name)) > 0:
        name += ' - '
    name += track.name
    return Ref.track(uri=track.uri, name=name)
1147604
def add_ref(self, reftype, data):
        """"""
        ref = (reftype, data)
        try:
            index = self.refs.index(ref)
        except ValueError:
            self.refs.append(ref)
            index = len(self.refs) - 1
        return str(index)
1071756
def create_artist(self):
        
        verts = self.coordinates

        if not self.tracky:
            trans = self.ax.get_xaxis_transform(which='grid')
        elif not self.trackx:
            trans = self.ax.get_yaxis_transform(which='grid')
        else:
            trans = self.ax.transData

        self.artist = pl.Line2D([verts[0]], [verts[1]], transform=trans, picker=15)
        self.update_looks('inactive')
        self.ax.add_artist(self.artist)
527888
def transform_outgoing(self, son, collection):
        """"""
        if isinstance(son, dict):
            for (key, value) in son.items():
                if self.replacement in key:
                    k = self.revert_key(key)
                    son[k] = self.transform_outgoing(son.pop(key), collection)
                elif isinstance(value, dict):  # recurse into sub-docs
                    son[key] = self.transform_outgoing(value, collection)
                elif isinstance(value, list):
                    son[key] = [self.transform_outgoing(item, collection)
                                for item in value]
            return son
        elif isinstance(son, list):
            return [self.transform_outgoing(item, collection)
                    for item in son]
        else:
            return son
1202959
function getArtistFromChartItem(chartItem) {
	var artist;
	try {
		artist = chartItem.children[1].children[5].children[1].children[3].children[0].data.replace(/\n/g, '');
	} catch (e) {
		artist = '';
	}
	if (artist.trim().length < 1) {
		try {
			artist = chartItem.children[1].children[5].children[1].children[3].children[1].children[0].data.replace(/\n/g, '');
		} catch (e) {
			artist = '';
		}
	}
	return artist;
}
835996
def mat_convert(self, infile, item):
        """"""
        data = sio.loadmat(infile)
        labels = self._labels(data)
        features = data['features']
        self._write(item, labels, features)