当前位置: 首页>>代码示例>>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;未经允许,请勿转载。