Get Help

new_project

Creates a new project folder from a template — a project file and, depending on the template, sample data, a read-me and a run script.

Signature

cat.new_project(name: str = None, path: str = None, template: str = None,
                online: bool = False, commented: bool = False, force: bool = False,
                wrap: bool = False, logging_level: LoggingLevel = None) -> None

Parameters

Parameter Type Default Meaning
name str TestMyData Name of the project; becomes the project file name (.cat.yaml is appended when missing) and, with wrap, the folder name. Letters and digits.
path str current directory Where to create the files. Must exist.
template str default Template code — see get_project_templates. Not case-sensitive.
online bool False True: first fetch the template from the CAT server if a newer version exists there. Without it, CAT never goes online.
commented bool False True: use the commented variant of the template’s project file — every setting explained inline.
force bool False True deletes everything in the target folder first. The target is path itself unless wrap=True, so force without wrap empties the directory you point it at.
wrap bool False True: create a sub-folder named after the project inside path and put everything there.
logging_level LoggingLevel None cat.LoggingLevel member; used only when this is the first call of the process. See Logging.

What it does

Copies the template’s files into the target folder, keeps the plain or the commented project file according to commented, renames it to <name>.cat.yaml and replaces the project-name placeholder in every file. Two templates ship with CAT: default — one simple test against a local SQL Server database, the starting point for a real project — and getStartedWindows — a few tests over two sample CSV files with a read-me and a Run.ps1, the project the Get started tutorial walks through. get_project_templates(online=True) may show more. A template fetched with online=True is stored under %APPDATA%\CAT\Templates\Projects\ and used from there afterwards.

Without force, a target that already holds a file of the same name makes the call fail — nothing is overwritten. The function signs in like every project function, even though it touches no data.

Returns

None. The files appear in the target folder; the log says where.

Raises

The sign-in and plan check (first call of the process) raises the CatPortalError family listed on the Introduction page. CatException: The directory where you are trying to create a new CAT project does not exist: …; CatException: Cannot create project from template <code>, the template does not exist. Try to check online templates.; CatException: Failed to extract the project template to the target directory. when files are in the way.

Examples

# a lean TestMyData.cat.yaml in the current directory
cat.new_project()

# a project of your own: Dwh.cat.yaml in a new folder D:/Testing/Dwh, with inline comments
cat.new_project(name="Dwh", path="D:/Testing", wrap=True, commented=True)

# the tutorial sample, refreshed from the server, in its own folder
cat.new_project(name="CatSampleProject", path="C:/Users/grace/Documents/CAT",
                template="getStartedWindows", wrap=True, online=True)

# start the sample over: empties D:/Samples/CatSampleProject first
cat.new_project(name="CatSampleProject", path="D:/Samples", template="getStartedWindows",
                wrap=True, force=True)