From: Uwe Hermann Date: Wed, 24 Oct 2012 00:51:58 +0000 (+0200) Subject: new-driver: Whitespace and cosmetics. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0af91589fc36b2cac91ebf8ca0a7200bafa0e5b1;p=sigrok-util.git new-driver: Whitespace and cosmetics. - new-driver.py -> new-driver in a string. - Consistently use 4 spaces for indentation (some lines had tabs). - Minor whitespace/cosmetic fixes. --- diff --git a/source/new-driver b/source/new-driver index b591b06..1a393d1 100755 --- a/source/new-driver +++ b/source/new-driver @@ -1,22 +1,22 @@ #!/usr/bin/python3 -# -# This file is part of the sigrok-util project. -# -# Copyright (C) 2012 Bert Vermeulen -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2012 Bert Vermeulen +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +## import os import sys @@ -27,13 +27,14 @@ import re import socket import datetime -TMPL_AUTOCONF_AC_ARG_ENABLE = """AC_ARG_ENABLE(${short}, AC_HELP_STRING([--enable-${short}], - [enable ${name} driver support [default=yes]]), - [HW_${upper}="$enableval"], - [HW_${upper}=yes]) +TMPL_AUTOCONF_AC_ARG_ENABLE = """\ +AC_ARG_ENABLE(${short}, AC_HELP_STRING([--enable-${short}], + [enable ${name} driver support [default=yes]]), + [HW_${upper}="$enableval"], + [HW_${upper}=yes]) AM_CONDITIONAL(HW_${upper}, test x$HW_${upper} = xyes) if test "x$HW_${upper}" = "xyes"; then - AC_DEFINE(HAVE_HW_${upper}, 1, [${name} driver support]) + AC_DEFINE(HAVE_HW_${upper}, 1, [${name} driver support]) fi """ @@ -193,7 +194,7 @@ def do_driverskel(gitdir): def make_patch(gitdir): os.chdir(gitdir) command('git add hardware/' + names['short']) - cmd = 'git commit -m "%s: initial driver skeleton" ' % names['short'] + cmd = 'git commit -m "%s: Initial driver skeleton." ' % names['short'] cmd += 'configure.ac hardware/Makefile.am hardware/' + names['short'] command(cmd) cmd = "git format-patch HEAD~1" @@ -212,25 +213,25 @@ def command(cmd): def parse_gitconfig(): - try: - author = email = None - for line in open(os.environ['HOME'] + '/.gitconfig').readlines(): - m = re.match('\s*(\w+)\s*=\s*(.*)\s*$', line) - if m: - key, value = m.groups() - if key == 'name': - author = value - elif key == 'email': - email = value - if author and email: - break - except: - pass - if not author or not email: - print("Please put your name and email in ~/.gitconfig") - sys.exit() - - return author, email + try: + author = email = None + for line in open(os.environ['HOME'] + '/.gitconfig').readlines(): + m = re.match('\s*(\w+)\s*=\s*(.*)\s*$', line) + if m: + key, value = m.groups() + if key == 'name': + author = value + elif key == 'email': + email = value + if author and email: + break + except: + pass + if not author or not email: + print("Please put your name and email in ~/.gitconfig") + sys.exit() + + return author, email # # main @@ -238,14 +239,14 @@ def parse_gitconfig(): scriptdir = os.getcwd() if socket.gethostname() == 'sigrok': - LIBSR = '/data/git/libsigrok' - TMPLDIR = '/data/tools/tmpl' + LIBSR = '/data/git/libsigrok' + TMPLDIR = '/data/tools/tmpl' else: - LIBSR = 'git://sigrok.org/libsigrok' - TMPLDIR = scriptdir + LIBSR = 'git://sigrok.org/libsigrok' + TMPLDIR = scriptdir if len(sys.argv) < 2: - print("Usage: new-driver.py ") + print("Usage: new-driver ") sys.exit() author, email = parse_gitconfig() @@ -256,10 +257,9 @@ names = { 'lib': re.sub('[^a-z0-9]', '_', name.lower()), 'upper': re.sub('[^A-Z0-9]', '_', name.upper()), 'libupper': re.sub('[^A-Z0-9]', '', name.upper()), - 'year': datetime.datetime.now().year, - 'author': author, - 'email': email, + 'year': datetime.datetime.now().year, + 'author': author, + 'email': email, } new_driver() -