|
Revision 2229, 1.2 kB
(checked in by arj..@yirdis.nl, 10 months ago)
|
gaphor command line can accept a model file as argument. Fixes #101
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
""" |
|---|
| 3 |
This is Gaphor, a Python based UML modelling tool. |
|---|
| 4 |
""" |
|---|
| 5 |
|
|---|
| 6 |
__all__ = [ 'main', 'GaphorError' ] |
|---|
| 7 |
|
|---|
| 8 |
import os |
|---|
| 9 |
|
|---|
| 10 |
import misc.logger |
|---|
| 11 |
|
|---|
| 12 |
if os.name == 'nt': |
|---|
| 13 |
home = 'USERPROFILE' |
|---|
| 14 |
else: |
|---|
| 15 |
home = 'HOME' |
|---|
| 16 |
|
|---|
| 17 |
user_data_dir = os.path.join(os.getenv(home), '.gaphor') |
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class GaphorError(Exception): |
|---|
| 21 |
""" |
|---|
| 22 |
Gaphor specific exception class |
|---|
| 23 |
""" |
|---|
| 24 |
def __init__(self, args=None): |
|---|
| 25 |
Exception.__init__(self) |
|---|
| 26 |
self.args = args |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
def launch(gaphor_file=None): |
|---|
| 30 |
""" |
|---|
| 31 |
Start the main application by initiating and running |
|---|
| 32 |
gaphor.application.Application. |
|---|
| 33 |
""" |
|---|
| 34 |
import pkg_resources |
|---|
| 35 |
|
|---|
| 36 |
from gaphor.application import Application |
|---|
| 37 |
Application.init() |
|---|
| 38 |
|
|---|
| 39 |
file_manager = Application.get_service('file_manager') |
|---|
| 40 |
if gaphor_file: |
|---|
| 41 |
file_manager.load(gaphor_file) |
|---|
| 42 |
else: |
|---|
| 43 |
file_manager.new() |
|---|
| 44 |
|
|---|
| 45 |
Application.run() |
|---|
| 46 |
Application.shutdown() |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
def main(): |
|---|
| 50 |
""" |
|---|
| 51 |
Main from the command line |
|---|
| 52 |
""" |
|---|
| 53 |
import sys |
|---|
| 54 |
if len(sys.argv) > 1: |
|---|
| 55 |
launch(sys.argv[1]) |
|---|
| 56 |
else: |
|---|
| 57 |
launch() |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
import __builtin__ |
|---|
| 62 |
__builtin__.__dict__['log'] = misc.logger.Logger() |
|---|
| 63 |
|
|---|
| 64 |
if __debug__: |
|---|
| 65 |
refs = [] |
|---|
| 66 |
|
|---|
| 67 |
|
|---|