Skip to content

Commit

Permalink
Merge pull request #96 from yarikoptic/enh-codespell
Browse files Browse the repository at this point in the history
add codespell: configuration, workflow + get it to fix found typos
  • Loading branch information
SteffenBrinckmann authored Oct 25, 2023
2 parents b161f9a + 8a38220 commit c7d42b6
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 25 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ and execute "python -m pasta_eln.test"

#### HOW TO DIFF Version-1 and Version-2
**COMPARE BOTH DIRECTIONS**
at .. pasta-eln$ and remeber the changes required to Version2 in first change. If nothing to remember, do not execute 2nd command
at .. pasta-eln$ and remember the changes required to Version2 in first change. If nothing to remember, do not execute 2nd command
``` bash
kdiff pasta_eln/miscTools.py ../Python/miscTools.py
kdiff ../Python/miscTools.py pasta_eln/miscTools.py
Expand Down
4 changes: 2 additions & 2 deletions docs/source/faqs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Implementation
- no lock-in by software, software-architecture
- Best version
- A scientist has a desktop-based version that uploads the data to central servers.
- Supervisors, guests can use the webbased version to see the meta-data
- Supervisors, guests can use the web-based version to see the meta-data
- The database can be filled with a command-line-interface (CLI), desktop program or cellphone.
- Similar to 'git' which is the standard for distributed development.

Expand All @@ -62,7 +62,7 @@ Implementation
*Why is the software for some users fast and for others slow?*
We are aware of different run-times in different operating system. A backend test has different execution times on Windows (Thinkpad E495: 57.9sec), macOS (Macbook Air 2020: 20.8sec) and Linux (Thinkpad E495: 14.8sec). The graphical user interface seems to work similarly fast on all operating systems. We will investigate how to speed up the backend for Windows users in the future.

*Why dont' you package everything in a flatpak or snap?*
*Why don't you package everything in a flatpak or snap?*
Containerization is a great concept for many software as it separates the host operating system from the software. This concept is not for PASTA-ELN because we require and want to extend extractors [See ...](extractors.md). As such the user/scientist should be able to change code and require libraries that are not included by default. These libraries cannot be added to the container. Scientist developed extractors cannot be archived in a container which should be self-sufficient and encapsulated. (Also, one could think of creating detours via system-calls / demons on the host system. However, flatpak and snap severely restrict host system-calls and cannot interact with processes on the host system.)

Why does PASTA-ELN work in the way it does?
Expand Down
2 changes: 1 addition & 1 deletion docs/source/motivation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ All documents have the following properties
- type is a list of hierarchical types:
- examples for most data: ["measurement", "Zeiss tif image"], ["measurement", "Indentation", "Pop-in study"]
- text items (projects, tasks) are ["x0"], ["x1"], ... as the types are non hierarchical in the class view (IT-term). A task is not a special class of the project class. Moreover, the hierarchical level is ingrained in the type
- Tags #tag, #1 (no spaces in the string). #1 implies one-star, #2 implies two-stars. Tags are stored as list of stings.
- Tags #tag, #1 (no spaces in the string). #1 implies one-star, #2 implies two-stars. Tags are stored as list of strings.
- other fields can be easily added in the comment field of the form and are thereafter separated. Examples for other fields: :BakingTime:2h: :quality:3: (':' is a marker here)
- Comments
- If the user enters a comment in the comment field: tags and fields are subtracted and everything that remains is the comment
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/GUI/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, comm:Communicate, startTab:str=''):
tabGUI = ConfigurationAuthors(self.comm, self.finished)
tabW.addTab(tabGUI, 'Authors')

# Setup / Troubeshoot Pasta: main widget
# Setup / Troubleshoot Pasta: main widget
tabSetup = ConfigurationSetup(self.comm, self.finished)
tabW.addTab(tabSetup, 'Setup')

Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/GUI/configSetupLinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, comm:Communicate, callbackFinished:Callable[[],None]):

def callbackProgress(self, number:int) -> None:
"""
Increse progressbar by moving to number
Increase progressbar by moving to number
Args:
number (int): integer to move to
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/GUI/configSetupWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, comm:Communicate, callbackFinished:Callable[[],None]):

def callbackProgress(self, number:int) -> None:
"""
Increse progressbar by moving to number
Increase progressbar by moving to number
Args:
number (int): integer to move to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def data(self,
index: Union[QModelIndex, QPersistentModelIndex],
role: int = Qt.ItemDataRole) -> Any: # type: ignore[assignment]
"""
Overriden method for getting the data, only handles the PROPS_TABLE_LIST_COLUMN_INDEX case
Overridden method for getting the data, only handles the PROPS_TABLE_LIST_COLUMN_INDEX case
Args:
index (Union[QModelIndex, QPersistentModelIndex]): Table cell index
role (int): Role for the data
Expand Down
4 changes: 2 additions & 2 deletions pasta_eln/GUI/projectGroup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Table Header dialog: change which colums are shown and in which order """
""" Table Header dialog: change which columns are shown and in which order """
import json, platform
from enum import Enum
from pathlib import Path
Expand All @@ -14,7 +14,7 @@
from ..guiCommunicate import Communicate

class ProjectGroup(QDialog):
""" Table Header dialog: change which colums are shown and in which order """
""" Table Header dialog: change which columns are shown and in which order """
def __init__(self, comm:Communicate):
"""
Initialization
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/GUI/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def change(self, docType:str, projID:str) -> None:
self.showHidden.setText(f'Show/hide hidden {docLabel.lower()}')
self.filterHeader = self.comm.backend.db.getColumnNames()[self.docType].split(',')
self.filterHeader = [i[1:] if i[0]=='-' else i for i in self.filterHeader] #change -something to something
self.filterHeader = [i[2:] if i[:2]=='#_' else i for i in self.filterHeader] #change #_something to somehing
self.filterHeader = [i[2:] if i[:2]=='#_' else i for i in self.filterHeader] #change #_something to something
self.headerW.show()
nrows, ncols = len(self.data), len(self.filterHeader)
model = QStandardItemModel(nrows, ncols)
Expand Down
4 changes: 2 additions & 2 deletions pasta_eln/GUI/tableHeader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Table Header dialog: change which colums are shown and in which order """
""" Table Header dialog: change which columns are shown and in which order """
from enum import Enum
from typing import Any
from PySide6.QtWidgets import QDialog, QVBoxLayout, QListWidget, QLineEdit, QDialogButtonBox # pylint: disable=no-name-in-module
Expand All @@ -8,7 +8,7 @@
from ..fixedStringsJson import tableHeaderHelp

class TableHeader(QDialog):
""" Table Header dialog: change which colums are shown and in which order """
""" Table Header dialog: change which columns are shown and in which order """
def __init__(self, comm:Communicate, docType:str):
"""
Initialization
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def main() -> None:
usage+= commands(True, argparse.Namespace())
argparser = argparse.ArgumentParser(usage=usage)
argparser.add_argument('command', help='see above...')
argparser.add_argument('-i','--docID', help='docID of project; a long alpha-numeric code', default='')
argparser.add_argument('-i','--docID', help='docID of project; a long alphanumeric code', default='')
argparser.add_argument('-c','--content', help='content to save/store', default=None)
argparser.add_argument('-l','--label', help='label used for printing', default='x0')
argparser.add_argument('-d','--database',help='name of database configuration', default='') #required for be = Pasta(args.database)
Expand Down
6 changes: 3 additions & 3 deletions pasta_eln/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def saveDoc(self, doc:dict[str,Any]) -> dict[str,Any]:
- full path (from basePath) allows to easily create a view of all paths and search through them
during each scan, which happens rather often
- just the incremental path (file-name, folder-name) allows to easily change that if the user wants
and not change all the children paths, too. However, the renaming of the folder is likely occuring
and not change all the children paths, too. However, the renaming of the folder is likely occurring
less often.
Args:
Expand Down Expand Up @@ -348,7 +348,7 @@ def updateDoc(self, change:dict[str,Any], docID:str) -> dict[str,Any]:
elif item in newDoc:
oldDoc[item] = newDoc[item]
newDoc[item] = change[item]
# Always update, for some reason single tags are not recongnized
# Always update, for some reason single tags are not recognized
# if nothingChanged:
# logging.debug('database.update.2: doc not updated-nothing changed: '+newDoc['_id']+' '+newDoc['-name'])
# return newDoc
Expand Down Expand Up @@ -720,7 +720,7 @@ def historyDB(self) -> dict[str,Any]:
if np.min(value) < firstSubmit:
firstSubmit = np.min(value)
bins = np.linspace(firstSubmit, datetime.now().timestamp(), 100 )
#calculate histgram and save it
#calculate histogram and save it
collectionCopy = dict(collection)
for key,value in collection.items():
hist, _ = np.histogram(value, bins)
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def mainGUI() -> tuple[Union[QCoreApplication, None], MainWindow]:
if not isinstance(qta.icon('fa5s.times'), QIcon):
logging.error('qtawesome: could not load. Likely matplotlib is included and can not coexist.')
print('qtawesome: could not load. Likely matplotlib is included and can not coexist.')
# end test coexistance
# end test coexistence
logging.info('End PASTA GUI')
return application, main_window

Expand Down
4 changes: 2 additions & 2 deletions pasta_eln/handleDictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def ontologyV2_to_V3(ontology: dict[str, Any]) -> None:

def fillDocBeforeCreate(data:dict[str,Any], docType:list[str]) -> dict[str,Any]:
""" Fill the data before submission to database with common data
- type, project, childs
- type, project, children
- separate comment into tags, fields
- create id if needed
Expand Down Expand Up @@ -101,7 +101,7 @@ def fillDocBeforeCreate(data:dict[str,Any], docType:list[str]) -> dict[str,Any]:
data['comment'] =''
if '-tags' not in data:
data['-tags'] = []
#always do regex expressions twice: if #lala at beginnig or in middle of comment
#always do regex expressions twice: if #lala at beginning or in middle of comment
curated = re.findall(r'(?:^|\s)#_curated(?:\s|$)', data['comment']) # #_curated
rating = re.findall(r'(?:^|\s)#_\d(?:\s|$)', data['comment']) # #_number
if rating is None:
Expand Down
2 changes: 1 addition & 1 deletion pasta_eln/miscTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def outputString(fmt:str='print', level:str='info', message:str='') -> str:
""" Output a message into different formats:
- print: print to stdout
- logging; log to file
- text: return text string (superseeds html)
- text: return text string (supersedes html)
- html: return html string https://doc.qt.io/qtforpython/overviews/richtext-html-subset.html#supported-html-subset
- else: no output
- formats can be union ('print,text')
Expand Down
6 changes: 3 additions & 3 deletions pasta_eln/serverActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def listDocuments(url:str, userName:str, password:str, database:str, full:bool=T

def backupCouchDB(location:str='', userName:str='', password:str='') -> None:
"""
Backup everything of the CouchDB installation accross all databases and all configurations
Backup everything of the CouchDB installation across all databases and all configurations
- remote location uses username/password combo in local keystore
- local location requires username and password
Expand Down Expand Up @@ -406,7 +406,7 @@ def backupCouchDB(location:str='', userName:str='', password:str='') -> None:

def restoreCouchDB(location:str='', userName:str='', password:str='', fileName:str='') -> None:
"""
restore everything to the CouchDB installation accross all databases and all configurations
restore everything to the CouchDB installation across all databases and all configurations
- remote location uses username/password combo in local keystore
- local location requires username and password
Expand Down Expand Up @@ -485,7 +485,7 @@ def restoreCouchDB(location:str='', userName:str='', password:str='', fileName:s
docID = fileParts[1]
if not docID.endswith('_attach'):
continue #Did already in the first loop
#test if attachement exists: create otherwise
#test if attachment exists: create otherwise
attachPath = f'{docID[:-7]}/{fileParts[-1]}'
resp = requests.get(f'http://{location}:5984/{database}/{attachPath}', headers=headers, auth=authUser, timeout=10)
if resp.status_code == 404 and 'missing' in resp.json()['reason']:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[build-system]
requires = ["setuptools >= 43.0.0", "wheel"]

[tool.codespell]
skip = '.git,*.pdf,*.svg,*lookup*.json'
# for shortcuts like [l]ist
ignore-regex = '\[[a-z]\][a-z]+'
#
ignore-words-list = 'speciall,ons,crate,ser'
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def test_re_order_property_table_should_work_as_expected(self,
assert ui_form.propsCategoryComboBox.currentText() == "default", f"propsCategoryComboBox.currentText() should be default!"
model = ui_form.typePropsTableView.model()
assert model.rowCount() == 5, "5 properties must be present before deletion!"
# Initial data oder
# Initial data order
init_data_order = ['-name', 'status', 'objective', '-tags', 'comment']
post_reorder_data_order1 = ['-name', 'status', 'objective', 'comment', '-tags']
post_reorder_data_order2 = ['status', '-name', 'objective', 'comment', '-tags']
Expand Down

0 comments on commit c7d42b6

Please sign in to comment.