Skip to content
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

Add license header #318

Merged
merged 9 commits into from
Jul 24, 2024
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: 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

- *Breaking*: Revised function names in `Logger` class and `files` class into snake_case. Enabled pylint rule to enforce function case. [#315] (https://github.com/zowe/zowe-client-python-sdk/issues/315)

- Added checks and auto addition for license headers on workflow. [#293] (https://github.com/zowe/zowe-client-python-sdk/issues/293)

### Bug Fixes

## `1.0.0-dev18`
Expand Down
56 changes: 56 additions & 0 deletions scripts/license_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import sys

# Define the license header you expect in each file
LICENSE_HEADER = '''"""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.
"""'''


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:
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) > 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):
if "build" in root.split(os.path.sep):
continue
for file in files:
if file.endswith(".py"):
file_path = os.path.join(root, file)
if not check_and_add_license_header(file_path, write_header):
print(f"License header missing in: {file_path}")
all_files_passed = False

if not all_files_passed:
sys.exit(1)
else:
print("All files have the correct license header.")


if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions src/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
"""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.
"""
__version__ = "1.0.0-dev18"
11 changes: 11 additions & 0 deletions src/core/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
14 changes: 11 additions & 3 deletions src/core/zowe/core_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
"""
Zowe Python SDK - Core package
"""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 .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
12 changes: 11 additions & 1 deletion src/core/zowe/core_for_zowe_sdk/custom_warnings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
"""A public module for custom warnings."""
"""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.
"""


class ProfileNotFoundWarning(Warning):
Expand Down
13 changes: 9 additions & 4 deletions src/core/zowe/core_for_zowe_sdk/logger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""
Logger module for handling application logging.
"""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

This module provides the `Log` class which allows for registering,
setting levels, opening, and closing loggers.
Copyright Contributors to the Zowe Project.
"""

import logging
Expand Down
12 changes: 10 additions & 2 deletions src/secrets/zowe/secrets_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - Client Secrets package
"""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 . import keyring
11 changes: 11 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import os.path
import uuid

Expand Down
11 changes: 11 additions & 0 deletions src/zos_console/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
12 changes: 10 additions & 2 deletions src/zos_console/zowe/zos_console_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - z/OS Console package
"""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.
"""

pem70 marked this conversation as resolved.
Show resolved Hide resolved
from .console import Console
12 changes: 11 additions & 1 deletion src/zos_console/zowe/zos_console_for_zowe_sdk/console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
"""Public module for class Console."""
"""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 typing import Optional

Expand Down
11 changes: 11 additions & 0 deletions src/zos_files/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
12 changes: 10 additions & 2 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - z/OS Files package
"""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 . import constants, exceptions
Expand Down
11 changes: 11 additions & 0 deletions src/zos_jobs/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
12 changes: 10 additions & 2 deletions src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - z/OS Jobs package
"""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 .jobs import Jobs
11 changes: 11 additions & 0 deletions src/zos_tso/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
12 changes: 10 additions & 2 deletions src/zos_tso/zowe/zos_tso_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - z/OS TSO package
"""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 .tso import Tso
11 changes: 11 additions & 0 deletions src/zosmf/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""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.
"""
import sys

from setuptools import find_namespace_packages, setup
Expand Down
12 changes: 10 additions & 2 deletions src/zosmf/zowe/zosmf_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Zowe Python SDK - z/OSMF package
"""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 .zosmf import Zosmf
2 changes: 1 addition & 1 deletion src/zosmf/zowe/zosmf_for_zowe_sdk/zosmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe project.
Copyright Contributors to the Zowe Project.
"""

from zowe.core_for_zowe_sdk import SdkApi
Expand Down
Loading