Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)

        def open_if_filename(file_or_path, mode=u'rb'):
    u"""
    file_or_path can be either a string or a file-like object.
    if it is a string, a file will be opened with mode.
    Returns a tuple (file, should_be_closed).
    """
    if isinstance(file_or_path, basestring):
        return (open(file_or_path, mode), True)
    else:
        return (file_or_path, False)
        


src/h/s/hsaudiotag3k-1.1.3/hsaudiotag/mp4.py   hsaudiotag3k(Download)
import struct
 
from .util import open_if_filename, tryint
from .genres import genre_by_index
 
    def __init__(self, infile):
        self._fp, self._shouldclose = open_if_filename(infile, 'rb')
        self._fp.seek(0, 2)
        AtomBox.__init__(self, None, 0, (self._fp.tell(), 'root'))
 

src/h/s/hsaudiotag-1.1.1/hsaudiotag/mp4.py   hsaudiotag(Download)
import struct
 
from .util import open_if_filename, tryint
from .genres import genre_by_index
 
    def __init__(self, infile):
        self._fp, self._shouldclose = open_if_filename(infile, u'rb')
        self._fp.seek(0, 2)
        AtomBox.__init__(self, None, 0, (self._fp.tell(), u'root'))