Skip to content

Commit

Permalink
Update workflow and remove duplicate headers
Browse files Browse the repository at this point in the history
Signed-off-by: pem70 <[email protected]>
  • Loading branch information
pem70 committed Jul 22, 2024
1 parent e110515 commit b31ed30
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
pylint src --errors-only --disable=E0401,E0611 --ignore=build
# check for lint
pylint ./src --disable=all --enable=C0103,C0301 --ignore=build --max-line-length=127
- name: Check license headers
run: python scripts/license_header.py src
- name: Test with pytest
run: |
coverage run -m pytest ./tests/unit
Expand Down
16 changes: 9 additions & 7 deletions scripts/license_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@
"""'''


def check_and_add_license_header(file_path):
def check_and_add_license_header(file_path, write_header):
with open(file_path, "r+", encoding="utf-8") as file:
content = file.read()
if LICENSE_HEADER not in content:
print(f"Adding license header to: {file_path}")
file.seek(0, 0)
file.write(LICENSE_HEADER + "\n" + content)
if write_header:
print(f"Adding license header to: {file_path}")
file.seek(0, 0)
file.write(LICENSE_HEADER + "\n" + content)
return False
return True


def main():
if len(sys.argv) != 2:
print("Usage: python check_license_header.py <directory>")
if len(sys.argv) > 3:
print("Usage: python check_license_header.py <directory> optional(W)")
sys.exit(1)

directory = sys.argv[1]
write_header = True if len(sys.argv) == 3 and sys.argv[2] == "W" else False
all_files_passed = True

for root, _, files in os.walk(directory):
Expand All @@ -40,7 +42,7 @@ def main():
for file in files:
if file.endswith(".py"):
file_path = os.path.join(root, file)
if not check_and_add_license_header(file_path):
if not check_and_add_license_header(file_path, write_header):
print(f"License header missing in: {file_path}")
all_files_passed = False

Expand Down
5 changes: 1 addition & 4 deletions src/core/zowe/core_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
Copyright Contributors to the Zowe Project.
"""
"""
Zowe Python SDK - Core package
"""

from .config_file import ConfigFile
from .connection import ApiConnection
from .constants import constants
from .credential_manager import CredentialManager
from .exceptions import *
from .logger import Log
from .profile_manager import ProfileManager
from .request_handler import RequestHandler
from .sdk_api import SdkApi
from .session import Session
from .session_constants import *
from .zosmf_profile import ZosmfProfile
from .logger import Log
1 change: 0 additions & 1 deletion src/core/zowe/core_for_zowe_sdk/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Copyright Contributors to the Zowe Project.
"""

import json
import os.path
import re
Expand Down
1 change: 0 additions & 1 deletion src/core/zowe/core_for_zowe_sdk/custom_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Copyright Contributors to the Zowe Project.
"""
"""A public module for custom warnings."""


class ProfileNotFoundWarning(Warning):
Expand Down
6 changes: 0 additions & 6 deletions src/core/zowe/core_for_zowe_sdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
Copyright Contributors to the Zowe Project.
"""
"""
Logger module for handling application logging.
This module provides the `Log` class which allows for registering,
setting levels, opening, and closing loggers.
"""

import logging
import os
Expand Down
3 changes: 0 additions & 3 deletions src/zos_console/zowe/zos_console_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
Copyright Contributors to the Zowe Project.
"""
"""
Zowe Python SDK - z/OS Console package
"""

from .console import Console
1 change: 0 additions & 1 deletion src/zos_console/zowe/zos_console_for_zowe_sdk/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Copyright Contributors to the Zowe Project.
"""
"""Public module for class Console."""

from typing import Optional

Expand Down
3 changes: 0 additions & 3 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
Copyright Contributors to the Zowe Project.
"""
"""
Zowe Python SDK - z/OS Files package
"""

from . import constants, exceptions
from .datasets import DatasetOption, Datasets
Expand Down
3 changes: 0 additions & 3 deletions src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
Copyright Contributors to the Zowe Project.
"""
"""
Zowe Python SDK - z/OS Jobs package
"""

from .jobs import Jobs
3 changes: 0 additions & 3 deletions src/zos_tso/zowe/zos_tso_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
Copyright Contributors to the Zowe Project.
"""
"""
Zowe Python SDK - z/OS TSO package
"""

from .tso import Tso
11 changes: 0 additions & 11 deletions src/zosmf/zowe/zosmf_for_zowe_sdk/zosmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
Copyright Contributors to the Zowe Project.
"""
"""Zowe Python Client SDK.
This program and the accompanying materials are made available under the terms of the
Eclipse Public License v2.0 which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe project.
"""

from zowe.core_for_zowe_sdk import SdkApi

Expand Down

0 comments on commit b31ed30

Please sign in to comment.