Giter Club home page Giter Club logo

burocrata's Introduction

Burocrata: Check and insert copyright and license notices into source code

Part of the Fatiando a Terra project.

Latest release on PyPI Latest release on conda-forge Test coverage report Compatible Python versions

About

Burocrata is a small command-line program that can check the existence of copyright and license notices in source code files and add them when they are missing.

Installing

Burocrata is available from PyPI:

python -m pip install burocrata

and conda-forge:

conda install burocrata -c conda-forge

Using

Check that very .py file in a directory has a license notice:

$ burocrata --check --extension=py source_folder

Removing the --check option will make Burocrata add the license notice to the files that don't have them:

$ burocrata --extension=py source_folder

The license and copyright notice can be configured in a pyproject.toml file located in the directory where burocrata is run:

$ cat pyproject.toml
[tool.burocrata]
notice = '''
# Copyright (c) YYYY Name of Developer.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause'''

See a full list of options:

$ burocrata --help

Dependencies

We use the following dependencies (see pyproject.toml for specific version constraints):

  • click for building the command-line interface.
  • tomli to parse the TOML configuration files.
  • pathspec to parse .gitignore files.

Contacting Us

Find out more about how to reach us at fatiando.org/contact

Contributing

Code of conduct

Please note that this project is released with a Code of Conduct. By participating in this project you agree to abide by its terms.

Contributing Guidelines

Please read our Contributing Guide to see how you can help and give feedback.

License

Burocrata is free and open-source software distributed under the MIT License.

burocrata's People

Contributors

dependabot[bot] avatar leouieda avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

diogoocruz

burocrata's Issues

Allow to pass a single file as argument to the CLI

Description of the desired feature:

Currently, burocrata expects a directory to be passed as argument to the CLI. It would be nice if we could alternatively pass a single file to it.

We should be checking if the passed argument is a file or a directory and then act accordingly.
If the passed argument is a file, I think we can safely ignore the --extension option.

Maybe we can refactor the main function and move these lines to their own private function that will return the list of missing files. In case the passed argument is a file, then the function should just check if the file lacks the license notice or not:

missing_notice = []
for directory in directories:
amount = 0
for ext in extensions:
for path in directory.glob(f"**/*.{ext}"):
if gitignore.match_file(path):
continue
amount += 1
source_code = path.read_text().split("\n")
if not source_code:
missing_notice.append(path)
else:
for notice_line, file_line in zip(notice, source_code):
if notice_line != file_line:
missing_notice.append(path)
break

Are you willing to help implement and maintain this feature?

I'll be glad to!

Add some unit tests

Description of the desired feature:

This package was tested on its own code and other Fatiando projects but doesn't currently have any unit tests. It would be nice to have some for the parsing and editing code in burocrata/tests to get started. Testing the CLI is more complicated but if we can have some tests for the inner code it would already be great.

This will require moving the code from main() into separate functions that can be tested.

Are you willing to help implement and maintain this feature?

Maybe but it will take some time so if anyone else wants to try this I'd be more than happy.

Remove the --extension argument and set this value in pyproject.toml

Description of the desired feature:

From #10, it became clear that we should passing this sort of option on the command line. Having it all in the pyproject.toml file makes it easier to run the tool since no matter what the project wants, it's always just burocrata FILE or burocrata --check FILE.

We should remove the option and create a new section in the pyproject.toml to add extensions. It would be a list of extensions and could be with or without the .. It should default to the same as the current default.

Are you willing to help implement and maintain this feature?

Yes but would love some help if anyone is up for it!

Add option to ignore files

Description of the desired feature:

Would be nice if we can include a list of files in the pyproject.toml that we don't want to be checked or modified by burocrata. The syntax could be similar to what isort does with skip, flake8 with exclude, and ruff with exclude.

It would be nice if we can list files and/or globs. For example:

[tool.burocrata]
notice = '''
# Copyright (c) YYYY Name of Developer.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause'''
exclude = ["foo/bar.py", "lorem/*.py"]

This idea originated in https://github.com/orgs/fatiando/discussions/139#discussioncomment-8647144

Are you willing to help implement and maintain this feature?

That will be fun!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.