Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improved typing, event based signatures, issue #15 #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions .vscode/bookmarks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,72 @@
"path": "fpo.py",
"bookmarks": [
{
"line": 285,
"line": 396,
"column": 0,
"label": "Conventions"
},
{
"line": 298,
"line": 409,
"column": 0,
"label": "Imports"
},
{
"line": 358,
"line": 470,
"column": 0,
"label": "Symbol constants"
},
{
"line": 401,
"line": 510,
"column": 0,
"label": "Supported property types"
},
{
"line": 442,
"line": 547,
"column": 0,
"label": "Utility functions"
},
{
"line": 600,
"line": 717,
"column": 0,
"label": "Property"
},
{
"line": 714,
"line": 829,
"column": 0,
"label": "Display Mode"
},
{
"line": 910,
"line": 1029,
"column": 0,
"label": "Type Meta"
},
{
"line": 1067,
"line": 1198,
"column": 0,
"label": "Preference"
},
{
"line": 1187,
"line": 1364,
"column": 0,
"label": "proxy decorator"
},
{
"line": 1238,
"line": 1418,
"column": 0,
"label": "view_proxy decorator"
},
{
"line": 1322,
"column": 0,
"label": "DataProxy Templates"
},
{
"line": 1635,
"line": 1889,
"column": 0,
"label": "ViewProxy templates"
},
{
"line": 1870,
"line": 2133,
"column": 0,
"label": "Migrations"
},
{
"line": 1999,
"line": 2377,
"column": 0,
"label": "Module init"
}
Expand Down
13 changes: 12 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"editor.rulers": [
80, 100, 120
],
"cSpell.diagnosticLevel": "Hint",
"cSpell.words": [
"cleartext",
"fcapi",
Expand Down Expand Up @@ -142,5 +143,15 @@
"editor.wordBasedSuggestions": "off"
},
"ruff.lineLength": 100,
"ruff.nativeServer": true
"ruff.nativeServer": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.venv": true,
"**/__pycache__": true
}
}
34 changes: 34 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
Copyright 2024 Frank David Martinez M (mnesarco)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# 1.0.0 beta5 - 2024-12-09

## Global changes

- Added ruff linter and formatter

## fpo

- Explicit Property constructors to help linters and autocompletion
- [breaking] Changed callback methods signature to accept single event object or nothing
- Added events namespace with all *Event types
- Added DataProxy and ViewProxy protocols for documentation
- Updated Property* constructors, generated from FreeCAD source Application.cpp
- Improved typings

## fcui

- Improved typings
2,926 changes: 0 additions & 2,926 deletions dev_utils/Properties.html

This file was deleted.

14 changes: 14 additions & 0 deletions dev_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Frank David Martinez M (mnesarco)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

54 changes: 54 additions & 0 deletions dev_utils/gen_std_props.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2024 Frank David Martinez M (mnesarco)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Generator of Property constructors."""

# ruff: noqa: PTH123, T201

import re
import sys
from pathlib import Path

DIR = Path(__file__).parent
PROP = re.compile(r"App::(Property\w+)\s*::init\(\);")

EXCLUDE = {
"PropertyContainer",
"PropertyExpressionContainer",
"PropertyXLinkContainer",
"PropertyLinkBase",
"PropertyLinkListBase",
"PropertyLists",
"PropertyEnumeration",
}

def main(src: Path) -> None:
"""Extract Property classes initialized in Application.cpp from FreeCAD sources."""
with open(Path(DIR, "generated_properties.py"), "w") as fout:
for path in src.glob("**/Application.cpp"):
fout.write(f"##: Generated from <FreeCAD_sources>/src/App/{path.name}\n")
fout.write("##: Supported Property types\n")
fout.write(f"##: {'─' * 77}\n")

print(f"Extracting from: {path}")
with open(path) as file:
cpp = file.read()
all_unique = sorted(set(PROP.findall(cpp)))
for p in all_unique:
print(f"Found property: {p}")
if p not in EXCLUDE:
fout.write(f'{p} = _prop_constructor("App::{p}")\n')

if __name__ == "__main__":
main(Path(sys.argv[1]))
13 changes: 0 additions & 13 deletions dev_utils/list_all_props.py

This file was deleted.

Loading