def _generateFiles(data): nameFolder = pathtools.convertPath( '/' + data['className'].replace(" ", "").lower()) outputFolder = data['outputFolder'] + nameFolder data['outputNameFolder'] = outputFolder import shutil, os shutil.copytree(_thisFolder, outputFolder) os.rename(pathtools.convertPath(outputFolder + '/__init__.txt'), pathtools.convertPath(outputFolder + '/__init__.py')) os.rename(pathtools.convertPath(outputFolder + '/add.txt'), pathtools.convertPath(outputFolder + '/add.py')) os.rename(pathtools.convertPath(outputFolder + '/gui.txt'), pathtools.convertPath(outputFolder + '/gui.py')) os.rename(pathtools.convertPath(outputFolder + '/manager.txt'), pathtools.convertPath(outputFolder + '/manager.py'))
def __init__(self): self._cfgFile = pathtools.convertPath( pathtools.getPathProgramFolder() + 'tools/settings.cfg') self._config = ConfigParser.RawConfigParser() self._config.read(self._cfgFile) if not os.path.exists(self._cfgFile): cfg = open(self._cfgFile, 'w') cfg.write('[settings]\npath_bd = ') cfg.close()
def __init__(self): self._cfgFile = pathtools.convertPath( pathtools.getPathProgramFolder() + 'tools/settings.cfg') self._config = ConfigParser.RawConfigParser() self._config.read(self._cfgFile) if not os.path.exists(self._cfgFile) : cfg = open(self._cfgFile,'w') cfg.write('[settings]\npath_bd = ') cfg.close()
def __generarPlantilla(destino, tipo, metodos=None): """ {str} tipo = Dialog | MainWindow """ nombre_archivo = os.path.basename(destino).split(".")[0] + ".py" ruta_destino = pathtools.convertPath(os.path.dirname(destino) + "/" + nombre_archivo) shutil.copyfile(pathtools.convertPath(pathtools.getPathProgramFolder() + "plantillas/plantilla.py"), ruta_destino) archivo = open(ruta_destino, "r") contenido = archivo.read() archivo.close() # reemplaza en el texto los campos de la plantilla contenido = contenido.replace(u"%%%", tipo) contenido = contenido.replace(u"&&&", os.path.basename(destino).split(".")[0]) archivo = open(ruta_destino, "w") archivo.write(contenido) archivo.close() print ">>> Plantilla .py generada" return True
def loadUI(self, pathToFile=None): ''' Read and load the screen indicate by <pathToFile> @param {str} pathToFile = path to .ui file If is None, look the ui in the location relative to the current folder ''' import cStringIO import os from uis import ui from PyQt4 import uic from plasta.utils import pathtools if pathToFile is None: pathToFile = self.FILENAME if config.DEVELOP: mainFolder = pathtools.getPathProgramFolder() uic.loadUi(pathtools.convertPath(mainFolder + pathToFile), self) else: pathToFile = pathtools.convertPath(pathToFile) if os.name == 'nt': pathToFile = '\\' + pathToFile uic.loadUi(cStringIO.StringIO(ui[pathToFile]), self)
def __generarPlantilla(destino, tipo, metodos=None): """ {str} tipo = Dialog | MainWindow """ nombre_archivo = os.path.basename(destino).split('.')[0] + '.py' ruta_destino = pathtools.convertPath( os.path.dirname(destino) + '/' + nombre_archivo) shutil.copyfile( pathtools.convertPath(pathtools.getPathProgramFolder() + 'plantillas/plantilla.py'), ruta_destino) archivo = open(ruta_destino, 'r') contenido = archivo.read() archivo.close() # reemplaza en el texto los campos de la plantilla contenido = contenido.replace(u'%%%', tipo) contenido = contenido.replace(u'&&&', os.path.basename(destino).split('.')[0]) archivo = open(ruta_destino, 'w') archivo.write(contenido) archivo.close() print '>>> Plantilla .py generada' return True
def _generateFiles(data): nameFolder = pathtools.convertPath( '/' + data['className'].replace(" ", "").lower()) outputFolder = data['outputFolder'] + nameFolder data['outputNameFolder'] = outputFolder import shutil, os shutil.copytree(_thisFolder, outputFolder) os.rename( pathtools.convertPath(outputFolder + '/__init__.txt'), pathtools.convertPath(outputFolder + '/__init__.py') ) os.rename( pathtools.convertPath(outputFolder + '/add.txt'), pathtools.convertPath(outputFolder + '/add.py') ) os.rename( pathtools.convertPath(outputFolder + '/gui.txt'), pathtools.convertPath(outputFolder + '/gui.py') ) os.rename( pathtools.convertPath(outputFolder + '/manager.txt'), pathtools.convertPath(outputFolder + '/manager.py') )
def loadUI(self, pathToFile=None): ''' Read and load the screen indicate by <pathToFile> @param {str} pathToFile = path to .ui file If is None, look the ui in the location relative to the current folder ''' from plasta.config import config from PyQt4 import uic from plasta.utils import pathtools if pathToFile is None: pathToFile = self.FILENAME if config.DEVELOP: mainFolder = pathtools.getPathProgramFolder() uic.loadUi(pathtools.convertPath(mainFolder + pathToFile), self) else: import cStringIO, uis uic.loadUi(cStringIO.StringIO(uis[pathToFile]), self)
# The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from plasta.utils import pathtools ############################################################################################# _thisFolder = pathtools.getPathProgramFolder() + pathtools.convertPath( 'plasta/maker/templates/object')[1:] _meta = { 'widgets': { 'lineEdit': 'le', 'comboBox': 'cb', 'spinBox': 'sb', 'doubleSpinBox': 'dsb', 'textEdit': 'te', 'dateEdit': 'dt', 'dateTimeEdit': 'dte', 'timeEdit': 'tme', 'checkBox': 'chk', } }
# The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from plasta.utils import pathtools ############################################################################################# _thisFolder = pathtools.getPathProgramFolder() + pathtools.convertPath('plasta/maker/templates/object')[1:] _meta = { 'widgets':{ 'lineEdit':'le', 'comboBox':'cb', 'spinBox':'sb', 'doubleSpinBox':'dsb', 'textEdit':'te', 'dateEdit':'dt', 'dateTimeEdit':'dte', 'timeEdit':'tme', 'checkBox':'chk', } }