Turn this into a addon, seleect object of same volume

Hi,

I fond this Blender python code that works in the text editor.
But now i want to change this in to an addon.
I have tried a Little bit but I cant not getting it to work.
Can someone please add code so it works as an addon.


import bpy, bmesh

bm = bmesh.new()
bm.from_mesh( bpy.context.object.data )

ref_obj_name     = bpy.context.object.name
reference_volume = float( bm.calc_volume() )
ref_vol_scale    = ( '%.0E' % reference_volume )[-3:]

# Select all the objects in the scene that have a similar volume (of the same scale)
for o in [ m for m in bpy.context.scene.objects if m.type == 'MESH' ]:
    if o.name == ref_obj_name: continue

    bm = bmesh.new()
    bm.from_mesh( o.data )

    vol       = float( bm.calc_volume() )
    vol_scale = ( '%.0E' % vol )[-3:]

    if vol_scale == ref_vol_scale:
        o.select = True

*************************************************