from defcon import Glyph, Image, registerRepresentationFactory
from defconAppKit.representationFactories.nsBezierPathFactory import NSBezierPathFactory
from defconAppKit.representationFactories.glyphCellFactory import GlyphCellFactory
from defconAppKit.representationFactories.glyphCellDetailFactory import GlyphCellDetailFactory
from defconAppKit.representationFactories.glyphViewFactories import NoComponentsNSBezierPathFactory,\
    OnlyComponentsNSBezierPathFactory, OutlineInformationFactory, NSImageFactory
from defconAppKit.representationFactories.menuImageFactory import MenuImageRepresentationFactory

_glyphFactories = {
    "defconAppKit.NSBezierPath" : NSBezierPathFactory,
    "defconAppKit.NoComponentsNSBezierPath" : NoComponentsNSBezierPathFactory,
    "defconAppKit.OnlyComponentsNSBezierPath" : OnlyComponentsNSBezierPathFactory,
    "defconAppKit.GlyphCell" : GlyphCellFactory,
    "defconAppKit.GlyphCellDetail" : GlyphCellDetailFactory,
    "defconAppKit.OutlineInformation" : OutlineInformationFactory,
    "defconAppKit.MenuImage" : MenuImageRepresentationFactory,
}
_imageFactories = {
    "defconAppKit.NSImage" : NSImageFactory
}

def registerAllFactories():
    for name, factory in _glyphFactories.items():
        registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=None)
    for name, factory in _imageFactories.items():
        registerRepresentationFactory(Image, name, factory, destructiveNotifications=None)


from defcon import Glyph, Image, registerRepresentationFactory
from defconAppKit.representationFactories.nsBezierPathFactory import NSBezierPathFactory
from defconAppKit.representationFactories.glyphCellFactory import GlyphCellFactory
from defconAppKit.representationFactories.glyphCellDetailFactory import GlyphCellDetailFactory
from defconAppKit.representationFactories.glyphViewFactories import NoComponentsNSBezierPathFactory,\
    OnlyComponentsNSBezierPathFactory, OutlineInformationFactory, NSImageFactory
from defconAppKit.representationFactories.menuImageFactory import MenuImageRepresentationFactory

_glyphFactories = {
    "defconAppKit.NSBezierPath" : (NSBezierPathFactory, None),
    "defconAppKit.NoComponentsNSBezierPath" : (NoComponentsNSBezierPathFactory, None),
    "defconAppKit.OnlyComponentsNSBezierPath" : (OnlyComponentsNSBezierPathFactory, None),
    "defconAppKit.GlyphCell" : (GlyphCellFactory, None),
    "defconAppKit.GlyphCellDetail" : (GlyphCellDetailFactory, None),
    "defconAppKit.OutlineInformation" : (OutlineInformationFactory, None),
    "defconAppKit.MenuImage" : (MenuImageRepresentationFactory, None),
}
_imageFactories = {
    "defconAppKit.NSImage" : (NSImageFactory, ["Image.FileNameChanged", "Image.ColorChanged", "Image.ImageDataChanged"])
}

def registerAllFactories():
    for name, (factory, destructiveNotifications) in _glyphFactories.items():
        registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=destructiveNotifications)
    for name, (factory, destructiveNotifications) in _imageFactories.items():
        registerRepresentationFactory(Image, name, factory, destructiveNotifications=destructiveNotifications)


Use specific notifications when possible.
Use specific notifications when possible.

  from defcon import Glyph, Image, registerRepresentationFactory
  from defconAppKit.representationFactories.nsBezierPathFactory import NSBezierPathFactory
  from defconAppKit.representationFactories.glyphCellFactory import GlyphCellFactory
  from defconAppKit.representationFactories.glyphCellDetailFactory import GlyphCellDetailFactory
  from defconAppKit.representationFactories.glyphViewFactories import NoComponentsNSBezierPathFactory,\
      OnlyComponentsNSBezierPathFactory, OutlineInformationFactory, NSImageFactory
  from defconAppKit.representationFactories.menuImageFactory import MenuImageRepresentationFactory
  
  _glyphFactories = {
-     "defconAppKit.NSBezierPath" : NSBezierPathFactory,
+     "defconAppKit.NSBezierPath" : (NSBezierPathFactory, None),
-     "defconAppKit.NoComponentsNSBezierPath" : NoComponentsNSBezierPathFactory,
+     "defconAppKit.NoComponentsNSBezierPath" : (NoComponentsNSBezierPathFactory, None),
-     "defconAppKit.OnlyComponentsNSBezierPath" : OnlyComponentsNSBezierPathFactory,
+     "defconAppKit.OnlyComponentsNSBezierPath" : (OnlyComponentsNSBezierPathFactory, None),
-     "defconAppKit.GlyphCell" : GlyphCellFactory,
+     "defconAppKit.GlyphCell" : (GlyphCellFactory, None),
-     "defconAppKit.GlyphCellDetail" : GlyphCellDetailFactory,
+     "defconAppKit.GlyphCellDetail" : (GlyphCellDetailFactory, None),
-     "defconAppKit.OutlineInformation" : OutlineInformationFactory,
+     "defconAppKit.OutlineInformation" : (OutlineInformationFactory, None),
-     "defconAppKit.MenuImage" : MenuImageRepresentationFactory,
+     "defconAppKit.MenuImage" : (MenuImageRepresentationFactory, None),
  }
  _imageFactories = {
-     "defconAppKit.NSImage" : NSImageFactory
+     "defconAppKit.NSImage" : (NSImageFactory, ["Image.FileNameChanged", "Image.ColorChanged", "Image.ImageDataChanged"])
  }
  
  def registerAllFactories():
-     for name, factory in _glyphFactories.items():
+     for name, (factory, destructiveNotifications) in _glyphFactories.items():
-         registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=None)
+         registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=destructiveNotifications)
-     for name, factory in _imageFactories.items():
+     for name, (factory, destructiveNotifications) in _imageFactories.items():
-         registerRepresentationFactory(Image, name, factory, destructiveNotifications=None)
+         registerRepresentationFactory(Image, name, factory, destructiveNotifications=destructiveNotifications)
  
  
Use specific notifications when possible.
## Code Before:
from defcon import Glyph, Image, registerRepresentationFactory
from defconAppKit.representationFactories.nsBezierPathFactory import NSBezierPathFactory
from defconAppKit.representationFactories.glyphCellFactory import GlyphCellFactory
from defconAppKit.representationFactories.glyphCellDetailFactory import GlyphCellDetailFactory
from defconAppKit.representationFactories.glyphViewFactories import NoComponentsNSBezierPathFactory,\
    OnlyComponentsNSBezierPathFactory, OutlineInformationFactory, NSImageFactory
from defconAppKit.representationFactories.menuImageFactory import MenuImageRepresentationFactory

_glyphFactories = {
    "defconAppKit.NSBezierPath" : NSBezierPathFactory,
    "defconAppKit.NoComponentsNSBezierPath" : NoComponentsNSBezierPathFactory,
    "defconAppKit.OnlyComponentsNSBezierPath" : OnlyComponentsNSBezierPathFactory,
    "defconAppKit.GlyphCell" : GlyphCellFactory,
    "defconAppKit.GlyphCellDetail" : GlyphCellDetailFactory,
    "defconAppKit.OutlineInformation" : OutlineInformationFactory,
    "defconAppKit.MenuImage" : MenuImageRepresentationFactory,
}
_imageFactories = {
    "defconAppKit.NSImage" : NSImageFactory
}

def registerAllFactories():
    for name, factory in _glyphFactories.items():
        registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=None)
    for name, factory in _imageFactories.items():
        registerRepresentationFactory(Image, name, factory, destructiveNotifications=None)


## Instruction:
Use specific notifications when possible.
## Code After:
from defcon import Glyph, Image, registerRepresentationFactory
from defconAppKit.representationFactories.nsBezierPathFactory import NSBezierPathFactory
from defconAppKit.representationFactories.glyphCellFactory import GlyphCellFactory
from defconAppKit.representationFactories.glyphCellDetailFactory import GlyphCellDetailFactory
from defconAppKit.representationFactories.glyphViewFactories import NoComponentsNSBezierPathFactory,\
    OnlyComponentsNSBezierPathFactory, OutlineInformationFactory, NSImageFactory
from defconAppKit.representationFactories.menuImageFactory import MenuImageRepresentationFactory

_glyphFactories = {
    "defconAppKit.NSBezierPath" : (NSBezierPathFactory, None),
    "defconAppKit.NoComponentsNSBezierPath" : (NoComponentsNSBezierPathFactory, None),
    "defconAppKit.OnlyComponentsNSBezierPath" : (OnlyComponentsNSBezierPathFactory, None),
    "defconAppKit.GlyphCell" : (GlyphCellFactory, None),
    "defconAppKit.GlyphCellDetail" : (GlyphCellDetailFactory, None),
    "defconAppKit.OutlineInformation" : (OutlineInformationFactory, None),
    "defconAppKit.MenuImage" : (MenuImageRepresentationFactory, None),
}
_imageFactories = {
    "defconAppKit.NSImage" : (NSImageFactory, ["Image.FileNameChanged", "Image.ColorChanged", "Image.ImageDataChanged"])
}

def registerAllFactories():
    for name, (factory, destructiveNotifications) in _glyphFactories.items():
        registerRepresentationFactory(Glyph, name, factory, destructiveNotifications=destructiveNotifications)
    for name, (factory, destructiveNotifications) in _imageFactories.items():
        registerRepresentationFactory(Image, name, factory, destructiveNotifications=destructiveNotifications)

