Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
barryyosi-panw committed Oct 4, 2024
1 parent b11f358 commit 7028647
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Packs/Base/Scripts/ValidateContent/ValidateContent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from ruamel.yaml import YAML

from demisto_sdk.commands.content_graph.objects.base_content import BaseContent
from demisto_sdk.commands.content_graph.objects.base_content import (BaseContent, CONTENT_TYPE_TO_MODEL)
from demisto_sdk.commands.validate.config_reader import (
ConfigReader,
ConfiguredValidations,
Expand All @@ -52,6 +52,8 @@
PACK_DEFAULT_MARKETPLACES,
MarketplaceVersions,
)


class CustomContentItemParser(ContentItemParser):

@staticmethod
Expand All @@ -68,7 +70,7 @@ def from_path(
"""
from demisto_sdk.commands.content_graph.common import ContentType

demisto.debug(f"Parsing content item {path}")
demisto.debug(f"Parsing content item {path} | {git_sha=}")
if not ContentItemParser.is_content_item(path):
if ContentItemParser.is_content_item(path.parent):
path = path.parent
Expand Down Expand Up @@ -100,13 +102,11 @@ def from_path(
raise NotAContentItemException



##############################################################################################################################
from typing import Type
from demisto_sdk.commands.content_graph.common import (
ContentType,
)
CONTENT_TYPE_TO_MODEL: Dict[ContentType, Type["BaseContent"]] = {}
from functools import cached_property, lru_cache

from demisto_sdk.commands.content_graph.parsers import content_item
Expand All @@ -120,6 +120,7 @@ def from_path(
)
from demisto_sdk.commands.content_graph.parsers.pack import PackParser


class CustomBaseContent(BaseContent):
@staticmethod
@lru_cache
Expand Down Expand Up @@ -170,9 +171,18 @@ def from_path(
return model.from_orm(content_item_parser) # type: ignore
except Exception as e:
demisto.error(
f"Could not parse content item from path {path} using {content_item_parser} | {str(e)}"
f"Could not parse content item from path {path} using {content_item_parser} | {str(e)} | {str(traceback.format_exc())}"
)
return None

# Log the error message
demisto.error(f"Error: {str(e)}")

# Log the detailed stack trace
demisto.error("Stack Trace: " + traceback.format_exc())
traceback.print_exc()

return None


##############################################################################################################################
from demisto_sdk.commands.content_graph.objects.repository import (
Expand All @@ -183,6 +193,7 @@ def from_path(
NotAContentItemException,
)


class CustomInitializer(Initializer):

def paths_to_basecontent_set(
Expand Down Expand Up @@ -280,6 +291,8 @@ def gather_objects_to_run_on(
f"Invalid content path provided: {str(non_content_item)}. Please provide a valid content item or pack path."
)
return content_objects_to_run_with_packs, invalid_content_items


##############################################################################################################################


Expand Down Expand Up @@ -475,7 +488,6 @@ def run_validate(path_to_validate: str, json_output_file: str) -> None:
initializer = CustomInitializer(
staged=False,
committed_only=False,
prev_ver="origin/master",
file_path=str(path_to_validate),
execution_mode=ExecutionMode.SPECIFIC_FILES
)
Expand Down

0 comments on commit 7028647

Please sign in to comment.