Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
Browse files Browse the repository at this point in the history
…-creation
  • Loading branch information
TheoPascoli committed Sep 18, 2024
2 parents e3e2158 + fa16619 commit 2c37fff
Show file tree
Hide file tree
Showing 424 changed files with 5,527 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/license_header.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ jobs:
run: |
python license_checker_and_adder.py --path=../antarest/ --action=check-strict
python license_checker_and_adder.py --path=../tests/ --action=check-strict
python license_checker_and_adder.py --path=../webapp/src --action=check-strict
working-directory: scripts
51 changes: 40 additions & 11 deletions scripts/license_checker_and_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Use to skip subtrees that have their own licenses (forks)
LICENSE_FILE_PATTERN = re.compile("LICENSE.*")

ANTARES_LICENSE_HEADER = """# Copyright (c) 2024, RTE (https://www.rte-france.com)
BACKEND_LICENSE_HEADER = """# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
Expand All @@ -21,17 +21,29 @@
# This file is part of the Antares project.
"""

LICENSE_AS_LIST = ANTARES_LICENSE_HEADER.splitlines()
LICENSE_TO_SAVE = [header + "\n" for header in LICENSE_AS_LIST] + ["\n"]
FRONTEND_LICENSE_HEADER = """/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/
"""


def is_license_file(filename: str) -> bool:
return LICENSE_FILE_PATTERN.match(filename) is not None


def check_file(file_path: Path, action: str) -> bool:
def check_file(file_path: Path, action: str, license_as_list: List[str], license_to_save: List[str]) -> bool:
file_content = file_path.read_text().splitlines()
if len(file_content) >= 11 and file_content[:11] == LICENSE_AS_LIST:
n = len(license_as_list)
if len(file_content) >= n and file_content[:n] == license_as_list:
return True
click.echo(f"{file_path} has no valid header.")
new_lines = []
Expand All @@ -45,13 +57,21 @@ def check_file(file_path: Path, action: str) -> bool:
if already_licensed: # I don't really know what to do here
raise ValueError(f"File {file_path} already licensed.")
else:
new_lines = LICENSE_TO_SAVE + lines
new_lines = license_to_save + lines
if new_lines:
with open(file_path, "w") as f:
f.writelines(new_lines)


def check_dir(cwd: Path, dir_path: Path, action: str, invalid_files: List[Path]) -> None:
def check_dir(
cwd: Path,
dir_path: Path,
action: str,
invalid_files: List[Path],
suffixes: List[str],
license_as_list: List[str],
license_to_save: List[str],
) -> None:
_, dirnames, filenames = next(os.walk(dir_path))
for f in filenames:
if dir_path != cwd and is_license_file(f):
Expand All @@ -61,14 +81,14 @@ def check_dir(cwd: Path, dir_path: Path, action: str, invalid_files: List[Path])
for f in filenames:
file_path = dir_path / f

if file_path.suffixes != [".py"]:
if file_path.suffix not in suffixes:
continue

if not check_file(file_path, action):
if not check_file(file_path, action, license_as_list, license_to_save):
invalid_files.append(file_path)

for d in dirnames:
check_dir(cwd, dir_path / d, action, invalid_files)
check_dir(cwd, dir_path / d, action, invalid_files, suffixes, license_as_list, license_to_save)


@click.command("license_checker_and_adder")
Expand All @@ -93,7 +113,16 @@ def cli(path: Path, action: str) -> None:

invalid_files = []
cwd = Path.cwd()
check_dir(cwd, path, action, invalid_files)
# --------- infer which files to check and which license to add
suffixes = [".ts", ".tsx"]
license_header = FRONTEND_LICENSE_HEADER
if path.name in ["antarest", "tests"]:
suffixes = [".py"]
license_header = BACKEND_LICENSE_HEADER
license_as_list = license_header.splitlines()
license_to_save = [header + "\n" for header in license_as_list] + ["\n"]
# --------
check_dir(cwd, path, action, invalid_files, suffixes, license_as_list, license_to_save)
file_count = len(invalid_files)
if file_count > 0:
if action == "fix":
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/common/types.ts

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { ReactNode } from "react";

export type IdType = number | string;
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Api.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Api.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { Box } from "@mui/material";
import SwaggerUI from "swagger-ui-react";
import "swagger-ui-react/swagger-ui.css";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/DataListing.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Data/DataListing.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { memo } from "react";
import { Typography, Box, styled } from "@mui/material";
import AutoSizer from "react-virtualized-auto-sizer";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/DataPropsView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Data/DataPropsView.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { useState } from "react";
import { MatrixDataSetDTO, MatrixInfoDTO } from "../../../common/types";
import PropertiesView from "../../common/PropertiesView";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/DatasetCreationDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Data/DatasetCreationDialog.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { useState, useEffect, forwardRef, ChangeEvent } from "react";
import {
Box,
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/MatrixDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Data/MatrixDialog.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { useState, useEffect } from "react";
import { AxiosError } from "axios";
import { useTranslation } from "react-i18next";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)

Check warning on line 1 in webapp/src/components/App/Data/index.tsx

View workflow job for this annotation

GitHub Actions / npm-lint

Should have no text on the "0th" line (after the `/**`)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { useState, useEffect } from "react";
import { AxiosError } from "axios";
import { useSnackbar } from "notistack";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/styles.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { styled, Box, Typography } from "@mui/material";
import DownloadIcon from "@mui/icons-material/Download";

Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Data/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import {
GroupDTO,
MatrixDataSetDTO,
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Settings/Groups/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { Box, Button } from "@mui/material";
import GroupAddIcon from "@mui/icons-material/GroupAdd";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import GroupAddIcon from "@mui/icons-material/GroupAdd";
import { useSnackbar } from "notistack";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { useTranslation } from "react-i18next";
import { useMemo, useRef, useState } from "react";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import FormDialog, {
FormDialogProps,
} from "../../../../../common/dialogs/FormDialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import EditIcon from "@mui/icons-material/Edit";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Settings/Groups/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import {
Box,
CircularProgress,
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Settings/Maintenance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import {
Backdrop,
Box,
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/App/Settings/Tokens/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright (c) 2024, RTE (https://www.rte-france.com)
*
* See AUTHORS.txt
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*
* This file is part of the Antares project.
*/

import { Box, Button } from "@mui/material";
import TokenIcon from "@mui/icons-material/Token";
import { useTranslation } from "react-i18next";
Expand Down
Loading

0 comments on commit 2c37fff

Please sign in to comment.