-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move HidraProjectFileMode into separate file refs #219
- Loading branch information
1 parent
c0e923d
commit 8bebdbd
Showing
15 changed files
with
70 additions
and
47 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
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# flake8: noqa | ||
# pylint: disable=undefined-variable | ||
from .constants import HidraConstants | ||
from .file_mode import HidraProjectFileMode | ||
|
||
__all__ = ['HidraConstants'] | ||
__all__ = constants.__all__ + file_mode.__all__ |
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,37 @@ | ||
# This is rs_scan_io.DiffractionFile's 2.0 version | ||
from enum import Enum | ||
|
||
__all__ = ['HidraProjectFileMode'] | ||
|
||
|
||
class HidraProjectFileMode(Enum): | ||
''' | ||
Enumeration for file access mode | ||
These values match the strings of :py:obj:`h5py.File` | ||
''' | ||
READONLY = 'r' # read-only | ||
READWRITE = 'a' # read and write | ||
OVERWRITE = 'w' # new file | ||
|
||
def __str__(self): | ||
return self.value | ||
|
||
@staticmethod | ||
def getMode(mode): | ||
'''Private function to convert anything into :py:obj:`HidraProjectFileMode`''' | ||
if mode in HidraProjectFileMode: | ||
return mode # already a member of the enum | ||
else: | ||
# all other checks are for strings | ||
# the first checks are against nominal values | ||
# the last check is against the enum names | ||
mode = str(mode).lower() | ||
if mode in ['a', 'rw']: | ||
return HidraProjectFileMode.READWRITE | ||
elif mode == 'r': | ||
return HidraProjectFileMode.READONLY | ||
elif mode == 'w': | ||
return HidraProjectFileMode.OVERWRITE | ||
else: | ||
return HidraProjectFileMode[mode.upper()] |
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
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
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