vsgen package¶
Subpackages¶
Submodules¶
Module contents¶
Main __init__.py for the vsgen package
-
class
vsgen.VSGSolution(**kwargs)[source]¶ Bases:
vsgen.writer.VSGWritable,vsgen.writer.VSGJinjaRendererVSGSolution encapsulates the logic needed to create a
.slnfile.Variables: - GUID (uuid) – The GUI of the solution; if not provided one is generated automatically.
- FileName (str) – The absolute filename of the solution file; if not provided the value is “”
- Name (str) – The display name of the solution; if not provide the value is “”.
- Projects (list) – The list of VSGProject derived classes; if not provide the value is [].
-
class
vsgen.VSGProject(**kwargs)[source]¶ Bases:
objectVSGProject encapsulates the data and logic needed to act as a base project.
Variables: - GUID (uuid) – The GUID of the project; if not provided one is generated automatically.
- FileName (str) – The absolute filename of the project file; if not provided the value is “”
- Name (str) – The display name of the project; if not provide the value is “”.
- WorkingDirectory (str) – The absolute directory that will be the working directory of the project; if not provide the value is “”
- OutputPath (str) – The absolute directory that will be the output directory of the project; if not provide the value is “”.
- RootNamespace (str) – The name of the root namespace of the project; if not provide the value is “”. Ignored.
- ProjectHome (str) – The absolute directory of the project’s source root folder; if not provide the value is “”
- StartupFile (str) – The absolute path to the Startup file; if not provide the value is “”
- CompileFiles (list) – The list of absolute files that will comprise the projects compile group; if not provide the value is [].
- ContentFiles (list) – The list of absolute files that will comprise the projects content group; if not provide the value is [].
- Directories (list) – The list of absolute directories that will comprise the projects directory group; if not provide the value is [].
- DirectoryInFilter (list) – A list of fnmatch expressions to match directories to be included during the item generation step; if not provided the value is [].
- DirectoryExFilter (list) – A list of fnmatch expressions to match directories to be excludes during the item generation step; if not provided the value is [].
- CompileInFilter (list) – A list of fnmatch expressions to match compile files to be included during the item generation step; if not provide the value is [].
- CompileExFilter (list) – A list of fnmatch expressions to match compile files to be excluded during the item generation step; if not provide the value is [].
- ContentInFilter (list) – A list of fnmatch expressions to match content files to be included during the item generation step; if not provide the value is [].
- ContentExFilter (list) – A list of fnmatch expressions to match content files to be excluded during the item generation step; if not provide the value is [].
- VSVersion (float) – The Visual Studio version; if not provide the value is
None.
-
CompileFilesRelative¶ Returns a generator iterating over the each file in
ContentFilesrelative toProjectHomedirectory.
-
ContentFilesRelative¶ Returns a generator iterating over the each file in
ContentFilesrelative toProjectHomedirectory.
-
DirectoriesRelative¶ Returns a generator iterating over the each directory referenced by the project, relative to
ProjectHomedirectory.
-
OutputPathRelative¶ Returns the
OutputPathrelative toProjectHomedirectory.
-
ProjectHomeRelative¶ Returns the
ProjectHomerelative toFileNamedirectory.
-
StartupFileRelative¶ Returns the
StartupFilerelative toProjectHomedirectory.
-
WorkingDirectoryRelative¶ Returns the
WorkingDirectoryrelative toProjectHomedirectory.
-
classmethod
from_section(config, section, **kwargs)[source]¶ Creates a
VSGProjectfrom aConfigParsersection.Parameters: - config (ConfigParser) – A
ConfigParserinstance. - section (str) – A
ConfigParsersection key. - kwargs – List of additional keyworded arguments to be passed into the
VSGProject.
Returns: A valid
VSGProjectinstance if succesful; None otherwise.- config (ConfigParser) – A
-
insert_files(rootpath, directoryInFilter=None, directoryExFilter=None, compileInFilter=None, compileExFilter=None, contentInFilter=None, contentExFilter=None)[source]¶ Inserts files by recursive traversing the rootpath and inserting files according the addition filter parameters.
Parameters: - rootpath (str) – The absolute path to the root directory.
- directoryInFilter (list) – A list of fnmatch expressions to match directories to be included. A None value will default to
DirectoryInFilter. - directoryExFilter (list) – A list of fnmatch expressions to match directories to be excluded. A None value will default to
DirectoryExFilter. - compileInFilter (list) – A list of fnmatch expressions to match compile files to be included. A None value will default to
CompileInFilter. - compileExFilter (list) – A list of fnmatch expressions to match compile files to be excludes. A None value will default to
CompileExFilter. - contentInFilter (list) – A list of fnmatch expressions to match content files to be includes. A None value will default to
ContentInFilter. - contentExFilter (list) – A list of fnmatch expressions to match content files to be excludes. A None value will default to
ContentExFilter.
-
class
vsgen.VSGRegisterable[source]¶ Bases:
objectAn interface class defining methods necessary for VSGRegisterable
-
lower(value)[source]¶ Converts a value to lower case in a way compatible with Python2 and Python 3.
Parameters: value (object) – The value to convert. Returns: The value as lower case text.
-
-
class
vsgen.VSGRegisterCommand(logname, registerables)[source]¶ Bases:
objectThe VSGRegisterCommand class presents a simple command object to execute the register methods of a collection of VSGRegisterable objects.
-
class
vsgen.VSGWriter(pylist)[source]¶ Bases:
threading.ThreadVSGWriter encapsulates the logic needed to write any VSG object to disk.
-
class
vsgen.VSGWritable[source]¶ Bases:
objectAn interface class defining methods necessary for VSGWriter
-
lower(value)[source]¶ Converts a value to lower case in a way compatible with Python2 and Python 3.
Parameters: value (object) – The value to convert. Returns: The value as lower case text.
-
text(value)[source]¶ Converts a value to text in a way compatible with Python2 and Python 3.
Parameters: value (object) – The value to convert. Returns: The value as text.
-
-
class
vsgen.VSGWriteCommand(logname, writables, parallel=True)[source]¶ Bases:
objectThe VSGWriteCommand class presents a simple command object to execute the writing methods of a collection of VSGWritable objects.
-
class
vsgen.VSGSuite(config)[source]¶ Bases:
objectThe VSGSuite class groups a collection of solutions and projects into a single class.
-
classmethod
from_args(**kwargs)[source]¶ Generates one or more VSGSuite instances from command line arguments.
Parameters: kwargs – List of additional keyworded arguments to be passed into the VSGSuite defined in the make_parser()method.
-
classmethod
from_directory(directory, type, **kwargs)[source]¶ Creates an VSGSuite instance from a filename.
Parameters:
-
classmethod
from_file(filename)[source]¶ Creates an VSGSuite instance from a filename.
Parameters: filename (str) – The fully qualified path to the VSG configuration file.
-
classmethod
make_parser(**kwargs)[source]¶ Creates a
ArgumentParserinstances to work with VSGSuite classes.Parameters: kwargs – List of additional keyworded arguments to be passed into the ArgumentParser.Returns: A ArgumentParserinstance.
-
classmethod
-
class
vsgen.VSGLogger(filepath=None, threshold=20)[source]¶ Bases:
objectThe VSG Logger manages messages associate with various priority level.
Optional, it can redirect the messages to any output channel (usually a file).
-
BASENAME= 'VSG'¶
-
class
LevelFilter(levels=None)[source]¶ Bases:
logging.FilterThe LevelFilter class implements a Filter Object specific to the VSGLogger
-
classmethod
critical(name, message, *args)[source]¶ Convenience function to log a message at the CRITICAL level.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: The native logger’s kwargs are not used in this function.
-
classmethod
debug(name, message, *args)[source]¶ Convenience function to log a message at the DEBUG level.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: The native logger’s kwargs are not used in this function.
-
classmethod
error(name, message, *args)[source]¶ Convenience function to log a message at the ERROR level.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: The native logger’s kwargs are not used in this function.
-
classmethod
exception(name, message, *args)[source]¶ Convenience function to log a message at the ERROR level with additonal exception information.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: This method should only be called from an exception handler.
-
classmethod
getLogger(name=None)[source]¶ Retrieves the Python native logger
Parameters: name – The name of the logger instance in the VSG namespace (VSG.<name>); a None value will use the VSG root. Returns: The instacne of the Python logger object.
-
classmethod
info(name, message, *args)[source]¶ Convenience function to log a message at the INFO level.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: The native logger’s kwargs are not used in this function.
-
classmethod
warning(name, message, *args)[source]¶ Convenience function to log a message at the WARNING level.
Parameters: - name – The name of the logger instance in the VSG namespace (VSG.<name>)
- message – A message format string.
- args – The arguments that are are merged into msg using the string formatting operator.
..note: The native logger’s kwargs are not used in this function.
-
-
class
vsgen.VSGTimer(message=None)[source]¶ Bases:
objectThe VSGTimer class presents a simply timer using Python’s native time module.
-
pprint(seconds)[source]¶ Pretty Prints seconds as Hours:Minutes:Seconds.MilliSeconds
Parameters: seconds – The time in seconds.
-
-
class
vsgen.VSGConfigParser(*args, **kwargs)[source]¶ Bases:
configparser.ConfigParserThe VSG ConfigParser extends Python’s ConfigParser class with VSG specific functionality.
Note: VSGConfigParser uses ExtendedInterpolationas the default interpolation.-
getdir(section, option, raw=False, vars=None, fallback='', validate=False)[source]¶ A convenience method which coerces the option in the specified section to a directory.
-
getdirs(section, option, raw=False, vars=None, fallback=[])[source]¶ A convenience method which coerces the option in the specified section to a list of directories.
-
getfile(section, option, raw=False, vars=None, fallback='', validate=False)[source]¶ A convenience method which coerces the option in the specified section to a file.
-
getlist(section, option, raw=False, vars=None, fallback=[], delimiters=', ')[source]¶ A convenience method which coerces the option in the specified section to a list of strings.
-