Skip to main content

Minimum version of dsenergy's ncore library

Project description

minicore

minicore是定势能源数据组件ncore的简化版。

用法

配置

环境变量

MINICORE_CONFIG_FILE=""  # 可选

config相关

配置类型目前可选用file,此时使用一个Python文件来提供配置参数。配置文件的查找顺序为:

  • $MINICORE_CONFIG_FILE (如提供该环境变量)
  • ./minicore_config.py
  • $HOME/.minicore/minicore_config.py

配置文件示例可见examples/minicore_config.py, 详解见下文。

核心枢纽:NCore单例对象

from minicore import NCore

nc = NCore()

minicore系统的核心枢纽类型NCore是一个单例类型,也就是在一个程序中无论写多少次初始化过程NCore(),返回的都是同一个对象,实质的初始化过程也只在第一次过程中发生,不会造成额外开销。所以通过上面的方式, 可以在任何需要用到它的地方来现场生成该对象。

如果没有提供正确的配置文件,会抛出MiniCoreBadConfig异常。

获取数据类型(DataType)

nc.ls_types()  # 打印出可用的数据类型 
SomeType = nc.get_type(TYPE_NAME) 

生成Data对象,并获取数据结果

data = SomeType(**para)
result = data.result

快捷方式

from minicore import D

data = D(type_name, **para)
result = data.result

配置文件详解

配置文件示例可见examples/minicore_config.py

SOURCE 数据源

SOURCE配置项是一个列表,可以包含一或多个数据源。

SOURCE = [
    {
        "name": "SourceName",  # 数据源名称
        "base_url": "http://some.com/ncore/",  # 数据服务基础url路径
        "auth": {
            "type": "token",
            "token": "SomeToken",
        },  # 身份认证参数
    }
]

其中,身份认证参数目前支持以下形式:

auth type="token"

{
    "type": "token",
    "token": "SomeToken"
}

TMP_DIR 临时文件目录

MiniCore临时文件目录的根路径

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minicore-0.1.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minicore-0.1.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file minicore-0.1.2.tar.gz.

File metadata

  • Download URL: minicore-0.1.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for minicore-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2138f7aed9248f13a5044944eb88609010932bbb66d5ed936f23f437f6a19868
MD5 838d0d8d124b8981dc406f699f0495b2
BLAKE2b-256 d1c139fe1ef9035a4d5e62f6dc46bc05548177e429f0329875900f769b278e45

See more details on using hashes here.

File details

Details for the file minicore-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: minicore-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for minicore-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d6ae012df7b2afc4fdc7e0b098a7ff7f644a9fee92a269d4ce49079594f4c50b
MD5 6856c95bfa6c914db3c3de61baab0669
BLAKE2b-256 902217f9831608ccd3292aa26f56b85c029659db7b68d07bb99cc6932080d7ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page