Skip to content

Downstream changes from main to c-cpp branch #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cldk/analysis/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
Python package
"""

from .python import PythonAnalysis
from .python_analysis import PythonAnalysis

__all__ = ["PythonAnalysis"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
Python module
"""

from abc import ABC
from pathlib import Path
from typing import Dict, List
from pandas import DataFrame
from typing import List

from cldk.analysis import SymbolTable
from cldk.analysis.python.treesitter import PythonSitter
from cldk.models.python.models import PyMethod, PyImport, PyModule, PyClass


class PythonAnalysis(SymbolTable):
"""Python Analysis Class"""

def __init__(
self,
analysis_backend: str,
Expand All @@ -48,13 +48,13 @@ def __init__(

# Initialize the analysis analysis_backend
if analysis_backend.lower() == "codeql":
raise NotImplementedError(f"Support for {analysis_backend} has not been implemented yet.")
raise NotImplementedError("Support for {analysis_backend} has not been implemented yet.")
elif analysis_backend.lower() == "codeanalyzer":
raise NotImplementedError(f"Support for {analysis_backend} has not been implemented yet.")
raise NotImplementedError("Support for {analysis_backend} has not been implemented yet.")
elif analysis_backend.lower() == "treesitter":
self.analysis_backend: PythonSitter = PythonSitter()
else:
raise NotImplementedError(f"Support for {analysis_backend} has not been implemented yet.")
raise NotImplementedError("Support for {analysis_backend} has not been implemented yet.")

def get_methods(self) -> List[PyMethod]:
"""
Expand Down Expand Up @@ -89,14 +89,14 @@ def get_method_details(self, method_signature: str) -> PyMethod:

def is_parsable(self, source_code: str) -> bool:
"""
Check if the code is parsable
Args:
source_code: source code
Check if the code is parsable
Args:
source_code: source code

Returns:
True if the code is parsable, False otherwise
Returns:
True if the code is parsable, False otherwise
"""
return PythonSitter.is_parsable(self, source_code)
return PythonSitter().is_parsable(source_code)

def get_raw_ast(self, source_code: str) -> str:
"""
Expand All @@ -107,9 +107,9 @@ def get_raw_ast(self, source_code: str) -> str:
Returns:
Tree: the raw AST
"""
return PythonSitter.get_raw_ast(self, source_code)
return PythonSitter().get_raw_ast(source_code)

def get_imports(self) -> List[PyImport]:
def get_imports(self) -> List[PyImport]:
"""
Given an application or a source code, get all the imports
"""
Expand All @@ -119,7 +119,7 @@ def get_variables(self, **kwargs):
"""
Given an application or a source code, get all the variables
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_classes(self) -> List[PyClass]:
"""
Expand All @@ -131,34 +131,34 @@ def get_classes_by_criteria(self, **kwargs):
"""
Given an application or a source code, get all the classes given the inclusion and exclution criteria
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_sub_classes(self, **kwargs):
"""
Given an application or a source code, get all the sub-classes
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_nested_classes(self, **kwargs):
"""
Given an application or a source code, get all the nested classes
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_constructors(self, **kwargs):
"""
Given an application or a source code, get all the constructors
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_methods_in_class(self, **kwargs):
"""
Given an application or a source code, get all the methods within the given class
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")

def get_fields(self, **kwargs):
"""
Given an application or a source code, get all the fields
"""
raise NotImplementedError(f"Support for this functionality has not been implemented yet.")
raise NotImplementedError("Support for this functionality has not been implemented yet.")
Empty file.
Loading