-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sebastien FOUREST
committed
Dec 17, 2024
1 parent
f510c0e
commit cfe0f98
Showing
42 changed files
with
15,677 additions
and
818 deletions.
There are no files selected for viewing
Binary file not shown.
4,210 changes: 4,210 additions & 0 deletions
4,210
data/GSM-2_2002213-2002243_GRAC_COSTG_BF01_0100.gfc
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import importlib | ||
import inspect | ||
import sys | ||
|
||
|
||
def list_classes_and_functions(package_name): | ||
results = {} | ||
package = importlib.import_module(package_name) | ||
package_path = package.__path__[0] | ||
|
||
def walk_package(package_path, package_name): | ||
for root, _, files in os.walk(package_path): | ||
for file in files: | ||
if file.endswith(".py") and file != "__init__.py": | ||
module_path = os.path.join(root, file) | ||
relative_module_path = os.path.relpath(module_path, package_path) | ||
module_name = os.path.splitext(relative_module_path.replace(os.sep, "."))[0] | ||
full_module_name = f"{package_name}.{module_name}" | ||
|
||
try: | ||
module = importlib.import_module(full_module_name) | ||
results[full_module_name] = {"classes": {}, "functions": []} | ||
|
||
for name, obj in inspect.getmembers(module): | ||
if inspect.isclass(obj) and obj.__module__ == full_module_name: | ||
class_methods = [method_name for method_name, method_obj in inspect.getmembers(obj) | ||
if inspect.isfunction(method_obj)] | ||
results[full_module_name]["classes"][name] = class_methods | ||
elif inspect.isfunction(obj) and obj.__module__ == full_module_name: | ||
results[full_module_name]["functions"].append(name) | ||
except ImportError as e: | ||
print(f"Failed to import module {full_module_name}: {e}", file=sys.stderr) | ||
|
||
walk_package(package_path, package_name) | ||
return results | ||
|
||
|
||
def write_results_to_file(results, output_file): | ||
with open(output_file, 'w') as f: | ||
f.write('.. autosummary::\n :toctree:\n :recursive:\n :nosignatures:\n\n') | ||
|
||
for module, members in results.items(): | ||
for cls, methods in members["classes"].items(): | ||
for method in methods: | ||
if method == "__init__": | ||
f.write(f" {module}.{cls}\n") | ||
f.write(f" {module}.{cls}.{method}\n") | ||
elif method == "__repr__": | ||
f.write(f" {module}.{cls}\n") | ||
else: | ||
f.write(f" {module}.{cls}.{method}\n") | ||
for func in members["functions"]: | ||
f.write(f" {module}.{func}\n") | ||
|
||
|
||
result = list_classes_and_functions('lenapy') | ||
write_results_to_file(result, os.path.join(os.getcwd(), 'functions_classes.rst')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.