本文整理汇总了Python中libs.Paths类的典型用法代码示例。如果您正苦于以下问题:Python Paths类的具体用法?Python Paths怎么用?Python Paths使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Paths类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: endSetup
def endSetup(self):
# get pio version
executable = os.path.join(self.env_bin_dir, 'pio')
cmd = ['\"' + executable + '\"', '--version']
out = childProcess(cmd)
pio_version = match(r"\w+\W \w+ (.+)", out[1]).group(1)
self.Preferences.set('pio_version', pio_version)
# save env paths
env_path = [self.env_bin_dir]
self.saveEnvPaths(env_path)
# copy menu
sys_os = Tools.getOsName()
preset_path = Paths.getPresetPath()
plg_path = Paths.getPluginPath()
dst = os.path.join(plg_path, 'Settings-Default', 'Main.sublime-menu')
if(sys_os == 'windows'):
src_path = os.path.join(preset_path, 'Main.sublime-menu.windows')
copy(src_path, dst)
elif(sys_os == 'osx'):
src_path = os.path.join(preset_path, 'Main.sublime-menu.osx')
copy(src_path, dst)
else:
src_path = os.path.join(preset_path, 'Main.sublime-menu.linux')
copy(src_path, dst)
# creating files (menu, completions, syntax)
generateFiles()
示例2: listIds
def listIds(self):
language_list_path = Paths.getLanguageList()
self.lang_params = JSONFile(language_list_path).getData()
language_path = Paths.getLanguagePath()
lang_file_paths = glob.glob(language_path + '/*.lang')
lang_file_names = [os.path.basename(p) for p in lang_file_paths]
self.ids_lang += [os.path.splitext(nam)[0] for nam in lang_file_names]
self.id_path_dict.update(dict(zip(self.ids_lang, lang_file_paths)))
self.ids_lang.sort(key=lambda _id: self.lang_params.get(_id)[1])
示例3: createSyntaxFile
def createSyntaxFile():
"""
Generate the syntax file based in the installed libraries
"""
try:
from . import Paths
from .JSONFile import JSONFile
except:
from libs import Paths
from libs.JSONFile import JSONFile
keywords = getKeywords()
LITERAL1s = []
KEYWORD1s = []
KEYWORD2s = []
KEYWORD3s = []
# set keywords
for k in keywords:
for w in k.get_keywords():
if 'LITERAL1' in w.get_type():
LITERAL1s.append(w.get_id())
if 'KEYWORD1' in w.get_type():
KEYWORD1s.append(w.get_id())
if 'KEYWORD2' in w.get_type():
KEYWORD2s.append(w.get_id())
if 'KEYWORD3' in w.get_type():
KEYWORD3s.append(w.get_id())
# formating
LITERAL1s = set(LITERAL1s)
LITERAL1s = '|'.join(LITERAL1s)
KEYWORD1s = set(KEYWORD1s)
KEYWORD1s = '|'.join(KEYWORD1s)
KEYWORD2s = set(KEYWORD2s)
KEYWORD2s = '|'.join(KEYWORD2s)
KEYWORD3s = set(KEYWORD3s)
KEYWORD3s = '|'.join(KEYWORD3s)
# get sintax preset
sintax_path = Paths.getSyntaxPath()
sintax_file = JSONFile(sintax_path)
sintax = sintax_file.readFile()
# replace words in sintax file
sintax = sintax.replace('${LITERAL1}', LITERAL1s)
sintax = sintax.replace('${KEYWORD1}', KEYWORD1s)
sintax = sintax.replace('${KEYWORD2}', KEYWORD2s)
sintax = sintax.replace('${KEYWORD3}', KEYWORD3s)
# Save File
file_path = Paths.getTmLanguage()
language_file = JSONFile(file_path)
language_file.writeFile(sintax)
示例4: removeEnvFromFile
def removeEnvFromFile(self, env):
"""
Removes the environment select from the platformio.ini file
Arguments:
env {string} -- environment to remove
"""
ini_path = self.Preferences.get('ini_path', False)
if(not ini_path):
return
found = False
write = False
buffer = ""
# exclude environment selected
ini_path = Paths.getFullIniPath(ini_path)
if(not os.path.isfile(ini_path)):
return
with open(ini_path) as file:
for line in file:
if(env in line and not found):
found = True
write = True
if(not found):
buffer += line
if(found and line == '\n'):
found = False
# save new platformio.ini
if(write):
with open(ini_path, 'w') as file:
file.write(buffer)
示例5: initSketchProject
def initSketchProject(self, chosen):
'''
command to initialize the board(s) selected by the user. This
function can only be use if the workig file is an IoT type
(checked by isIOTFile)
'''
# check if it was already initialized
ini_path = Paths.getFullIniPath(self.dir)
if(os.path.isfile(ini_path)):
with open(ini_path) as file:
if(chosen in file.read()):
return
init_board = '--board=%s ' % chosen
if(not init_board):
current_time = time.strftime('%H:%M:%S')
msg = 'none_board_sel_{0}'
self.message_queue.put(msg, current_time)
self.Commands.error_running = True
return
command = ['init', '%s' % (init_board)]
self.Commands.runCommand(command)
if(not self.Commands.error_running):
if(self.is_native):
self.Preferences.set('init_queue', '')
if(not self.is_native and self.src):
self.overrideSrc(self.dir, self.src)
示例6: removePreferences
def removePreferences():
from shutil import rmtree
try:
from . import Paths
except:
from libs import Paths
plug_path = Paths.getPluginPath()
dst = os.path.join(plug_path, 'Settings-Default', 'Main.sublime-menu')
user_path = Paths.getDeviotUserPath()
main_menu = Paths.getSublimeMenuPath()
# remove files
rmtree(user_path, ignore_errors=False)
os.remove(main_menu)
os.remove(dst)
示例7: createCompletions
def createCompletions():
"""
Generate the completions file
"""
try:
from . import Paths
from .JSONFile import JSONFile
except:
from libs import Paths
from libs.JSONFile import JSONFile
keywords = getKeywords()
keyword_ids = []
user_path = Paths.getDeviotUserPath()
completion_path = os.path.join(user_path, 'Deviot.sublime-completions')
cpp_keywords = ['define', 'error', 'include', 'elif', 'endif']
cpp_keywords += ['ifdef', 'ifndef', 'undef', 'line', 'pragma']
for k in keywords:
for w in k.get_keywords():
keyword_ids += [w.get_id() for w in k.get_keywords()]
keyword_ids = set(keyword_ids)
keyword_ids = [word for word in keyword_ids]
completions_dict = {'scope': 'source.iot'}
completions_dict['completions'] = keyword_ids
file = JSONFile(completion_path)
file.setData(completions_dict)
示例8: saveCodeInFile
def saveCodeInFile(self, view):
"""
If the sketch in the current view has been not saved, it generate
a random name and stores in a temp folder.
Arguments: view {ST Object} -- Object with multiples options of ST
"""
ext = '.ino'
tmp_path = Paths.getTempPath()
file_name = str(time.time()).split('.')[0]
file_path = os.path.join(tmp_path, file_name)
file_path = os.path.join(file_path, 'src')
os.makedirs(file_path)
full_path = file_name + ext
full_path = os.path.join(file_path, full_path)
region = sublime.Region(0, view.size())
text = view.substr(region)
file = JSONFile(full_path)
file.writeFile(text)
view.set_scratch(True)
window = view.window()
window.run_command('close')
view = window.open_file(full_path)
return (True, view)
示例9: __init__
def __init__(self):
self.Preferences = Preferences()
self.base_dir = Paths.getDeviotUserPath()
self.env_dir = Paths.getEnvDir()
self.env_bin_dir = Paths.getEnvBinDir()
self.cache_dir = Paths.getCacheDir()
self.env_file = Paths.getEnvFile()
self.cached_file = False
# console
window = sublime.active_window()
console_name = 'Deviot|Pio_Install' + str(time.time())
console = Messages.Console(window, name=console_name)
# Queue for the user console
self.message_queue = Messages.MessageQueue(console)
示例10: endSetup
def endSetup(self):
try:
from .PlatformioCLI import generateFiles
except:
from libs.PlatformioCLI import generateFiles
# save env paths
if(self.os != 'osx'):
env_path = [self.env_bin_dir]
self.saveEnvPaths(env_path)
# get pio version
if(self.os == 'osx'):
executable = os.path.join(self.env_bin_dir, 'python')
cmd = ['"%s"' % (executable), '-m', 'platformio', '--version']
else:
executable = os.path.join(self.env_bin_dir, 'pio')
cmd = ['"%s"' % (executable), '--version']
out = childProcess(cmd)
pio_version = match(r"\w+\W \w+ (.+)", out[1]).group(1)
self.Preferences.set('pio_version', pio_version)
# copy menu
sys_os = Tools.getOsName()
preset_path = Paths.getPresetPath()
plg_path = Paths.getPluginPath()
dst = os.path.join(plg_path, 'Settings-Default', 'Main.sublime-menu')
if(sys_os == 'windows'):
if(platform.release() == '7'):
src_path = os.path.join(preset_path, 'Main.sublime-menu.w7')
else:
src_path = os.path.join(preset_path, 'Main.sublime-menu.windows')
copy(src_path, dst)
elif(sys_os == 'osx'):
src_path = os.path.join(preset_path, 'Main.sublime-menu.osx')
copy(src_path, dst)
else:
src_path = os.path.join(preset_path, 'Main.sublime-menu.linux')
copy(src_path, dst)
# creating files (menu, completions, syntax)
sublime.set_timeout(generateFiles, 0)
self.Preferences.set('protected', True)
self.Preferences.set('enable_menu', True)
示例11: getSublimeMenu
def getSublimeMenu(self, user_path=False):
"""
Get the data of the different files that make up the main menu
Keyword Arguments:
user_path {boolean} -- True: get file from Packages/Deviot/Preset
--False: get file from Packages/User/Deviot/Preset
(Defaul:False)
"""
menu_path = Paths.getSublimeMenuPath(user_path)
menu_file = JSONFile(menu_path)
menu_data = menu_file.getData()
return menu_data
示例12: getTemplateMenu
def getTemplateMenu(self, file_name, user_path=False):
"""
Get the template menu file to be modified by the different methods
Arguments
file_name {string} -name of the file including the extension
user_path {boolean} -- True: get file from Packages/Deviot/Preset
--False: get file from Packages/User/Deviot/Preset
(Defaul:False)
"""
file_path = Paths.getTemplateMenuPath(file_name, user_path)
preset_file = JSONFile(file_path)
preset_data = preset_file.getData()
return preset_data
示例13: saveLibraryData
def saveLibraryData(self, data, file_name):
"""
Stores the data of the libraries in a json file
Arguments:
data {json}
json data with the libraries
file_name {string}
name of the json file
"""
libraries_path = Paths.getLibraryPath()
library_path = os.path.join(libraries_path, file_name)
libraries = JSONFile(library_path)
libraries.setData(data)
libraries.saveData()
示例14: saveTemplateMenu
def saveTemplateMenu(self, data, file_name, user_path=False):
"""
Save the menu template in json format
Arguments:
data {json} -- st json object with the data of the menu
file_name {string} -- name of the file including the extension
user_path {boolean} -- True: save file in Packages/Deviot/Preset
--False: save file in Packages/User/Deviot/Preset
(Defaul:False)
"""
file_path = Paths.getTemplateMenuPath(file_name, user_path)
preset_file = JSONFile(file_path)
preset_file.setData(data)
preset_file.saveData()
示例15: getLibrary
def getLibrary(self, file_name):
"""
Get a specific json file and return the data
Arguments:
file_name {string}
Json file name where is stored the library data
Returns:
[dict] -- Dictionary with the library data
"""
plugin_path = Paths.getLibraryPath()
library_path = os.path.join(plugin_path, file_name)
libraries = JSONFile(library_path).getData()
return libraries