def get_fno()

in pystemd/run.py [0:0]


def get_fno(obj):
    """
    Try to get the best fileno of a obj:
        * If the obj is a integer, it return that integer.
        * If the obj has a fileno method, it return that function call.
    """
    if obj is None:
        return None
    elif isinstance(obj, int):
        return obj
    elif hasattr(obj, "fileno") and callable(getattr(obj, "fileno")):
        return obj.fileno()

    raise TypeError("Expected None, int or fileobject with fileno method")