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 to dev folder files #4868

Merged
merged 2 commits into from Oct 30, 2023
Merged

Conversation

Astro-Kirsty
Copy link
Member

As mentioned here the dev folder did not have licenses.
This PR solves this

Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #4868 (a64e05e) into main (d61fe4d) will increase coverage by 0.00%.
Report is 7 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #4868   +/-   ##
=======================================
  Coverage   75.62%   75.62%           
=======================================
  Files         226      226           
  Lines       33069    33071    +2     
=======================================
+ Hits        25007    25009    +2     
  Misses       8062     8062           
Files Coverage Δ
gammapy/datasets/__init__.py 100.00% <ø> (ø)
gammapy/estimators/map/__init__.py 100.00% <ø> (ø)
gammapy/estimators/points/__init__.py 100.00% <ø> (ø)
gammapy/estimators/points/tests/test_lightcurve.py 28.32% <ø> (ø)
gammapy/irf/core.py 86.72% <ø> (ø)
gammapy/irf/edisp/__init__.py 100.00% <ø> (ø)
gammapy/irf/psf/__init__.py 100.00% <ø> (ø)
gammapy/makers/__init__.py 100.00% <ø> (ø)
gammapy/makers/background/__init__.py 100.00% <ø> (ø)
gammapy/makers/reduce.py 25.00% <ø> (ø)
... and 17 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

bkhelifi
bkhelifi previously approved these changes Oct 27, 2023
Copy link
Member

@bkhelifi bkhelifi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Astro-Kirsty

@MRegeard
Copy link
Member

Thanks @Astro-Kirsty,
There are actually a lot more files that don't have the license comment at the beginning.

If you run this small script :

import os

def check_license(directory):
    license_comment = '# Licensed under a 3-clause BSD style license - see LICENSE.rst'
    
    for root, _, files in os.walk(directory):
        for filename in files:
            if filename.endswith('.py'):
                file_path = os.path.join(root, filename)
                with open(file_path, 'r', encoding='utf-8') as file:
                    first_line = file.readline().strip()
                    if first_line != license_comment:
                        print(f"File '{file_path}' does not have the correct license comment.")

if __name__ == '__main__':
    directory_path = input("Enter the directory path to search for Python files: ")
    check_license(directory_path)

@MRegeard
Copy link
Member

You can actually run this script, that will do it for you !

import os


def add_license_comment(directory):
    license_comment = '# Licensed under a 3-clause BSD style license - see LICENSE.rst'

    for root, _, files in os.walk(directory):
        for filename in files:
            if filename.endswith('.py'):
                file_path = os.path.join(root, filename)
                with open(file_path, 'r', encoding='utf-8') as file:
                    lines = file.readlines()
                with open(file_path, 'w', encoding='utf-8') as file:
                    if not lines:
                        file.write(license_comment + '\n')
                    else:
                        first_line = lines[0].strip()
                        if first_line != license_comment:
                            lines = [license_comment + '\n'] + lines
                        file.writelines(lines)


if __name__ == '__main__':
    directory_path = input("Enter the directory path to search for Python files: ")
    add_license_comment(directory_path)

@MRegeard
Copy link
Member

@registerrier, @bkhelifi, @AtreyeeS, @adonath, do we want a script like this in the dev rep that we can run from time to time to be sure that the license is in all the files ?

@Astro-Kirsty
Copy link
Member Author

+1 for adding a script like this in the dev rep!!

Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
@Astro-Kirsty
Copy link
Member Author

Added the license to the rest of the files!

Did not add to gammapy.extern.xmltodict, due to the line #!/usr/bin/env python
Does this need to be specified here?

@MRegeard
Copy link
Member

Did not add to gammapy.extern.xmltodict, due to the line #!/usr/bin/env python
Does this need to be specified here?

You can probably put it just after this line.

Copy link
Contributor

@registerrier registerrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Astro-Kirsty . Good point.

I assume empty files might not need a license :-) But that's fine as they might be filled later.

An option could be to include this type of check as part of the CI code checks.

@registerrier
Copy link
Contributor

Added the license to the rest of the files!

Did not add to gammapy.extern.xmltodict, due to the line #!/usr/bin/env python Does this need to be specified here?

This is external package. I don't think we should re-license it.

@registerrier
Copy link
Contributor

Merging now.

@registerrier registerrier merged commit b0491df into gammapy:main Oct 30, 2023
14 of 15 checks passed
@Astro-Kirsty Astro-Kirsty deleted the dev_license branch November 20, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants