コード例 #1
0
def getUserFilesDirectory():
    global _userFilesDirectory
    if _userFilesDirectory is not None:
        return _userFilesDirectory

    if hasattr(sys, 'frozen'):
        # On Windows, filenames are UTF-16 encoded.
        # Filenames are defined as UTF-16.
        #
        # However, sys.executable is codepage-encoded. Codepages cannot represent all possible
        # filenames, so we must get the exe filename using this wide-character API.
        # Wide-character APIs in pywin32 always return a `unicode`.
        #
        # Filenames must be passed to Python's filesystem functions as `unicode` to call the
        # wide-character forms of the underlying Win32 APIs.
        #
        # We take care not to store filenames as `bytes`, as this causes the filesystem functions
        # to use the legacy codepage APIs.

        import win32api
        exe = win32api.GetModuleFileNameW(None)
        assert os.path.exists(exe), "MCEdit executable %r does not exist! Something is very wrong." % exe
        folder = os.path.dirname(exe)
        dataDir = os.path.join(folder, "MCEdit 2 Files")

    else:
        folder = os.path.dirname(resources.getSrcFolder())
        dataDir = os.path.join(folder, "MCEdit User Data")

    if not os.path.exists(dataDir):
        os.makedirs(dataDir)

    _userFilesDirectory = dataDir
    return dataDir
コード例 #2
0
ファイル: gen_ui.py プロジェクト: pamunoz/mcedit2
def compile_ui():
    from mcedit2.util import resources
    if not resources.isSrcCheckout():
        return

    src = resources.getSrcFolder()
    uiDir = os.path.join(src, "mcedit2", "ui")

    from pysideuic import compileUiDir

    compileUiDir(uiDir, recurse=True)
コード例 #3
0
ファイル: gen_ui.py プロジェクト: wcpe/mcedit2
def compile_ui():
    from mcedit2.util import resources
    if not resources.isSrcCheckout():
        return

    src = resources.getSrcFolder()
    uiDir = os.path.join(src, "mcedit2", "ui")

    from pysideuic import compileUiDir

    log.info("Compiling .ui files...")
    compileUiDir(uiDir, recurse=True)
    log.info("Done.")
コード例 #4
0
ファイル: posix.py プロジェクト: mcedit/mcedit2
def getUserFilesDirectory():
    # On Linux, the FS encoding is given by the current locale
    # Linux filenames are defined to be bytestrings.

    # We handle filenames internally as 'unicode', so decode 'sys.argv[0]'
    # If a linux filename cannot be decoded with the current locale, ignore it.
    # If this filename is the script filename, you lose.

    if resources.isSrcCheckout():
        # Source checkouts don't use the same folder as regular installs.
        dataDir = os.path.join(os.path.dirname(resources.getSrcFolder()), "MCEdit 2 Files")
    else:
        dataDir = os.path.expanduser(u"~/.mcedit2")

    if not os.path.exists(dataDir):
        os.makedirs(dataDir)

    return dataDir
コード例 #5
0
ファイル: posix.py プロジェクト: wcpe/mcedit2
def getUserFilesDirectory():
    # On Linux, the FS encoding is given by the current locale
    # Linux filenames are defined to be bytestrings.

    # We handle filenames internally as 'unicode', so decode 'sys.argv[0]'
    # If a linux filename cannot be decoded with the current locale, ignore it.
    # If this filename is the script filename, you lose.

    if resources.isSrcCheckout():
        # Source checkouts don't use the same folder as regular installs.
        dataDir = os.path.join(os.path.dirname(resources.getSrcFolder()),
                               "MCEdit 2 Files")
    else:
        dataDir = os.path.expanduser(u"~/.mcedit2")

    if not os.path.exists(dataDir):
        os.makedirs(dataDir)

    return dataDir
コード例 #6
0
ファイル: mac.py プロジェクト: KevinKelley/mcedit2
def getUserFilesDirectory():

    # TODO if sys.getattr('frozen', False):
    # TODO os.getenv('RESOURCEPATH') or sys.getattr('_MEIPASS'), etc etc...

    # On OS X, the FS encoding is always UTF-8
    # OS X filenames are defined to be UTF-8 encoded.
    # We internally handle filenames as unicode.

    if resources.isSrcCheckout():
        # Source checkouts don't use the same folder as regular installs.
        dataDir = os.path.join(os.path.dirname(resources.getSrcFolder()), "MCEdit User Data")
    else:
        dataDir = os.path.expanduser(u"~/Documents/MCEdit 2 Files")

    if not os.path.exists(dataDir):
        os.makedirs(dataDir)

    return dataDir
コード例 #7
0
def getUserFilesDirectory():

    # TODO if sys.getattr('frozen', False):
    # TODO os.getenv('RESOURCEPATH') or sys.getattr('_MEIPASS'), etc etc...

    # On OS X, the FS encoding is always UTF-8
    # OS X filenames are defined to be UTF-8 encoded.
    # We internally handle filenames as unicode.

    if resources.isSrcCheckout():
        # Source checkouts don't use the same folder as regular installs.
        dataDir = os.path.join(os.path.dirname(resources.getSrcFolder()),
                               "MCEdit 2 Files")
    else:
        dataDir = os.path.expanduser(u"~/Documents/MCEdit 2 Files")

    if not os.path.exists(dataDir):
        os.makedirs(dataDir)

    return dataDir