prefact 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prefact-0.0.5/CHANGELOG.md +42 -0
- prefact-0.0.5/LICENSE +201 -0
- prefact-0.0.5/MANIFEST.in +6 -0
- prefact-0.0.5/PKG-INFO +37 -0
- prefact-0.0.5/README.md +9 -0
- prefact-0.0.5/VERSION +1 -0
- prefact-0.0.5/prefact.egg-info/PKG-INFO +37 -0
- prefact-0.0.5/prefact.egg-info/SOURCES.txt +17 -0
- prefact-0.0.5/prefact.egg-info/dependency_links.txt +1 -0
- prefact-0.0.5/prefact.egg-info/entry_points.txt +2 -0
- prefact-0.0.5/prefact.egg-info/requires.txt +7 -0
- prefact-0.0.5/prefact.egg-info/top_level.txt +1 -0
- prefact-0.0.5/pyproject.toml +67 -0
- prefact-0.0.5/refactoring/__init__.py +16 -0
- prefact-0.0.5/refactoring/cli.py +121 -0
- prefact-0.0.5/refactoring/core.py +81 -0
- prefact-0.0.5/refactoring/utils.py +137 -0
- prefact-0.0.5/setup.cfg +4 -0
- prefact-0.0.5/tests/test_refactoring.py +11 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.0.5] - 2026-03-27
|
|
11
|
+
|
|
12
|
+
### Other
|
|
13
|
+
- Update .idea/inspectionProfiles/Project_Default.xml
|
|
14
|
+
- Update .idea/inspectionProfiles/profiles_settings.xml
|
|
15
|
+
- Update .idea/misc.xml
|
|
16
|
+
- Update .idea/modules.xml
|
|
17
|
+
- Update .idea/refactoring.iml
|
|
18
|
+
- Update .idea/vcs.xml
|
|
19
|
+
|
|
20
|
+
## [0.0.4] - 2026-03-27
|
|
21
|
+
|
|
22
|
+
## [0.0.3] - 2026-03-27
|
|
23
|
+
|
|
24
|
+
### Other
|
|
25
|
+
- Update MANIFEST.in
|
|
26
|
+
|
|
27
|
+
## [0.0.2] - 2026-03-27
|
|
28
|
+
|
|
29
|
+
### Test
|
|
30
|
+
- Update tests/test_refactoring.py
|
|
31
|
+
|
|
32
|
+
### Other
|
|
33
|
+
- Update refactoring/__init__.py
|
|
34
|
+
- Update refactoring/cli.py
|
|
35
|
+
- Update refactoring/core.py
|
|
36
|
+
- Update refactoring/utils.py
|
|
37
|
+
|
|
38
|
+
## [0.0.1] - 2026-03-27
|
|
39
|
+
|
|
40
|
+
### Other
|
|
41
|
+
- Update .idea/.gitignore
|
|
42
|
+
|
prefact-0.0.5/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
prefact-0.0.5/PKG-INFO
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prefact
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: A package for code analysis and refactoring tools
|
|
5
|
+
Author-email: Semcod Team <team@semcod.com>, Tom Sapletta <tom@sapletta.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/semcod/prefact
|
|
8
|
+
Project-URL: Repository, https://github.com/semcod/prefact
|
|
9
|
+
Project-URL: Issues, https://github.com/semcod/prefact/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: click>=8.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black; extra == "dev"
|
|
25
|
+
Requires-Dist: flake8; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# refactoring
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
|
34
|
+
|
|
35
|
+
## Author
|
|
36
|
+
|
|
37
|
+
Created by **Tom Sapletta** - [tom@sapletta.com](mailto:tom@sapletta.com)
|
prefact-0.0.5/README.md
ADDED
prefact-0.0.5/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.5
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prefact
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: A package for code analysis and refactoring tools
|
|
5
|
+
Author-email: Semcod Team <team@semcod.com>, Tom Sapletta <tom@sapletta.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/semcod/prefact
|
|
8
|
+
Project-URL: Repository, https://github.com/semcod/prefact
|
|
9
|
+
Project-URL: Issues, https://github.com/semcod/prefact/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: click>=8.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black; extra == "dev"
|
|
25
|
+
Requires-Dist: flake8; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# refactoring
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
|
34
|
+
|
|
35
|
+
## Author
|
|
36
|
+
|
|
37
|
+
Created by **Tom Sapletta** - [tom@sapletta.com](mailto:tom@sapletta.com)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CHANGELOG.md
|
|
2
|
+
LICENSE
|
|
3
|
+
MANIFEST.in
|
|
4
|
+
README.md
|
|
5
|
+
VERSION
|
|
6
|
+
pyproject.toml
|
|
7
|
+
prefact.egg-info/PKG-INFO
|
|
8
|
+
prefact.egg-info/SOURCES.txt
|
|
9
|
+
prefact.egg-info/dependency_links.txt
|
|
10
|
+
prefact.egg-info/entry_points.txt
|
|
11
|
+
prefact.egg-info/requires.txt
|
|
12
|
+
prefact.egg-info/top_level.txt
|
|
13
|
+
refactoring/__init__.py
|
|
14
|
+
refactoring/cli.py
|
|
15
|
+
refactoring/core.py
|
|
16
|
+
refactoring/utils.py
|
|
17
|
+
tests/test_refactoring.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
refactoring
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "prefact"
|
|
7
|
+
version = "0.0.5"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Semcod Team", email = "team@semcod.com"},
|
|
10
|
+
{name = "Tom Sapletta", email = "tom@sapletta.com"},
|
|
11
|
+
]
|
|
12
|
+
description = "A package for code analysis and refactoring tools"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
license = "Apache-2.0"
|
|
15
|
+
requires-python = ">=3.8"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"click>=8.0.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = [
|
|
32
|
+
"pytest>=6.0",
|
|
33
|
+
"black",
|
|
34
|
+
"flake8",
|
|
35
|
+
"mypy",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/semcod/prefact"
|
|
40
|
+
Repository = "https://github.com/semcod/prefact"
|
|
41
|
+
Issues = "https://github.com/semcod/prefact/issues"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
prefact = "refactoring.cli:main"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["."]
|
|
48
|
+
include = ["refactoring*"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
"*" = ["*.txt", "*.md", "*.rst", "*.yaml", "*.yml"]
|
|
52
|
+
|
|
53
|
+
[tool.black]
|
|
54
|
+
line-length = 88
|
|
55
|
+
target-version = ['py38']
|
|
56
|
+
|
|
57
|
+
[tool.mypy]
|
|
58
|
+
python_version = "3.8"
|
|
59
|
+
warn_return_any = true
|
|
60
|
+
warn_unused_configs = true
|
|
61
|
+
disallow_untyped_defs = true
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
python_files = ["test_*.py"]
|
|
66
|
+
python_classes = ["Test*"]
|
|
67
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Refactoring package for code analysis and transformation tools.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "0.0.5"
|
|
6
|
+
__author__ = "Your Name"
|
|
7
|
+
__email__ = "your.email@example.com"
|
|
8
|
+
|
|
9
|
+
from .core import RefactoringEngine
|
|
10
|
+
from .utils import parse_code, analyze_structure
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"RefactoringEngine",
|
|
14
|
+
"parse_code",
|
|
15
|
+
"analyze_structure"
|
|
16
|
+
]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command line interface for the refactoring package.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from .core import RefactoringEngine
|
|
10
|
+
from .utils import parse_code, analyze_structure, get_file_stats
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.group()
|
|
14
|
+
@click.version_option()
|
|
15
|
+
def main():
|
|
16
|
+
"""Refactoring tools for Python code analysis and transformation."""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@main.command()
|
|
21
|
+
@click.argument('file_path', type=click.Path(exists=True))
|
|
22
|
+
def analyze(file_path):
|
|
23
|
+
"""Analyze a Python file and display its structure."""
|
|
24
|
+
engine = RefactoringEngine()
|
|
25
|
+
|
|
26
|
+
# Parse the file
|
|
27
|
+
parsed = parse_code(file_path)
|
|
28
|
+
if not parsed["success"]:
|
|
29
|
+
click.echo(f"Error parsing file: {parsed['error']}", err=True)
|
|
30
|
+
sys.exit(1)
|
|
31
|
+
|
|
32
|
+
# Analyze the code
|
|
33
|
+
analysis = engine.analyze_code(parsed["code"])
|
|
34
|
+
if not analysis["success"]:
|
|
35
|
+
click.echo(f"Error analyzing code: {analysis['error']}", err=True)
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
|
|
38
|
+
# Display results
|
|
39
|
+
click.echo(f"\n📁 File: {file_path}")
|
|
40
|
+
click.echo("=" * 50)
|
|
41
|
+
|
|
42
|
+
click.echo(f"\n📊 Functions ({len(analysis['functions'])}):")
|
|
43
|
+
for func in analysis['functions']:
|
|
44
|
+
click.echo(f" • {func['name']} (line {func['line']}) - {len(func['args'])} args")
|
|
45
|
+
|
|
46
|
+
click.echo(f"\n🏗️ Classes ({len(analysis['classes'])}):")
|
|
47
|
+
for cls in analysis['classes']:
|
|
48
|
+
click.echo(f" • {cls['name']} (line {cls['line']}) - {len(cls['methods'])} methods")
|
|
49
|
+
|
|
50
|
+
click.echo(f"\n📦 Imports ({len(analysis['imports'])}):")
|
|
51
|
+
for imp in analysis['imports']:
|
|
52
|
+
if imp['type'] == 'import':
|
|
53
|
+
alias = f" as {imp['alias']}" if imp['alias'] else ""
|
|
54
|
+
click.echo(f" • import {imp['module']}{alias}")
|
|
55
|
+
else:
|
|
56
|
+
name = f" as {imp['alias']}" if imp['alias'] else imp['name']
|
|
57
|
+
click.echo(f" • from {imp['module']} import {name}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@main.command()
|
|
61
|
+
@click.argument('file_path', type=click.Path(exists=True))
|
|
62
|
+
def stats(file_path):
|
|
63
|
+
"""Display statistics about a Python file."""
|
|
64
|
+
stats_data = get_file_stats(file_path)
|
|
65
|
+
|
|
66
|
+
if not stats_data["success"]:
|
|
67
|
+
click.echo(f"Error getting stats: {stats_data['error']}", err=True)
|
|
68
|
+
sys.exit(1)
|
|
69
|
+
|
|
70
|
+
click.echo(f"\n📊 Statistics for: {file_path}")
|
|
71
|
+
click.echo("=" * 40)
|
|
72
|
+
click.echo(f"Total lines: {stats_data['total_lines']}")
|
|
73
|
+
click.echo(f"Code lines: {stats_data['code_lines']}")
|
|
74
|
+
click.echo(f"Comment lines: {stats_data['comment_lines']}")
|
|
75
|
+
click.echo(f"Blank lines: {stats_data['blank_lines']}")
|
|
76
|
+
click.echo(f"Functions: {stats_data['functions']}")
|
|
77
|
+
click.echo(f"Classes: {stats_data['classes']}")
|
|
78
|
+
click.echo(f"Cyclomatic complexity: {stats_data['complexity']}")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@main.command()
|
|
82
|
+
@click.argument('directory', type=click.Path(exists=True, file_okay=False))
|
|
83
|
+
@click.option('--recursive', '-r', is_flag=True, help='Search recursively')
|
|
84
|
+
def scan(directory):
|
|
85
|
+
"""Scan directory for Python files and show basic info."""
|
|
86
|
+
path = Path(directory)
|
|
87
|
+
|
|
88
|
+
if recursive:
|
|
89
|
+
py_files = list(path.rglob('*.py'))
|
|
90
|
+
else:
|
|
91
|
+
py_files = list(path.glob('*.py'))
|
|
92
|
+
|
|
93
|
+
if not py_files:
|
|
94
|
+
click.echo("No Python files found.")
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
click.echo(f"\n🔍 Found {len(py_files)} Python files:")
|
|
98
|
+
click.echo("=" * 50)
|
|
99
|
+
|
|
100
|
+
total_lines = 0
|
|
101
|
+
total_functions = 0
|
|
102
|
+
total_classes = 0
|
|
103
|
+
|
|
104
|
+
for file_path in sorted(py_files):
|
|
105
|
+
stats_data = get_file_stats(str(file_path))
|
|
106
|
+
if stats_data["success"]:
|
|
107
|
+
click.echo(f"📄 {file_path.relative_to(path)}")
|
|
108
|
+
click.echo(f" Lines: {stats_data['total_lines']}, Functions: {stats_data['functions']}, Classes: {stats_data['classes']}")
|
|
109
|
+
total_lines += stats_data['total_lines']
|
|
110
|
+
total_functions += stats_data['functions']
|
|
111
|
+
total_classes += stats_data['classes']
|
|
112
|
+
|
|
113
|
+
click.echo(f"\n📈 Summary:")
|
|
114
|
+
click.echo(f"Total files: {len(py_files)}")
|
|
115
|
+
click.echo(f"Total lines: {total_lines}")
|
|
116
|
+
click.echo(f"Total functions: {total_functions}")
|
|
117
|
+
click.echo(f"Total classes: {total_classes}")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == '__main__':
|
|
121
|
+
main()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Core refactoring engine for code analysis and transformation.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
from typing import List, Dict, Any, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RefactoringEngine:
|
|
10
|
+
"""Main engine for performing code refactoring operations."""
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.transformations = []
|
|
14
|
+
|
|
15
|
+
def analyze_code(self, code: str) -> Dict[str, Any]:
|
|
16
|
+
"""Analyze Python code and return structural information."""
|
|
17
|
+
try:
|
|
18
|
+
tree = ast.parse(code)
|
|
19
|
+
return {
|
|
20
|
+
"success": True,
|
|
21
|
+
"tree": tree,
|
|
22
|
+
"functions": self._extract_functions(tree),
|
|
23
|
+
"classes": self._extract_classes(tree),
|
|
24
|
+
"imports": self._extract_imports(tree)
|
|
25
|
+
}
|
|
26
|
+
except SyntaxError as e:
|
|
27
|
+
return {
|
|
28
|
+
"success": False,
|
|
29
|
+
"error": str(e),
|
|
30
|
+
"line": e.lineno
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def _extract_functions(self, tree: ast.AST) -> List[Dict[str, Any]]:
|
|
34
|
+
"""Extract function definitions from AST."""
|
|
35
|
+
functions = []
|
|
36
|
+
for node in ast.walk(tree):
|
|
37
|
+
if isinstance(node, ast.FunctionDef):
|
|
38
|
+
functions.append({
|
|
39
|
+
"name": node.name,
|
|
40
|
+
"line": node.lineno,
|
|
41
|
+
"args": [arg.arg for arg in node.args.args],
|
|
42
|
+
"docstring": ast.get_docstring(node)
|
|
43
|
+
})
|
|
44
|
+
return functions
|
|
45
|
+
|
|
46
|
+
def _extract_classes(self, tree: ast.AST) -> List[Dict[str, Any]]:
|
|
47
|
+
"""Extract class definitions from AST."""
|
|
48
|
+
classes = []
|
|
49
|
+
for node in ast.walk(tree):
|
|
50
|
+
if isinstance(node, ast.ClassDef):
|
|
51
|
+
classes.append({
|
|
52
|
+
"name": node.name,
|
|
53
|
+
"line": node.lineno,
|
|
54
|
+
"bases": [base.id for base in node.bases if isinstance(base, ast.Name)],
|
|
55
|
+
"methods": [n.name for n in node.body if isinstance(n, ast.FunctionDef)],
|
|
56
|
+
"docstring": ast.get_docstring(node)
|
|
57
|
+
})
|
|
58
|
+
return classes
|
|
59
|
+
|
|
60
|
+
def _extract_imports(self, tree: ast.AST) -> List[Dict[str, Any]]:
|
|
61
|
+
"""Extract import statements from AST."""
|
|
62
|
+
imports = []
|
|
63
|
+
for node in ast.walk(tree):
|
|
64
|
+
if isinstance(node, ast.Import):
|
|
65
|
+
for alias in node.names:
|
|
66
|
+
imports.append({
|
|
67
|
+
"type": "import",
|
|
68
|
+
"module": alias.name,
|
|
69
|
+
"alias": alias.asname,
|
|
70
|
+
"line": node.lineno
|
|
71
|
+
})
|
|
72
|
+
elif isinstance(node, ast.ImportFrom):
|
|
73
|
+
for alias in node.names:
|
|
74
|
+
imports.append({
|
|
75
|
+
"type": "from_import",
|
|
76
|
+
"module": node.module,
|
|
77
|
+
"name": alias.name,
|
|
78
|
+
"alias": alias.asname,
|
|
79
|
+
"line": node.lineno
|
|
80
|
+
})
|
|
81
|
+
return imports
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for code parsing and analysis.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
from typing import Dict, List, Any, Optional
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def parse_code(file_path: str) -> Dict[str, Any]:
|
|
11
|
+
"""Parse a Python file and return its AST and metadata."""
|
|
12
|
+
try:
|
|
13
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
14
|
+
code = f.read()
|
|
15
|
+
|
|
16
|
+
tree = ast.parse(code)
|
|
17
|
+
return {
|
|
18
|
+
"success": True,
|
|
19
|
+
"file_path": file_path,
|
|
20
|
+
"code": code,
|
|
21
|
+
"tree": tree,
|
|
22
|
+
"lines": code.splitlines()
|
|
23
|
+
}
|
|
24
|
+
except (SyntaxError, FileNotFoundError, UnicodeDecodeError) as e:
|
|
25
|
+
return {
|
|
26
|
+
"success": False,
|
|
27
|
+
"error": str(e),
|
|
28
|
+
"file_path": file_path
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def analyze_structure(tree: ast.AST) -> Dict[str, Any]:
|
|
33
|
+
"""Analyze the structure of an AST and return detailed information."""
|
|
34
|
+
structure = {
|
|
35
|
+
"functions": [],
|
|
36
|
+
"classes": [],
|
|
37
|
+
"variables": [],
|
|
38
|
+
"imports": [],
|
|
39
|
+
"complexity": 0
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for node in ast.walk(tree):
|
|
43
|
+
if isinstance(node, ast.FunctionDef):
|
|
44
|
+
structure["functions"].append({
|
|
45
|
+
"name": node.name,
|
|
46
|
+
"line": node.lineno,
|
|
47
|
+
"args": [arg.arg for arg in node.args.args],
|
|
48
|
+
"decorators": [d.id if isinstance(d, ast.Name) else str(d) for d in node.decorator_list],
|
|
49
|
+
"returns": ast.unparse(node.returns) if node.returns else None,
|
|
50
|
+
"docstring": ast.get_docstring(node)
|
|
51
|
+
})
|
|
52
|
+
structure["complexity"] += _calculate_complexity(node)
|
|
53
|
+
|
|
54
|
+
elif isinstance(node, ast.ClassDef):
|
|
55
|
+
structure["classes"].append({
|
|
56
|
+
"name": node.name,
|
|
57
|
+
"line": node.lineno,
|
|
58
|
+
"bases": [base.id for base in node.bases if isinstance(base, ast.Name)],
|
|
59
|
+
"methods": [n.name for n in node.body if isinstance(n, ast.FunctionDef)],
|
|
60
|
+
"docstring": ast.get_docstring(node)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
elif isinstance(node, ast.Assign):
|
|
64
|
+
for target in node.targets:
|
|
65
|
+
if isinstance(target, ast.Name):
|
|
66
|
+
structure["variables"].append({
|
|
67
|
+
"name": target.id,
|
|
68
|
+
"line": node.lineno,
|
|
69
|
+
"type": "variable"
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
elif isinstance(node, (ast.Import, ast.ImportFrom)):
|
|
73
|
+
if isinstance(node, ast.Import):
|
|
74
|
+
for alias in node.names:
|
|
75
|
+
structure["imports"].append({
|
|
76
|
+
"type": "import",
|
|
77
|
+
"module": alias.name,
|
|
78
|
+
"alias": alias.asname,
|
|
79
|
+
"line": node.lineno
|
|
80
|
+
})
|
|
81
|
+
else:
|
|
82
|
+
for alias in node.names:
|
|
83
|
+
structure["imports"].append({
|
|
84
|
+
"type": "from_import",
|
|
85
|
+
"module": node.module,
|
|
86
|
+
"name": alias.name,
|
|
87
|
+
"alias": alias.asname,
|
|
88
|
+
"line": node.lineno
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return structure
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _calculate_complexity(node: ast.AST) -> int:
|
|
95
|
+
"""Calculate cyclomatic complexity of a function."""
|
|
96
|
+
complexity = 1 # Base complexity
|
|
97
|
+
|
|
98
|
+
for child in ast.walk(node):
|
|
99
|
+
if isinstance(child, (ast.If, ast.While, ast.For, ast.With)):
|
|
100
|
+
complexity += 1
|
|
101
|
+
elif isinstance(child, ast.ExceptHandler):
|
|
102
|
+
complexity += 1
|
|
103
|
+
elif isinstance(child, ast.BoolOp):
|
|
104
|
+
complexity += len(child.values) - 1
|
|
105
|
+
|
|
106
|
+
return complexity
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def get_file_stats(file_path: str) -> Dict[str, Any]:
|
|
110
|
+
"""Get basic statistics about a Python file."""
|
|
111
|
+
path = Path(file_path)
|
|
112
|
+
|
|
113
|
+
if not path.exists():
|
|
114
|
+
return {"success": False, "error": "File not found"}
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
118
|
+
lines = f.readlines()
|
|
119
|
+
|
|
120
|
+
code = ''.join(lines)
|
|
121
|
+
tree = ast.parse(code)
|
|
122
|
+
structure = analyze_structure(tree)
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
"success": True,
|
|
126
|
+
"file_path": file_path,
|
|
127
|
+
"total_lines": len(lines),
|
|
128
|
+
"code_lines": len([line for line in lines if line.strip() and not line.strip().startswith('#')]),
|
|
129
|
+
"comment_lines": len([line for line in lines if line.strip().startswith('#')]),
|
|
130
|
+
"blank_lines": len([line for line in lines if not line.strip()]),
|
|
131
|
+
"functions": len(structure["functions"]),
|
|
132
|
+
"classes": len(structure["classes"]),
|
|
133
|
+
"complexity": structure["complexity"]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
except Exception as e:
|
|
137
|
+
return {"success": False, "error": str(e)}
|
prefact-0.0.5/setup.cfg
ADDED