Get an object’s line numbers
346699
def get_linenos(obj):
    """"""
    try:
        lines, start = inspect.getsourcelines(obj)
    except TypeError:
        return None, None
    else:
        return start, start + len(lines) - 1
1249629
def build_lines_data(self, code_obj):
        

        # Offset: lineno pairs, only for offsets which start line.
        # Locally we use list for more convenient iteration using indices
        if self.version > 1.4:
            linestarts = list(self.opc.findlinestarts(code_obj))
        else:
            linestarts = [[0, 1]]
        self.linestarts = dict(linestarts)

        # 'List-map' which shows line number of current op and offset of
        # first op on following line, given offset of op as index
        lines = []
        LineTuple = namedtuple('LineTuple', ['l_no', 'next'])

        # Iterate through available linestarts, and fill
        # the data for all code offsets encountered until
        # last linestart offset
        _, prev_line_no = linestarts[0]
        offset = 0
        for start_offset, line_no in linestarts[1:]:
            while offset < start_offset:
                lines.append(LineTuple(prev_line_no, start_offset))
                offset += 1
            prev_line_no = line_no

        # Fill remaining offsets with reference to last line number
        # and code length as start offset of following non-existing line
        codelen = len(self.code)
        while offset < codelen:
            lines.append(LineTuple(prev_line_no, codelen))
            offset += 1
        return lines
1249659
def _get_num_similar_objects(self, obj):
        """"""
        return StatementLine.objects.filter(
            date=obj.date, amount=obj.amount, description=obj.description
        ).count()
171202
def r_num(obj):
    """"""
    if isinstance(obj, (list, tuple)):
        it = iter
    else:
        it = LinesIterator
    dataset = Dataset([Dataset.FLOAT])
    return dataset.load(it(obj))
233547
def get_object_as_string(obj):
    
    if isinstance(obj, str):
        return obj
    if isinstance(obj, list):
        return '\r\n\;'.join([get_object_as_string(item) for item in obj])
    attrs = vars(obj)
    as_string = ', '.join("%s: %s" % item for item in attrs.items())
    return as_string
674907
def get_line_at(self, coordinates):
        """"""
        cursor = self.cursorForPosition(coordinates)
        cursor.select(QTextCursor.BlockUnderCursor)
        return to_text_string(cursor.selectedText()).replace(u'\u2029', '')
841610
def get_relativelinenumbertable(self):
        

        lnt = self.get_linenumbertable()
        if lnt:
            lineoff = lnt[0][1]
            return tuple((o, l - lineoff) for (o, l) in lnt)
        else:
            return tuple()
602306
def getlines(self, bufnr=None):
        
        buf = self._vim.buffers[bufnr] if bufnr else self._vim.current.buffer
        return buf[:]
952823
def s(obj):
    """"""
    if isinstance(obj, bytes):
        return obj.replace(b'\n', os.linesep.encode())
    else:
        return obj.replace('\n', os.linesep)
817200
def number_text_lines(text):
    
    """
    numbered_linelist = [
        ''.join((('%2d' % (count + 1)), ' >>> ', line))
        for count, line in enumerate(text.splitlines())
    ]
    text_with_lineno = '\n'.join(numbered_linelist)
    return text_with_lineno
804962
def _draw_line_numbers(self):
        
        if not self.line_numbers:
            return
        for p in xrange(self.maxlineno):
            n = p + self.line_number_start
            if (n % self.line_number_step) == 0:
                self._draw_linenumber(p, n)
352987
def get_object_id(obj):
    """"""
    try:
        idx = objIds.index(obj)
        return idx + 1
    except ValueError:
        objIds.append(obj)
        return len(objIds)
672131
def _dump_linestring(obj, decimals):
    
    coords = obj['coordinates']
    ls = 'LINESTRING (%s)'
    ls %= ', '.join(' '.join(_round_and_pad(c, decimals)
                             for c in pt) for pt in coords)
    return ls
83613
def get(self, line_number):
        
        if line_number not in self._get_cache:
            self._get_cache[line_number] = self._get(line_number)
        return self._get_cache[line_number]
1154206
function getPos(lines, lineNum, code, indicator) {

	var line, min, max, dots = false, prefix = 0;
	var pos = {};

	// console.log('code', code);

	// handle special cases
	if (code === '{{{{') {
		pos.min = 0;
		pos.max = 4;
		return pos;
	} else if (code === '{{{') {
		pos.min = 0;
		pos.max = 3;
		return pos;
	} else  if (code === '{{') {
		pos.min = 0;
		pos.max = 2;
		return pos;
	} else if (code.indexOf('{{<') !== -1) {
		pos.min = lines[lineNum].indexOf('{{<');
		pos.max = pos.min + 3;
		return pos;
	} else if (code === '{{}}') {
		pos.min = 0;
		pos.max = 4;
		return pos;
	} else if (code.indexOf('{{{}}{') !== -1) {
		pos.min = lines[lineNum].indexOf('{{{}}}');
		pos.max = pos.min + 6;
		return pos;
	} else if (code.indexOf('{{#}}') !== -1) {
		pos.min = lines[lineNum].indexOf('{{#}}');
		pos.max = pos.min + 5;
		return pos;
	}

	// trim off extra prefix and suffix from code which
	// could force us to not find the pos in the line.
	code = code.substring(0, indicator.length);
	code = code.replace('...', function() {
		dots = true;
		return '';
	});

	prefix = code.indexOf('{{');
	line = lines[lineNum];
	min = line.indexOf(code);
	min = min + prefix;
	max = (!dots)
		? min + indicator.length - 1
		: min + indicator.length - 4;

	// todo: if (min === max) max = findMax(line, min); // find first ' ' or '}'
	if (min === max) max++;

	if (min === -1) {
		return {
			min: 0,
			max: 1
		};
	} else {
		return {
			min: min,
			max: max
		};
	}
}
925066
def get_object_name(object):
    

    if type(object) is property:
        return object.fget.__name__
    elif hasattr(object, "__name__"):
        return object.__name__
    elif hasattr(object, "__class__"):
        return object.__class__.__name__
    else:
        return NULL_OBJECT_NAME
164576
def get_numbers(s):
    """"""

    result = map(int, re.findall(r'[0-9]+', unicode(s)))
    return result + [1] * (2 - len(result))