IHEWAcollect.base package

Submodules

IHEWAcollect.base.base module

Base

Examples:

from IHEWAcollect.base import Base

base = Base(product='CFSR', is_print=True)
class IHEWAcollect.base.base.Base(product, is_print)[source]

Bases: object

This Base class

Load base.yml file.

Parameters:
  • product (str) – Product name of data products.

  • is_print (bool) – Is to print status message.

classmethod check_conf(key, is_print) dict[source]

Check configuration information

This is the function to get user’s configuration data.

Don’t synchronize the details to github.

  • File to read: collect.yml.

Parameters:

key (str) – Key name.

Returns:

Configuration data.

Return type:

dict

Example:
>>> from IHEWAcollect.base.base import Base
>>> conf = Base.check_conf('data', is_print=False)
>>> conf['messages'][0]
{'msg': 'No error', 'level': 0}
check_input(vname, rtype, vdata) bool[source]
get_conf(key) dict[source]

Get configuration information

This is the function to get project’s configuration data.

Parameters:

key (str) – Key name.

Returns:

Configuration data.

Return type:

dict

Example:
>>> import os
>>> from IHEWAcollect.base.base import Base
>>> base = Base(is_print=False)
>>> file = base.get_conf('file')
>>> print(file)
base.yml
get_status() str[source]

Get status

This is the function to get project status.

Returns:

Status message.

Return type:

str

status = 'Global status.'

IHEWAcollect.base.exception module

Exception

https://julien.danjou.info/python-exceptions-guide/

exception IHEWAcollect.base.exception.IHEClassInitError(mod, msg=None)[source]

Bases: Exception

IHEClassInitError Class

Parameters:
  • mod (str) – Module name.

  • msg (bool) – Extra message.

exception IHEWAcollect.base.exception.IHEFileError(file, msg=None)[source]

Bases: Exception

IHEFileError Class

Parameters:
  • file (str) – File name.

  • msg (bool) – Extra message.

exception IHEWAcollect.base.exception.IHEKeyError(key, val, msg=None)[source]

Bases: Exception

IHEKeyError Class

Parameters:
  • key (str) – Key name.

  • val (list) – Key name list.

  • msg (bool) – Extra message.

exception IHEWAcollect.base.exception.IHEPassError(vname, msg=None)[source]

Bases: Exception

IHEPassError Class

Parameters:
  • vname (str) – Account name.

  • msg (bool) – Extra message.

exception IHEWAcollect.base.exception.IHEStringError(vname, msg=None)[source]

Bases: Exception

IHEStringError Class

Parameters:
  • vname (str) – Variable name.

  • msg (bool) – Extra message.

exception IHEWAcollect.base.exception.IHETypeError(vname, rtype, vdata, msg=None)[source]

Bases: Exception

IHETypeError Class

Parameters:
  • vname (str) – Variable name.

  • rtype (str) – Required type.

  • vdata (float) – Variable value.

  • msg (bool) – Extra message.

IHEWAcollect.base.user module

User

Before use this module, set account information in the accounts.yml file.

Examples:

from IHEWAcollect.base.user import User

user = User(workspace=path, product='CFSR', is_print=True)

Note

  1. Create accounts.yml under root folder of the project, based on the config-example.yml.

  2. Run User.credential.encrypt_cfg(path, file, password) to generate accounts.yml-encrypted file.

  3. Save key to credential.yml.

class IHEWAcollect.base.user.User(workspace, product, is_print, **kwargs)[source]

Bases: Base

This User class

Description

Parameters:
  • workspace (str) – Directory to accounts.yml.

  • product (str) – Product name of data products.

  • is_print (bool) – Is to print status message.

  • kwargs (dict) – Other arguments.

generate_encrypt()[source]

Generate encrypted files

get_user(key)[source]

Get user information

This is the function to get user’s configuration data.

Don’t synchronize the details to github.

  • File to read: accounts.yml-credential contains key: accounts.yml-encrypted.

  • File to read: accounts.yml-encrypted generated from: accounts.yml.

Parameters:

key (str) – Key name.

Returns:

User data.

Return type:

dict

Example:
>>> import os
>>> from IHEWAcollect.base.user import User
>>> user = User(os.getcwd(), 'FTP_WA_GUESS', is_print=False)
>>> account = user.get_user('account')
>>> account['FTP_WA_GUESS']
{'username': 'wateraccountingguest', 'password': 'W@t3r@ccounting', ...
>>> accounts = user.get_user('accounts')
Traceback (most recent call last):
...
KeyError:
set_status(fun='', prt=False, ext='')[source]

Set status

Parameters:
  • fun (str) – Function name.

  • prt (bool) – Is to print on screen?

  • ext (str) – Extra message.

status = 'Global status.'

Module contents

IHEWAcollect base modules