It makes no difference for me to be honest and moving them might cause some problems in CMake files and downstream for package maintaners. I'd leave them for now unless someone is willing to move thembernd wrote:I'm with you here.PrzemoF wrote:...
My proposition:
1. Fem* for general python modules,
2. ccx* for CalculiX related stuff
3. _Command* for GUI commands (underscore suggest internal use only).
Most of FEM python modules match this convention already
How about Python ui files? Should they be moved together with cpp ui files in a separate directory like the icons ?
FEM Python coding standard
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: Python coding standad [WORK IN PROGRESS]
Re: Python coding standard [WORK IN PROGRESS]
No Licence ?microelly2 wrote:I had some requirements for handling macros and want remember this here
A macro should have at least theese meta information for autogeneration
Re: Python coding standad [WORK IN PROGRESS]
okIt makes no difference for me to be honest and moving them might cause some problems in CMake files and downstream for package maintaners. I'd leave them for now unless someone is willing to move thembernd wrote:... How about Python ui files? Should they be moved together with cpp ui files in a separate directory like the icons ?
Re: Python coding standard [WORK IN PROGRESS]
The macro manager is/will be in the master branch of FreeCAD or it's a separate piece of code?microelly2 wrote:I had some requirements for handling macros and want remember this here
A macro should have at least theese meta information for autogenerationbackref: viewtopic.php?f=21&t=10905&start=20#p91086Code: Select all
__Comment__ = 'Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline)' __Web__ = "http://forum.freecadweb.org/viewtopic.php?f=22&t=5554" __Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Airfoil_Import_%26_Scale" __Icon__ = "/usr/lib/freecad/Mod/plugins/icons/airfoil.png" __Help__ = "start the macro and follow the instructions" __Author__ = "quick61" __Version__ = '2.1' __Status__ = 'stable' __Requires__ = 'freecad 0.14.3706' __Communication__ = 'your email adress or yourgit or something else'
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Python coding standard [WORK IN PROGRESS]
the plugin manager is still standalone. I want to have some standards for community plugins to improve the possibility to integrate them.
Until now it needs still extra work to integrate the macros,
so some conventions must be accepted to simplify and automate the process.
After this the plugin manager can become integrated and a standard plugin database can hold the information about community macros and workbenches.
Until now it needs still extra work to integrate the macros,
so some conventions must be accepted to simplify and automate the process.
After this the plugin manager can become integrated and a standard plugin database can hold the information about community macros and workbenches.
Re: Python coding standard [WORK IN PROGRESS]
OK, I'll add id in a separate section with macro requirements to the opening post.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Python coding standard [WORK IN PROGRESS]
Macros are stored in gits and have a Licence file inside (until now ).bernd wrote:No Licence ?microelly2 wrote:I had some requirements for handling macros and want remember this here
A macro should have at least theese meta information for autogeneration
My focus was:
If there is a published macro I can support the installation and updates for freecad users.
Mostly the licence is in the header of the file with the meta info and can be displayed.
But of course a link to the licence file/message can be integrated into the install dialog.
Re: Python coding standard [WORK IN PROGRESS]
Is there also a way to make code Python 3 ready, i.e. to force e.g. write print ("test") instead of print "test" ?The general rule is to follow PEP8 [1] and use flake8 [2] (or anything that allows PEP8 checks) to enforce it.
Re: Python coding standard [WORK IN PROGRESS]
In a way yes, but flake8 has to be run with python3 [1]:wmayer wrote:Is there also a way to make code Python 3 ready, i.e. to force e.g. write print ("test") instead of print "test" ?The general rule is to follow PEP8 [1] and use flake8 [2] (or anything that allows PEP8 checks) to enforce it.
Code: Select all
$fedora:/home/przemo/software/FreeCAD/freecad
$ python /usr/bin/flake8 --ignore=E265,E501 src/Mod/Fem/FemTools.py <-- clean run on python2
fedora:/home/przemo/software/FreeCAD/freecad
$ python3 /usr/bin/flake8 --ignore=E265,E501 src/Mod/Fem/FemTools.py
src/Mod/Fem/FemTools.py:242:71: E901 SyntaxError: invalid syntax <-- error on python3
Code: Select all
print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
P.S. For fedora users there is a package python3-flake8, so it's enough to run:
Code: Select all
fedora:/home/przemo/software/FreeCAD/freecad
$ python3-flake8 --ignore=E265,E501 src/Mod/Fem/FemTools.py
src/Mod/Fem/FemTools.py:242:71: E901 SyntaxError: invalid syntax
For those experimenting with phabricator: arc lint config for python2/3 checks:
Code: Select all
$ cat .arclint
{
"linters": {
"flake8-python2.7": {
"type": "flake8",
"bin": "/usr/bin/flake8",
"include": "(\\.py$)",
"exclude": "(^src/3rdParty/)",
"severity": {
"E265": "disabled",
"E501": "disabled"
}
},
"flake8-python3": {
"type": "flake8",
"bin": "/usr/bin/python3-flake8",
"include": "(\\.py$)",
"exclude": "(^src/3rdParty/)",
"severity": {
"E265": "disabled",
"E501": "disabled"
}
}
}
}
Re: Python coding standard [WORK IN PROGRESS]
I think the ui and icon files should be in a separate subdirectory /Mod/Fem/ and not the same location as the CPP files. It makes development easier for a beginner.How about Python ui files? Should they be moved together with cpp ui files in a separate directory like the icons ?