Fixed syntax highlight for variables
This commit is contained in:
parent
a700ab99ea
commit
dda94af474
4 changed files with 31 additions and 30 deletions
15
defaults
15
defaults
|
@ -1,8 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
author="Antonio J. Delgado"
|
|
||||||
authoring_date=$(date +%Y)
|
export AUTHOR="Antonio J. Delgado"
|
||||||
project_name="Project Name"
|
export AUTHORING_DATE=$(date +%Y)
|
||||||
project_codename="project-codename"
|
export PROJECT_NAME="Project Name"
|
||||||
version=0.0.1
|
export PROJECT_CODENAME="project-codename"
|
||||||
deployment_path="${HOME}/repos/"
|
export VERSION=0.0.1
|
||||||
description=""
|
export DEPLOYMENT_PATH="${HOME}/repos/"
|
||||||
|
export DESCRIPTION=""
|
|
@ -9,31 +9,31 @@ do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--author")
|
"--author")
|
||||||
shift
|
shift
|
||||||
author="${1}"
|
AUTHOR="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"--authoring-date")
|
"--authoring-date")
|
||||||
shift
|
shift
|
||||||
authoring_date="${1}"
|
AUTHORING_DATE="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"--project-name")
|
"--project-name")
|
||||||
shift
|
shift
|
||||||
project_name="${1}"
|
PROJECT_NAME="${1}"
|
||||||
;;
|
;;
|
||||||
"--project-codename")
|
"--project-codename")
|
||||||
shift
|
shift
|
||||||
project_codename="${1}"
|
PROJECT_CODENAME="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"--version")
|
"--version")
|
||||||
shift
|
shift
|
||||||
version="${1}"
|
VERSION="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"--deployment-path")
|
"--deployment-path")
|
||||||
shift
|
shift
|
||||||
deployment_path="${1}"
|
DEPLOYMENT_PATH="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -43,16 +43,16 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
destination_path="${deployment_path}/${project_codename}"
|
destination_path="${DEPLOYMENT_PATH}/${PROJECT_CODENAME}"
|
||||||
mkdir "${destination_path}"
|
mkdir "${destination_path}"
|
||||||
script_path=$(dirname "${0}")
|
script_path=$(dirname "${0}")
|
||||||
cp "${script_path}/skeleton" "${destination_path}" -rfp
|
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
|
while read -r file
|
||||||
do
|
do
|
||||||
sed -i "s/%project_codename%/${project_codename}/g" "${file}"
|
sed -i "s/__project_codename__/${PROJECT_CODENAME}/g" "${file}"
|
||||||
sed -i "s/%author%/${author}/g" "${file}"
|
sed -i "s/__author__/${AUTHOR}/g" "${file}"
|
||||||
sed -i "s/%authoring_date%/${authoring_date}/g" "${file}"
|
sed -i "s/__authoring_date__/${AUTHORING_DATE}/g" "${file}"
|
||||||
sed -i "s/%project_name%/${project_name}/g" "${file}"
|
sed -i "s/__project_name__/${PROJECT_NAME}/g" "${file}"
|
||||||
sed -i "s/%version%/${version}/g" "${file}"
|
sed -i "s/__version__/${VERSION}/g" "${file}"
|
||||||
done <<< "$(ls "${destination_path}/")"
|
done <<< "$(ls "${destination_path}/")"
|
|
@ -1,4 +1,4 @@
|
||||||
# %project_codename%
|
# __project_codename__
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@
|
||||||
|
|
||||||
## Usage
|
## 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`
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# This script is licensed under GNU GPL version 2.0 or above
|
# This script is licensed under GNU GPL version 2.0 or above
|
||||||
# (c) %authoring_date% %author%
|
# (c) __authoring_date__ __author__
|
||||||
# %description%
|
# __description__
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -12,7 +12,7 @@ import click
|
||||||
import click_config_file
|
import click_config_file
|
||||||
from logging.handlers import SysLogHandler
|
from logging.handlers import SysLogHandler
|
||||||
|
|
||||||
class %project_codename%:
|
class __project_codename__:
|
||||||
|
|
||||||
def _init_(self, debug_level, log_file):
|
def _init_(self, debug_level, log_file):
|
||||||
''' Initial function called when object is created '''
|
''' Initial function called when object is created '''
|
||||||
|
@ -22,7 +22,7 @@ class %project_codename%:
|
||||||
|
|
||||||
def _init_log(self):
|
def _init_log(self):
|
||||||
''' Initialize log object '''
|
''' Initialize log object '''
|
||||||
self._log = logging.getLogger("%project_codename%")
|
self._log = logging.getLogger("__project_codename__")
|
||||||
self._log.setLevel(logging.DEBUG)
|
self._log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
sysloghandler = SysLogHandler()
|
sysloghandler = SysLogHandler()
|
||||||
|
@ -38,14 +38,14 @@ class %project_codename%:
|
||||||
else:
|
else:
|
||||||
home_folder = os.environ.get('HOME', os.environ.get('USERPROFILE', ''))
|
home_folder = os.environ.get('HOME', os.environ.get('USERPROFILE', ''))
|
||||||
log_folder = os.path.join(home_folder, "log")
|
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)):
|
if not os.path.exists(os.path.dirname(log_file)):
|
||||||
os.path.mkdir(os.path.dirname(log_file))
|
os.path.mkdir(os.path.dirname(log_file))
|
||||||
|
|
||||||
filehandler = logging.handlers.RotatingFileHandler(log_file, maxBytes=102400000)
|
filehandler = logging.handlers.RotatingFileHandler(log_file, maxBytes=102400000)
|
||||||
# create formatter
|
# 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.setFormatter(formatter)
|
||||||
filehandler.setLevel(logging.DEBUG)
|
filehandler.setLevel(logging.DEBUG)
|
||||||
self._log.addHandler(filehandler)
|
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.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()
|
@click_config_file.configuration_option()
|
||||||
def main(debug_level, log_file):
|
def main(debug_level, log_file):
|
||||||
object = %project_codename%(debug_level, log_file)
|
object = __project_codename__(debug_level, log_file)
|
||||||
object._log.info('Initialized %project_codename%')
|
object._log.info('Initialized __project_codename__')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue