mirror of
https://github.com/infeeeee/dyn2py
synced 2025-12-16 22:16:18 +01:00
Compare commits
4 Commits
0.3.2
...
53712f76ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 53712f76ce | |||
| d5fad2beb6 | |||
| 4e4ada293e | |||
| 1e48aa144e |
1
.github/workflows/build-installer.yml
vendored
1
.github/workflows/build-installer.yml
vendored
@@ -19,7 +19,6 @@ jobs:
|
|||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dyn2py.exe
|
name: dyn2py.exe
|
||||||
path: dist/dyn2py.exe
|
|
||||||
- name: Update version number
|
- name: Update version number
|
||||||
run: |
|
run: |
|
||||||
$regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$'
|
$regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$'
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ dist
|
|||||||
docs
|
docs
|
||||||
tests/output_files
|
tests/output_files
|
||||||
Output
|
Output
|
||||||
|
dyn2py.exe
|
||||||
@@ -53,7 +53,7 @@ options:
|
|||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-v, --version show program's version number and exit
|
-v, --version show program's version number and exit
|
||||||
-l LOGLEVEL, --loglevel LOGLEVEL
|
-l LOGLEVEL, --loglevel LOGLEVEL
|
||||||
set log level, possible options: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
set log level, possible options: HEADLESS, CRITICAL, ERROR, WARNING, INFO, DEBUG
|
||||||
-n, --dry-run do not modify files, only show log
|
-n, --dry-run do not modify files, only show log
|
||||||
-F, --force overwrite even if the files are older
|
-F, --force overwrite even if the files are older
|
||||||
-b, --backup create a backup for updated files
|
-b, --backup create a backup for updated files
|
||||||
@@ -68,6 +68,7 @@ dynamo options, only for processing Dynamo graphs:
|
|||||||
The script by default overwrites older files with newer files.
|
The script by default overwrites older files with newer files.
|
||||||
Do not move the source Dynamo graphs, or update won't work with them later.
|
Do not move the source Dynamo graphs, or update won't work with them later.
|
||||||
Multiple sources are supported, separate them by spaces.
|
Multiple sources are supported, separate them by spaces.
|
||||||
|
HEADLESS loglevel only prints modified filenames.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
@@ -180,7 +181,7 @@ pyinstaller dyn2py.spec
|
|||||||
### Create installer for Windows
|
### Create installer for Windows
|
||||||
|
|
||||||
- Install Inno Setup: https://jrsoftware.org/isdl.php
|
- Install Inno Setup: https://jrsoftware.org/isdl.php
|
||||||
- The already built exe should be in `dist\dyn2py.exe`
|
- The already built exe should be in the root folder
|
||||||
- Run this in powershell:
|
- Run this in powershell:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ ChangesEnvironment=yes
|
|||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Source: "dist\dyn2py.exe"; DestDir: "{app}"; Flags: ignoreversion external
|
Source: "dyn2py.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
|
||||||
|
|
||||||
[Code]
|
[Code]
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ def __command_line() -> None:
|
|||||||
The script by default overwrites older files with newer files.
|
The script by default overwrites older files with newer files.
|
||||||
Do not move the source Dynamo graphs, or update won't work with them later.
|
Do not move the source Dynamo graphs, or update won't work with them later.
|
||||||
Multiple sources are supported, separate them by spaces.
|
Multiple sources are supported, separate them by spaces.
|
||||||
|
HEADLESS loglevel only prints modified filenames.
|
||||||
""")
|
""")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -117,8 +118,13 @@ def run(options: Options) -> None:
|
|||||||
from_command_line = bool(inspect.stack()[1].function == "__command_line")
|
from_command_line = bool(inspect.stack()[1].function == "__command_line")
|
||||||
|
|
||||||
# Set up logging:
|
# Set up logging:
|
||||||
|
if options.loglevel == "HEADLESS":
|
||||||
|
loglevel = "CRITICAL"
|
||||||
|
else:
|
||||||
|
loglevel = options.loglevel
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s: %(message)s',
|
logging.basicConfig(format='%(levelname)s: %(message)s',
|
||||||
level=options.loglevel)
|
level=loglevel)
|
||||||
logging.debug(f"Run options: {vars(options)}")
|
logging.debug(f"Run options: {vars(options)}")
|
||||||
|
|
||||||
# Set up sources:
|
# Set up sources:
|
||||||
@@ -197,4 +203,7 @@ def run(options: Options) -> None:
|
|||||||
|
|
||||||
# Write files at the end:
|
# Write files at the end:
|
||||||
for f in DynamoFile.open_files | PythonFile.open_files:
|
for f in DynamoFile.open_files | PythonFile.open_files:
|
||||||
|
try:
|
||||||
f.write(options)
|
f.write(options)
|
||||||
|
except FileNotFoundError:
|
||||||
|
logging.error(f"Cannot save file! {f.filepath}")
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ class File():
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
TypeError: If called on a File object
|
TypeError: If called on a File object
|
||||||
|
FileNotFoundError: Target folder does not exist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not options:
|
if not options:
|
||||||
@@ -140,14 +141,20 @@ class File():
|
|||||||
backup_path = self.dirpath.joinpath(backup_filename)
|
backup_path = self.dirpath.joinpath(backup_filename)
|
||||||
logging.info(f"Creating backup to {backup_path}")
|
logging.info(f"Creating backup to {backup_path}")
|
||||||
self.filepath.rename(backup_path)
|
self.filepath.rename(backup_path)
|
||||||
|
if options.loglevel == "HEADLESS":
|
||||||
|
print(backup_path)
|
||||||
|
|
||||||
# Call filetype specific methods:
|
# Call filetype specific methods:
|
||||||
if options.dry_run:
|
if options.dry_run:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Should write file, but it's a dry-run: {self.filepath}")
|
f"Should write file, but it's a dry-run: {self.filepath}")
|
||||||
else:
|
else:
|
||||||
|
if not self.dirpath.exists():
|
||||||
|
raise FileNotFoundError("File dir does not exist!")
|
||||||
logging.info(f"Writing file: {self.filepath}")
|
logging.info(f"Writing file: {self.filepath}")
|
||||||
self._write_file()
|
self._write_file()
|
||||||
|
if options.loglevel == "HEADLESS":
|
||||||
|
print(self.filepath)
|
||||||
|
|
||||||
def _write_file(self):
|
def _write_file(self):
|
||||||
"""Should be implemented in subclasses
|
"""Should be implemented in subclasses
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import argparse
|
|||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
LOGLEVELS = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
|
LOGLEVELS = ["HEADLESS", "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
|
||||||
DEFAULT_LOGLEVEL = "INFO"
|
DEFAULT_LOGLEVEL = "INFO"
|
||||||
FILTERS = ["py", "dyn"]
|
FILTERS = ["py", "dyn"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "dyn2py"
|
name = "dyn2py"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
description = "Extract python code from Dynamo graphs"
|
description = "Extract python code from Dynamo graphs"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
|
|||||||
Reference in New Issue
Block a user