summaryrefslogtreecommitdiff
path: root/gr-utils/python
diff options
context:
space:
mode:
authorSwapnil Negi <swapnil.negi09@gmail.com>2019-02-20 00:09:41 +0530
committerMartin Braun <martin.braun@ettus.com>2019-02-22 14:06:49 -0800
commit0ab1a75a8181e2d89d82b499913d5e30b2bca018 (patch)
tree322d0d34cef2e71dce7f75396cf292333f70f592 /gr-utils/python
parent1808e96543f4eafc84aef00ff5d3bca634bba387 (diff)
Modtool: Add copyright feature
Diffstat (limited to 'gr-utils/python')
-rw-r--r--gr-utils/python/modtool/cli/add.py12
-rw-r--r--gr-utils/python/modtool/tools/scm.py2
2 files changed, 12 insertions, 2 deletions
diff --git a/gr-utils/python/modtool/cli/add.py b/gr-utils/python/modtool/cli/add.py
index 45f749c375..fcc2ff539b 100644
--- a/gr-utils/python/modtool/cli/add.py
+++ b/gr-utils/python/modtool/cli/add.py
@@ -25,6 +25,7 @@ from __future__ import absolute_import
from __future__ import unicode_literals
import re
+import getpass
import click
@@ -109,7 +110,16 @@ def get_blockname(self):
def get_copyrightholder(self):
""" Get the copyrightholder of the block to be added """
if self.info['copyrightholder'] is None:
- self.info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
+ user = getpass.getuser()
+ git_user = self.scm.get_gituser()
+ if git_user:
+ copyright_candidates = (user, git_user, 'GNU Radio')
+ else:
+ copyright_candidates = (user, 'GNU Radio')
+ with SequenceCompleter(copyright_candidates):
+ self.info['copyrightholder'] = cli_input("Please specify the copyright holder: ")
+ if not self.info['copyrightholder'] or self.info['copyrightholder'].isspace():
+ self.info['copyrightholder'] = "gr-{} author".format(self.info['modname'])
elif self.info['is_component']:
click.secho("For GNU Radio components the FSF is added as copyright holder",
fg='cyan')
diff --git a/gr-utils/python/modtool/tools/scm.py b/gr-utils/python/modtool/tools/scm.py
index 249616ade3..c91f891123 100644
--- a/gr-utils/python/modtool/tools/scm.py
+++ b/gr-utils/python/modtool/tools/scm.py
@@ -91,7 +91,7 @@ class SCMRepository(object):
def get_gituser(self):
""" Gets the git user """
try:
- return subprocess.check_output('git config --global user.name', shell=True).strip()
+ return (subprocess.check_output('git config --global user.name', shell=True).strip()).decode('utf-8')
except (OSError, subprocess.CalledProcessError):
return None