-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from creativecommons/moar-title-work
App: improve title handling
- Loading branch information
Showing
5 changed files
with
341 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Standard library | ||
import logging | ||
from argparse import ArgumentParser | ||
|
||
# Third-party | ||
from django.core.management import BaseCommand | ||
|
||
# First-party/Local | ||
from legal_tools.utils import init_utils_logger, update_title | ||
|
||
LOG = logging.getLogger(__name__) | ||
LOG_LEVELS = { | ||
0: logging.ERROR, | ||
1: logging.WARNING, | ||
2: logging.INFO, | ||
3: logging.DEBUG, | ||
} | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Update the title property of all legal tools by normalizing legalcy titles | ||
and normalizing translated titles for current legal tools (Licenses 4.0 and | ||
CC0 1.0). | ||
""" | ||
|
||
def add_arguments(self, parser: ArgumentParser): | ||
# Python defaults to lowercase starting character for the first | ||
# character of help text, but Djano appears to use uppercase and so | ||
# shall we | ||
parser.description = self.__doc__ | ||
parser._optionals.title = "Django optional arguments" | ||
parser.add_argument( | ||
"-n", | ||
"--dryrun", | ||
action="store_true", | ||
help="dry run: do not make any changes", | ||
) | ||
|
||
def handle(self, **options): | ||
self.options = options | ||
LOG.setLevel(LOG_LEVELS[int(options["verbosity"])]) | ||
init_utils_logger(LOG) | ||
update_title(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.