Skip to content

micah0912/mSCL.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

  • its a source file header management utility base on Spairaru framework.
  • developed for internal use originally, free for public use.
  • collaboration or service request, contact me.
  • a coffee donation will help to keep the package updated :)


Highlights


  • With custom files stored in .scl folder in each directory, settings can be overridden and stacked up.
  • As the result, you can apply different header template with dynamitic text to all or specified file accordingly.
  • Easy switch to license and un-license files for development or release branch, development or production state, by the use of your scenario.
  • Auto generate LICENSE.txt with default or customized template, and with dynamic text.


Supporting File Types


Currently supported source file types are below, will continue to expand in future release.

  • .cnf, .css, .cmd, .html, .ini, .java, js, .php, .py, .sh, .swift, .ts, .xml


Environment Requirements


  1. Python version 3.9+


Dependency Requirements


  1. Spairaru-Python framework
    • information and documentation, see Git or Web.
    # importing spairaru must be fesible

    import sprr


Installation


  1. PIP  
    • To be determine.
    # TBD

    $ pip install xxxxxxxxx


  1. Installer
    1. Download from Git or Web.
    2. Extra and find installer in __installation__ folder.
    3. Execute installer.


  1. Manually
    1. Download from Git or Web.
    2. Extra and move src source folder or dist distribution folder to python path or working directory.
    3. rename src or dist folder to preferred name; Suggest to scl.


Basic Usage


To apply license

# long syntax
from scl import SourceCodeLicenser

SourceCodeLicenser.license( "__path_of_application_root__" )


# short syntax
from scl import scl

scl.lic( "__path_of_application_root__" )


To dispose license

# long syntax
from scl import SourceCodeLicenser

SourceCodeLicenser.unlicense( "__path_of_application_root__" )


# short syntax
from scl import scl

scl.ulic( "__path_of_application_root__" )


Advanced Usage


copy to and license in different folder

# give `dist` or `distribution` option

scl.lic(
	"__path_of_application_root__" 
	# Locational Options
	# distribution_directory
	, dist = "__path_of_distribution_root__" 
)

license over symbolic folders and files

# give `flw_lnk` or `flow_link` option

scl.lic(
	"__path_of_application_root__" 
	# Search Options
	# follow_link
	, flw_lnk = True
)


Customization


  • place add custom .tpl template files or .cnf configuration files, or .ign ignore glob patterns in .scl folder.
# Exanple Hierarchy

__path_of_application_root__

    + .scl
        - custom.tpl
        - custom.ign
        - custom.cnf
    + __some_folder__
    + __some_folder__
        + .scl
            - custom.tpl
            - custom.ign
            - custom.cnf
  • If no .tpl present, settings will inherit from parent directory.


Custom - Template


Naming

  • For default template, name it to @.tpl.
  • To specify template, name it to __name__.__extention__.tpl.
# Exanple Naming

__path_of_application_root__

    + .scl
        - @.tpl
    + __some_folder__
        + .scl
            - test.html.tpl
        - test.html
  • In above hierarchy,
    • test.html will apply to test.html.tpl.
    • the rest of file will apply @.tpl


Design

  • Input text without comment in template file.
  • Where the dynamic variable surround it with double braces plus parent mark.
  • Dynamic variables can define in .cnf configuration files.
# Exanple of xxx.tpl

{{%SCL_PTN_NM}} {{%SCL_PTN_VER}}

Copyright {{%SCL_LIC_HLDR}} {{%SCL_LIC_YR}}. All Rights Reserved.

This file is part of {{%SCL_PTN_NM}}, which released under {{%SCL_LIC_TYP}}.
# above example in licensing stage outputs below

SourceCodeLicenser-Python sr1.0.0

Copyright EtroTech, and its contributor 2022. All Rights Reserved.

This file is part of SourceCodeLicenser, which released under GPL-3.0-or-later.


Custom - Configuration


  • .cnf configuration file use standard .conf or .ini file syntax.
  • Configuration category must be [scl]
# Exanple of xxx.cnf

[scl]
__custom_var_Name__=__Custom_Var_Value__


Custom - Ignores


  • By adding glob pattern to .ign ignore file be faster license or un-license processes.
  • Accept standard glob syntax.
# Exanple of xxx.ign

**/**.__extension__
**/__folder_name__