hio.base.filing
hio.base.filing module
Module Contents
Classes
Filer instances manage file directories and files to hold keri installation |
|
Basic Filer Doer |
Functions
|
Context manager wrapper Filer instances for managing a filesystem directory |
Attributes
- hio.base.filing.openFiler(cls=None, name='test', temp=True, reopen=True, clear=False, **kwa)[source]
Context manager wrapper Filer instances for managing a filesystem directory and or files in a directory.
Defaults to using temporary directory path. Context ‘with’ statements call .close on exit of ‘with’ block
- Parameters
instance (cls is Class instance of subclass) –
oglers (name is str name of ogler instance for filename so can have multiple) – at different paths thar each use different log file directories
Boolean (temp is) – Otherwise open in persistent directory, do not clear on close
directory (True means open in temporary) – Otherwise open in persistent directory, do not clear on close
close (clear on) – Otherwise open in persistent directory, do not clear on close
Usage:
with openFiler(name=”bob”) as filer:
with openFiler(name=”eve”, cls=FilerSubClass) as filer:
- class hio.base.filing.Filer(name='main', base='', temp=False, headDirPath=None, perm=None, reopen=True, clear=False, reuse=False, clean=False, filed=False, mode=None, fext=None, **kwa)[source]
Filer instances manage file directories and files to hold keri installation specific resources like databases and configuration files.
- name
unique path component used in directory or file path name
- Type
str
- base
another unique path component inserted before name
- Type
str
- temp
True means use /tmp directory
- Type
bool
- headDirPath is head directory path
- path is full directory path
- perm is numeric os permissions for directory and/or file
- Type
s
- filed
True means .path ends in file. False means .path ends in directory
- Type
bool
- mode
file open mode if filed
- Type
str
- fext
file extension if filed
- Type
str
- file
- Type
File
- opened is Boolean, True means directory created and if file then file
is opened. False otherwise
- File/Directory Creation Mode Notes:
.Perm provides default restricted access permissions to directory and/or files stat.S_ISVTX | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR 0o1700==960
- stat.S_ISVTX is Sticky bit. When this bit is set on a directory it means
that a file in that directory can be renamed or deleted only by the owner of the file, by the owner of the directory, or by a privileged process. When this bit is set on a file it means nothing
stat.S_IRUSR Owner has read permission. stat.S_IWUSR Owner has write permission. stat.S_IXUSR Owner has execute permission.
- reopen(self, temp=None, headDirPath=None, perm=None, clear=False, reuse=False, clean=False, mode=None, fext=None, **kwa)[source]
Open if closed or close and reopen if opened or create and open if not
- Parameters
temp (bool) – assign to .temp True means open in temporary directory, clear on close False means open persistent directory, do not clear on close
headDirPath (str) – optional head directory pathname for main database Default .HeadDirpath
perm (int) – optional numeric os dir permissions for database directory and database files. Default .Perm
clear (bool) – True means remove directory upon close False means do not remove directory upon close
reuse (bool) – True means reuse self.path if already exists False means do not reuse but remake self.path
clean (bool) – True means path uses clean tail variant False means path uses normal tail variant
mode (str) – file open mode when .filed
fext (str) – File extension when .filed
- remake(self, *, name='', base='', temp=None, headDirPath=None, perm=None, clean=False, filed=False, mode=None, fext=None, **kwa)[source]
Make and return (path. file) by opening or creating and opening if not preexistent, directory or file at path
- Parameters
name (str) – unique name alias portion of path
base (str) – optional base inserted before name in path
temp (bool) – optional None means ignore, True means open temporary directory, may clear on close False menans open persistent directory, may not clear on close
headDirPath (str) – optional head directory pathname of main database
perm (int) – directory or file permissions such as stat.S_IRUSR Owner has read permission. stat.S_IWUSR Owner has write permission. stat.S_IXUSR Owner has execute permission.
clean (bool) – True means make path for cleaned version and remove old directory or file at clean path if any. False means make path normally (not clean)
filed (bool) – True means .path is file path not directory path False means .path is directiory path not file path
mode (str) – file open mode when .filed such as “w+”
fext (str) – File extension when .filed
- class hio.base.filing.FilerDoer(filer, **kwa)[source]
Bases:
hio.base.doing.DoerBasic Filer Doer
- done
completion state: True means completed Otherwise incomplete. Incompletion maybe due to close or abort.
- Type
bool
- Properties:
- tyme (float): relative cycle time of associated Tymist .tyme obtained
via injected .tymth function wrapper closure.
- tymth (func): closure returned by Tymist .tymeth() method.
When .tymth is called it returns associated Tymist .tyme. .tymth provides injected dependency on Tymist tyme base.
- tock (float)): desired time in seconds between runs or until next run,
non negative, zero means run asap