def __init__(self, filename, version=ID3V2_DEFAULT_VERSION):
        """
        @param filename: the file to open or write to.
        @type filename: string

        @param version: if header doesn't exists, we need this to tell us what version \
                        header to use
        @type version: float

        @raise ID3Exception: if file does not have an ID3v2 but is specified
        to be in read or modify mode.
        """

        if str(version) not in self.supported:
            raise ID3ParameterException("version %s not valid" % str(version))

        if not os.path.exists(filename):
            raise ID3ParameterException("filename %s not valid" % filename)
        
        try:
          self.f = open(filename, 'rb+')
          self.read_only = False
        except __HOLE__, (errno, strerror):
            if errno == 13: # permission denied
                self.f = open(filename, 'rb')
                self.read_only = True

        self.filename = filename

        if self.tag_exists():
            self.parse_header()
            self.parse_frames()
        else:
            self.new_header(str(version))
dataset/ETHPy150Open Ciantic/pytagger/tagger/id3v2.py/ID3v2.__init__