1- from Handler import Handler
1+ from Dyson . Export . Handler import Handler
22
33import Dyson .Utils .Shapes
44from Dyson .Utils .Shapes import shape_params
88import re
99
1010# Exception handling
11- from AgMLExceptions import ContentError , MissingError , AgmlArrayError , AgmlNameError , AgmlCommentError , AgmlShapeError , AgmlAttributeWarning , AgmlFillMissingVarError , MixtureComponentError , AgmlMissingAttributeWarning
11+ from Dyson . Export . AgMLExceptions import ContentError , MissingError , AgmlArrayError , AgmlNameError , AgmlCommentError , AgmlShapeError , AgmlAttributeWarning , AgmlFillMissingVarError , MixtureComponentError , AgmlMissingAttributeWarning
1212
1313#enable_warnings = os.getenv('AGML_WARNINGS',False)
1414#enable_warnings = ( os.getenv('STAR','...adev').find('adev') < 0 )
@@ -212,7 +212,7 @@ def checkAttributes( tag, attr, mylist, skip=[], warning=True ):
212212 to the expected values provided in mylist. Keys provided in
213213 the except list will not be checked.
214214 """
215- for key ,value in attr .iteritems ():
215+ for key ,value in attr .items ():
216216 if key in skip : continue
217217 if key .lower () in skip : continue
218218 key = key .lower ()
@@ -353,10 +353,6 @@ def replacements( line ):
353353
354354 for struct in document .structs :
355355
356- # if struct in myline:
357- # print "----------------------------------------------------------"
358- # print ":in: %s"%myline
359-
360356 # Lower case struct to be certain
361357 struct = struct .lower ()
362358
@@ -365,7 +361,7 @@ def replacements( line ):
365361 # myline = myline.replace(',',')(')
366362
367363 # Loop over all variables in this struct.
368- for key ,value in _struct_dims .iteritems (): # isnt this backward?
364+ for key ,value in _struct_dims .items (): # isnt this backward?
369365
370366 if ( key not in myline .lower () ): continue # can skip finditer
371367
@@ -406,21 +402,10 @@ def replacements( line ):
406402 New = Old .replace ('(' ,'[int(' )
407403 New = New .replace (')' ,')-1]' )
408404
409- #print match
410- #print New
411-
412405 myline = myline .replace (Old ,New )
413406
414407
415408
416- # if struct in myline:
417- # print ":out: %s"%myline
418-
419-
420-
421-
422-
423-
424409
425410 #
426411 # Replace single quote for double quote
@@ -614,10 +599,6 @@ def characters(self,content):
614599 for flag in content .split (' ' ):
615600 if len (flag .strip ()):
616601 self .flags .append (flag )
617- ## name = flag[:4]
618- ## print '%s::setup();' % flag
619- ## print '%s::Module *%s = new %s::Module();' % ( flag, name, flag )
620- ## print '%s -> ConstructGeometry();' %name
621602
622603
623604 def endElement (self ,tag ):
@@ -1696,7 +1677,6 @@ def endElement(self,tag):
16961677 if i < len (self .arglist )- 1 :
16971678 mydef += ','
16981679 mydef += ') { return %s; }' % self .rvalue
1699- #print mydef
17001680
17011681 # Add this inline function to the implementation file
17021682 document .impl ( mydef , unit = self .name )
@@ -1966,13 +1946,13 @@ def startElement(self,tag,attr):
19661946 try :
19671947 self .parent .addVar (name ,type ,dim ,value ,comment )
19681948 except AttributeError :
1969- print 'AttributeError: %s does not implement addVar' % self .parent
1970- print ' : name %s' % name
1971- print ' : type %s' % type
1972- print ' : dim %s' % dim
1973- print ' : value %s' % value
1974- print ' : comment %s' % comment
1975- assert 2 + 2 == 5
1949+ print ( 'AttributeError: %s does not implement addVar' % self .parent )
1950+ print ( ' : name %s' % name )
1951+ print ( ' : type %s' % type )
1952+ print ( ' : dim %s' % dim )
1953+ print ( ' : value %s' % value )
1954+ print ( ' : comment %s' % comment )
1955+ assert ( 2 + 2 == 5 )
19761956
19771957 self .type = type
19781958
@@ -2568,7 +2548,6 @@ def endElement(self,tag):
25682548 output += '// %s_docum.%s = "%s";\n ' % (name ,var ,com )
25692549
25702550 output += "%s.fill();\n " % name .upper ()
2571- #print output
25722551
25732552 document .impl ( output , unit = current )
25742553
@@ -3005,7 +2984,7 @@ def startElement(self,tag,attr):
30052984 """
30062985 block = attr .get ('block' )
30072986 keys = []
3008- for key ,value in attr .iteritems ():
2987+ for key ,value in attr .items ():
30092988 keys .append (key )
30102989
30112990
@@ -3025,15 +3004,15 @@ def startElement(self,tag,attr):
30253004 if count :
30263005 document .impl ('{ // Paramters passed in via the Create operator' , unit = current );
30273006 document .impl ('AgCreate createin("%s");' % block , unit = current )
3028- for key ,value in shape .iteritems ():
3007+ for key ,value in shape .items ():
30293008 document .impl ('createin.par("%s")=%s;' % (key ,value ), unit = current )
30303009 document .impl ('_create = createin;' , unit = current )
30313010 document .impl ('}' , unit = current );
30323011
30333012
30343013 document .impl ( '{' , unit = current );
30353014 document .impl ( 'AgShape myshape; // undefined shape' ,unit = current )
3036- for key ,value in shape .iteritems ():
3015+ for key ,value in shape .items ():
30373016 value = value .lower ()
30383017 value = replacements (value )
30393018 document .impl ( '/// Set shape par: %s = %s' % (key ,value ), unit = current )
@@ -3080,7 +3059,7 @@ def startElement(self,tag,attr):
30803059
30813060 # Check validity of attributes and issue warning if we are provided
30823061 # an unknown attribute
3083- for key ,value in attr .iteritems ():
3062+ for key ,value in attr .items ():
30843063 if key == 'block' : continue
30853064 if key == 'into' : continue
30863065 key = key .lower ()
@@ -3125,7 +3104,6 @@ def startElement(self,tag,attr):
31253104 val = attr .get (key ,None )
31263105 if ( val != None ):
31273106 pos = "%s=%s" % (key ,val );
3128- #print "Add pos=%s" %pos
31293107 self .pos .append (pos )
31303108
31313109 # And next the position arguements
@@ -3191,7 +3169,7 @@ def startElement(self,tag,attr):
31913169 parent = parent .parent
31923170
31933171 if into == None :
3194- print 'AgROOT Warning: parent of block %s not in stack WTF?' % block
3172+ print ( 'AgROOT Warning: parent of block %s not in stack WTF?' % block )
31953173
31963174
31973175
@@ -3918,7 +3896,7 @@ def setParent(self,p): self.parent = p
39183896
39193897
39203898 if ( 1 ):
3921- print ag_variable ( 'material::dens*vacuum' )
3899+ print ( ag_variable ( 'material::dens*vacuum' ) )
39223900
39233901
39243902 if ( 0 ):
0 commit comments