Fixed syntax highlight for variables

This commit is contained in:
Antonio J. Delgado 2021-01-13 17:17:31 +02:00
parent a700ab99ea
commit dda94af474
4 changed files with 31 additions and 30 deletions

View file

@ -1,8 +1,9 @@
#!/bin/bash
author="Antonio J. Delgado"
authoring_date=$(date +%Y)
project_name="Project Name"
project_codename="project-codename"
version=0.0.1
deployment_path="${HOME}/repos/"
description=""
export AUTHOR="Antonio J. Delgado"
export AUTHORING_DATE=$(date +%Y)
export PROJECT_NAME="Project Name"
export PROJECT_CODENAME="project-codename"
export VERSION=0.0.1
export DEPLOYMENT_PATH="${HOME}/repos/"
export DESCRIPTION=""

View file

@ -9,31 +9,31 @@ do
case "$1" in
"--author")
shift
author="${1}"
AUTHOR="${1}"
shift
;;
"--authoring-date")
shift
authoring_date="${1}"
AUTHORING_DATE="${1}"
shift
;;
"--project-name")
shift
project_name="${1}"
PROJECT_NAME="${1}"
;;
"--project-codename")
shift
project_codename="${1}"
PROJECT_CODENAME="${1}"
shift
;;
"--version")
shift
version="${1}"
VERSION="${1}"
shift
;;
"--deployment-path")
shift
deployment_path="${1}"
DEPLOYMENT_PATH="${1}"
shift
;;
*)
@ -43,16 +43,16 @@ do
esac
done
destination_path="${deployment_path}/${project_codename}"
destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}"
mkdir "${destination_path}"
script_path=$(dirname "${0}")
cp "${script_path}/skeleton" "${destination_path}" -rfp
mv "${destination_path}/project_codename.py" "${destination_path}/${project_codename}.py"
mv "${destination_path}/project_codename.py" "${destination_path}/${PROJECT_CODENAME}.py"
while read -r file
do
sed -i "s/%project_codename%/${project_codename}/g" "${file}"
sed -i "s/%author%/${author}/g" "${file}"
sed -i "s/%authoring_date%/${authoring_date}/g" "${file}"
sed -i "s/%project_name%/${project_name}/g" "${file}"
sed -i "s/%version%/${version}/g" "${file}"
sed -i "s/__project_codename__/${PROJECT_CODENAME}/g" "${file}"
sed -i "s/__author__/${AUTHOR}/g" "${file}"
sed -i "s/__authoring_date__/${AUTHORING_DATE}/g" "${file}"
sed -i "s/__project_name__/${PROJECT_NAME}/g" "${file}"
sed -i "s/__version__/${VERSION}/g" "${file}"
done <<< "$(ls "${destination_path}/")"

View file

@ -1,4 +1,4 @@
# %project_codename%
# __project_codename__
## Requirements
@ -14,4 +14,4 @@
## Usage
`%project_codename%.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters`
`__project_codename__.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters`

View file

@ -2,8 +2,8 @@
# -*- encoding: utf-8 -*-
#
# This script is licensed under GNU GPL version 2.0 or above
# (c) %authoring_date% %author%
# %description%
# (c) __authoring_date__ __author__
# __description__
import sys
import os
@ -12,7 +12,7 @@ import click
import click_config_file
from logging.handlers import SysLogHandler
class %project_codename%:
class __project_codename__:
def _init_(self, debug_level, log_file):
''' Initial function called when object is created '''
@ -22,7 +22,7 @@ class %project_codename%:
def _init_log(self):
''' Initialize log object '''
self._log = logging.getLogger("%project_codename%")
self._log = logging.getLogger("__project_codename__")
self._log.setLevel(logging.DEBUG)
sysloghandler = SysLogHandler()
@ -38,14 +38,14 @@ class %project_codename%:
else:
home_folder = os.environ.get('HOME', os.environ.get('USERPROFILE', ''))
log_folder = os.path.join(home_folder, "log")
log_file = os.path.join(log_folder, "%project_codename%.log")
log_file = os.path.join(log_folder, "__project_codename__.log")
if not os.path.exists(os.path.dirname(log_file)):
os.path.mkdir(os.path.dirname(log_file))
filehandler = logging.handlers.RotatingFileHandler(log_file, maxBytes=102400000)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
formatter = logging.Formatter('__(asctime)s - __(name)s - __(levelname)s - __(message)s')
filehandler.setFormatter(formatter)
filehandler.setLevel(logging.DEBUG)
self._log.addHandler(filehandler)
@ -61,8 +61,8 @@ class %project_codename%:
#@click.option("--dummy","-n" is_flag=True, help="Don't do anything, just show what would be done.") # Don't forget to add dummy to parameters of main function
@click_config_file.configuration_option()
def main(debug_level, log_file):
object = %project_codename%(debug_level, log_file)
object._log.info('Initialized %project_codename%')
object = __project_codename__(debug_level, log_file)
object._log.info('Initialized __project_codename__')
if __name__ == "__main__":
main()