-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
plugin_module_name = plugin_name + "Builder"
plugin_module = "salome.%s.%s" % (plugin_name, plugin_module_name)
try:
- exec( "from salome.smesh.smeshBuilder import *")
- exec( "import %s" % plugin_module )
- exec( "mod = %s" % plugin_module )
+ exec("from salome.smesh.smeshBuilder import *", globals())
+ exec("import %s" % plugin_module, globals())
+ exec("mod = %s" % plugin_module , globals())
methods = {}
for attr in dir( mod ):
if attr.startswith( '_' ): continue
if docHelper: break
pass
if not docHelper: docHelper = "Creates new algorithm."
- output.append( " ## %s" % docHelper )
- output.append( " #" )
- output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " )
- output.append( " #" )
- output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." )
- output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." )
- output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in (see below)" )
- output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" )
- output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " )
- output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) )
- output.append( " def %s(algo_type, geom_shape=0):" % method )
- output.append( " pass" )
+ output.append( " ## %s" % docHelper )
+ output.append( " #" )
+ output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " )
+ output.append( " #" )
+ output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." )
+ output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." )
+ output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in (see below)" )
+ output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" )
+ output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " )
+ output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) )
+ output.append( " def %s(algo_type, geom_shape=0):" % method )
+ output.append( " pass" )
pass
- f = open(output_file, "w")
- for line in output: f.write( line + "\n" )
- f.close()
+ with open(output_file, "w", encoding='utf8') as f:
+ f.write('\n'.join(output))
pass
pass
except Exception as e:
pass
if __name__ == "__main__":
- import optparse
- parser = optparse.OptionParser(usage="%prog [options] plugin")
+ import argparse
+ parser = argparse.ArgumentParser()
h = "Output file (smesh.py by default)"
- parser.add_option("-o", "--output", dest="output",
- action="store", default=None, metavar="file",
+ parser.add_argument("-o", "--output", dest="output",
+ action="store", default='smesh.py', metavar="file",
help=h)
h = "If this option is True, dummy help for Mesh class is added. "
h += "This option should be False (default) when building documentation for SMESH module "
h += "and True when building documentation for meshing plug-ins."
- parser.add_option("-d", "--dummy-mesh-help", dest="dummymeshhelp",
+ parser.add_argument("-d", "--dummy-mesh-help", dest="dummymeshhelp",
action="store_true", default=False,
help=h)
- (options, args) = parser.parse_args()
+ parser.add_argument("plugin", help='Name of plugin')
+ args = parser.parse_args()
- if len( args ) < 1: sys.exit("Plugin name is not specified")
- main( args[0], options.dummymeshhelp, options.output )
+ main( args.plugin, args.dummymeshhelp, args.output )
pass