def __init__(self, username, password, parent=None): self.parent = parent QObject.__init__(self, self.parent) # Set appdata path, this will end up in something like ~/.config/jayme-github/SteamIdle/ self._appdata_path = os.path.join( os.path.dirname(QDir.toNativeSeparators(self.settings.fileName())), 'SteamIdle' ) for p in (os.path.dirname(QDir.toNativeSeparators(self.settings.fileName())), self._appdata_path): if not os.path.isdir(p): os.mkdir(p, stat.S_IRWXU) self.logger.debug('_appdata_path: "%s"', self._appdata_path) SteamWebBrowser.__init__(self, username=username, password=password)
def get_user_query_folder(over_write=False): """ Get the user folder for queries. For instance on linux : ~/.qgis2/QuickOSM/queries @rtype: str @return: path """ folder = get_QuickOSM_folder() queries_folder = join(folder, "queries") if not QDir(queries_folder).exists() or over_write: folder = join(dirname(dirname(dirname(abspath(__file__)))), "queries") copy_tree(folder, QDir.toNativeSeparators(queries_folder)) return unicode(QDir.toNativeSeparators(queries_folder))
def get_open_file_names(*args, **kwargs): filenames = [] for filename in QFileDialog.getOpenFileNames(*args, **kwargs): filenames.append(QDir.toNativeSeparators(filename)) return filenames
def get_save_file_name(*args, **kwargs): filename = QFileDialog.getSaveFileName(*args, **kwargs) if len(filename) > 0: filename = QDir.toNativeSeparators(filename) return filename
def testQgsSVGFillSymbolLayer(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsSVGFillSymbolLayer') mFilePath = QDir.toNativeSeparators( QString('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsSVGFillSymbolLayer.createFromSld( mDoc.elementsByTagName('PolygonSymbolizer').item(0).toElement()) mExpectedValue = type(QgsSVGFillSymbolLayer()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 'accommodation_camping.svg' mValue = os.path.basename (str (mSymbolLayer.svgFilePath())) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 6 mValue = mSymbolLayer.patternWidth() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def add_editor(self, fileName="", project=None, tabIndex=None, syntax=None, use_open_highlight=False): editorWidget = editor.create_editor( fileName=fileName, project=project, syntax=syntax, use_open_highlight=use_open_highlight ) if not fileName: tabName = "New Document" else: tabName = file_manager.get_basename(fileName) # add the tab inserted_index = self.add_tab(editorWidget, tabName, tabIndex=tabIndex) self.actualTab.setTabToolTip(inserted_index, QDir.toNativeSeparators(fileName)) # Connect signals self.connect(editorWidget, SIGNAL("modificationChanged(bool)"), self._editor_tab_was_modified) self.connect(editorWidget, SIGNAL("fileSaved(QPlainTextEdit)"), self._editor_tab_was_saved) self.connect(editorWidget, SIGNAL("openDropFile(QString)"), self.open_file) self.connect( editorWidget, SIGNAL("addBackItemNavigation()"), lambda: self.emit(SIGNAL("addBackItemNavigation()")) ) self.connect(editorWidget, SIGNAL("locateFunction(QString, QString, bool)"), self._editor_locate_function) self.connect(editorWidget, SIGNAL("warningsFound(QPlainTextEdit)"), self._show_warning_tab_indicator) self.connect(editorWidget, SIGNAL("errorsFound(QPlainTextEdit)"), self._show_error_tab_indicator) self.connect(editorWidget, SIGNAL("cleanDocument(QPlainTextEdit)"), self._hide_icon_tab_indicator) self.connect(editorWidget, SIGNAL("findOcurrences(QString)"), self._find_occurrences) # Cursor position changed self.connect(editorWidget, SIGNAL("cursorPositionChange(int, int)"), self._cursor_position_changed) # keyPressEventSignal for plugins self.connect(editorWidget, SIGNAL("keyPressEvent(QEvent)"), self._editor_keyPressEvent) # emit a signal about the file open self.emit(SIGNAL("fileOpened(QString)"), fileName) return editorWidget
def defaultOutputFolder(): folder = os.path.join(os.path.dirname(QgsApplication.qgisUserDbFilePath()), "processing", "outputs") if not QDir(folder).exists(): QDir().mkpath(folder) return unicode(QDir.toNativeSeparators(folder))
def __init__(self, parent=None): custom_dock.CustomDock.__init__(self) self.explorador = QTreeView() self.setWidget(self.explorador) self.explorador.header().setHidden(True) self.explorador.setAnimated(True) # Modelo self.modelo = QFileSystemModel(self.explorador) path = QDir.toNativeSeparators(QDir.homePath()) self.modelo.setRootPath(path) self.explorador.setModel(self.modelo) self.modelo.setNameFilters(["*.c", "*.h", "*.s"]) self.explorador.setRootIndex(QModelIndex(self.modelo.index(path))) self.modelo.setNameFilterDisables(False) # Se ocultan algunas columnas self.explorador.hideColumn(1) self.explorador.hideColumn(2) self.explorador.hideColumn(3) # Conexion self.explorador.doubleClicked.connect(self._abrir_archivo) EDIS.cargar_lateral("explorador", self)
def testQgsSvgMarkerSymbolLayerV2(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsSvgMarkerSymbolLayerV2') mFilePath = QDir.toNativeSeparators (QString ('%1/symbol_layer/%2.sld').arg (unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsSvgMarkerSymbolLayerV2.createFromSld(mDoc.elementsByTagName('PointSymbolizer').item(0).toElement()) mExpectedValue = type(QgsSvgMarkerSymbolLayerV2()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'skull.svg') mValue = os.path.basename (str(mSymbolLayer.path())) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 12 mValue = mSymbolLayer.size() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 45 mValue = mSymbolLayer.angle() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def testQgsCentroidFillSymbolLayerV2(self): ''' Create a new style from a .sld file and match test ''' mTestName = 'QgsCentroidFillSymbolLayerV2' mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile(mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsCentroidFillSymbolLayerV2.createFromSld( mDoc.elementsByTagName('PointSymbolizer').item(0).toElement()) mExpectedValue = type(QgsCentroidFillSymbolLayerV2()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = u'regular_star' mValue = mSymbolLayer.subSymbol().symbolLayer(0).name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = u'#55aaff' mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = u'#00ff00' mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def userFolder(): userDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() \ + '/processing' if not QDir(userDir).exists(): QDir().mkpath(userDir) return unicode(QDir.toNativeSeparators(userDir))
def toNativeSeparators(path): """ Function returning a path, that is using native separator characters. @param path path to be converted (QString) @return path with converted separator characters (QString) """ return QDir.toNativeSeparators(path)
def _file_changed(self, change_type, file_path): file_path = QDir.toNativeSeparators(file_path) editorWidget = self.currentWidget() current_open = QDir.toNativeSeparators(editorWidget and editorWidget.ID or "") opened = [path for path, _ in self.get_documents_data()] if ( (file_path in opened) and ((not editorWidget) or (current_open != file_path)) and (change_type in (MODIFIED, DELETED)) ): self._change_map.setdefault(file_path, []).append(change_type) elif not editorWidget: return elif (current_open == file_path) and (not self.question_already_open): # dont ask again if you are already asking! self._prompt_reload(editorWidget, change_type)
def get_QuickOSM_folder(): """ Get the user folder, ~/.qgis2/QuickOSM on linux for instance @rtype: str @return: path """ folder = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "QuickOSM" return unicode(QDir.toNativeSeparators(folder))
def expand(name_item): item_type = name_item.data(USER_ROLE_ITEM_TYPE) if item_type == ITEM_TYPE_DIRECTORY: for i in range(name_item.rowCount()): expand(name_item.child(i, 0)) elif item_type == ITEM_TYPE_FILE: filename = get_full_item_path(name_item) downloads.append(Download(filename, QDir.toNativeSeparators(filename)))
def destroy_database(self, dbfile="freshdb"): ''' this will remove the file from the system the directory will still exist ''' db_file_path = QDir.toNativeSeparators("{file_path}/{file}".format(file_path=self.db_path, file=dbfile)).__str__() try: return QFile(db_file_path).remove() except: return 0 # -------------------------------------------------------------------------- # EOF ------------------------------------------------------------------------------------------------------------
def chooseEbook(self): path = QFileDialog.getOpenFileName(self, 'Open eBook', QDesktopServices.storageLocation( QDesktopServices.DocumentsLocation),'EPUBs (*.epub)') if not isfile(path): return if self.ebook_info is not None and 'temp_path' in self.ebook_info: if exists(self.ebook_info['temp_path']): rmtree(self.ebook_info['temp_path']) path = QDir.toNativeSeparators(path) self.ebook_info = self.openBook(path)
def get_existing_directory(*args, **kwargs): directory = QFileDialog.getExistingDirectory(*args, **kwargs) if len(directory) > 0: directory = QDir.toNativeSeparators(directory) # FIXME: on Mac OS X the getExistingDirectory() might return the directory with # the last part being invalid, try to find the valid part of the directory if sys.platform == 'darwin': while len(directory) > 0 and not os.path.isdir(directory): directory = os.path.split(directory)[0] return directory
def testQgsSimpleLineSymbolLayerV2(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsSimpleLineSymbolLayerV2') mFilePath = QDir.toNativeSeparators( QString('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsSimpleLineSymbolLayerV2.createFromSld( mDoc.elementsByTagName('LineSymbolizer').item(0).toElement()) mExpectedValue = type(QgsSimpleLineSymbolLayerV2()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#aa007f') mValue = mSymbolLayer.color().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 1.26 mValue = mSymbolLayer.width() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = Qt.RoundCap mValue = mSymbolLayer.penCapStyle() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = Qt.MiterJoin mValue = mSymbolLayer.penJoinStyle() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = True mValue = mSymbolLayer.useCustomDashPattern() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = [5.0, 2.0] mValue = mSymbolLayer.customDashVector() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def testQgsPointPatternFillSymbolLayer(self): ''' Create a new style from a .sld file and match test ''' # at the moment there is an empty createFromSld implementation # that return nulls mTestName = QString('QgsPointPatternFillSymbolLayer') mFilePath = QDir.toNativeSeparators( QString ('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsPointPatternFillSymbolLayer.createFromSld( mDoc.elementsByTagName('PolygonSymbolizer').item(0).toElement()) mExpectedValue = type(QgsPointPatternFillSymbolLayer()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'triangle') mValue = mSymbolLayer.subSymbol().symbolLayer(0).name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#ffaa00') mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#ff007f') mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 5 mValue = mSymbolLayer.subSymbol().symbolLayer(0).angle() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 3 mValue = mSymbolLayer.subSymbol().symbolLayer(0).size() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def dropEvent(self, ev): if not ev.source() and ev.mimeData().hasUrls(): ev.accept() lyurls = [] impurls = [] for url in ev.mimeData().urls(): imp = file_import.FileImport.instance(self) if imp.isImportable(url.toLocalFile()): impurls.append(QDir.toNativeSeparators(url.toLocalFile())) else: lyurls.append(url) docs = self.openUrls(lyurls) if docs: self.setCurrentDocument(docs[-1]) for i in impurls: imp.openDialog(i)
def getExistingDirectory(parent = None, caption = QString(), dir_ = QString(), options = QFileDialog.Options(QFileDialog.ShowDirsOnly)): """ Module function to get the name of a directory. @param parent parent widget of the dialog (QWidget) @param caption window title of the dialog (QString) @param dir_ working directory of the dialog (QString) @param options various options for the dialog (QFileDialog.Options) @return name of selected directory (QString) """ if Preferences.getUI("UseKDEDialogs") and not sys.e4nokde: d = __kdeGetExistingDirectory(parent, caption, dir_, options) else: d = __qtGetExistingDirectory(parent, caption, dir_, options) return QDir.toNativeSeparators(d)
def display_downloaded_content(self): """ Called when an unsupported content type is finished downloading. """ file_path = QDir.toNativeSeparators(QDir.tempPath() + "/XXXXXX_" + self.content_filename) myfile = QTemporaryFile(file_path) myfile.setAutoRemove(False) if (myfile.open()): myfile.write(self.reply.readAll()) myfile.close() subprocess.Popen([self.content_handlers.get(str(self.content_type)), myfile.fileName()]) #Sometimes downloading files opens an empty window. #So if the current window has no URL, close it. if(str(self.url().toString()) in ('', 'about:blank')): self.close()
def _decode_dragged_data(data): if data.hasUrls(): items = [QDir.toNativeSeparators(url.toLocalFile()) for url in data.urls() if url.isLocalFile()] elif data.hasText(): items = data.text().strip().split("\n") else: return None if len(items) == 0: return None first_path = os.path.abspath(items[0]) if (len(items) > 1) or (not os.path.isdir(first_path)): first_path, _ = os.path.split(first_path) return first_path
def testQgsEllipseSymbolLayerV2(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsEllipseSymbolLayerV2') mFilePath = QDir.toNativeSeparators( QString('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsEllipseSymbolLayerV2.createFromSld( mDoc.elementsByTagName('PointSymbolizer').item(0).toElement()) mExpectedValue = type(QgsEllipseSymbolLayerV2()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'circle') mValue = mSymbolLayer.symbolName() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#ffff7f') mValue = mSymbolLayer.fillColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#aaaaff') mValue = mSymbolLayer.outlineColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 7 mValue = mSymbolLayer.symbolWidth() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 5 mValue = mSymbolLayer.symbolHeight() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def getConfigDir(): """ Global function to get the name of the directory storing the config data. @return directory name of the config dir (string) """ if sys.platform.startswith("win"): cdn = "_eric4" else: cdn = ".eric4" hp = QDir.homePath() dn = QDir(hp) dn.mkdir(cdn) hp.append("/").append(cdn) try: return unicode(QDir.toNativeSeparators(hp)) except AttributeError: return unicode(QDir.convertSeparators(hp))
def add_editor(self, fileName="", tabIndex=None): ninjaide = IDE.get_service('ide') project = ninjaide.get_project_for_file(fileName) editable = ninjaide.get_editable(fileName, project) editorWidget = editor.create_editor(editable) tab_name = editable.display_name #add the tab index = self.add_tab(editorWidget, tab_name, tabIndex=tabIndex) self.tabs.setTabToolTip(index, QDir.toNativeSeparators(fileName)) #Connect signals self.connect(editorWidget, SIGNAL("modificationChanged(bool)"), self._editor_tab_was_modified) self.connect(editorWidget, SIGNAL("fileSaved(QPlainTextEdit)"), self._editor_tab_was_saved) self.connect(editorWidget, SIGNAL("openDropFile(QString)"), self.open_file) self.connect(editorWidget, SIGNAL("addBackItemNavigation()"), self.add_back_item_navigation) self.connect(editorWidget, SIGNAL("locateFunction(QString, QString, bool)"), self._editor_locate_function) self.connect(editorWidget, SIGNAL("checksFound(QPlainTextEdit, PyQt_PyObject)"), self._show_tab_indicator) self.connect(editorWidget, SIGNAL("cleanDocument(QPlainTextEdit)"), self._hide_icon_tab_indicator) self.connect(editorWidget, SIGNAL("findOcurrences(QString)"), self._find_occurrences) self.connect(editorWidget, SIGNAL("migrationAnalyzed()"), lambda: self.emit(SIGNAL("migrationAnalyzed()"))) #Cursor position changed self.connect(editorWidget, SIGNAL("cursorPositionChange(int, int)"), self._cursor_position_changed) #keyPressEventSignal for plugins self.connect(editorWidget, SIGNAL("keyPressEvent(QEvent)"), self._editor_keyPressEvent) #emit a signal about the file open self.emit(SIGNAL("fileOpened(QString)"), fileName) return editorWidget
def detect_python_path(): if (IS_WINDOWS and PYTHON_EXEC_CONFIGURED_BY_USER) or not IS_WINDOWS: return [] suggested = [] try: drives = [QDir.toNativeSeparators(d.absolutePath()) for d in QDir.drives()] dirs = [] for drive in drives: info = QFileInfo(drive) if info.isReadable(): dirs += [os.path.join(drive, folder) for folder in os.listdir(drive)] for folder in dirs: file_path = os.path.join(folder, "python.exe") if ("Python" in folder) and os.path.exists(file_path): suggested.append(file_path) except: print("Detection couldnt be executed") return suggested
def testQgsLinePatternFillSymbolLayer(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsLinePatternFillSymbolLayer') mFilePath = QDir.toNativeSeparators( QString ('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsLinePatternFillSymbolLayer.createFromSld( mDoc.elementsByTagName('PolygonSymbolizer').item(0).toElement()) mExpectedValue = type(QgsLinePatternFillSymbolLayer()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#ff55ff') mValue = mSymbolLayer.color().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 1.5 mValue = mSymbolLayer.lineWidth() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 4 mValue = mSymbolLayer.distance() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 57 mValue = mSymbolLayer.lineAngle() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def testQgsMarkerLineSymbolLayerV2(self): ''' Create a new style from a .sld file and match test ''' mTestName = QString ('QgsMarkerLineSymbolLayerV2') mFilePath = QDir.toNativeSeparators( QString('%1/symbol_layer/%2.sld').arg( unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile (mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile,True) mFile.close() mSymbolLayer = QgsMarkerLineSymbolLayerV2.createFromSld( mDoc.elementsByTagName('LineSymbolizer').item(0).toElement()) mExpectedValue = type(QgsMarkerLineSymbolLayerV2()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QgsMarkerLineSymbolLayerV2.CentralPoint mValue = mSymbolLayer.placement() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString (u'circle') mValue = mSymbolLayer.subSymbol().symbolLayer(0).name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#000000') mValue = mSymbolLayer.subSymbol().symbolLayer(0).borderColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = QString(u'#ff0000') mValue = mSymbolLayer.subSymbol().symbolLayer(0).color().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue,mValue) assert mExpectedValue == mValue, mMessage
def homeDirectory(): return str(QDir.toNativeSeparators(QDir.homePath()))
def get_home_path(): return QDir.toNativeSeparators(QDir.homePath())
# You should have received a copy of the GNU General Public License # along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>. from PyQt4.QtGui import QKeySequence from PyQt4.QtCore import QDir from PyQt4.QtCore import QSettings from PyQt4.QtCore import Qt import os import sys ############################################################################### # PATHS ############################################################################### HOME_PATH = unicode(QDir.toNativeSeparators(QDir.homePath())) NINJA_EXECUTABLE = os.path.realpath(sys.argv[0]) PRJ_PATH = os.path.abspath(os.path.dirname(__file__)) #Only for py2exe frozen = getattr(sys, 'frozen', '') if frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: PRJ_PATH = os.path.abspath(os.path.dirname(sys.executable)) HOME_NINJA_PATH = os.path.join(HOME_PATH, ".ninja_ide") ADDINS = os.path.join(HOME_NINJA_PATH, "addins") SYNTAX_FILES = os.path.join(PRJ_PATH, "addins", "syntax")
# Host MOD_KEY_HOST_VERBOSE = "Host/Verbose" # bool MOD_KEY_HOST_PATH = "Host/Path2" # str # WebView MOD_KEY_WEBVIEW_INSPECTOR = "WebView/Inspector" # bool MOD_KEY_WEBVIEW_VERBOSE = "WebView/Verbose" # bool MOD_KEY_WEBVIEW_SHOW_INSPECTOR = "WebView/ShowInspector" # bool # ------------------------------------------------------------------------------------------------------------ # Settings defaults # Main MOD_DEFAULT_MAIN_REFRESH_INTERVAL = 30 MOD_DEFAULT_MAIN_PROJECT_FOLDER = QDir.toNativeSeparators(QDir.homePath()) # Host MOD_DEFAULT_HOST_NUM_AUDIO_INS = 2 MOD_DEFAULT_HOST_NUM_AUDIO_OUTS = 2 MOD_DEFAULT_HOST_NUM_MIDI_INS = 1 MOD_DEFAULT_HOST_NUM_MIDI_OUTS = 1 MOD_DEFAULT_HOST_NUM_CV_INS = 0 MOD_DEFAULT_HOST_NUM_CV_OUTS = 0 MOD_DEFAULT_HOST_AUTO_CONNNECT_INS = True MOD_DEFAULT_HOST_AUTO_CONNNECT_OUTS = True MOD_DEFAULT_HOST_VERBOSE = False MOD_DEFAULT_HOST_PATH = "/usr/bin/mod-host" # WebView MOD_DEFAULT_WEBVIEW_INSPECTOR = False
def getfile(self): path=QFileDialog.getOpenFileName(self, 'Open file', self.lineEditvalue.text(),"text files (*.txt *.*)") self.lineEditvalue.setText(QDir.toNativeSeparators(path)) self.upconfig()
def _open_config_folder(self): QDesktopServices.openUrl( QUrl("file:///" + QDir.toNativeSeparators(cfclient.config_path)))
def _open_config_folder(self): QDesktopServices.openUrl( QUrl("file:///" + QDir.toNativeSeparators(sys.path[1])))
from PyQt4.QtGui import QKeySequence from PyQt4.QtCore import QDir from PyQt4.QtCore import QSettings from PyQt4.QtCore import Qt ############################################################################### # CHECK PYTHON VERSION ############################################################################### IS_PYTHON3 = sys.version_info.major == 3 ############################################################################### # PATHS ############################################################################### HOME_PATH = QDir.toNativeSeparators(QDir.homePath()) NINJA_EXECUTABLE = os.path.realpath(sys.argv[0]) PRJ_PATH = os.path.abspath(os.path.dirname(__file__)) if not IS_PYTHON3: PRJ_PATH = PRJ_PATH.decode('utf-8') #Only for py2exe frozen = getattr(sys, 'frozen', '') if frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: PRJ_PATH = os.path.abspath(os.path.dirname(sys.executable)) HOME_NINJA_PATH = os.path.join(HOME_PATH, ".ninja_ide") NINJA_KNOWLEDGE_PATH = os.path.join(HOME_NINJA_PATH, 'knowledge')