本文整理汇总了Python中spyderlib.config.base.get_conf_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_conf_path函数的具体用法?Python get_conf_path怎么用?Python get_conf_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_conf_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_spyderplugins_mods
def get_spyderplugins_mods(io=False):
"""Import modules from plugins package and return the list"""
base_namespace = "spyplugins"
if io:
plugins_namespace = "io"
else:
plugins_namespace = "ui"
namespace = '.'.join([base_namespace, plugins_namespace])
# Import parent module
importlib.import_module(namespace)
# Create user directory
user_conf_path = get_conf_path()
user_plugin_basepath = osp.join(user_conf_path, base_namespace)
user_plugin_path = osp.join(user_conf_path, base_namespace,
plugins_namespace)
create_userplugins_files(user_plugin_basepath)
create_userplugins_files(user_plugin_path)
modlist, modnames = [], []
# The user plugins directory is given the priority when looking for modules
for plugin_path in [user_conf_path] + sys.path:
_get_spyderplugins(plugin_path, base_namespace, plugins_namespace,
modnames, modlist)
return modlist
示例2: save_session
def save_session(filename):
"""Save Spyder session"""
local_fname = get_conf_path(osp.basename(filename))
filename = osp.abspath(filename)
old_cwd = getcwd()
os.chdir(get_conf_path())
error_message = None
try:
tar = tarfile.open(local_fname, "w")
for fname in SAVED_CONFIG_FILES:
if osp.isfile(fname):
tar.add(fname)
tar.close()
shutil.move(local_fname, filename)
except Exception as error:
error_message = to_text_string(error)
os.chdir(old_cwd)
return error_message
示例3: load_plugin
def load_plugin(self):
"""Load the Rope introspection plugin"""
if not programs.is_module_installed('rope', ROPE_REQVER):
raise ImportError('Requires Rope %s' % ROPE_REQVER)
self.project = None
self.create_rope_project(root_path=get_conf_path())
submods = get_preferred_submodules()
if self.project is not None:
self.project.prefs.set('extension_modules', submods)
示例4: __init__
def __init__(
self,
parent=None,
namespace=None,
commands=[],
message=None,
max_line_count=300,
font=None,
exitfunc=None,
profile=False,
multithreaded=True,
light_background=True,
):
PythonShellWidget.__init__(self, parent, get_conf_path("history_internal.py"), profile)
self.set_light_background(light_background)
self.multithreaded = multithreaded
self.setMaximumBlockCount(max_line_count)
# For compatibility with ExtPythonShellWidget
self.is_ipykernel = False
if font is not None:
self.set_font(font)
# Allow raw_input support:
self.input_loop = None
self.input_mode = False
# KeyboardInterrupt support
self.interrupted = False # used only for not-multithreaded mode
self.sig_keyboard_interrupt.connect(self.keyboard_interrupt)
# Code completion / calltips
getcfg = lambda option: CONF.get("internal_console", option)
case_sensitive = getcfg("codecompletion/case_sensitive")
self.set_codecompletion_case(case_sensitive)
# keyboard events management
self.eventqueue = []
# Init interpreter
self.exitfunc = exitfunc
self.commands = commands
self.message = message
self.interpreter = None
self.start_interpreter(namespace)
# Clear status bar
self.status.emit("")
# Embedded shell -- requires the monitor (which installs the
# 'open_in_spyder' function in builtins)
if hasattr(builtins, "open_in_spyder"):
self.go_to_error.connect(self.open_with_external_spyder)
示例5: reset_session
def reset_session():
"""Remove all config files"""
print("*** Reset Spyder settings to defaults ***", file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if osp.isfile(cfg_fname):
os.remove(cfg_fname)
elif osp.isdir(cfg_fname):
shutil.rmtree(cfg_fname)
else:
continue
print("removing:", cfg_fname, file=STDERR)
示例6: get_spyderplugins_mods
def get_spyderplugins_mods(io=False):
"""Import modules from plugins package and return the list"""
# Create user directory
user_plugin_path = osp.join(get_conf_path(), USER_PLUGIN_DIR)
if not osp.isdir(user_plugin_path):
os.makedirs(user_plugin_path)
modlist, modnames = [], []
# The user plugins directory is given the priority when looking for modules
for plugin_path in [user_plugin_path] + sys.path:
_get_spyderplugins(plugin_path, io, modnames, modlist)
return modlist
示例7: load_plugin
def load_plugin(self):
"""Load the Rope introspection plugin"""
if not programs.is_module_installed('rope', ROPE_REQVER):
raise ImportError('Requires Rope %s' % ROPE_REQVER)
self.project = None
self.create_rope_project(root_path=get_conf_path())
submods = get_preferred_submodules()
actual = []
for submod in submods:
try:
imp.find_module(submod)
actual.append(submod)
except ImportError:
pass
if self.project is not None:
self.project.prefs.set('extension_modules', actual)
示例8: __init__
def __init__(self, parent, history_filename, profile=False):
"""
parent : specifies the parent widget
"""
ConsoleBaseWidget.__init__(self, parent)
SaveHistoryMixin.__init__(self)
# Prompt position: tuple (line, index)
self.current_prompt_pos = None
self.new_input_line = True
# History
self.histidx = None
self.hist_wholeline = False
assert is_text_string(history_filename)
self.history_filename = history_filename
self.history = self.load_history()
# Session
self.historylog_filename = CONF.get('main', 'historylog_filename',
get_conf_path('history.log'))
# Context menu
self.menu = None
self.setup_context_menu()
# Simple profiling test
self.profile = profile
# Buffer to increase performance of write/flush operations
self.__buffer = []
self.__timestamp = 0.0
self.__flushtimer = QTimer(self)
self.__flushtimer.setSingleShot(True)
self.__flushtimer.timeout.connect(self.flush)
# Give focus to widget
self.setFocus()
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('console')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
示例9: __init__
def __init__(self, plugin, name, history_filename, connection_file=None,
hostname=None, sshkey=None, password=None,
kernel_widget_id=None, menu_actions=None):
super(IPythonClient, self).__init__(plugin)
SaveHistoryMixin.__init__(self)
self.options_button = None
# stop button and icon
self.stop_button = None
self.stop_icon = ima.icon('stop')
self.connection_file = connection_file
self.kernel_widget_id = kernel_widget_id
self.hostname = hostname
self.sshkey = sshkey
self.password = password
self.name = name
self.get_option = plugin.get_option
self.shellwidget = IPythonShellWidget(config=self.shellwidget_config(),
local_kernel=False)
self.shellwidget.hide()
self.infowidget = WebView(self)
self.menu_actions = menu_actions
self.history_filename = get_conf_path(history_filename)
self.history = []
self.namespacebrowser = None
self.set_infowidget_font()
self.loading_page = self._create_loading_page()
self.infowidget.setHtml(self.loading_page,
QUrl.fromLocalFile(CSS_PATH))
vlayout = QVBoxLayout()
toolbar_buttons = self.get_toolbar_buttons()
hlayout = QHBoxLayout()
for button in toolbar_buttons:
hlayout.addWidget(button)
vlayout.addLayout(hlayout)
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addWidget(self.shellwidget)
vlayout.addWidget(self.infowidget)
self.setLayout(vlayout)
self.exit_callback = lambda: plugin.close_client(client=self)
示例10: load_session
def load_session(filename):
"""Load Spyder session"""
filename = osp.abspath(filename)
old_cwd = getcwd()
os.chdir(osp.dirname(filename))
error_message = None
renamed = False
try:
tar = tarfile.open(filename, "r")
extracted_files = tar.getnames()
# Rename original config files
for fname in extracted_files:
orig_name = get_conf_path(fname)
bak_name = get_conf_path(fname+'.bak')
if osp.isfile(bak_name):
os.remove(bak_name)
if osp.isfile(orig_name):
os.rename(orig_name, bak_name)
renamed = True
tar.extractall()
for fname in extracted_files:
shutil.move(fname, get_conf_path(fname))
except Exception as error:
error_message = to_text_string(error)
if renamed:
# Restore original config files
for fname in extracted_files:
orig_name = get_conf_path(fname)
bak_name = get_conf_path(fname+'.bak')
if osp.isfile(orig_name):
os.remove(orig_name)
if osp.isfile(bak_name):
os.rename(bak_name, orig_name)
finally:
# Removing backup config files
for fname in extracted_files:
bak_name = get_conf_path(fname+'.bak')
if osp.isfile(bak_name):
os.remove(bak_name)
os.chdir(old_cwd)
return error_message
示例11: load_plugin
def load_plugin(self):
"""Load the Rope introspection plugin"""
if not programs.is_module_installed('rope', ROPE_REQVER):
raise ImportError('Requires Rope %s' % ROPE_REQVER)
self.project = None
self.create_rope_project(root_path=get_conf_path())
示例12: import
from spyderlib.utils.dochelpers import getargtxt, getdoc, getsource, getobjdir, isdefined
from spyderlib.utils.bsdsocket import (
communicate,
read_packet,
write_packet,
PACKET_NOT_RECEIVED,
PICKLE_HIGHEST_PROTOCOL,
)
from spyderlib.utils.introspection.module_completion import module_completion
from spyderlib.config.base import get_conf_path, get_supported_types, DEBUG
from spyderlib.py3compat import getcwd, is_text_string, pickle, _thread
SUPPORTED_TYPES = {}
LOG_FILENAME = get_conf_path("monitor.log")
DEBUG_MONITOR = DEBUG >= 2
if DEBUG_MONITOR:
import logging
logging.basicConfig(filename=get_conf_path("monitor_debug.log"), level=logging.DEBUG)
REMOTE_SETTINGS = (
"check_all",
"exclude_private",
"exclude_uppercase",
"exclude_capitalized",
"exclude_unsupported",
"excluded_names",
示例13: __init__
def __init__(
self,
parent=None,
fname=None,
wdir=None,
history_filename=None,
show_icontext=True,
light_background=True,
menu_actions=None,
show_buttons_inside=True,
show_elapsed_time=True,
):
QWidget.__init__(self, parent)
self.menu_actions = menu_actions
self.run_button = None
self.kill_button = None
self.options_button = None
self.icontext_action = None
self.show_elapsed_time = show_elapsed_time
self.fname = fname
if wdir is None:
wdir = osp.dirname(osp.abspath(fname))
self.wdir = wdir if osp.isdir(wdir) else None
self.arguments = ""
self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename))
self.shell.set_light_background(light_background)
self.shell.execute.connect(self.send_to_process)
self.shell.sig_keyboard_interrupt.connect(self.keyboard_interrupt)
# Redirecting some SIGNALs:
self.shell.redirect_stdio.connect(lambda state: self.redirect_stdio.emit(state))
self.state_label = None
self.time_label = None
vlayout = QVBoxLayout()
toolbar_buttons = self.get_toolbar_buttons()
if show_buttons_inside:
self.state_label = QLabel()
hlayout = QHBoxLayout()
hlayout.addWidget(self.state_label)
hlayout.addStretch(0)
hlayout.addWidget(self.create_time_label())
hlayout.addStretch(0)
for button in toolbar_buttons:
hlayout.addWidget(button)
vlayout.addLayout(hlayout)
else:
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addWidget(self.get_shell_widget())
self.setLayout(vlayout)
self.resize(640, 480)
if parent is None:
self.setWindowIcon(self.get_icon())
self.setWindowTitle(_("Console"))
self.t0 = None
self.timer = QTimer(self)
self.process = None
self.is_closing = False
if show_buttons_inside:
self.update_time_label_visibility()
示例14: get_conf_path
import re
from time import time
import sys
from zipimport import zipimporter
from spyderlib.config.base import get_conf_path, running_in_mac_app
from spyderlib.py3compat import PY3
from pickleshare import PickleShareDB
#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------
# Path to the modules database
MODULES_PATH = get_conf_path('db')
# Time in seconds after which we give up
if os.name == 'nt':
TIMEOUT_GIVEUP = 30
else:
TIMEOUT_GIVEUP = 20
# Py2app only uses .pyc files for the stdlib when optimize=0,
# so we need to add it as another suffix here
if running_in_mac_app():
suffixes = imp.get_suffixes() + [('.pyc', 'rb', '2')]
else:
suffixes = imp.get_suffixes()
# Regular expression for the python import statement
示例15: main
def main():
"""
Start Spyder application.
If single instance mode is turned on (default behavior) and an instance of
Spyder is already running, this will just parse and send command line
options to the application.
"""
# Renaming old configuration files (the '.' prefix has been removed)
# (except for .spyder.ini --> spyder.ini, which is done in config/user.py)
if DEV is None:
cpath = get_conf_path()
for fname in os.listdir(cpath):
if fname.startswith('.'):
old, new = osp.join(cpath, fname), osp.join(cpath, fname[1:])
try:
os.rename(old, new)
except OSError:
pass
# Parse command line options
options, args = get_options()
# Store variable to be used in self.restart (restart spyder instance)
os.environ['SPYDER_ARGS'] = str(sys.argv[1:])
if CONF.get('main', 'single_instance') and not options.new_instance \
and not running_in_mac_app():
# Minimal delay (0.1-0.2 secs) to avoid that several
# instances started at the same time step in their
# own foots while trying to create the lock file
time.sleep(random.randrange(1000, 2000, 90)/10000.)
# Lock file creation
lock_file = get_conf_path('spyder.lock')
lock = lockfile.FilesystemLock(lock_file)
# Try to lock spyder.lock. If it's *possible* to do it, then
# there is no previous instance running and we can start a
# new one. If *not*, then there is an instance already
# running, which is locking that file
try:
lock_created = lock.lock()
except:
# If locking fails because of errors in the lockfile
# module, try to remove a possibly stale spyder.lock.
# This is reported to solve all problems with
# lockfile (See issue 2363)
try:
if os.name == 'nt':
if osp.isdir(lock_file):
import shutil
shutil.rmtree(lock_file, ignore_errors=True)
else:
if osp.islink(lock_file):
os.unlink(lock_file)
except:
pass
# Then start Spyder as usual and *don't* continue
# executing this script because it doesn't make
# sense
from spyderlib import spyder
spyder.main()
return
if lock_created:
# Start a new instance
if TEST is None:
atexit.register(lock.unlock)
from spyderlib import spyder
spyder.main()
else:
# Pass args to Spyder or print an informative
# message
if args:
send_args_to_spyder(args)
else:
print("Spyder is already running. If you want to open a new \n"
"instance, please pass to it the --new-instance option")
else:
from spyderlib import spyder
spyder.main()