# vim: ts=4 et sts=4 sw=4 autoindent

"""
Adapted from Thomas Heller's code posted to the py2exe mailing list.
"""

import imp, os, sys

class Win32HelperMixin(object):

    def main_is_frozen(self):
       return (hasattr(sys, "frozen") or # new py2exe
               hasattr(sys, "importers") # old py2exe
               or imp.is_frozen("__main__")) # tools/freeze

    def get_main_dir(self):
       if self.main_is_frozen():
           return os.path.dirname(sys.executable)
       return os.path.dirname(sys.argv[0])
