corretti problemi di pylint

c'e' da renderlo meno rompicoglioni
This commit is contained in:
2020-10-12 16:00:20 +02:00
parent e195ea5532
commit 16ab928383
6 changed files with 1248 additions and 1167 deletions

29
SPEx/poetry.lock generated
View File

@@ -34,6 +34,18 @@ docs = ["sphinx", "sphinx-rtd-theme", "zope.interface"]
tests = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"] tests = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"]
tests_no_zope = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"] tests_no_zope = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"]
[[package]]
category = "dev"
description = "A tool that automatically formats Python code to conform to the PEP 8 style guide"
name = "autopep8"
optional = false
python-versions = "*"
version = "1.5.4"
[package.dependencies]
pycodestyle = ">=2.6.0"
toml = "*"
[[package]] [[package]]
category = "dev" category = "dev"
description = "Cross-platform colored terminal text." description = "Cross-platform colored terminal text."
@@ -119,6 +131,14 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "1.9.0" version = "1.9.0"
[[package]]
category = "dev"
description = "Python style guide checker"
name = "pycodestyle"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.6.0"
[[package]] [[package]]
category = "dev" category = "dev"
description = "python code static checker" description = "python code static checker"
@@ -238,7 +258,7 @@ python-versions = "*"
version = "1.12.1" version = "1.12.1"
[metadata] [metadata]
content-hash = "e35375126d07552fb1e200007cf6bd02991d90c71eb261f21b33919e77395a58" content-hash = "f2c0aacdec9a2b08fb05b279563096aab92c78d4b64ccc312db25de8e74a910f"
lock-version = "1.0" lock-version = "1.0"
python-versions = "^3.8" python-versions = "^3.8"
@@ -255,6 +275,9 @@ attrs = [
{file = "attrs-20.2.0-py2.py3-none-any.whl", hash = "sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"}, {file = "attrs-20.2.0-py2.py3-none-any.whl", hash = "sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"},
{file = "attrs-20.2.0.tar.gz", hash = "sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594"}, {file = "attrs-20.2.0.tar.gz", hash = "sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594"},
] ]
autopep8 = [
{file = "autopep8-1.5.4.tar.gz", hash = "sha256:d21d3901cb0da6ebd1e83fc9b0dfbde8b46afc2ede4fe32fbda0c7c6118ca094"},
]
colorama = [ colorama = [
{file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"},
{file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"},
@@ -309,6 +332,10 @@ py = [
{file = "py-1.9.0-py2.py3-none-any.whl", hash = "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2"}, {file = "py-1.9.0-py2.py3-none-any.whl", hash = "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2"},
{file = "py-1.9.0.tar.gz", hash = "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"}, {file = "py-1.9.0.tar.gz", hash = "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"},
] ]
pycodestyle = [
{file = "pycodestyle-2.6.0-py2.py3-none-any.whl", hash = "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367"},
{file = "pycodestyle-2.6.0.tar.gz", hash = "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"},
]
pylint = [ pylint = [
{file = "pylint-2.6.0-py3-none-any.whl", hash = "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f"}, {file = "pylint-2.6.0-py3-none-any.whl", hash = "sha256:bfe68f020f8a0fece830a22dd4d5dddb4ecc6137db04face4c3420a46a52239f"},
{file = "pylint-2.6.0.tar.gz", hash = "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210"}, {file = "pylint-2.6.0.tar.gz", hash = "sha256:bb4a908c9dadbc3aac18860550e870f58e1a02c9f2c204fdf5693d73be061210"},

View File

@@ -13,6 +13,7 @@ parse = "*"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "^5.2" pytest = "^5.2"
pylint = "^2.6.0" pylint = "^2.6.0"
autopep8 = "^1.5.4"
[build-system] [build-system]
requires = ["poetry>=0.12"] requires = ["poetry>=0.12"]

View File

@@ -6,34 +6,35 @@ TODO LIST
1. rendere threaded lo splitter.. tentativo colore 100.. 1. rendere threaded lo splitter.. tentativo colore 100..
''' '''
import sys, copy, json, os import sys
import PyQt5.QtWidgets import copy
import json
import os
from mainwindow import Ui_mainwin
from selezout import Ui_selezout
from titolow import Ui_titolo
from avanzatetitolo3 import Ui_advtitolo3 as Ui_advtitolo
from advopt import Ui_editconf
from about import Ui_about
from libfancylogger import fancyLogger
from libconfload import bananaCONF
from libsplit import bananaSPLITTER
import PyQt5.QtGui import PyQt5.QtGui
from userInterface.compiledUI.mainwindow import Ui_mainwin
from userInterface.compiledUI.selezout import Ui_selezout
from userInterface.compiledUI.titolow import Ui_titolo
from userInterface.compiledUI.avanzatetitolo3 import Ui_advtitolo3 as Ui_advtitolo
from userInterface.compiledUI.advopt import Ui_editconf
from userInterface.compiledUI.about import Ui_about
from libbananasplit.libfancylogger import fancyLogger
from libbananasplit.libconfload import bananaCONF
from libbananasplit.libsplit import bananaSPLITTER
from PyQt5.QtCore import QDir, QSize, QTranslator, pyqtSlot, pyqtSignal from PyQt5.QtCore import QDir, QSize, QTranslator, pyqtSlot, pyqtSignal
from PyQt5.QtWidgets import QMessageBox, QSizePolicy, QInputDialog from PyQt5.QtWidgets import QMessageBox, QSizePolicy, QInputDialog
#modo brutto per mettere la lista delle lingue in un posto solo #modo brutto per mettere la lista delle lingue in un posto solo
langlist = ['it', 'en'] langlist = ['it', 'en']
class bananaMain(PyQt5.QtWidgets.QMainWindow): class bananaMain(PyQt5.QtWidgets.QMainWindow):
def __init__(self, logger=None, confloader=None): def __init__(self, logger=None, confloader=None):
PyQt5.QtWidgets.QMainWindow.__init__(self) PyQt5.QtWidgets.QMainWindow.__init__(self)
self.logger = logger self.logger = logger
self.conf = confloader self.conf = confloader
# inizializzazione interfaccia # inizializzazione interfaccia
self.ui = Ui_mainwin() self.ui = Ui_mainwin()
self.ui.setupUi(self) self.ui.setupUi(self)
@@ -41,64 +42,55 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
self.titoloav = bananaTitoloAvanzate(self.conf, self.logger) self.titoloav = bananaTitoloAvanzate(self.conf, self.logger)
self.selezout = bananaSelezOut(self.conf, self.logger) self.selezout = bananaSelezOut(self.conf, self.logger)
self.advopt = bananaAdvOpt(self.conf, self.logger) self.advopt = bananaAdvOpt(self.conf, self.logger)
#popola le tab con le finestre giuste #popola le tab con le finestre giuste
self.ui.wgt_main.addTab(self.titolo, self.tr("Impostazioni Titolo")) self.ui.wgt_main.addTab(self.titolo, self.tr("Impostazioni Titolo"))
self.ui.wgt_main.addTab(self.selezout, self.tr("Selezione Output")) self.ui.wgt_main.addTab(self.selezout, self.tr("Selezione Output"))
# connetti bottoni avanti # connetti bottoni avanti
self.ui.btn_avanti.clicked.connect(self.nextTab) self.ui.btn_avanti.clicked.connect(self.nextTab)
self.titolo.titoloui.btn_avanti.clicked.connect(self.nextTab) self.titolo.titoloui.btn_avanti.clicked.connect(self.nextTab)
#connetti bottoni indietro #connetti bottoni indietro
self.titolo.titoloui.btn_indietro.clicked.connect(self.prevTab) self.titolo.titoloui.btn_indietro.clicked.connect(self.prevTab)
self.selezout.selezoutui.btn_indietro.clicked.connect(self.prevTab) self.selezout.selezoutui.btn_indietro.clicked.connect(self.prevTab)
#connetti bottoni selezione cartelle #connetti bottoni selezione cartelle
self.ui.btn_cartellasorg.clicked.connect(self.selezSorg) self.ui.btn_cartellasorg.clicked.connect(self.selezSorg)
self.ui.btn_cartelladest.clicked.connect(self.selezDest) self.ui.btn_cartelladest.clicked.connect(self.selezDest)
#connetti action tab #connetti action tab
self.ui.actionLingua.triggered.connect(self.openLanguage) self.ui.actionLingua.triggered.connect(self.openLanguage)
self.ui.actionAvanzate.triggered.connect(self.openAdvOpt) self.ui.actionAvanzate.triggered.connect(self.openAdvOpt)
self.ui.actionCarica_Preset.triggered.connect(self.openLoadPreset) self.ui.actionCarica_Preset.triggered.connect(self.openLoadPreset)
self.ui.actionSalva_Preset.triggered.connect(self.openSavePreset) self.ui.actionSalva_Preset.triggered.connect(self.openSavePreset)
self.ui.actionAbout_SPEx.triggered.connect(self.openAbout) self.ui.actionAbout_SPEx.triggered.connect(self.openAbout)
#connetti i radbutton versione #connetti i radbutton versione
self.ui.rad_fileNew.clicked.connect(self.selezVers) self.ui.rad_fileNew.clicked.connect(self.selezVers)
self.ui.rad_fileOld.clicked.connect(self.selezVers) self.ui.rad_fileOld.clicked.connect(self.selezVers)
#connetti segnali delle sottointerfacce #connetti segnali delle sottointerfacce
self.advopt.update.connect(self.fillAllInterfaces) self.advopt.update.connect(self.fillAllInterfaces)
self.logger.sendLog.connect(self.appendLog) self.logger.sendLog.connect(self.appendLog)
#riempi pagine di interfaccia #riempi pagine di interfaccia
self.fillAllInterfaces() self.fillAllInterfaces()
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.setFixedSize(QSize(self.conf.getParam('settings','winW'), self.conf.getParam('settings','winH'))) self.setFixedSize(QSize(self.conf.getParam(
'settings', 'winW'), self.conf.getParam('settings', 'winH')))
pass pass
def fillInterface(self): def fillInterface(self):
#pagina principale #pagina principale
try: try:
self.ui.lbl_preset.setText(self.conf.inUse.replace('.json', '')) self.ui.lbl_preset.setText(self.conf.inUse.replace('.json', ''))
self.ui.lbl_sorg.setText(self.conf.getParam('paths', 'INworkPath')) self.ui.lbl_sorg.setText(self.conf.getParam('paths', 'INworkPath'))
self.ui.lbl_dest.setText(self.conf.getParam('paths', 'OUTworkPath')) self.ui.lbl_dest.setText(self.conf.getParam('paths', 'OUTworkPath'))
self.ui.rad_fileNew.setChecked(self.conf.getParam('docStruct', 'fileVersNew')) self.ui.rad_fileNew.setChecked(
self.ui.rad_fileOld.setChecked(not self.conf.getParam('docStruct', 'fileVersNew')) self.conf.getParam('docStruct', 'fileVersNew'))
self.ui.rad_fileOld.setChecked(
not self.conf.getParam('docStruct', 'fileVersNew'))
self.fillFileList() self.fillFileList()
except: except:
self.log.critical(self.tr("MainWindow: Configurazione non accettata")) self.log.critical(self.tr("MainWindow: Configurazione non accettata"))
def fillAllInterfaces(self): def fillAllInterfaces(self):
self.fillInterface() self.fillInterface()
self.titolo.fillInterface() self.titolo.fillInterface()
self.titoloav.fillInterface() self.titoloav.fillInterface()
self.selezout.fillInterface() self.selezout.fillInterface()
self.advopt.fillInterface() self.advopt.fillInterface()
def fillFileList(self): def fillFileList(self):
fl = QDir(self.conf.getParam('paths', 'INworkPath')) fl = QDir(self.conf.getParam('paths', 'INworkPath'))
fl.setNameFilters(['*.txt', '*.TXT']) fl.setNameFilters(['*.txt', '*.TXT'])
@@ -107,20 +99,18 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
for f in fl: for f in fl:
self.ui.lst_files.addItem(PyQt5.QtWidgets.QListWidgetItem(f)) self.ui.lst_files.addItem(PyQt5.QtWidgets.QListWidgetItem(f))
self.conf.setParam(('paths', 'fileList'), fl) self.conf.setParam(('paths', 'fileList'), fl)
def nextTab(self): def nextTab(self):
self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()+1) self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()+1)
self.logger.debug(self.tr("Prossima Tab")) self.logger.debug(self.tr("Prossima Tab"))
pass pass
def prevTab(self): def prevTab(self):
self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()-1) self.ui.wgt_main.setCurrentIndex(self.ui.wgt_main.currentIndex()-1)
self.logger.debug(self.tr("Tab Precedente")) self.logger.debug(self.tr("Tab Precedente"))
pass pass
def openLoadPreset(self): def openLoadPreset(self):
self.logger.debug(self.tr("Apri Carica Preset")) self.logger.debug(self.tr("Apri Carica Preset"))
lf = PyQt5.QtWidgets.QFileDialog(self,self.tr("Carica Preset"),self.conf.getParam('paths', 'configurationPath')) lf = PyQt5.QtWidgets.QFileDialog(self, self.tr(
"Carica Preset"), self.conf.getParam('paths', 'configurationPath'))
lf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptOpen) lf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptOpen)
lf.setFileMode(PyQt5.QtWidgets.QFileDialog.ExistingFile) lf.setFileMode(PyQt5.QtWidgets.QFileDialog.ExistingFile)
lf.setNameFilter("bananaCONF (*.json)") lf.setNameFilter("bananaCONF (*.json)")
@@ -132,11 +122,11 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
self.logger.debug(self.tr("Riempio tutte le tab")) self.logger.debug(self.tr("Riempio tutte le tab"))
self.fillAllInterfaces() self.fillAllInterfaces()
pass pass
def openSavePreset(self): def openSavePreset(self):
self.logger.debug(self.tr("Apri Salva Preset")) self.logger.debug(self.tr("Apri Salva Preset"))
self.applicaTutto() self.applicaTutto()
sf = PyQt5.QtWidgets.QFileDialog(self,"Salva Preset",self.conf.getParam('paths', 'configurationPath')) sf = PyQt5.QtWidgets.QFileDialog(
self, "Salva Preset", self.conf.getParam('paths', 'configurationPath'))
sf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptSave) sf.setAcceptMode(PyQt5.QtWidgets.QFileDialog.AcceptSave)
sf.setNameFilter("bananaCONF (*.json)") sf.setNameFilter("bananaCONF (*.json)")
if sf.exec(): if sf.exec():
@@ -152,18 +142,17 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
self.logger.debug(self.tr(f"Scrivo la configurazione: {rv}")) self.logger.debug(self.tr(f"Scrivo la configurazione: {rv}"))
self.conf.save(fName=rv) self.conf.save(fName=rv)
pass pass
def openAdvOpt(self): def openAdvOpt(self):
self.logger.debug(self.tr("Apri Opzioni Avanzate")) self.logger.debug(self.tr("Apri Opzioni Avanzate"))
self.advopt.fillInterface() self.advopt.fillInterface()
self.advopt.show() self.advopt.show()
pass pass
def openLanguage(self): def openLanguage(self):
global langlist global langlist
self.logger.debug(self.tr("Apri Opzioni Lingua")) self.logger.debug(self.tr("Apri Opzioni Lingua"))
flag = False flag = False
lang,flag = QInputDialog.getItem(self, self.tr("Lingua"), self.tr("Disponibili"), langlist, 0, False) lang, flag = QInputDialog.getItem(self, self.tr(
"Lingua"), self.tr("Disponibili"), langlist, 0, False)
if flag: if flag:
self.conf.setParam(('settings', 'uiLang'), lang) self.conf.setParam(('settings', 'uiLang'), lang)
else: else:
@@ -174,24 +163,29 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
self.spxabt = spexAbout(confloader=self.conf) self.spxabt = spexAbout(confloader=self.conf)
def selezSorg(self): def selezSorg(self):
rv = PyQt5.QtWidgets.QFileDialog.getExistingDirectory(self,self.tr("Seleziona Cartella Sorgente"),self.conf.getParam('paths','INworkPath')) rv = PyQt5.QtWidgets.QFileDialog.getExistingDirectory(self, self.tr(
if rv is not "": "Seleziona Cartella Sorgente"), self.conf.getParam('paths', 'INworkPath'))
if rv != "":
self.conf.setParam(keys=('paths', 'INworkPath',), val=rv+"/") self.conf.setParam(keys=('paths', 'INworkPath',), val=rv+"/")
self.ui.lbl_sorg.setText(rv) self.ui.lbl_sorg.setText(rv)
self.logger.info(self.tr("Selezionata Cartella Sorgente: {}").format(rv+"/")) self.logger.info(
self.tr("Selezionata Cartella Sorgente: {}").format(rv+"/"))
self.fillFileList() self.fillFileList()
pass pass
def selezDest(self): def selezDest(self):
rv = PyQt5.QtWidgets.QFileDialog.getExistingDirectory(self,self.tr("Seleziona Cartella Destinazione"),self.conf.getParam('paths','OUTworkPath')) rv = PyQt5.QtWidgets.QFileDialog.getExistingDirectory(self, self.tr(
if rv is not "": "Seleziona Cartella Destinazione"), self.conf.getParam('paths', 'OUTworkPath'))
if rv != "":
self.conf.setParam(keys=('paths', 'OUTworkPath',), val=rv+"/") self.conf.setParam(keys=('paths', 'OUTworkPath',), val=rv+"/")
self.ui.lbl_dest.setText(rv) self.ui.lbl_dest.setText(rv)
self.logger.info(self.tr("Selezionata Cartella Destinazione: {}").format(rv+"/")) self.logger.info(
self.tr("Selezionata Cartella Destinazione: {}").format(rv+"/"))
pass pass
def selezVers(self): def selezVers(self):
self.conf.setParam(('docStruct','fileVersNew'), self.ui.rad_fileNew.isChecked()) self.conf.setParam(('docStruct', 'fileVersNew'),
self.ui.rad_fileNew.isChecked())
self.logger.debug(self.tr(f"Selezionata Versione File")) self.logger.debug(self.tr(f"Selezionata Versione File"))
def openFileDialog(self, name, path): def openFileDialog(self, name, path):
@@ -209,6 +203,7 @@ class bananaMain(PyQt5.QtWidgets.QMainWindow):
####################### INTERFACES ########################## ####################### INTERFACES ##########################
############################################################# #############################################################
class bananaTitolo(PyQt5.QtWidgets.QWidget): class bananaTitolo(PyQt5.QtWidgets.QWidget):
def __init__(self, confloader=None, logger=None): def __init__(self, confloader=None, logger=None):
PyQt5.QtWidgets.QWidget.__init__(self) PyQt5.QtWidgets.QWidget.__init__(self)
@@ -227,15 +222,22 @@ class bananaTitolo(PyQt5.QtWidgets.QWidget):
try: try:
# imposta predefiniti interfaccia da file # imposta predefiniti interfaccia da file
#Data (la piu complicata) #Data (la piu complicata)
self.titoloui.chk_data.setChecked(self.conf.getParam('docStruct','outDate')) self.titoloui.chk_data.setChecked(
self.titoloui.rad_datajpn.setChecked(self.conf.getParam('docStruct', 'outDateType') == 'jpn') self.conf.getParam('docStruct', 'outDate'))
self.titoloui.rad_dataita.setChecked(self.conf.getParam('docStruct', 'outDateType') == 'it') self.titoloui.rad_datajpn.setChecked(
self.titoloui.rad_datausa.setChecked(self.conf.getParam('docStruct', 'outDateType') == 'usa') self.conf.getParam('docStruct', 'outDateType') == 'jpn')
self.titoloui.rad_dataita.setChecked(
self.conf.getParam('docStruct', 'outDateType') == 'it')
self.titoloui.rad_datausa.setChecked(
self.conf.getParam('docStruct', 'outDateType') == 'usa')
#Titolo #Titolo
self.titoloui.chk_titolo.setChecked(self.conf.getParam('docStruct','outTitle')) self.titoloui.chk_titolo.setChecked(
self.titoloui.spn_ncarat.setValue(self.conf.getParam('docStruct', 'maxTitleLen')) self.conf.getParam('docStruct', 'outTitle'))
self.titoloui.spn_ncarat.setValue(
self.conf.getParam('docStruct', 'maxTitleLen'))
#Numero Documento #Numero Documento
self.titoloui.chk_docnum.setChecked(self.conf.getParam('docStruct','outNumber')) self.titoloui.chk_docnum.setChecked(
self.conf.getParam('docStruct', 'outNumber'))
#Separatore #Separatore
found = False found = False
for itmn in range(self.titoloui.lyt_sep.count()): for itmn in range(self.titoloui.lyt_sep.count()):
@@ -246,7 +248,8 @@ class bananaTitolo(PyQt5.QtWidgets.QWidget):
found = True found = True
if not found: if not found:
self.titoloui.rad_altro.setChecked(True) self.titoloui.rad_altro.setChecked(True)
self.titoloui.lin_altro.setText(self.conf.getParam('docStruct', 'customSep')) self.titoloui.lin_altro.setText(
self.conf.getParam('docStruct', 'customSep'))
#finestra avanzate #finestra avanzate
self.advtitolo.fillInterface() self.advtitolo.fillInterface()
except: except:
@@ -259,17 +262,22 @@ class bananaTitolo(PyQt5.QtWidgets.QWidget):
def applica(self): def applica(self):
self.log.info(self.tr("Applico impostazioni Titolo")) self.log.info(self.tr("Applico impostazioni Titolo"))
self.conf.setParam(('docStruct','outDate'),self.titoloui.chk_data.isChecked()) self.conf.setParam(('docStruct', 'outDate'),
self.conf.setParam(('docStruct','outNumber'),self.titoloui.chk_docnum.isChecked()) self.titoloui.chk_data.isChecked())
self.conf.setParam(('docStruct','outTitle'),self.titoloui.chk_titolo.isChecked()) self.conf.setParam(('docStruct', 'outNumber'),
self.titoloui.chk_docnum.isChecked())
self.conf.setParam(('docStruct', 'outTitle'),
self.titoloui.chk_titolo.isChecked())
if self.titoloui.rad_dataita.isChecked(): if self.titoloui.rad_dataita.isChecked():
self.conf.setParam(('docStruct', 'outDateType'), 'ita') self.conf.setParam(('docStruct', 'outDateType'), 'ita')
elif self.titoloui.rad_datajpn.isChecked(): elif self.titoloui.rad_datajpn.isChecked():
self.conf.setParam(('docStruct', 'outDateType'), 'jpn') self.conf.setParam(('docStruct', 'outDateType'), 'jpn')
elif self.titoloui.rad_datausa.isChecked(): elif self.titoloui.rad_datausa.isChecked():
self.conf.setParam(('docStruct', 'outDateType'), 'usa') self.conf.setParam(('docStruct', 'outDateType'), 'usa')
self.conf.setParam(('docStruct','maxTitleLen'), self.titoloui.spn_ncarat.value()) self.conf.setParam(('docStruct', 'maxTitleLen'),
self.conf.setParam(('docStruct', 'customSep'),self.titoloui.lin_altro.text()) self.titoloui.spn_ncarat.value())
self.conf.setParam(('docStruct', 'customSep'),
self.titoloui.lin_altro.text())
for itmn in range(self.titoloui.lyt_sep.count()): for itmn in range(self.titoloui.lyt_sep.count()):
itm = self.titoloui.lyt_sep.itemAt(itmn).widget() itm = self.titoloui.lyt_sep.itemAt(itmn).widget()
if isinstance(itm, PyQt5.QtWidgets.QRadioButton): if isinstance(itm, PyQt5.QtWidgets.QRadioButton):
@@ -278,6 +286,7 @@ class bananaTitolo(PyQt5.QtWidgets.QWidget):
self.advtitolo.applica() self.advtitolo.applica()
pass pass
class bananaTitoloAvanzate(PyQt5.QtWidgets.QWidget): class bananaTitoloAvanzate(PyQt5.QtWidgets.QWidget):
def __init__(self, confloader=None, logger=None): def __init__(self, confloader=None, logger=None):
PyQt5.QtWidgets.QWidget.__init__(self) PyQt5.QtWidgets.QWidget.__init__(self)
@@ -303,17 +312,28 @@ class bananaTitoloAvanzate(PyQt5.QtWidgets.QWidget):
def fillInterface(self): def fillInterface(self):
try: try:
#rimepi interfaccia #rimepi interfaccia
self.titoloavui.rad_dataprimo.setChecked(self.conf.getParam('docStruct','datePos')==1) self.titoloavui.rad_dataprimo.setChecked(
self.titoloavui.rad_datasecondo.setChecked(self.conf.getParam('docStruct','datePos')==2) self.conf.getParam('docStruct', 'datePos') == 1)
self.titoloavui.rad_dataterzo.setChecked(self.conf.getParam('docStruct','datePos')==3) self.titoloavui.rad_datasecondo.setChecked(
self.titoloavui.rad_titoloprimo.setChecked(self.conf.getParam('docStruct','titlePos')==1) self.conf.getParam('docStruct', 'datePos') == 2)
self.titoloavui.rad_titolosecondo.setChecked(self.conf.getParam('docStruct','titlePos')==2) self.titoloavui.rad_dataterzo.setChecked(
self.titoloavui.rad_titoloterzo.setChecked(self.conf.getParam('docStruct','titlePos')==3) self.conf.getParam('docStruct', 'datePos') == 3)
self.titoloavui.rad_numeroprimo.setChecked(self.conf.getParam('docStruct','numberPos')==1) self.titoloavui.rad_titoloprimo.setChecked(
self.titoloavui.rad_numerosecondo.setChecked(self.conf.getParam('docStruct','numberPos')==2) self.conf.getParam('docStruct', 'titlePos') == 1)
self.titoloavui.rad_numeroterzo.setChecked(self.conf.getParam('docStruct','numberPos')==3) self.titoloavui.rad_titolosecondo.setChecked(
self.titoloavui.txt_prefisso.setText(self.conf.getParam('docStruct','outPrefix')) self.conf.getParam('docStruct', 'titlePos') == 2)
self.titoloavui.txt_suffisso.setText(self.conf.getParam('docStruct','outSuffix')) self.titoloavui.rad_titoloterzo.setChecked(
self.conf.getParam('docStruct', 'titlePos') == 3)
self.titoloavui.rad_numeroprimo.setChecked(
self.conf.getParam('docStruct', 'numberPos') == 1)
self.titoloavui.rad_numerosecondo.setChecked(
self.conf.getParam('docStruct', 'numberPos') == 2)
self.titoloavui.rad_numeroterzo.setChecked(
self.conf.getParam('docStruct', 'numberPos') == 3)
self.titoloavui.txt_prefisso.setText(
self.conf.getParam('docStruct', 'outPrefix'))
self.titoloavui.txt_suffisso.setText(
self.conf.getParam('docStruct', 'outSuffix'))
except: except:
self.log.critical(self.tr("AvanzateTitolo: Configurazione non accettata")) self.log.critical(self.tr("AvanzateTitolo: Configurazione non accettata"))
@@ -408,8 +428,10 @@ class bananaTitoloAvanzate(PyQt5.QtWidgets.QWidget):
else: else:
self.conf.setParam(('docStruct', 'titlePos'), -1) self.conf.setParam(('docStruct', 'titlePos'), -1)
#prefisso e suffisso #prefisso e suffisso
self.conf.setParam(('docStruct','outPrefix'), self.titoloavui.txt_prefisso.text()) self.conf.setParam(('docStruct', 'outPrefix'),
self.conf.setParam(('docStruct','outSuffix'), self.titoloavui.txt_suffisso.text()) self.titoloavui.txt_prefisso.text())
self.conf.setParam(('docStruct', 'outSuffix'),
self.titoloavui.txt_suffisso.text())
class bananaSelezOut(PyQt5.QtWidgets.QWidget): class bananaSelezOut(PyQt5.QtWidgets.QWidget):
@@ -428,16 +450,26 @@ class bananaSelezOut(PyQt5.QtWidgets.QWidget):
def fillInterface(self): def fillInterface(self):
try: try:
self.selezoutui.cmb_lingua.clear() self.selezoutui.cmb_lingua.clear()
self.selezoutui.cmb_lingua.addItems(self.conf.settingsList['languageconf.json'].keys()) self.selezoutui.cmb_lingua.addItems(
self.selezoutui.cmb_lingua.setCurrentIndex(self.conf.getParam('docStruct','languageIdx')) self.conf.settingsList['languageconf.json'].keys())
self.selezoutui.rad_mainbodyEFile.setChecked(self.conf.getParam('settings', 'saveBodyFile') and self.conf.getParam('settings', 'saveSeparateFiles')) self.selezoutui.cmb_lingua.setCurrentIndex(
self.selezoutui.rad_file.setChecked(self.conf.getParam('settings', 'saveSeparateFiles') and not self.conf.getParam('settings', 'saveBodyFile')) self.conf.getParam('docStruct', 'languageIdx'))
self.selezoutui.rad_mainbody.setChecked(self.conf.getParam('settings', 'saveBodyFile') and not self.conf.getParam('settings', 'saveSeparateFiles')) self.selezoutui.rad_mainbodyEFile.setChecked(self.conf.getParam(
self.selezoutui.chk_removeDuplicates.setChecked(self.conf.getParam('settings', 'removeDuplicates')) 'settings', 'saveBodyFile') and self.conf.getParam('settings', 'saveSeparateFiles'))
self.selezoutui.chk_includeTitle.setChecked(self.conf.getParam('settings', 'includeTitle')) self.selezoutui.rad_file.setChecked(self.conf.getParam(
self.selezoutui.chk_removeBreakWord.setChecked(self.conf.getParam('settings', 'delWordBreak')) 'settings', 'saveSeparateFiles') and not self.conf.getParam('settings', 'saveBodyFile'))
self.selezoutui.chk_cleaDestFolder.setChecked(self.conf.getParam('settings', 'removeOldFiles')) self.selezoutui.rad_mainbody.setChecked(self.conf.getParam(
self.selezoutui.lin_specialChars.setText(''.join(self.conf.getParam('settings', 'delChars'))) 'settings', 'saveBodyFile') and not self.conf.getParam('settings', 'saveSeparateFiles'))
self.selezoutui.chk_removeDuplicates.setChecked(
self.conf.getParam('settings', 'removeDuplicates'))
self.selezoutui.chk_includeTitle.setChecked(
self.conf.getParam('settings', 'includeTitle'))
self.selezoutui.chk_removeBreakWord.setChecked(
self.conf.getParam('settings', 'delWordBreak'))
self.selezoutui.chk_cleaDestFolder.setChecked(
self.conf.getParam('settings', 'removeOldFiles'))
self.selezoutui.lin_specialChars.setText(
''.join(self.conf.getParam('settings', 'delChars')))
pass pass
except: except:
self.log.critical(self.tr("SelezUscita: Configurazione non accettata")) self.log.critical(self.tr("SelezUscita: Configurazione non accettata"))
@@ -445,24 +477,32 @@ class bananaSelezOut(PyQt5.QtWidgets.QWidget):
def applica(self): def applica(self):
self.log.info(self.tr("Applico Impostazioni File Uscita")) self.log.info(self.tr("Applico Impostazioni File Uscita"))
self.conf.setParam(('docStruct', 'language'), self.selezoutui.cmb_lingua.currentText()) self.conf.setParam(('docStruct', 'language'),
self.conf.setParam(('docStruct', 'languageIdx'), self.selezoutui.cmb_lingua.currentIndex()) self.selezoutui.cmb_lingua.currentText())
self.conf.setParam(('docStruct', 'languageIdx'),
self.selezoutui.cmb_lingua.currentIndex())
self.conf.setParam(('settings', 'saveBodyFile'), self.selezoutui.rad_mainbody.isChecked() self.conf.setParam(('settings', 'saveBodyFile'), self.selezoutui.rad_mainbody.isChecked()
| self.selezoutui.rad_mainbodyEFile.isChecked()) | self.selezoutui.rad_mainbodyEFile.isChecked())
self.conf.setParam(('settings', 'saveSeparateFiles'), self.selezoutui.rad_file.isChecked() self.conf.setParam(('settings', 'saveSeparateFiles'), self.selezoutui.rad_file.isChecked()
| self.selezoutui.rad_mainbodyEFile.isChecked()) | self.selezoutui.rad_mainbodyEFile.isChecked())
self.conf.setParam(('settings', 'removeDuplicates'), self.selezoutui.chk_removeDuplicates.isChecked()) self.conf.setParam(('settings', 'removeDuplicates'),
self.conf.setParam(('settings', 'includeTitle'), self.selezoutui.chk_removeDuplicates.isChecked()) self.selezoutui.chk_removeDuplicates.isChecked())
self.conf.setParam(('settings', 'delWordBreak'), self.selezoutui.chk_removeBreakWord.isChecked()) self.conf.setParam(('settings', 'includeTitle'),
self.conf.setParam(('settings', 'removeOldFiles'), self.selezoutui.chk_cleaDestFolder.isChecked()) self.selezoutui.chk_removeDuplicates.isChecked())
self.conf.setParam(('settings', 'delChars'), list(self.selezoutui.lin_specialChars.text())) self.conf.setParam(('settings', 'delWordBreak'),
self.selezoutui.chk_removeBreakWord.isChecked())
self.conf.setParam(('settings', 'removeOldFiles'),
self.selezoutui.chk_cleaDestFolder.isChecked())
self.conf.setParam(('settings', 'delChars'), list(
self.selezoutui.lin_specialChars.text()))
pass pass
def splitta(self): def splitta(self):
# costruisco il dizionario di configurazione # costruisco il dizionario di configurazione
prefile = self.conf.inUse prefile = self.conf.inUse
splconf = copy.deepcopy(self.conf.dump()) splconf = copy.deepcopy(self.conf.dump())
lang = copy.deepcopy(self.conf.use('languageconf.json').getParam(splconf['docStruct']['language'])) lang = copy.deepcopy(self.conf.use(
'languageconf.json').getParam(splconf['docStruct']['language']))
splconf['docStruct']['language'] = lang splconf['docStruct']['language'] = lang
self.conf.use(prefile) self.conf.use(prefile)
@@ -472,19 +512,23 @@ class bananaSelezOut(PyQt5.QtWidgets.QWidget):
if i == splconf['docStruct']['numberPos'] and splconf['docStruct']['outNumber']: if i == splconf['docStruct']['numberPos'] and splconf['docStruct']['outNumber']:
nametemp.append("{docnum}") nametemp.append("{docnum}")
if i == splconf['docStruct']['datePos'] and splconf['docStruct']['outDate']: if i == splconf['docStruct']['datePos'] and splconf['docStruct']['outDate']:
nametemp.append(splconf['docStruct']['dateFormats'][splconf['docStruct']['outDateType']]) nametemp.append(splconf['docStruct']['dateFormats']
[splconf['docStruct']['outDateType']])
if i == splconf['docStruct']['titlePos'] and splconf['docStruct']['outTitle']: if i == splconf['docStruct']['titlePos'] and splconf['docStruct']['outTitle']:
nametemp.append("{title}") nametemp.append("{title}")
pass pass
if splconf['docStruct']['outPrefix'] != '': if splconf['docStruct']['outPrefix'] != '':
nametemp.insert(0, splconf['docStruct']['outPrefix']) #inserisco prefisso e suffisso # inserisco prefisso e suffisso
nametemp.insert(0, splconf['docStruct']['outPrefix'])
if splconf['docStruct']['outSuffix'] != '': if splconf['docStruct']['outSuffix'] != '':
nametemp.append(splconf['docStruct']['outSuffix']) nametemp.append(splconf['docStruct']['outSuffix'])
#unisco i pezzi #unisco i pezzi
splconf['docStruct']['outNameFormat'] = splconf['docStruct']['outNameSep'].join(nametemp)+splconf['docStruct']['outExt'] splconf['docStruct']['outNameFormat'] = splconf['docStruct']['outNameSep'].join(
nametemp)+splconf['docStruct']['outExt']
#costruisco messageBox #costruisco messageBox
msgb = QMessageBox(parent=self, icon=QMessageBox.Warning, text=self.tr("Sto SPLITTANDO, attendi..")) msgb = QMessageBox(parent=self, icon=QMessageBox.Warning,
text=self.tr("Sto SPLITTANDO, attendi.."))
msgb.setWindowTitle(self.tr("Sto Splittando..")) msgb.setWindowTitle(self.tr("Sto Splittando.."))
msgb.show() msgb.show()
@@ -497,7 +541,8 @@ class bananaSelezOut(PyQt5.QtWidgets.QWidget):
try: try:
for f in splconf['paths']['fileList']: for f in splconf['paths']['fileList']:
splconf['name'] = f splconf['name'] = f
tDict[f] = bananaSPLITTER(fileParams=copy.deepcopy(splconf), logger=self.log) tDict[f] = bananaSPLITTER(
fileParams=copy.deepcopy(splconf), logger=self.log)
tDict[f].sendStatus.connect(updateState) tDict[f].sendStatus.connect(updateState)
tDict[f].run() tDict[f].run()
#QThreadPool.globalInstance().start(tDict[f]) #QThreadPool.globalInstance().start(tDict[f])
@@ -507,6 +552,7 @@ class bananaSelezOut(PyQt5.QtWidgets.QWidget):
msgb.setText(self.tr("FINITO!")) msgb.setText(self.tr("FINITO!"))
pass pass
class bananaAdvOpt(PyQt5.QtWidgets.QWidget): class bananaAdvOpt(PyQt5.QtWidgets.QWidget):
update = pyqtSignal() update = pyqtSignal()
@@ -526,7 +572,8 @@ class bananaAdvOpt(PyQt5.QtWidgets.QWidget):
def fillInterface(self): def fillInterface(self):
try: try:
self.advoptui.txt_confFile.setPlainText(json.dumps(self.conf.dump(),indent=2)) self.advoptui.txt_confFile.setPlainText(
json.dumps(self.conf.dump(), indent=2))
except: except:
self.log.critical(self.tr("AdvancedOptions: Configurazione non accettata")) self.log.critical(self.tr("AdvancedOptions: Configurazione non accettata"))
pass pass
@@ -536,13 +583,16 @@ class bananaAdvOpt(PyQt5.QtWidgets.QWidget):
self.errmsg.setModal(True) self.errmsg.setModal(True)
self.errmsg.setWindowTitle(self.tr("Avanzate Globali")) self.errmsg.setWindowTitle(self.tr("Avanzate Globali"))
icon = PyQt5.QtGui.QIcon() icon = PyQt5.QtGui.QIcon()
icon.addPixmap(PyQt5.QtGui.QPixmap(":/icons/icons8-smartphone-ram-100.png"), PyQt5.QtGui.QIcon.Normal, PyQt5.QtGui.QIcon.Off) icon.addPixmap(PyQt5.QtGui.QPixmap(":/icons/icons8-smartphone-ram-100.png"),
PyQt5.QtGui.QIcon.Normal, PyQt5.QtGui.QIcon.Off)
self.errmsg.setWindowIcon(icon) self.errmsg.setWindowIcon(icon)
try: try:
self.conf.loads(self.advoptui.txt_confFile.toPlainText()) self.conf.loads(self.advoptui.txt_confFile.toPlainText())
self.log.info(self.tr("Parametri inseriti validi, configurazione accettata")) self.log.info(
self.tr("Parametri inseriti validi, configurazione accettata"))
self.errmsg.setIcon(QMessageBox.Information) self.errmsg.setIcon(QMessageBox.Information)
self.errmsg.setText(self.tr("Parametri inseriti validi, configurazione accettata")) self.errmsg.setText(
self.tr("Parametri inseriti validi, configurazione accettata"))
self.errmsg.show() self.errmsg.show()
self.update.emit() self.update.emit()
self.hide() self.hide()
@@ -558,31 +608,38 @@ class bananaAdvOpt(PyQt5.QtWidgets.QWidget):
self.hide() self.hide()
pass pass
class bananaSplitterInterface(PyQt5.QtWidgets.QWidget): class bananaSplitterInterface(PyQt5.QtWidgets.QWidget):
def __init__(self, confloader=None, logger=None): def __init__(self, confloader=None, logger=None):
PyQt5.QtWidgets.QWidget.__init__(self) PyQt5.QtWidgets.QWidget.__init__(self)
pass pass
class spexAbout(PyQt5.QtWidgets.QDialog): class spexAbout(PyQt5.QtWidgets.QDialog):
def __init__(self, confloader=None, logger=None): def __init__(self, confloader=None, logger=None):
PyQt5.QtWidgets.QDialog.__init__(self) PyQt5.QtWidgets.QDialog.__init__(self)
self.abt = Ui_about() self.abt = Ui_about()
self.abt.setupUi(self) self.abt.setupUi(self)
self.abt.lbl_info.setText(self.abt.lbl_info.text().replace('{ver}',confloader.getParam('version'))) self.abt.lbl_info.setText(self.abt.lbl_info.text().replace(
'{ver}', confloader.getParam('version')))
self.show() self.show()
pass pass
############################################################# #############################################################
####################### MAIN ################################ ####################### MAIN ################################
############################################################# #############################################################
def except_hook(cls, exception, traceback): def except_hook(cls, exception, traceback):
sys.__excepthook__(cls, exception, traceback) sys.__excepthook__(cls, exception, traceback)
if __name__ == '__main__': if __name__ == '__main__':
app = PyQt5.QtWidgets.QApplication(sys.argv) app = PyQt5.QtWidgets.QApplication(sys.argv)
sys.excepthook = except_hook sys.excepthook = except_hook
try: try:
print(os.getcwd()) print(f"Running directory {os.environ['WORKSPACELOC']}")
print(f"Pythonpath: {os.environ['PYTHONPATH']}")
LOGGER = fancyLogger(filepath=r"./conf/loggerconf.json", fileLog=False) LOGGER = fancyLogger(filepath=r"./conf/loggerconf.json", fileLog=False)
conf = bananaCONF(workdir=r"./conf", logger=LOGGER) conf = bananaCONF(workdir=r"./conf", logger=LOGGER)
conf.open() conf.open()

View File

@@ -109,5 +109,3 @@ class bananaCONF(QObject):
jconf = json.loads(conf) jconf = json.loads(conf)
self.settingsList[self.inUse]=jconf self.settingsList[self.inUse]=jconf

View File

@@ -10,9 +10,7 @@ import time, parse, re, copy, os, json
import traceback import traceback
class bananaSPLITTER(QObject): class bananaSPLITTER(QObject):
sendStatus = pyqtSignal(str) sendStatus = pyqtSignal(str)
def __init__(self, fileParams=None, logger=None): def __init__(self, fileParams=None, logger=None):
try: try:
QObject.__init__(self) QObject.__init__(self)