Package: scriptgen
scriptgenA collection of script generation helpers and templates.InstallationpipinstallscriptgenUsagefromscriptgenimportStringBuilderif__name__=="__main__":# Create a StringBuilder instance.sb=StringBuilder()sb.wt("Hello ")# write text "Hello "sb.wl("World!")# write line "World!\n"print(str(sb))Hello World!fromscriptgenimportStringBuilderfromscriptgen.templates.csharpimport\csharp_usings,\csharp_namespace,\csharp_class,\csharp_methodif__name__=="__main__":# Create a StringBuilder instance.sb=StringBuilder()# Write using statements.sb.wb(csharp_usings("System"))# Add a new line after the using statements.sb.nl()# Create a namespace StringBuilder instance.ns=csharp_namespace("Sample")# Create a class StringBuilder instance.c=csharp_class(class_name="Program",access_modifier="public")# Create a method StringBuilder instance.m=csharp_method(method_name="Main",access_modifier="public static",return_type="int")# Write the following lines inside the method.m.wl('Console.WriteLine("Hello World!");')m.wl("return 0;")c.wb(m)# Write the method inside the class.ns.wb(c)# Write the class inside the namespace.sb.wb(ns)# Write the namespace.print(str(sb))usingSystem;namespaceSample{publicclassProgram{publicstaticintMain(){Console.WriteLine("Hello World!");return0;}}}fromscriptgenimportStringBuilderfromscriptgen.templates.csharpimport\csharp_autogen,\csharp_namespace,\csharp_class,\csharp_regionif__name__=="__main__":# Get version from arguments..# i.e. python script.py -major 0 -minor 0 -patch 1major:int=0minor:int=0patch:int=1# Create a StringBuilder instance.sb=StringBuilder()# Write timestamp.sb.wb(csharp_autogen())# Add a new line after the using statements.sb.nl()# Create a namespace StringBuilder instance.ns=csharp_namespace("Sample")# Create a class StringBuilder instance.c=csharp_class(class_name="BuildInfo",access_modifier="public static partial")# Create a "Constants" region StringBuilder instance.r=csharp_region("Constants")# Write the following lines inside the "Constants" region.r.wl(f"public const int MAJOR ={major};")r.nl()r.wl(f"public const int MINOR ={minor};")r.nl()r.wl(f"public const int PATCH ={patch};")c.wb(r)# Write the region inside the class.ns.wb(c)# Write the class inside the namespace.sb.wb(ns)# Write the namespace.print(str(sb))// Auto-generated: 2020-03-15T04:20:47.909851namespaceSample{publicstaticpartialclassBuildInfo{#region ConstantspublicconstintMAJOR=0;publicconstintMINOR=0;publicconstintPATCH=1;#endregion Constants}}Look at thisscriptto see its practical use case.ContributionSuggestions and contributions are always welcome.
Make sure to read theContribution Guidelinesfile for more information before submitting apull request.Licensescriptgenis released under the MIT License. See theLICENSEfile for details.Changelogv0.0.5Fixed multiple new lines in Windows.Added more C# templates.v0.0.4Added XML templates.v0.0.3Added index parameter in filter_func.Changed from current working path to file directory path ingen_docs.pyscript.v0.0.2Added default values for the builder classes.Added optional parameters.ExposedCSharpBlockBuilderclass inscriptgen.templates.csharppackage.Bug fixes.v0.0.1AddedIndentType,StringBuilder, andBlockBuilderclasses.Addeddiff_lines,diff_text,interpolate_text,timestamp, andwrite_text_fileutility methods.Added C# and Markdown templates.Added tests for the utility methods, C# templates, and Markdown templates.Addedgen_docs.pyscript and template files.