當前位置: 首頁>>代碼示例>>Python>>正文


Python appdirs.user_data_dir方法代碼示例

本文整理匯總了Python中appdirs.user_data_dir方法的典型用法代碼示例。如果您正苦於以下問題:Python appdirs.user_data_dir方法的具體用法?Python appdirs.user_data_dir怎麽用?Python appdirs.user_data_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在appdirs的用法示例。


在下文中一共展示了appdirs.user_data_dir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: data_dir

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def data_dir(self) -> Path:
        try:
            from appdirs import user_data_dir
        except ImportError:

            # linux
            path = Path.home() / '.local' / 'share'
            if path.exists():
                return path / 'dephell'

            # mac os
            path = Path.home() / 'Library' / 'Application Support'
            if path.exists():
                return path / 'dephell'

            self.pip_main(['install', 'appdirs'])
            from appdirs import user_data_dir

        return Path(user_data_dir('dephell')) 
開發者ID:dephell,項目名稱:dephell,代碼行數:21,代碼來源:install.py

示例2: getDataDirectory

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def getDataDirectory(moduleName=None):
    """
    Get a data directory for the caller function, or C{moduleName} if given.

    @param moduleName: The module name if you don't wish to have the caller's
        module.
    @type moduleName: L{str}

    @returns: A directory for putting data in.
    @rtype: L{str}
    """
    if not moduleName:
        caller = currentframe(1)
        moduleName = inspect.getmodule(caller).__name__

    return appdirs.user_data_dir(moduleName) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:_appdirs.py

示例3: load_combo_catalog

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def load_combo_catalog():
    """Load a union of the user and global catalogs for convenience"""
    user_dir = user_data_dir()
    global_dir = global_data_dir()
    desc = 'Generated from data packages found on your intake search path'
    cat_dirs = []
    if os.path.isdir(user_dir):
        cat_dirs.append(user_dir + '/*.yaml')
        cat_dirs.append(user_dir + '/*.yml')
    if os.path.isdir(global_dir):
        cat_dirs.append(global_dir + '/*.yaml')
        cat_dirs.append(global_dir + '/*.yml')
    for path_dir in conf.get('catalog_path', []):
        if path_dir != '':
            if not path_dir.endswith(('yaml', 'yml')):
                cat_dirs.append(path_dir + '/*.yaml')
                cat_dirs.append(path_dir + '/*.yml')
            else:
                cat_dirs.append(path_dir)

    return YAMLFilesCatalog(cat_dirs, name='builtin', description=desc) 
開發者ID:intake,項目名稱:intake,代碼行數:23,代碼來源:default.py

示例4: get_windows_directories

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def get_windows_directories() -> typing.Tuple[str, str, str]:
    from lbry.winpaths import get_path, FOLDERID, UserHandle, \
        PathNotFoundException  # pylint: disable=import-outside-toplevel

    try:
        download_dir = get_path(FOLDERID.Downloads, UserHandle.current)
    except PathNotFoundException:
        download_dir = os.getcwd()

    # old
    appdata = get_path(FOLDERID.RoamingAppData, UserHandle.current)
    data_dir = os.path.join(appdata, 'lbrynet')
    lbryum_dir = os.path.join(appdata, 'lbryum')
    if os.path.isdir(data_dir) or os.path.isdir(lbryum_dir):
        return data_dir, lbryum_dir, download_dir

    # new
    data_dir = user_data_dir('lbrynet', 'lbry')
    lbryum_dir = user_data_dir('lbryum', 'lbry')
    return data_dir, lbryum_dir, download_dir 
開發者ID:lbryio,項目名稱:lbry-sdk,代碼行數:22,代碼來源:conf.py

示例5: get_linux_directories

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def get_linux_directories() -> typing.Tuple[str, str, str]:
    try:
        with open(os.path.join(user_config_dir(), 'user-dirs.dirs'), 'r') as xdg:
            down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)', xdg.read())
        if down_dir:
            down_dir = re.sub(r'\$HOME', os.getenv('HOME') or os.path.expanduser("~/"), down_dir.group(1))
            download_dir = re.sub('\"', '', down_dir)
    except OSError:
        download_dir = os.getenv('XDG_DOWNLOAD_DIR')
    if not download_dir:
        download_dir = os.path.expanduser('~/Downloads')

    # old
    data_dir = os.path.expanduser('~/.lbrynet')
    lbryum_dir = os.path.expanduser('~/.lbryum')
    if os.path.isdir(data_dir) or os.path.isdir(lbryum_dir):
        return data_dir, lbryum_dir, download_dir

    # new
    return user_data_dir('lbry/lbrynet'), user_data_dir('lbry/lbryum'), download_dir 
開發者ID:lbryio,項目名稱:lbry-sdk,代碼行數:22,代碼來源:conf.py

示例6: check_legacy_v2

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def check_legacy_v2(self):
        """ Look for legacy wallet and move to new directory
        """
        appname = "steem"
        appauthor = "Fabian Schuh"
        storageDatabase = "steem.sqlite"
        data_dir = user_data_dir(appname, appauthor)
        sqlDataBaseFile = os.path.join(data_dir, storageDatabase)

        if os.path.isdir(data_dir) and not os.path.exists(self.sqlDataBaseFile):
            # Move whole directory
            try:
                shutil.copytree(data_dir, self.data_dir)
            except FileExistsError:
                pass
            # Copy piston.sql to steem.sql (no deletion!)
            shutil.copy(sqlDataBaseFile, self.sqlDataBaseFile)
            log.info("Your settings have been moved to {}".format(self.sqlDataBaseFile)) 
開發者ID:xeroc,項目名稱:piston-lib,代碼行數:20,代碼來源:storage.py

示例7: __init__

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def __init__(self, *args, **kwargs):
        appauthor = "Fabian Schuh"
        appname = kwargs.get("appname", "graphene")
        data_dir = kwargs.get("data_dir", user_data_dir(appname, appauthor))

        if "profile" in kwargs:
            self.storageDatabase = "{}.sqlite".format(kwargs["profile"])
        else:
            self.storageDatabase = "{}.sqlite".format(appname)

        self.sqlite_file = os.path.join(data_dir, self.storageDatabase)

        """ Ensure that the directory in which the data is stored
            exists
        """
        if os.path.isdir(data_dir):  # pragma: no cover
            return
        else:  # pragma: no cover
            os.makedirs(data_dir) 
開發者ID:xeroc,項目名稱:python-graphenelib,代碼行數:21,代碼來源:sqlite.py

示例8: __init__

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def __init__(self):
        if not ConfigStore.store:
            print "ConfigStoreShelve.__init__"
            self.app_data_dir = user_data_dir('kotori', 'daqzilla')
            if not os.path.exists(self.app_data_dir):
                os.makedirs(self.app_data_dir)
            self.config_file = os.path.join(self.app_data_dir, 'config')
            ConfigStore.store = shelve.open(self.config_file, writeback=True) 
開發者ID:daq-tools,項目名稱:kotori,代碼行數:10,代碼來源:common.py

示例9: go

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def go():
        dialog = IDAngrConnectDialog()
        r = dialog.exec_()
        if r == QtWidgets.QDialog.Accepted:
            if dialog.ui.saveBox.isChecked():
                config = {
                    "host": dialog.ui.hostTxt.displayText(),
                    "port": int(dialog.ui.portTxt.displayText()),
                    "save": True,
                    "local": dialog.ui.localBox.isChecked()
                }
                mkpath(user_data_dir("IDAngr", "IDA Pro"))
                with open(config_file, "w") as f:
                    json.dump(config, f, indent=4)
            
            try:
                if dialog.ui.localBox.isChecked():
                    manage.init(use_pin=dialog.ui.pinBox.isChecked())
                else:
                    manage.init(True, dialog.ui.hostTxt.displayText(), int(dialog.ui.portTxt.displayText()), use_pin=dialog.ui.pinBox.isChecked())
            except Exception as ee:
                QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'IDAngr init error', str(ee)).exec_()
                return False
            
            return True
        return False 
開發者ID:andreafioraldi,項目名稱:IDAngr,代碼行數:28,代碼來源:init_gui.py

示例10: get_dbhash_file_path

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def get_dbhash_file_path():
    if default_dbhash_file:
        return default_dbhash_file
    try:
        dbhash_file = os.path.join(config.DATA_DIR, "dbhashes.txt")
    except:
        dbhash_file = os.path.join(appdirs.user_data_dir(appauthor='Counterparty', appname='counterblockd', roaming=True), "dbhashes.txt")
    return dbhash_file 
開發者ID:CounterpartyXCP,項目名稱:counterblock,代碼行數:10,代碼來源:tests.py

示例11: get_dirs

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def get_dirs():
    import appdirs
    data_dir = appdirs.user_data_dir(appauthor=XCP_NAME, appname=APP_NAME, roaming=True)
    config_dir = appdirs.user_config_dir(appauthor=XCP_NAME, appname=APP_NAME, roaming=True)
    log_dir = appdirs.user_log_dir(appauthor=XCP_NAME, appname=APP_NAME)
    return data_dir, config_dir, log_dir 
開發者ID:CounterpartyXCP,項目名稱:counterblock,代碼行數:8,代碼來源:config.py

示例12: get_myterraria

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def get_myterraria():
    import os

    if os.name == "nt":
        # get the my documents folder in windows. on other OS it will fail somewhere
        import ctypes

        dll = ctypes.windll.shell32
        buf = ctypes.create_unicode_buffer(300)
        dll.SHGetSpecialFolderPathW(None, buf, 0x0005, False)

        p = Path(buf.value) / "My Games" / "Terraria"
    else:
        p = appdirs.user_data_dir('Terraria')
    return Path(p) 
開發者ID:Berserker66,項目名稱:omnitool,代碼行數:17,代碼來源:tinterface.py

示例13: load_user_catalog

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def load_user_catalog():
    """Return a catalog for the platform-specific user Intake directory"""
    cat_dir = user_data_dir()
    if not os.path.isdir(cat_dir):
        return Catalog()
    else:
        return YAMLFilesCatalog(cat_dir) 
開發者ID:intake,項目名稱:intake,代碼行數:9,代碼來源:default.py

示例14: user_data_dir

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def user_data_dir():
    """Return the user Intake catalog directory"""
    return appdirs.user_data_dir(appname='intake', appauthor='intake') 
開發者ID:intake,項目名稱:intake,代碼行數:5,代碼來源:default.py

示例15: user_catalog

# 需要導入模塊: import appdirs [as 別名]
# 或者: from appdirs import user_data_dir [as 別名]
def user_catalog():
    target_catalog = copy_test_file('catalog1.yml',
                                    appdirs.user_data_dir(appname='intake',
                                                          appauthor='intake'))
    yield target_catalog
    # Remove the file, but not the directory (because there might be other
    # files already there)
    os.remove(target_catalog) 
開發者ID:intake,項目名稱:intake,代碼行數:10,代碼來源:test_top_level.py


注:本文中的appdirs.user_data_dir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。