Exemple #1
0
    def cmd(args):
        """Handle subcommand."""
        (module, _, _) = syslloader.load(args.modules, args.validations,
                                         args.root)
        out = str(module)

        (open(args.output, 'w') if args.output else sys.stdout).write(out)
Exemple #2
0
    def cmd(args):
        """Handle subcommand."""
        (module, _, _) = syslloader.load(args.modules, args.validations,
                                         args.root)
        out = module.SerializeToString()

        (open(args.output, 'wb') if args.output else sys.stdout).write(out)
Exemple #3
0
    def test_set_of(self):

        try:
            (module, _, _) = syslloader.load('/test/data/test_data', True, '.')

            d = {
                'project': 'TestData :: Data Views',
                'output': 'test_set_of-data.png',
                'plantuml': '',
                'verbose': '',
                'filter': None,
            }
            args = ap.Namespace(**d)

            out = sysldata.dataviews(module, args)

            self.assertTrue(
                re.search(r'(?ms)^class "Type1" as _1 .*^_0  \*-- "0..\*" _1',
                          out[0])
                or re.search(
                    r'(?ms)^class "Type1" as _0 .*^_1  \*-- "0..\*" _0',
                    out[0]), out[0])

        except (IOError, Exception) as e:
            self.fail(traceback.format_exc())
Exemple #4
0
    def cmd(args):
        """Handle subcommand."""
        (module, deps, _) = syslloader.load(args.modules, args.validations,
                                            args.root)

        if not args.exclude and args.project:
            args.exclude = {args.project}

        integration_views(module, deps, args)
Exemple #5
0
    def genAndCompare(self, sysl_module, model, xsd_comparison_file):
        outpath = '.'
        package_prefix = 'io.sysl.test.data'
        (module, _, _) = syslloader.load(sysl_module, True, '.')

        reljam.export('xsd', module, model, outpath, package_prefix, {}, [])

        self.assertTrue(
            filecmp.cmp("./" + xsd_comparison_file, "./" + model + ".xsd"))
Exemple #6
0
    def integration_view_helper(self, modulename, d):
        (module, deps, _) = syslloader.load(modulename, True, '.')

        args = ap.Namespace(**d)

        #TODO(kirkpatg): find out what this is doing
        if not args.exclude and args.project:
            args.exclude = {args.project}

        return syslints.integration_views(module, deps, args)
Exemple #7
0
 def setUp(self):
   self.outpath  = '.'
   self.package_prefix  = 'io.sysl.test.data.petshop.'
   self.entities = {'Employee', 'Breed', 'Pet', 'EmployeeTendsPet'}
   (self.module, _, _) = syslloader.load('/test/data/petshop/petshop', True, '.')
   # export has the side effect of removing entities from the list, so the member list
   # is not passed in
   reljam.export('model', self.module, 'PetShopModel', self.outpath,
                 self.package_prefix + 'model', {'Employee', 'Breed', 'Pet', 'EmployeeTendsPet'},
                 ['json_out', 'xml_out'])
   reljam.export('facade', self.module, 'PetShopFacade', self.outpath,
                 self.package_prefix + 'facade', {'Employee', 'Breed', 'Pet', 'EmployeeTendsPet'}, [])
Exemple #8
0
    def cmd(args):
        """Handle subcommand."""
        out = cStringIO.StringIO()
        fmt = args.target + ' : {}\n'

        for module in args.modules:
            (_, _, modules) = syslloader.load([module], args.validations,
                                              args.root)

            print >> out, fmt.format(module,
                                     ' '.join(m + '.sysl' for m in modules))

        (open(args.output, 'w') if args.output else sys.stdout).write(
            out.getvalue())
Exemple #9
0
def main():
    argp = argparse.ArgumentParser(
        description='sysl relational Java Model exporter')

    argp.add_argument('--root',
                      '-r',
                      default='.',
                      help='sysl system root directory')
    argp.add_argument('--out', '-o', default='.', help='Output root directory')
    argp.add_argument(
        '--entities',
        help=
        ('Commalist of entities that are expected to have corresponding '
         'output files generated.  This is for verification only.  It doesn’t '
         'determine which files are output.'))
    argp.add_argument(
        '--package',
        help=('Package expected to be used for generated classes. This is for '
              'verification only.  It doesn’t determine the package used.'))
    argp.add_argument(
        '--serializers',
        default='*_*',
        help='Control output of XML and JSON serialization code.')
    argp.add_argument('mode',
                      choices=[
                          'model',
                          'facade',
                          'view',
                          'xsd',
                          'swagger',
                          'spring-rest-service',
                      ],
                      help='Code generation mode')
    argp.add_argument('module', help='Module to load')
    argp.add_argument('app', help='Application to export')
    args = argp.parse_args()

    out = os.path.normpath(args.out)

    (module, _, _) = syslloader.load(args.module, True, args.root)

    entities = set(args.entities.split(',')) if args.entities else set()

    export(args.mode, module, args.app, out, args.package, entities,
           args.serializers.split(',') if args.serializers else [])

    if entities:
        raise RuntimeError('Some entities not output as expected: ' +
                           ', '.join(sorted(entities)))
Exemple #10
0
    def cmd(args):
        """Handle subcommand."""
        (module, _, _) = syslloader.load(args.modules, args.validations,
                                         args.root)

        out = dataviews(module, args)
Exemple #11
0
    def cmd(args):
        """Handle subcommand."""
        (module, _, _) = syslloader.load(args.modules, args.validations,
                                         args.root)

        def output_sd(args, params):
            """Generate and output a sequence diagram."""
            # pdb.set_trace()
            out = sequence_diag(module, params)

            diagutil.output_plantuml(args, out)

        epfilters = os.getenv('SYSL_SD_FILTERS', '*').split(',')

        # TODO: Find a cleaner way to trigger multi-output.
        if '%(epname)' in args.output:
            out_fmt = diagutil.parse_fmt(args.output)
            for appname in args.app:
                app = module.apps[appname]

                bbs = [[e.s for e in bbox.a.elt]
                       for bbox in syslx.View(app.attrs)['blackboxes'].a.elt]

                seqtitle = diagutil.parse_fmt(
                    syslx.View(app.attrs)['seqtitle'].s or args.seqtitle)
                epfmt = diagutil.parse_fmt(
                    syslx.View(app.attrs)['epfmt'].s or args.endpoint_format)
                appfmt = diagutil.parse_fmt(
                    syslx.View(app.attrs)['appfmt'].s or args.app_format)

                for (name, endpt) in sorted(app.endpoints.iteritems(),
                                            key=lambda kv: kv[1].name):
                    if not any(
                            fnmatch.fnmatch(name, filt) for filt in epfilters):
                        continue

                    attrs = {
                        u'@' + name: value.s
                        for (name, value) in endpt.attrs.iteritems()
                    }
                    args.output = out_fmt(appname=appname,
                                          epname=name,
                                          eplongname=endpt.long_name,
                                          **attrs)

                    if args.filter and not re.match(args.filter, args.output):
                        continue

                    bbs2 = [[
                        e.s for e in bbox.a.elt
                    ] for bbox in syslx.View(endpt.attrs)['blackboxes'].a.elt]

                    varrefs = diagutil.attr_fmt_vars(
                        app.attrs,
                        endpt.attrs,
                        epname=endpt.name,
                        eplongname=endpt.long_name)

                    out = sequence_diag(
                        module,
                        SequenceDiagParams(endpoints=[
                            ' :: '.join(s.call.target.part) + ' <- ' +
                            s.call.endpoint for s in endpt.stmt
                            if s.WhichOneof('stmt') == 'call'
                        ],
                                           epfmt=epfmt,
                                           appfmt=appfmt,
                                           activations=args.activations,
                                           title=seqtitle(**varrefs).replace(
                                               '\n', r'\n'),
                                           blackboxes=bbs + bbs2))
                    diagutil.output_plantuml(args, out)

        else:
            out = sequence_diag(
                module,
                SequenceDiagParams(
                    endpoints=[i[0] for i in args.endpoint
                               ],  # -s builds list of lists (idkw).
                    epfmt=diagutil.parse_fmt(args.endpoint_format),
                    appfmt=diagutil.parse_fmt(args.app_format),
                    activations=args.activations,
                    title=args.title,
                    blackboxes=args.blackboxes))
            diagutil.output_plantuml(args, out)