Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

110 lines (73 sloc) 3.668 kB

OVERVIEW

Creates diagrams from code and sometimes vice versa. Primary use cases:

  1. Generate object models from Django models
  2. Generate even flow diagram from code regexes

Diagram layout is autogenerated.

Status

Just used by me. I'd be happy to clean up the code and generalize it if there's interest.

Turns the following Django code:

 class TestType(models.Model):
     OS_TYPES_LIST = ["Windows", "Mac", "Ubuntu"]
     os_types_max_len, OS_TYPES, OS_TYPES_CHOICES = model_utils.convert_to_choices(OS_TYPES_LIST)

     OS_VERSION_LIST = ["7", "XP", "Vista", "X.4", "X.5", "X.6", "8.04", "9.06"]
     os_version_max_len, OS_VERSION, OS_VERSION_CHOICES = model_utils.convert_to_choices(OS_VERSION_LIST)

     FF_VERSION_LIST = ["3.0", "3.5", "3.6"]
     ff_max_len, FF_VERSION, FF_VERSION_CHOICES = model_utils.convert_to_choices(FF_VERSION_LIST)

     slug = models.CharField(max_length=200)
     name = models.CharField(max_length=200)
     os_type = models.CharField(max_length=os_types_max_len, choices=OS_TYPES_CHOICES)
     os_version = models.CharField(max_length=os_version_max_len, choices=OS_VERSION_CHOICES)
     ff_version = models.CharField(max_length=ff_max_len, choices=FF_VERSION_CHOICES)

     ...

 class TestRun(models.Model):
     test_type = models.ForeignKey(TestType)
     dtime = models.DateTimeField(db_index=True)
     is_pass = models.BooleanField(default=False)
     number_fail = models.IntegerField(default=-1)
     total = models.IntegerField(default=-1)
     duration = models.IntegerField(default=-1)

     ...

into an OmniGraffle diagram that looks like this:

Turns the above OmniGraffle diagram into the following Django code:

 class TestType(models.Model):
     id = models.AutoField()
     slug = models.CharField(max_length=200)
     name = models.CharField(max_length=200)
     os_type = models.CharField(max_length=200)
     os_version = models.CharField(max_length=200)
     ff_version = models.CharField(max_length=200)

 class TestRun(models.Model):
     id = models.AutoField()
     test_type = models.ForeignKey('TestType')
     dtime = models.DateTimeField()
     is_pass = models.BooleanField()
     number_fail = models.IntegerField()
     total = models.IntegerField()
     duration = models.IntegerField()

Turns code that matches source and dest regex into graphviz/dot diagram that looks like this:

POTENTIAL DEPENDENCIES

DOT/Graphviz

OmniGraffle

Django

RUN

Command line interface:

Event Flow Diagram

  1. cd to Auto-Models root
  2. edit config.py
  3. python main.py ef2dot

Object Model Diagram

  1. cd to
  2. python <path to Auto-Models>/main.py help

When creating OmniGraffle diagrams, the script does a force-directed layout on the models.

Jump to Line
Something went wrong with that request. Please try again.