Skip to content

Commit d75deae

Browse files
committed
refactored code
1 parent 77c47d2 commit d75deae

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

metadata-ingestion/src/datahub/configuration/common.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@ def allow_all(cls) -> "AllowDenyPattern":
258258
return AllowDenyPattern()
259259

260260
def allowed(self, string: str) -> bool:
261-
if self._denied(string):
261+
if self.denied(string):
262262
return False
263263

264264
return any(
265265
re.match(allow_pattern, string, self.regex_flags)
266266
for allow_pattern in self.allow
267267
)
268268

269-
def _denied(self, string: str) -> bool:
269+
def denied(self, string: str) -> bool:
270270
for deny_pattern in self.deny:
271271
if re.match(deny_pattern, string, self.regex_flags):
272272
return True
@@ -290,7 +290,7 @@ def get_allowed_list(self) -> List[str]:
290290
raise ValueError(
291291
"allow list must be fully specified to get list of allowed strings"
292292
)
293-
return [a for a in self.allow if not self._denied(a)]
293+
return [a for a in self.allow if not self.denied(a)]
294294

295295
def __eq__(self, other): # type: ignore
296296
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

metadata-ingestion/src/datahub/ingestion/source/tableau/tableau.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -935,26 +935,9 @@ def _is_denied_project(self, project: TableauProject) -> bool:
935935
# Either project_pattern or project_path_pattern is set in a recipe
936936
# TableauConfig.projects_backward_compatibility ensures that at least one of these properties is configured.
937937

938-
# for backward compatibility check deny list of project_pattern
939-
for deny_pattern in self.config.project_pattern.deny:
940-
if re.match(
941-
deny_pattern, project.name, self.config.project_pattern.regex_flags
942-
):
943-
return True
944-
945-
for deny_pattern in self.config.project_path_pattern.deny:
946-
if re.match(
947-
deny_pattern,
948-
self._get_project_path(project),
949-
self.config.project_pattern.regex_flags,
950-
):
951-
return True
952-
953-
logger.info(
954-
f"project({project.name}) is not denied as per project_pattern(or project_path_pattern)"
955-
)
956-
957-
return False
938+
return self.config.project_pattern.denied(
939+
project.name
940+
) or self.config.project_path_pattern.denied(self._get_project_path(project))
958941

959942
def _init_tableau_project_registry(self, all_project_map: dict) -> None:
960943
list_of_skip_projects: List[TableauProject] = []
@@ -982,9 +965,11 @@ def _init_tableau_project_registry(self, all_project_map: dict) -> None:
982965
for project in list_of_skip_projects:
983966
if (
984967
project.parent_id in projects_to_ingest
985-
and self._is_denied_project(project) is False
968+
and not self._is_denied_project(project)
986969
):
987-
logger.debug(f"Project {project.name} is added in project registry")
970+
logger.debug(
971+
f"Project {project.name} is added in project registry as it's a child project and not explicitly denied in `deny` list"
972+
)
988973
projects_to_ingest[project.id] = project
989974

990975
# We rely on automatic browse paths (v2) when creating containers. That's why we need to sort the projects here.

0 commit comments

Comments
 (0)