The Managed_file Module

File class definition

Project Name: MakeHuman

Product Home Page: http://www.makehuman.org/

Code Home Page: https://bitbucket.org/MakeHuman/makehuman/

Authors: Thanasis Papoutsidakis

Copyright(c): MakeHuman Team 2001-2016

Licensing: AGPL3

This file is part of MakeHuman (www.makehuman.org).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Abstract

This module defines the File class, an object that represents a file that is being edited inside MakeHuman.

class managed_file.File[source]

Object class representing a file that is being opened and edited from inside the application.

It can be used for managing project files, and handling the currently opened files in a Graphical User Interface using an organized structure.

changed(reason=None, data=None)[source]

Method to be called when the File’s associated data is modified.

Without arguments, it is equivalent to File.modified = True. Extra arguments are passed to the FileModifiedEvent constructor.

closed(reason=None, data=None)[source]

Method to be called after closing the file.

dir

Get the directory of the associated file.

extension

Get the extension of the associated file.

getModified()[source]

Get the state of the modified flag.

loaded(path, reason=None, data=None)[source]

Method to be called after loading the file from a path.

modified

Get the state of the modified flag.

name

Get the filename of the associated file.

path

Get the full path of the associated file.

saved(path, reason=None, data=None)[source]

Method to be called after saving the file to a path.

setModified(value)[source]

Set the value of the modified flag and emit an event.

title

Get the title of the associated file, which is the filename without the extension.

class managed_file.FileModifiedEvent(file, value, oldvalue, reason=None, data=None)[source]

Event class to be emitted upon modification of a managed File object.

It contains information about the state of the modified flag and possibly about the reason that the event was triggered.

addReason(reason)[source]

Add the given reason to the event’s reason list.

classmethod fromObjectAssignment(newfileobj, oldfileobj)[source]

Class method that returns a new FileModifiedEvent object properly modified to inform about a modification event, in the case that the change was done with the use of assignment (instead of the standard object’s methods e.g. load() etc.).

objectWasChanged

Return whether the cause that triggered the event has altered the associated object’s data.

This method can be used by external classes for invoking update routines.

pathWasChanged

Return whether the cause that triggered the event has changed the location of the associated file.

This method can be used by external classes for updating path inspectors like path explorers / tree views.