Skip to content

Commit cf80dd2

Browse files
committed
fix: error with custom_function args
1 parent ed03b51 commit cf80dd2

File tree

4 files changed

+191
-12
lines changed

4 files changed

+191
-12
lines changed

config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ rules:
1111
specific_command_mapping:
1212
"*DEL": stardel
1313
"C***": c
14+
"/INQUIRE": inquire
1415

1516
specific_classes:
16-
2D to 3D Analysis: Analysis 2D to 3D
17+
2D to 3D Analysis: Analysis 2D to 3D
18+
Parameters: Parameter definition

doc/source/conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved"
1111
author = "ANSYS, Inc."
1212
release = version = __version__
13-
cname = os.getenv("DOCUMENTATION_CNAME", "<DEFAULT_CNAME>")
13+
cname = os.getenv("DOCUMENTATION_CNAME", "pyconverter-xml2py.docs.pyansys.com")
1414
switcher_version = get_version_match(__version__)
1515

1616
REPOSITORY_NAME = "pyconverter-xml2py"
@@ -38,7 +38,7 @@
3838
"icon_links": [
3939
{
4040
"name": "Support",
41-
"url": "https://github.com/ansys/pyconverter-xml2py/discussions",
41+
"url": f"https://github.com/{USERNAME}/{REPOSITORY_NAME}/discussions",
4242
"icon": "fa fa-comment fa-fw",
4343
},
4444
],
@@ -54,9 +54,9 @@
5454

5555
html_context = {
5656
"display_github": True, # Integrate GitHub
57-
"github_user": "ansys",
57+
"github_user": USERNAME,
5858
"github_repo": REPOSITORY_NAME,
59-
"github_version": "main",
59+
"github_version": BRANCH,
6060
"doc_path": "doc/source",
6161
}
6262

@@ -65,13 +65,13 @@
6565
"ansys_sphinx_theme.extension.autoapi",
6666
"jupyter_sphinx",
6767
"numpydoc",
68-
"sphinx.ext.autodoc",
6968
"sphinx_autodoc_typehints",
70-
"sphinx.ext.intersphinx",
71-
"sphinx.ext.extlinks",
72-
"sphinx.ext.graphviz",
7369
"sphinx_copybutton",
7470
"sphinx_design",
71+
"sphinx.ext.autodoc",
72+
"sphinx.ext.extlinks",
73+
"sphinx.ext.graphviz",
74+
"sphinx.ext.intersphinx",
7575
]
7676

7777
# Intersphinx mapping

src/pyconverter/xml2py/custom_functions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ def get_docstring_lists(filename: str) -> Tuple[list[str], list[str], list[str],
7373
for split_arg in split_def:
7474
if "**kwarg" in split_arg:
7575
break
76-
elif ":" in split_arg:
77-
find = re.search(r"\w*(?=\:)", split_arg).group()
78-
list_py_args.append(find)
7976
elif "=" in split_arg:
8077
find = re.search(r"\w*(?=\=)", split_arg).group()
8178
list_py_args.append(find)
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Copyright (C) 2024 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
24+
def inquire(self, strarray="", func="", arg1="", arg2=""):
25+
"""Returns system information.
26+
27+
By default, with no arguments, it returns the working directory.
28+
29+
>>> mapdl.inquire()
30+
C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh
31+
32+
Parameters
33+
----------
34+
strarray : str, optional
35+
Name of the string array or parameter that will hold the returned values.
36+
Normally, if used in a python script you should just work with the
37+
return value from this method.
38+
39+
func : str, optional
40+
Specifies the type of system information returned. See the
41+
notes section for more information.
42+
43+
arg1 : str, optional
44+
First argument. See notes for ``arg1`` definition.
45+
46+
arg2 : str, optional
47+
Second argument. See notes for ``arg1`` definition.
48+
49+
Returns
50+
-------
51+
str
52+
Value of the inquired item.
53+
54+
Notes
55+
-----
56+
The ``/INQUIRE`` command is valid in any processor.
57+
58+
.. warning::
59+
Take note that from version 0.60.4 and later, the command behaviour
60+
has been changed.
61+
Previously, the ``StrArray`` argument was omitted. For example:
62+
>>> mapdl.inquire('DIRECTORY')
63+
C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh
64+
65+
Now this will raise an exception.
66+
The default behaviour now, requires to input ``StrArray``:
67+
>>> mapdl.inquire('', 'DIRECTORY')
68+
C:\\Users\\user\\AppData\\Local\\Temp\\ansys_nynvxsaooh
69+
70+
**GENERAL FUNC OPTIONS**
71+
72+
- ``LOGIN`` - Returns the pathname of the login directory on Linux
73+
systems or the pathname of the default directory (including
74+
drive letter) on Windows systems.
75+
- ``DOCU`` - Pathname of the ANSYS documentation directory.
76+
- ``APDL`` - Pathname of the ANSYS APDL directory.
77+
- ``PROG`` - Pathname of the ANSYS executable directory.
78+
- ``AUTH`` - Pathname of the directory in which the license file resides.
79+
- ``USER`` - Name of the user currently logged-in.
80+
- ``DIRECTORY`` - Pathname of the current directory.
81+
- ``JOBNAME`` - Current Jobname.
82+
- ``RSTDIR`` - Result file directory.
83+
- ``RSTFILE`` - Result file name.
84+
- ``RSTEXT`` - Result file extension.
85+
- ``OUTPUT`` - Current output file name.
86+
87+
88+
**RETURNING THE VALUE OF AN ENVIRONMENT VARIABLE TO A PARAMETER**
89+
90+
If ``FUNC=ENV``, the command format is ``/INQUIRE,StrArray,ENV,ENVNAME,Substring``.
91+
In this instance, ENV specifies that the command should return the
92+
value of an environment variable.
93+
The following defines the remaining fields:
94+
95+
Envname:
96+
Specifies the name of the environment variable.
97+
98+
Substring:
99+
If ``Substring = 1``, the first substring (up to the first colon (:)) is returned.
100+
If ``Substring = 2``, the second substring is returned, etc. For Windows platforms,
101+
the separating character is semicolon (;).
102+
If this argument is either blank or 0, the entire value of the environment
103+
variable is returned.
104+
105+
106+
**RETURNING THE VALUE OF A TITLE TO A PARAMETER**
107+
108+
If ``FUNC = TITLE``, the command format is ``/INQUIRE,StrArray,TITLE,Title_num``.
109+
In this context, the value of Title_num can be blank or ``1`` through ``5``. If the
110+
value is ``1`` or blank, the title is returned. If the value is ``2`` through ``5``,
111+
a corresponding subtitle is returned (``2`` denoting the first subtitle, and so on).
112+
113+
114+
**RETURNING INFORMATION ABOUT A FILE TO A PARAMETER**
115+
116+
The ``/INQUIRE`` command can also return information about specified files
117+
within the file system.
118+
For these capabilities, the format is ``/INQUIRE,Parameter,FUNC,Fname, Ext, --``.
119+
The following defines the fields:
120+
121+
Parameter:
122+
Name of the parameter that will hold the returned values.
123+
124+
Func:
125+
Specifies the type of file information returned:
126+
127+
EXIST:
128+
Returns a ``1`` if the specified file exists, and ``0`` if it does not.
129+
130+
DATE:
131+
Returns the date stamp of the specified file in the format ``*yyyymmdd.hhmmss*``.
132+
133+
SIZE:
134+
Returns the size of the specified file in MB.
135+
136+
WRITE:
137+
Returns the status of the write attribute. A ``0`` denotes no write permission while a ``1`` denotes
138+
write permission.
139+
140+
READ:
141+
Returns the status of the read attribute. A ``0`` denotes no read permission while a ``1`` denotes read
142+
permission.
143+
144+
EXEC:
145+
Returns the status of the execute attribute (this has meaning only on Linux). A ``0`` denotes no
146+
execute permission while a ``1`` denotes execute permission.
147+
148+
LINES:
149+
Returns the number of lines in an ASCII file.
150+
151+
Fname:
152+
File name and directory path (248 characters maximum, including the characters needed for the
153+
directory path). An unspecified directory path defaults to the working directory; in this case, you
154+
can use all 248 characters for the file name.
155+
156+
Ext:
157+
Filename extension (eight-character maximum).
158+
159+
Examples
160+
--------
161+
Return the MAPDL working directory
162+
>>> mapdl.inquire('', 'DIRECTORY')
163+
C:\\Users\\gayuso\\AppData\\Local\\Temp\\ansys_nynvxsaooh
164+
165+
Or
166+
167+
>>> mapdl.inquire()
168+
C:\\Users\\gayuso\\AppData\\Local\\Temp\\ansys_nynvxsaooh
169+
170+
Return the job name
171+
172+
>>> mapdl.inquire('', 'JOBNAME')
173+
file
174+
175+
Return the result file name
176+
177+
>>> mapdl.inquire('', 'RSTFILE')
178+
'file.rst'
179+
"""
180+
return self.run(f"/INQUIRE,{strarray},{func},{arg1},{arg2}")

0 commit comments

Comments
 (0)