Logo   Home Table of Contents    News  Dev Blogs  Gallery  Timeline  Legend  Tags  Sponsors 
Join us on... 
Banner

Current: Month Day, Year

9.1.9 Code of core/targetcat.py

core/targetcat provides methods to deal with target categories. The file contains 1 class:

Class TargetCategories

This class is used to work with target categories

Variables

These variables are all preset by __init__.
namedescription
glob reference to global object.
env reference to global environment.
basename Contains the current basename.
user_targets list of user targets, preset as empty list.
icon_repos list of icon-repositiories, preset as empty list.

Methods:

nameparametersreturnsdescription
addUserTarget folder
subfolder
filename
latest
newer (bool) this class add a user target name to user_targets and checks date. If newer true is returned.
formatModellingEntry user:mod
cats
folder
filename
None Formats an entry for categories in user section. The name is created by replacing '-' with spaces. If folder is not none it is prepended to the name using URI mode (so with '/') The element is a combination of capitalized folder and name. The group is simply "user|" + folder and the iconname would be folder and filename connected by '-'. Without subfolder the name is prepended by "User " and the group is "user|unsorted".

Then a dual-target (in user folder only incr and decr are allowed) is tested. If it ends with "incr" the opposite is calculated. If this opposite is found in cats the complete entry can be done (including icon-name). If the file is decr it is placed in the opposite table.

For all targets not being recognized as an dualtarget a single entry is done.

getIcons folder
lastest
newer (bool) scans folder for icons (ending with png) and appends them to icon_repos. If file is newer, true is returned.
getAListOfTargets folder
lastest
newer (bool) Scans a list of targets, 2 layers are maximum. It first checks the date of the folder itself. After that it scans all entries. An "icons" folder is scanned with getIcons(). If the file itself is a directory it checks this directory for file names ending with ".target". Also targets in the first layer are accepted.
createJStruct categoriesuser_cat
user_modNone
creates a dictionary for later use as JSON with formatModellingEntry and returns evaluated user_cat and user_mod entry.
recreateUserCategories Noneuserjson recreates target category for user space. No target folder in user space would be ignored. Then dates of target_cat.json and modelling.json are evaluated. With the older date all targets are compared with the help of getAListOfTargets. If a rescan should be done, the new JSON files are written. The current (or new) user JSON file is (re-)read and returned.
connectCategories jsonNone When glob.targetCategories is not None the user categories are appended to "User", otherwise they are directly used for glob.targetCategories.
readFiles NoneNone create internal structure of target categories, the user category is appended to system category. contarget is tested first (user only system). Otherwise system target is used. glob.targetCategories will be linked and newUserCategories is called.
newUserCategories NoneNone main command to create new user categories.
findUserAsset searchname
t
Searches for a certain target and returns target and name. Also can deal with two layers or dual target. Returns name and target itself. None, None if not found.