grail.compass.projectinfo module

Version: 16.2

Table of Contents

Description

Allows access to the contents of a MineSight® Compass project file via a ProjectInfo object.

The project file often contains critical information needed to compose a runfile. This module gives a clean way to,

  • load in a project file
  • access the contents of a project file
  • mutate and commit those contents of the project file

Note

Changes to a ProjectInfo will not be persisted until a save() method is executed. This is because we keep a local copy of the Project files contents (for quick access), and modifications to the local copy do not effect the on-disk copy.

ProjectInfo Class

class ProjectInfo([loadfrom])

Contains information read from a MineSight® Compass project file.

Allows you to load a project file and access a local copy of the project files contents. In addition you can mutate the local copy and (optional) commit those mutations via the save() method.

ProjectInfo can be loaded either from the constructor or via the load() method.

Usage:

Accessing the contents of a ProjectInfo file is done much the same as accessing the contents of a dictionary. An example would be,

prj = ProjectInfo(loadfrom="myproj.prj")
file08 = prj.get(projectinfo.FILE08_TAG)

to change the contents of a the "file08" parameter you would:

prj = ProjectInfo(loadfrom="myproj.prj")
prj.set(projectinfo.FILE08_TAG, "mynewvalue")

# commit your modifications
prj.save()

The loadfrom path indicates what project file should be read in order to construct the ProjectInfo object. A default value of None implies that an empty ProjectInfo object is constructed.

get(key)
Accesses the specified item using the obj["<item>"] syntax (see ProjectInfo Keys for a list of valid keys).
load(path)

Retrieves the contents of a project file for this object.

Opens the project file, loads the resources, and closes the project file (to allow other file access/manipulations).

This will generate possible exceptions, either,
  1. IOError if the file is not found [1].
  2. ProjectInfoError if,
    1. File is not a MineSight® Compass Project file.
    2. There was an internal error reading the file.
path()
Returns the path to the ProjectInfo object.
save()

Commits the local copy of the ProjectInfo object to original path.

Takes the contents of the local ProjectInfo and commits it to the path that was originally used to load the ProjectInfo.

set(key, value)
Mutates a specified item using the obj["<item>"] syntax (see ProjectInfo Keys for a list of valid keys).

ProjectInfoError Exception

exception ProjectInfoError
An error generated whenever there is an access problem in this module. Tends to map errors generated by the GalRes module (to keep things easier to understand by the callee).

Functions

CreateProjectFile(path)
Internal usage only. Creates a new project file at the specified path populated with default values. Goes through the process of creating a new resource file to store project settings. Then populates that project file with empty values. This is mainly for testing.

ProjectInfo Keys

FILE08_TAG
Path to the File 8 file.
FILE09_TAG
Path to the File 9 file.
FILE11_TAG
Path to the File 11 file.
FILE12_TAG
Path to the File 12 file.
FILE13_TAG
Path to the File 13 file.
FILE14_TAG
Path to the File 14 file.
FILE15_TAG
Path to the File 15 file.
FILE25_TAG
Path to the File 25 file.
GROUP_TAG
Internal usage only.
PCFPATH_TAG
Access to the path for the PCF file.
USER_TAG
Name of the user.
ALL_BOOL_TAGS
Internal usage only. A list of all tags that are booleans inside the project file.
ALL_STR_TAGS
Internal usage only. A list of all tags that are strings inside the project file.
ALL_TAGS
Internal usage only. A list of all tags inside a project file.

[1]"Built-in Exceptions" Python Library Reference. 19 December 2001. 1 June 2004. <http://www.python.org/doc/2.2/lib/module-exceptions.html>