当前位置: 首页>>代码示例>>Python>>正文


Python path.expand_path函数代码示例

本文整理汇总了Python中mopidy.utils.path.expand_path函数的典型用法代码示例。如果您正苦于以下问题:Python expand_path函数的具体用法?Python expand_path怎么用?Python expand_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了expand_path函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_old_locations

def check_old_locations():
    dot_mopidy_dir = path.expand_path(b'~/.mopidy')
    if os.path.isdir(dot_mopidy_dir):
        logger.warning(
            'Old Mopidy dot dir found at %s. Please migrate your config to '
            'the ini-file based config format. See release notes for further '
            'instructions.', dot_mopidy_dir)

    old_settings_file = path.expand_path(b'$XDG_CONFIG_DIR/mopidy/settings.py')
    if os.path.isfile(old_settings_file):
        logger.warning(
            'Old Mopidy settings file found at %s. Please migrate your '
            'config to the ini-file based config format. See release notes '
            'for further instructions.', old_settings_file)
开发者ID:ArcherSys,项目名称:Peridot,代码行数:14,代码来源:__main__.py

示例2: deserialize

 def deserialize(self, value):
     value = value.strip()
     expanded = path.expand_path(value)
     validators.validate_required(value, self._required)
     validators.validate_required(expanded, self._required)
     if not value or expanded is None:
         return None
     return ExpandedPath(value, expanded)
开发者ID:abarisain,项目名称:mopidy,代码行数:8,代码来源:types.py

示例3: __getattr__

    def __getattr__(self, attr):
        if not self._is_setting(attr):
            return

        current = self.current # bind locally to avoid copying+updates
        if attr not in current:
            raise SettingsError(u'Setting "%s" is not set.' % attr)

        value = current[attr]
        if isinstance(value, basestring) and len(value) == 0:
            raise SettingsError(u'Setting "%s" is empty.' % attr)
        if not value:
            return value
        if attr.endswith('_PATH') or attr.endswith('_FILE'):
            value = path.expand_path(value)
        return value
开发者ID:Dvad,项目名称:mopidy,代码行数:16,代码来源:settings.py

示例4: create_file_structures_and_config

def create_file_structures_and_config(args, extensions):
    path.get_or_create_dir(b'$XDG_DATA_DIR/mopidy')
    path.get_or_create_dir(b'$XDG_CONFIG_DIR/mopidy')

    # Initialize whatever the last config file is with defaults
    config_file = args.config_files[-1]
    if os.path.exists(path.expand_path(config_file)):
        return

    try:
        default = config_lib.format_initial(extensions)
        path.get_or_create_file(config_file, mkdir=False, content=default)
        logger.info('Initialized %s with default config', config_file)
    except IOError as e:
        logger.warning('Unable to initialize %s with default config: %s',
                       config_file, e)
开发者ID:Shugyousha,项目名称:mopidy,代码行数:16,代码来源:__main__.py

示例5: test_xdg_subsititution_unknown

 def test_xdg_subsititution_unknown(self):
     self.assertIsNone(path.expand_path(b"/tmp/$XDG_INVALID_DIR/foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例6: test_xdg_subsititution

 def test_xdg_subsititution(self):
     self.assertEqual(glib.get_user_data_dir() + b"/foo", path.expand_path(b"$XDG_DATA_DIR/foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例7: test_abspath

 def test_abspath(self):
     self.assertEqual(os.path.abspath(b"./foo"), path.expand_path(b"./foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例8: test_home_dir_expansion

 def test_home_dir_expansion(self):
     self.assertEqual(os.path.expanduser(b"~/foo"), path.expand_path(b"~/foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例9: test_absolute_path

 def test_absolute_path(self):
     self.assertEqual(b"/tmp/foo", path.expand_path(b"/tmp/foo"))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例10: test_empty_path

 def test_empty_path(self):
     self.assertEqual(os.path.abspath(b"."), path.expand_path(b""))
开发者ID:karlpilkington,项目名称:mopidy,代码行数:2,代码来源:test_path.py

示例11: test_empty_path

 def test_empty_path(self):
     self.assertEqual(os.path.abspath(b'.'), path.expand_path(b''))
开发者ID:Halfnhav,项目名称:mopidy,代码行数:2,代码来源:path_test.py

示例12: test_xdg_subsititution_unknown

 def test_xdg_subsititution_unknown(self):
     self.assertEqual(
         '/tmp/$XDG_INVALID_DIR/foo',
         path.expand_path('/tmp/$XDG_INVALID_DIR/foo'))
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:4,代码来源:path_test.py

示例13: test_abspath

 def test_abspath(self):
     self.assertEqual(os.path.abspath('./foo'), path.expand_path('./foo'))
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:2,代码来源:path_test.py


注:本文中的mopidy.utils.path.expand_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。