Library for working with the .sd format designed to store configuration and service data
Project description
Library for working with the .sd format designed to store configuration and service data (En)
####################################################################################################
#
# The basic concepts and opportunities incorporated in the development of the format:
# Maximum accessibility for the perception of complex structured data
# Simple and intuitive syntactic rules
# Capability of lists as values
# Capability of using dictionaries as values
# Possibility of multilinear recording of values
# Ability to work with comments to the data
# Possibility to work with comments to the file
# --------------------------------------------------------------------------------------------------
# To convert data stored in .sd format into python dict format, you need to pass the address of the data file:
# from sd_format import sd
# sd_obj = sd(sd_file_path)
# my_dict = sd_obj.decoding_result
# If you want to save the Python dictionary as an .sd file, pass in the following address
# pass in the address where the file should be saved as well as the dictionary itself:
# from sd_format import sd
# sd(sd_file_path, my_dict)
# You can get detailed information with a description of the syntax and an example of the contents of the sd file in the console via a function call:
# sd_info()
#
####################################################################################################
# Example of recording data in .sd format:
_main_key_0 =
# some comment for main_key_1
main_key_1 =
.key_1:
..key_1_1: """String with spaces. Possibly other type of quotes.""" # some comment for key_1_1
..key_1_2:
...key_1_2_1: lue_without_spaces
...key_1_2_2: """triple quoted values can contain characters such as space or comma"""
.key_2: value_2_1, """last list element"""
.key_3: a_good_solution_is_to_place_an_element_value_greater_than_50_characters_as_the_only_one
main_key_2 = some_value_will_be_read_as_a_string # comment for the main_key_2
main_key_3 = value_3_1, value_3_2, the_long_element_value_over_50_characters_is_placed_last
main_key_4 = key_4_1: v_4_1_1, key_4_2: in_a_one_line_notation_each_key_has_only_one_str_value
main_key_5 = key_5_1: v_5_1_1, key_5_2: v_5_2_1, key_5_3: """should be used no more than 3 pair"""
# temporary comment
main_key_6 = # comment for the main_key_6
'''
Multi-line write of value,
for main_key_6.
'''
main_key_7 = """I'm glad to your attention. If bugs are found, write: bug_report@daliton.org"""
####################################################################################################
#
# After decoding, the data is converted to Python dict:
# dict = {
# 'keys_comments': {
# 'own_comments': ['Title of .sd file', 'Top description', 'Bottom description'],
# '_main_key_0': {'own_comments': ['', '']},
# 'main_key_1 ': {
# 'key_1': {
# 'own_comments': ['', ''],
# 'key_1_1': {'own_comments': ['', 'some comment for key_1_1']},
# 'key_1_2': {
# 'own_comments': ['', ''],
# 'key_1_2_1': {'own_comments': ['', '']},
# 'key_1_2_2': {'own_comments': ['', '']
# }
# }
# },
# 'key_2': {'own_comments': ['', '']},
# 'key_3': {'own_comments': ['', '']},
# 'own_comments': ['some comment for main_key_1', '']
# },
# 'main_key_2 ': {'own_comments': ['', 'comment for the main_key_2']},
# 'main_key_3 ': {'own_comments': ['', '']},
# 'main_key_4 ': {'own_comments': ['', '']},
# 'main_key_5 ': {'own_comments': ['', '']},
# 'main_key_6 ': {'own_comments': ['temporary comment', 'comment for the main_key_6']},
# 'main_key_7 ': {'own_comments': ['', '']}
# },
# '_main_key_0': '',
# 'main_key_1 ': {
# 'key_1': {
# 'key_1_1': 'String with spaces. Possibly other type of quotes.',
# 'key_1_2': {
# 'key_1_2_1': 'lue_without_spaces',
# 'key_1_2_2': 'triple quoted values can contain characters such as space or comma'
# }
# },
# 'key_2': ['value_2_1', 'last list element'],
# 'key_3': 'a_good_solution_is_to_place_an_element_value_greater_than_50_characters_as_the_only_one'
# },
# 'main_key_2 ': 'some_value_will_be_read_as_a_string',
# 'main_key_3 ': ['value_3_1', 'value_3_2', 'the_long_element_value_over_50_characters_is_placed_last'],
# 'main_key_4 ': {'key_4_1': 'v_4_1_1', 'key_4_2': 'in_a_one_line_notation_each_key_has_only_one_str_value'},
# 'main_key_5 ': {'key_5_1': 'v_5_1_1', 'key_5_2': 'v_5_2_1', 'key_5_3': 'should be used no more than 3 pair'},
# 'main_key_6 ': 'Multi-line write of value,\nfor main_key_6.',
# 'main_key_7 ': "I'm glad to your attention. If bugs are found, write: bug_report@daliton.org"
# }
#
####################################################################################################
Translated with www.DeepL.com/Translator (free version)
Библиотека для работы с .sd форматом, предназначенным для записи служебных и конфигурационных данных (Ru)
# Основные концепции и возможности, заложенные при разработке формата:
# Максимальная доступность для восприятия сложных по структуре данных
# Простые и интуитивно понятные синтаксические правила
# Возможность использования в качестве значений списков
# Возможность использования в качестве значений словарей
# Возможность многострочной записи значений
# Возможность работы с комментариями к данным
# Возможность работы с комментариями к файлу
# -------------------------------------------------------------------------------------------------
# Для преобразования данных хранящихся в формате .sd в формат python dict, необходимо передать адрес файла с данными:
# sd_obj = sd(sd_file_path)
# my_dict = sd_obj.decoding_result
# Для сохранения словаря Python в файл в формате .sd, в качестве параметров необходимо
# передать адрес по которому нужно сохранить файл, а также сам словарь:
# sd(sd_file_path, my_dict)
# Подробную информацию с описанием синтаксиса и примером содержимого файла sd всегда можно вывести в консоль
# через вызов функции:
# sd_info()
# Пример записи данных в формате .sd:
# some comment for main_key_1
main_key_1 =
.key_1:
..key_1_1: """String with spaces. Possibly other type of quotes.""" # some comment for key_1_1
..key_1_2:
...key_1_2_1: lue_without_spaces
...key_1_2_2: """triple quoted values can contain characters such as space or comma"""
.key_2: value_2_1, """last list element"""
.key_3: a_good_solution_is_to_place_an_element_value_greater_than_50_characters_as_the_only_one
main_key_2 = some_value_will_be_read_as_a_string # comment for the main_key_2
main_key_3 = value_3_1, value_3_2, the_long_element_value_over_50_characters_is_placed_last
main_key_4 = key_4_1: v_4_1_1, key_4_2: in_a_one_line_notation_each_key_has_only_one_str_value
main_key_5 = key_5_1: v_5_1_1, key_5_2: v_5_2_1, key_5_3: """should be used no more than 3 pair"""
# temporary comment
main_key_6 = # comment for the main_key_6
'''
Multi-line write of value,
for main_key_6.
'''
main_key_7 = """I'm glad to your attention. If bugs are found, write: bug_report@daliton.org"""
####################################################################################################
#
# После декодирования данные преобразуются в Python dict:
# dict = {
# 'keys_comments': {
# 'own_comments': ['Title of .sd file', 'Top description', 'Bottom description'],
# '_main_key_0': {'own_comments': ['', '']},
# 'main_key_1 ': {
# 'key_1': {
# 'own_comments': ['', ''],
# 'key_1_1': {'own_comments': ['', 'some comment for key_1_1']},
# 'key_1_2': {
# 'own_comments': ['', ''],
# 'key_1_2_1': {'own_comments': ['', '']},
# 'key_1_2_2': {'own_comments': ['', '']
# }
# }
# },
# 'key_2': {'own_comments': ['', '']},
# 'key_3': {'own_comments': ['', '']},
# 'own_comments': ['some comment for main_key_1', '']
# },
# 'main_key_2 ': {'own_comments': ['', 'comment for the main_key_2']},
# 'main_key_3 ': {'own_comments': ['', '']},
# 'main_key_4 ': {'own_comments': ['', '']},
# 'main_key_5 ': {'own_comments': ['', '']},
# 'main_key_6 ': {'own_comments': ['temporary comment', 'comment for the main_key_6']},
# 'main_key_7 ': {'own_comments': ['', '']}
# },
# '_main_key_0': '',
# 'main_key_1 ': {
# 'key_1': {
# 'key_1_1': 'String with spaces. Possibly other type of quotes.',
# 'key_1_2': {
# 'key_1_2_1': 'lue_without_spaces',
# 'key_1_2_2': 'triple quoted values can contain characters such as space or comma'
# }
# },
# 'key_2': ['value_2_1', 'last list element'],
# 'key_3': 'a_good_solution_is_to_place_an_element_value_greater_than_50_characters_as_the_only_one'
# },
# 'main_key_2 ': 'some_value_will_be_read_as_a_string',
# 'main_key_3 ': ['value_3_1', 'value_3_2', 'the_long_element_value_over_50_characters_is_placed_last'],
# 'main_key_4 ': {'key_4_1': 'v_4_1_1', 'key_4_2': 'in_a_one_line_notation_each_key_has_only_one_str_value'},
# 'main_key_5 ': {'key_5_1': 'v_5_1_1', 'key_5_2': 'v_5_2_1', 'key_5_3': 'should be used no more than 3 pair'},
# 'main_key_6 ': 'Multi-line write of value,\nfor main_key_6.',
# 'main_key_7 ': "I'm glad to your attention. If bugs are found, write: bug_report@daliton.org"
# }
#
####################################################################################################
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sd-format-1.3rc0.tar.gz
(22.6 kB
view hashes)
Built Distribution
sd_format-1.3rc0-py3-none-any.whl
(21.8 kB
view hashes)
Close
Hashes for sd_format-1.3rc0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cac3c348b1eea54dd29547c8f99d04a8c08b5f7e7ba033193e482bc159e7ee9e |
|
MD5 | daf8df6b47deddbd62f2615efe92dfcf |
|
BLAKE2b-256 | bd72571e8625cc1fc37bd407c2197ec0862a019677fa0b7fa894a077b13c7de8 |