PyForTool
Python-fortran-tool
|
Public Member Functions | |
upperCase (self) | |
lowerCase (self) | |
indent (self, nodeToUpdate=None, indentProgramunit=0, indentBranch=2, exclDirectives=None) | |
removeEmptyLines (self) | |
removeComments (self, exclDirectives=None, pattern=None) | |
updateContinuation (self, nodeToUpdate=None, align=True, removeALL=False, addBegin=True, removeBegin=False) | |
updateSpaces (self, beforeOp=1, afterOp=1, inOperator=True, beforeComma=0, afterComma=1, beforeParenthesis=0, afterParenthesis=0, beforeAffectation=1, afterAffectation=1, inAffectation=True, beforeRangeDelim=0, afterRangeDelim=0, beforeUseDelim=0, afterUseDelim=1, beforeDeclDelim=1, afterDeclDelim=1, inDeclDelim=True, afterTypeDecl=1, beforeEqDo=0, afterEqDo=0, beforeEqCall=0, afterEqCall=0, beforeEqInit=0, afterEqInit=0, beforeEndcnt=1, afterBegincnt=1, afterIfwherecase=1, beforeThen=1, beforeIfaction=1, afterProgunit=1, endOfLine=True, afterName=0, inName=True, beforeCmdsep=0, afterCmdsep=1, adjacentKeywords=__NO_VALUE__, afterKeywords=__NO_VALUE__) | |
changeIfStatementsInIfConstructs (self, singleItem=None) | |
removeEmptyCONTAINS (self) | |
Methods to deal with cosmetics
Definition at line 11 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.changeIfStatementsInIfConstructs | ( | self, | |
singleItem = None |
|||
) |
Convert if-stmt to if-then-stmt. If singleItem is not filled, conversion to entire object is performed. E.g., before : IF(A=B) print*,"C after : IF(A=B) THEN print*,"C END IF Conversion is not done if 'CYLE' is found in action-stmt :param singleItem: single if-stmt; in case transformation is applied on one if-stmt only
Definition at line 853 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.indent | ( | self, | |
nodeToUpdate = None , |
|||
indentProgramunit = 0 , |
|||
indentBranch = 2 , |
|||
exclDirectives = None |
|||
) |
:param nodeToUpdate: if None, the entire object is indented :param indentProgramunit: number of space characters inside program unit :param indentBranch: number of space characters fr other branches (do, if...) :param exclDirectives: some lines are directives and must stay unindented. The cpp directives are automatically recognized by fxtran but others appear as FORTRAN comments and must be indentified here. This option can take the following values: - None: to recognize as directives the lines begining with '!$OMP' (default) - []: to suppress the exclusion - [...]: to give another list of line beginings to consider :return: same object but with indentation corrected
Definition at line 34 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.lowerCase | ( | self | ) |
:return: same objetc but with lower case letters for FORTRAN code
Definition at line 25 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.removeComments | ( | self, | |
exclDirectives = None , |
|||
pattern = None |
|||
) |
:param exclDirectives: some lines are directives and must stay unindented. The cpp directives are automatically recognized by fxtran but others appear as FORTRAN comments and must be indentified here. This option can take the following values: - None: to recognize as directives the lines begining with '!$OMP', '!$mnh', '!$acc' or '!$ACC' (default) - []: to suppress the exclusion - [...]: to give another list of line beginings to consider :param pattern: remove only comments matching the pattern (string or re.compile output)
Definition at line 166 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.removeEmptyCONTAINS | ( | self | ) |
Remove the CONTAINS statement if this section is empty
Definition at line 922 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.removeEmptyLines | ( | self | ) |
Remove empty lines
Definition at line 153 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.updateContinuation | ( | self, | |
nodeToUpdate = None , |
|||
align = True , |
|||
removeALL = False , |
|||
addBegin = True , |
|||
removeBegin = False |
|||
) |
:param nodeToUpdate: if None, the entire xml is updated :param align: True to align begin of continued lines :param removeALL: True to suppress all the continuation line characters ('&') :param addBegin: True to add missing continuation line characters ('&') at the begining of lines :param removeBegin: True to suppress continuation line characters ('&') at the begining of lines When suppressed, the '&' are replaced by a space character Comments after a '&' are lost
Definition at line 216 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.updateSpaces | ( | self, | |
beforeOp = 1 , |
|||
afterOp = 1 , |
|||
inOperator = True , |
|||
beforeComma = 0 , |
|||
afterComma = 1 , |
|||
beforeParenthesis = 0 , |
|||
afterParenthesis = 0 , |
|||
beforeAffectation = 1 , |
|||
afterAffectation = 1 , |
|||
inAffectation = True , |
|||
beforeRangeDelim = 0 , |
|||
afterRangeDelim = 0 , |
|||
beforeUseDelim = 0 , |
|||
afterUseDelim = 1 , |
|||
beforeDeclDelim = 1 , |
|||
afterDeclDelim = 1 , |
|||
inDeclDelim = True , |
|||
afterTypeDecl = 1 , |
|||
beforeEqDo = 0 , |
|||
afterEqDo = 0 , |
|||
beforeEqCall = 0 , |
|||
afterEqCall = 0 , |
|||
beforeEqInit = 0 , |
|||
afterEqInit = 0 , |
|||
beforeEndcnt = 1 , |
|||
afterBegincnt = 1 , |
|||
afterIfwherecase = 1 , |
|||
beforeThen = 1 , |
|||
beforeIfaction = 1 , |
|||
afterProgunit = 1 , |
|||
endOfLine = True , |
|||
afterName = 0 , |
|||
inName = True , |
|||
beforeCmdsep = 0 , |
|||
afterCmdsep = 1 , |
|||
adjacentKeywords = __NO_VALUE__ , |
|||
afterKeywords = __NO_VALUE__ |
|||
) |
:param beforeOp, afterOp: number of spaces before and after operators :param inOperator: True to suppress spaces in operators :param beforeComma, afterComma: number of spaces before and after commas :param beforeParenthesis, afterParenthesis: number of spaces before and after parenthesis :param beforeAffectation, afterAffectation: number of spaces before and after affectations or associations :param inAffectation: True to suppress spaces in affectations and in association ('= >') :param beforeRangeDelim, afterRangeDelim: number of spaces before and after range delimiters :param beforeUseDelim, afterUseDelim: number of spaces before and after use delimiters (':') :param beforeDeclDelim, afterDeclDelim: number of spaces before and after declaration and enumerator delimiter ('::') :param inDeclDelim: True to suppress spaces in declaration and enumerator delimiter (': :') :param afterTypeDecl: number of spaces after the type in a declaration w/o '::' (e.g. 'INTEGER I'); also for enumerators (minimum 1) :param beforeEqDo, afterEqDo: number of spaces before and after '=' sign in DO and FORALL statements :param beforeEqCall, afterEqCall: number of spaces before and after '=' sign in CALL statement :param beforeEqInit, afterEqInit: number of spaces before and after '=' sign for init values :param beforeEndcnt, afterBegincnt: number of spaces before a continuation chararcter at the end of the line and after a continuation character at the begining of a line :param afterIfwherecase: number of spaces after the IF, ELSEIF, WHERE, ELSEWHERE, SELECTCASE, CASE and FORALL keywords :param beforeThen: number of spaces before the THEN keyword :param beforeIfaction: number of spaces between IF condition and action in one-line IF statement and between FORALL specification and affectation in one-line FORALL statement and between WHERE mask and action in one-line WHERE statement :param afterProgunit: between the program unit type (e.g. SUBROUTINE) and its name :param endOfLine: True to suppress spaces at the end of the line :param afterName: number of spaces after an indentifier, type or attribute name :param inName: True to suppress spaces in identifier names :param beforeCmdsep, afterCmdsep: number of spaces before and after command separator (';') :param adjacentKeywords: describes the number of spaces to introduce between adjancent keywords when this is legal (the list comes from the table "6.2 Adjacent keywords where separating blanks are optional" of the F2008 norm and has been complemented by "end select", "implicit none" and "module procedure"; for the last two, a minimum of 1 is required). The allowed dictionnary keys are: - block_data - double_precision - else_if - else_where - end_associate - end_block - end_block_data - end_critical - end_do - end_enum - end_file - end_forall - end_function - end_if - end_interface - end_module - end_procedure - end_program - end_selec - end_select - end_submodule - end_subroutine - end_team - end_type - end_where - go_to - in_out - select_case - select_type - implicit_none - module_procedure For example, use {'end_do':1} to write 'END DO' or {'end_do':0} to write 'ENDDO' or {'end_do':None} to not update the writting or use adjacentKeywords=None to disable everything :param afterKeywords: describes the number of spaces to introduce after keywords. Some keywords need a more sophisticated treatment and are controled by specific keys (e.g. CASE). The keys are the keyword in lowercase, some names can be tricky to guess (e.g. the key for ENDFILE is 'end-file'). By default only a few are defined. Use afterKeywords=None to disable everything. To not update spaces, put None instead of an integer and False in booleans. For example, to not change number of spaces after a comma, use afterComma=None Updates are done in the following order:
Definition at line 420 of file cosmetics.py.
pyfortool.cosmetics.Cosmetics.upperCase | ( | self | ) |
:return: same object but with upper case letters for FORTRAN code
Definition at line 16 of file cosmetics.py.