Пример #1
0
from swf.export import SVGExporter, SingleShapeSVGExporterMixin, FrameSVGExporterMixin, NamesSVGExporterMixin
from swf.tag import TagPlaceObject, TagDefineShape, TagDefineSprite, TagFrameLabel
from subprocess import call
import json

print "Parsing..."
swf = SWF(open('coachmap.swf'))

# NB: the order of these mixins matter.
class CoachExporter(SingleShapeSVGExporterMixin, FrameSVGExporterMixin, NamesSVGExporterMixin, SVGExporter):
  pass

exporter = CoachExporter()

# 1) Find the PlaceObject tag "floorplan".
placeobject = [x for x in swf.all_tags_of_type(TagPlaceObject) if x.instanceName == 'floorplan'][0]

# 2) Find corresponding DefineSprite.
sprite = [x for x in swf.all_tags_of_type((TagDefineShape, TagDefineSprite)) if x.characterId == placeobject.characterId][0]

# 3) Remove background (id=362) to get a tight viewbox for each coach type.
sprite.tags = [t for t in sprite.tags if not hasattr(t, 'characterId') or t.characterId != 362]

# 4) Remove filter from placeobject so there's something to see.
placeobject.colorTransform = None
placeobject.hasColorTransform = False

coaches = list(sprite.all_tags_of_type(TagFrameLabel))

# 5) For all coaches:
#    - export to dist/coaches/*.svg
Пример #2
0
print "Parsing..."
swf = SWF(open('coachmap.swf'))


# NB: the order of these mixins matter.
class CoachExporter(SingleShapeSVGExporterMixin, FrameSVGExporterMixin,
                    NamesSVGExporterMixin, SVGExporter):
    pass


exporter = CoachExporter()

# 1) Find the PlaceObject tag "floorplan".
placeobject = [
    x for x in swf.all_tags_of_type(TagPlaceObject)
    if x.instanceName == 'floorplan'
][0]

# 2) Find corresponding DefineSprite.
sprite = [
    x for x in swf.all_tags_of_type((TagDefineShape, TagDefineSprite))
    if x.characterId == placeobject.characterId
][0]

# 3) Remove background (id=362) to get a tight viewbox for each coach type.
sprite.tags = [
    t for t in sprite.tags
    if not hasattr(t, 'characterId') or t.characterId != 362
]
Пример #3
0
#!/usr/bin/env python
#!/usr/bin/python
#!python

from swf.actions import ActionGetURL
from swf.movie import SWF
from swf.tag import TagDefineButton2
import sys
import argparse

parser = argparse.ArgumentParser(description="Read and output the URLs linked to in a SWF file.")
parser.add_argument("--swf", type=argparse.FileType('rb'),
                    help="Location of SWF file to parse", required=True)
options = parser.parse_args()

# Load and parse the SWF.
swf = SWF(options.swf)

# Print all of the URLs that are targeted via ActionGetURL actions on Button2 tags.
for button in swf.all_tags_of_type(TagDefineButton2):
    for buttonAction in button.buttonActions:
        for action in buttonAction.actions:
            if isinstance(action, ActionGetURL):
                print action.urlString