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


Python AppLocation.get_data_path方法代码示例

本文整理汇总了Python中openlp.core.utils.AppLocation.get_data_path方法的典型用法代码示例。如果您正苦于以下问题:Python AppLocation.get_data_path方法的具体用法?Python AppLocation.get_data_path怎么用?Python AppLocation.get_data_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlp.core.utils.AppLocation的用法示例。


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

示例1: get_data_path_with_custom_location_test

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_data_path [as 别名]
 def get_data_path_with_custom_location_test(self):
     """
     Test the AppLocation.get_data_path() method when a custom location is set in the settings
     """
     with patch(u'openlp.core.utils.Settings') as mocked_class,\
          patch(u'openlp.core.utils.os') as mocked_os:
         # GIVEN: A mocked out Settings class which returns a custom data location
         mocked_settings = mocked_class.return_value
         mocked_settings.contains.return_value = True
         mocked_settings.value.return_value.toString.return_value = u'custom/dir'
         mocked_os.path.normpath.return_value = u'custom/dir'
         # WHEN: we call AppLocation.get_data_path()
         data_path = AppLocation.get_data_path()
         # THEN: the mocked Settings methods were called and the value returned was our set up value
         mocked_settings.contains.assert_called_with(u'advanced/data path')
         mocked_settings.value.assert_called_with(u'advanced/data path')
         assert data_path == u'custom/dir', u'Result should be "custom/dir"'
开发者ID:marmyshev,项目名称:transitions,代码行数:19,代码来源:test_applocation.py

示例2: get_data_path_test

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_data_path [as 别名]
 def get_data_path_test(self):
     """
     Test the AppLocation.get_data_path() method
     """
     with patch(u'openlp.core.utils.Settings') as mocked_class, \
          patch(u'openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
          patch(u'openlp.core.utils.check_directory_exists') as mocked_check_directory_exists, \
          patch(u'openlp.core.utils.os') as mocked_os:
         # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
         mocked_settings = mocked_class.return_value
         mocked_settings.contains.return_value = False
         mocked_get_directory.return_value = u'test/dir'
         mocked_check_directory_exists.return_value = True
         mocked_os.path.normpath.return_value = u'test/dir'
         # WHEN: we call AppLocation.get_data_path()
         data_path = AppLocation.get_data_path()
         # THEN: check that all the correct methods were called, and the result is correct
         mocked_settings.contains.assert_called_with(u'advanced/data path')
         mocked_get_directory.assert_called_with(AppLocation.DataDir)
         mocked_check_directory_exists.assert_called_with(u'test/dir')
         assert data_path == u'test/dir', u'Result should be "test/dir"'
开发者ID:marmyshev,项目名称:transitions,代码行数:23,代码来源:test_applocation.py

示例3: get_files

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_data_path [as 别名]
    def get_files(section=None, extension=None):
        """
        Get a list of files from the data files path.

        ``section``
            Defaults to *None*. The section of code getting the files - used to load from a section's data subdirectory.

        ``extension``
            Defaults to *None*. The extension to search for.
        """
        path = AppLocation.get_data_path()
        if section:
            path = os.path.join(path, section)
        try:
            files = os.listdir(path)
        except OSError:
            return []
        if extension:
            return [filename for filename in files if extension == os.path.splitext(filename)[1]]
        else:
            # no filtering required
            return files
开发者ID:marmyshev,项目名称:transitions,代码行数:24,代码来源:settingsmanager.py

示例4: load

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_data_path [as 别名]
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # The max recent files value does not have an interface and so never
     # gets actually stored in the settings therefore the default value of
     # 20 will always be used.
     self.recent_spin_box.setMaximum(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
         settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.default_color = settings.value('default color')
     self.default_file_edit.setText(settings.value('default image'))
     self.slide_limits = settings.value('slide limits')
     # Prevent the dialog displayed by the alternate_rows_check_box to display.
     self.alternate_rows_check_box.blockSignals(True)
     self.alternate_rows_check_box.setChecked(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     if self.slide_limits == SlideLimits.End:
         self.end_slide_radio_button.setChecked(True)
     elif self.slide_limits == SlideLimits.Wrap:
         self.wrap_slide_radio_button.setChecked(True)
     else:
         self.next_item_radio_button.setChecked(True)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     if not os.path.exists(self.current_data_path):
         log.error('Data path not found %s' % self.current_data_path)
         answer = QtGui.QMessageBox.critical(self,
             translate('OpenLP.AdvancedTab', 'Data Directory Error'),
             translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
             'This data directory was previously changed from the OpenLP '
             'default location.  If the new location was on removable '
             'media, that media needs to be made available.\n\n'
             'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
             'Click "Yes" to reset the data directory to the default '
             'location.').replace('%s', self.current_data_path),
             QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
             QtGui.QMessageBox.No)
         if answer == QtGui.QMessageBox.No:
             log.info('User requested termination')
             self.main_window.clean_up()
             sys.exit()
         # Set data location to default.
         settings.remove('advanced/data path')
         self.current_data_path = AppLocation.get_data_path()
         log.warning('User requested data path set to default %s' % self.current_data_path)
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     self.default_color_button.setStyleSheet('background-color: %s' % self.default_color)
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:73,代码来源:advancedtab.py


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