def export_(self, arg, key):
        'Encode all profiles and export them.'
        try:
            destination = open(arg, 'wb')
        except:
            raise Exception('%r CANNOT BE CREATED' % arg)
        random.seed(key)
        major = spice.major()
        minor = spice.minor()
        random.seed() # Restore randomness.
        for name in self.aliases:
            profile = self.profiles[name][0]
            assert len(profile) <= 16777216, '%r IS TOO LARGE' % name
            len_name = chr(len(name) - 1)
            len_profile = self.str_(len(profile) - 1)
            source = cStringIO.StringIO(len_name + len_profile + name + profile)
            spice.encode(source, destination, major, minor)
        destination.close()
Encode all profiles and export them.
recipes/Python/577008_Profile_Manager_21/recipe-577008.py