~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/addons_contrib/system_project_folder.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-05-12 20:02:22 UTC
  • mfrom: (14.2.16 sid)
  • Revision ID: package-import@ubuntu.com-20120512200222-lznjs2cxzaq96wua
Tags: 2.63a-1
* New upstream bugfix release
  + debian/patches/: re-worked since source code changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# system_project_folder.py (c) 2010 Dany Lebel (Axon_D)
2
 
#
3
 
# ***** BEGIN GPL LICENSE BLOCK *****
4
 
#
5
 
#
6
 
# This program is free software; you can redistribute it and/or
7
 
# modify it under the terms of the GNU General Public License
8
 
# as published by the Free Software Foundation; either version 2
9
 
# of the License, or (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program; if not, write to the Free Software Foundation,
18
 
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 
#
20
 
# ***** END GPL LICENCE BLOCK *****
21
 
 
22
 
bl_info = {
23
 
    "name": "Project Folder",
24
 
    "author": "Dany Lebel (Axon_D), Spirou4D",
25
 
    "version": (0,3, 1),
26
 
    "blender": (2, 6, 1),
27
 
    "api": 43260,
28
 
    "location": "Info -> File Menu -> Project Folder",
29
 
    "description": "Open the project folder in a file browser",
30
 
    "warning": "",
31
 
    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/System/Project_Folder",
32
 
    "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25910",
33
 
    "category": "System"}
34
 
 
35
 
 
36
 
import bpy
37
 
import os
38
 
from platform import system as currentOS
39
 
 
40
 
 
41
 
class ProjectFolder(bpy.types.Operator):
42
 
    """Open the Project Folder in a file Browser"""
43
 
    bl_idname = "file.project_folder"
44
 
    bl_label = "Project Folder"
45
 
    
46
 
    
47
 
    def execute(self, context):
48
 
        try :
49
 
            path = self.path()
50
 
        except ValueError:
51
 
            self.report({'INFO'}, "No project folder yet")
52
 
            return {'FINISHED'}
53
 
        
54
 
        bpy.ops.wm.path_open(filepath=path)
55
 
 
56
 
        
57
 
        return {'FINISHED'}
58
 
 
59
 
    def path(self):
60
 
        filepath = bpy.data.filepath
61
 
        relpath = bpy.path.relpath(filepath)
62
 
        path = filepath[0: -1 * (relpath.__len__() - 2)]
63
 
        return path
64
 
 
65
 
 
66
 
# Registration
67
 
 
68
 
def menu_func(self, context):
69
 
    self.layout.operator(
70
 
        ProjectFolder.bl_idname,
71
 
        text="Project Folder", 
72
 
        icon="FILESEL")
73
 
 
74
 
def register():
75
 
    bpy.utils.register_class(ProjectFolder)
76
 
    bpy.types.INFO_MT_file.prepend(menu_func)
77
 
 
78
 
def unregister():
79
 
    bpy.utils.unregister_class(ProjectFolder)
80
 
    bpy.types.INFO_MT_file.remove(menu_func)
81
 
 
82
 
if __name__ == "__main__":
83
 
    register()