示例#1
0
 def _transactional(*args, **kwargs):
     r = None
     event_manager = Application.get_service("event_manager")
     tx = Transaction(event_manager)
     try:
         r = func(*args, **kwargs)
     except Exception as e:
         log.error(
             "Transaction terminated due to an exception, performing a rollback",
             exc_info=True,
         )
         try:
             tx.rollback()
         except Exception as e:
             log.error("Rollback failed", exc_info=True)
         raise
     else:
         tx.commit()
     return r
示例#2
0
)

(options, args) = parser.parse_args()

if len(args) != 1:
    parser.print_help()
    sys.exit(1)

# The model file to load.
model = args[0]

# Create the Gaphor application object.
Application.init()

# Get services we need.
element_factory = Application.get_service("element_factory")
file_manager = Application.get_service("file_manager")

# Load model from file.
file_manager.load(model)

# Find all classes using factory select.
for cls in element_factory.select(lambda e: e.isKindOf(UML.Class)):

    print("Found class %s" % cls.name)

    if options.attrs:

        for attr in cls.ownedAttribute:

            print(" Attribute: %s" % attr.name)
示例#3
0
)

(options, args) = parser.parse_args()

if len(args) != 1:
    parser.print_help()
    sys.exit(1)

# The model file to load.
model = args[0]

# Create the Gaphor application object.
Application.init()

# Get services we need.
element_factory = Application.get_service("element_factory")
file_manager = Application.get_service("file_manager")

# Load model from file.
file_manager.load(model)

# Find all classes using factory select.
for cls in element_factory.select(lambda e: e.isKindOf(UML.Class)):

    print(f"Found class {cls.name}")

    if options.attrs:

        for attr in cls.ownedAttribute:

            print(f" Attribute: {attr.name}")
示例#4
0
                  help='Print class attributes')

(options, args) = parser.parse_args()

if len(args) != 1:
    parser.print_help()
    sys.exit(1)

# The model file to load.
model = args[0]

# Create the Gaphor application object.
Application.init()

# Get services we need.
element_factory = Application.get_service('element_factory')
file_manager = Application.get_service('file_manager')

# Load model from file.
file_manager.load(model)

# Find all classes using factory select.
for cls in element_factory.select(lambda e: e.isKindOf(uml2.Class)):

    print('Found class %s' % cls.name)

    if options.attrs:

        for attr in cls.ownedAttribute:
            print(' Attribute: %s' % attr.name)