forked from MetOffice/fab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 Added dedicated enum for categories.
- Loading branch information
Showing
7 changed files
with
74 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
############################################################################## | ||
# (c) Crown copyright Met Office. All rights reserved. | ||
# For further details please refer to the file COPYRIGHT | ||
# which you should have received as part of this distribution | ||
############################################################################## | ||
|
||
'''This simple module defines an Enum for all allowed categories. | ||
''' | ||
|
||
from enum import auto, Enum | ||
|
||
|
||
class Categories(Enum): | ||
'''This class defines the allowed tool categories.''' | ||
|
||
C_COMPILER = auto() | ||
C_PREPROCESSOR = auto() | ||
FORTRAN_COMPILER = auto() | ||
FORTRAN_PREPROCESSOR = auto() | ||
LINKER = auto() | ||
PSYCLONE = auto() | ||
|
||
def __str__(self): | ||
'''Simplify the str output by using only the name (e.g. `C_COMPILER` | ||
instead of `Categories.C_COMPILER)`.''' | ||
return str(self.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
############################################################################## | ||
# (c) Crown copyright Met Office. All rights reserved. | ||
# For further details please refer to the file COPYRIGHT | ||
# which you should have received as part of this distribution | ||
############################################################################## | ||
|
||
'''This module tests the Categories. | ||
''' | ||
|
||
from fab.newtools import Categories | ||
|
||
|
||
def test_categories(): | ||
'''Tests the categories.''' | ||
# Make sure that str of a category only prints the name (which is more | ||
# useful for error messages). | ||
for cat in list(Categories): | ||
assert str(cat) == cat.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters