Skip to content

Commit

Permalink
Merge pull request #188 from nodedge/feature/script-style-svg
Browse files Browse the repository at this point in the history
Add a script to change style of SVGs.
  • Loading branch information
nodedge committed Mar 17, 2023
2 parents b9834db + 9e98824 commit 04f85ac
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .idea/nodedge.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ include_trailing_comma = True
force_grid_wrap=0
use_parentheses=True

known_third_party = PIL,PySide6,black,coloredlogs,graphene,numpy,pandas,pylab,pyqtconsole,pyqtgraph,pytest,pytestqt,recommonmark,scipy,setuptools,yaml
known_third_party = PIL,PyQt5,PySide6,asammdf,black,coloredlogs,control,graphene,lxml,markdown2,matplotlib,nptdms,numpy,pandas,pylab,pyqtgraph,pytest,pytestqt,recommonmark,scipy,setuptools,yaml

91 changes: 64 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,70 @@ repos:
stages: [commit]
- id: requirements-txt-fixer
stages: [commit]
- repo: local
- id: detect-private-key
stages: [commit]
- id: detect-aws-credentials
stages: [commit]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: tests
name: run tests
entry: tox -e py36
language: system
types: [python]
stages: [push]
pass_filenames: false
- id: typing
name: run typing checks
entry: tox -e mypy
language: system
types: [python]
- id: pyupgrade
stages: [commit]
args: [--py38-plus]
# - repo: https://github.com/mgedmin/check-manifest
# rev: "0.49"
# hooks:
# - id: check-manifest
# stages: [commit]

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.9
hooks:
- id: pymarkdown
stages: [commit]
pass_filenames: false
- id: packaging
name: run checks on packaging
entry: tox -e packaging
language: system
types: [python]
stages: [push]
pass_filenames: false
- id: docs_sphinx
name: run checks on docs_sphinx building
entry: tox -e docs_sphinx
language: system
types: [python]
stages: [push]
pass_filenames: false
args:
- --config
- pymarkdown_config.json
- scan
- .
- ./docs
- ./docs_sphinx
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
hooks:
- id: rst-linter
stages: [commit]



# - repo: local
# hooks:
# - id: tests
# name: run tests
# entry: tox -e py36
# language: system
# types: [python]
# stages: [push]
# pass_filenames: false
# - id: typing
# name: run typing checks
# entry: tox -e mypy
# language: system
# types: [python]
# stages: [commit]
# pass_filenames: false
# - id: packaging
# name: run checks on packaging
# entry: tox -e packaging
# language: system
# types: [python]
# stages: [push]
# pass_filenames: false
# - id: docs_sphinx
# name: run checks on docs_sphinx building
# entry: tox -e docs_sphinx
# language: system
# types: [python]
# stages: [push]
# pass_filenames: false
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ recursive-include deploy *

include deploy.py
include nodedge.spec

recursive-exclude docs/build *

include pymarkdown_config.json
135 changes: 135 additions & 0 deletions examples/discrete/discrete_transfer_function_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"id": 2187663561552,
"sceneWidth": 64000,
"sceneHeight": 64000,
"nodes": [
{
"id": 2187628269008,
"title": "discrete_tf",
"posX": -105.0,
"posY": -30.0,
"inputSockets": [
{
"id": 2187631814160,
"index": 0,
"allowMultiEdges": false,
"location": 1,
"socketType": 1
}
],
"outputSockets": [
{
"id": 2187663402000,
"index": 0,
"allowMultiEdges": true,
"location": 4,
"socketType": 1
}
],
"content": {},
"operationCode": 53,
"params": {
"numerator": {
"value": "[1,1]",
"type": 3,
"minValue": null,
"maxValue": null,
"step": null
},
"denominator": {
"value": "[1,1]",
"type": 3,
"minValue": null,
"maxValue": null,
"step": null
},
"initial state": {
"value": 0.0,
"type": 0,
"minValue": null,
"maxValue": null,
"step": null
}
}
},
{
"id": 2187663428880,
"title": "constant",
"posX": -435.0,
"posY": -45.0,
"inputSockets": [],
"outputSockets": [
{
"id": 2187663569552,
"index": 0,
"allowMultiEdges": true,
"location": 4,
"socketType": 0
}
],
"content": {
"value": "1"
},
"operationCode": 1,
"params": {}
},
{
"id": 2187663439824,
"title": "output",
"posX": 222.0,
"posY": -60.0,
"inputSockets": [
{
"id": 2187777699984,
"index": 0,
"allowMultiEdges": false,
"location": 1,
"socketType": 0
}
],
"outputSockets": [],
"content": {},
"operationCode": 2,
"params": {
"Scientific notation": {
"value": true,
"type": 2,
"minValue": null,
"maxValue": null,
"step": null
},
"Digits": {
"value": 2,
"type": 1,
"minValue": null,
"maxValue": null,
"step": null
}
}
}
],
"edges": [
{
"id": 2187618686032,
"edgeType": 3,
"source": 2187663569552,
"target": 2187631814160
},
{
"id": 2187663562448,
"edgeType": 3,
"source": 2187663402000,
"target": 2187777699984
}
],
"elements": [],
"simulator": {
"solver": "Basic solver",
"solverName": "a",
"solverOptions": "",
"timeStep": 1.0,
"maxIterations": 1.0,
"tolerance": 1.0,
"finalTime": 10.0
}
}
7 changes: 5 additions & 2 deletions nodedge/editor_window.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Editor window module containing :class:`~nodedge.editor_window.EditorWindow` class.
"""
Expand Down Expand Up @@ -879,7 +878,11 @@ def readSettings(self):
self.debugMode = True
else:
self.debugMode = debugMode
self.recentFiles = list(settings.value("recent_files", []))
recentFilesSettings = settings.value("recent_files", [])
if recentFilesSettings:
self.recentFiles = list(recentFilesSettings)
else:
self.recentFiles = []
self.updateRecentFilesMenu()

def writeSettings(self):
Expand Down
16 changes: 16 additions & 0 deletions pymarkdown_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"plugins": {
"no-space-in-code": {
"enabled": false
},
"no-space-in-emphasis": {
"enabled": false
},
"line-length": {
"enabled": false
},
"no-duplicate-heading": {
"enabled": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
asammdf
coloredlogs
npTDMS
numpy
pandas
pyqtconsole
pyqtgraph
PySide6
PyYAML
types-PyYAML
pyqtgraph
asammdf
numpy
pandas
tables
scipy
npTDMS
tables
types-PyYAML
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-r requirements_tests.txt
bump2version
pillow
pip-licenses
pre-commit
wheel
pyinstaller
pip-licenses
wheel
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements_dev.txt
check-manifest
pyinstaller
readme_renderer
twine
pyinstaller
File renamed without changes.
34 changes: 34 additions & 0 deletions resources/change_svg_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import logging
import os

from lxml import etree


def change_svg_properties(in_dir, out_dir, stroke_color, stroke_width):
if not os.path.exists(out_dir):
logging.info(f"Creating directory: {out_dir}")
os.mkdir(out_dir)

for f in os.listdir(in_dir):
full_path = os.path.join(in_dir, f)
print(in_dir + "/" + f)
if f.endswith(".svg"):
tree = etree.parse(full_path)
root = tree.getroot()
if root.get("stroke") is not stroke_color:
logging.info(
f"Changing stroke color from {root.get('stroke')} to {stroke_color} in {f}"
)
root.set("stroke", stroke_color)

if root.get("stroke-width") is not stroke_width:
logging.info(
f"Changing stroke width from {root.get('stroke-width')} to {stroke_width} in {f}"
)
root.set("stroke-width", str(stroke_width))

tree.write(os.path.join(out_dir, f))


if __name__ == "__main__":
change_svg_properties("white_lucide", "red_lucide", "red", 1)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
with open("HISTORY.md") as history_file:
history = history_file.read()

with open("requirements/packages/requirements.in") as requirements_file:
with open("requirements/packages/requirements.txt") as requirements_file:
requirements = requirements_file.read()

setup_requirements = ["pytest-runner"]
Expand Down

0 comments on commit 04f85ac

Please sign in to comment.