import re


def text_has_service(s):
    """Check if a line in a file matches protobuf service definition

    Example:
        >>> text_has_service('    service  foo {')
        True
        >>> text_has_service('// service nope')
        False
        >>> lines = ['//some file', 'junk', '...', ' service  foo {', '    rpc Timeit (Empty) returns (TimeMsg) {}', '}']
        >>> any(text_has_service(l) for l in lines)
        True

    """
    pat = re.compile("^\s*service\s+.+$")
    if re.search(pat, s):
        return True
    return False