Skip to content

Commit

Permalink
adding pictures, figures, yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
jellepoland committed Aug 25, 2024
1 parent b396077 commit 08865c7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ classifiers = [
# For more on how this field compares to pip's requirements files, see:
# https://packaging.python.org/discussions/install-requires-vs-requirements/
dependencies = [
"importlib",
"pprintpp",
]

# You can define additional groups of dependencies here (e.g., development dependencies).
Expand Down
10 changes: 5 additions & 5 deletions scripts/testing_the_pip_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package_content = extract_package_contents(TUDELFT_V3_LEI_KITE)
print_dict_content(package_content)

print("\n")
print(f"--------------------------------")
print(f"Surfplan-export package content")
print(f"--------------------------------")
print_dict_content(package_content["surfplan_export"])
# print("\n")
# print(f"--------------------------------")
# print(f"Surfplan-export package content")
# print(f"--------------------------------")
# print_dict_content(package_content["surfplan_export"])
36 changes: 36 additions & 0 deletions src/TUDELFT_V3_LEI_KITE/extract_package_contents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import importlib
import pprintpp
from importlib.resources import files
from typing import List, Dict, Union


def extract_package_contents(package, top_level=True) -> Dict[str, Union[str, Dict]]:
package_path = files(package)
package_name = package.__name__.split(".")[0]
contents = {}

for item in package_path.iterdir():
if item.is_file():
contents[item.name] = "file"
elif item.is_dir():
try:
subpackage = importlib.import_module(f"{package.__name__}.{item.name}")
subcontents = extract_package_contents(subpackage, top_level=False)
contents[item.name] = subcontents
except ImportError:
# If it's not a valid Python package, just add it as an empty directory
contents[item.name] = "empty directory"

if top_level:
print(f"{package_name} package content extracted from path:")
print(f" {package_path}")
print(f"--------------------------------")
return contents


if __name__ == "__main__":
import TUDELFT_V3_LEI_KITE
from TUDELFT_V3_LEI_KITE.print_dict_content import print_dict_content

package_content = extract_package_contents(TUDELFT_V3_LEI_KITE)
print_dict_content(package_content)
15 changes: 15 additions & 0 deletions src/TUDELFT_V3_LEI_KITE/print_dict_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def print_dict_content(d, depth_level=0):
indent = " " * depth_level # Create indentation based on depth_level

for key, value in d.items():
if value == "file":
print(f"{indent}file: {key}")
elif value == "empty directory":
print(f"{indent}empty directory: {key}")
else:
if depth_level == 0:
print(f"{indent}directory: {key}")
else:
print(f"{indent}{'sub_' * depth_level}directory: {key}")

print_dict_content(value, depth_level + 1) # Recursive call

0 comments on commit 08865c7

Please sign in to comment.