quick-ini 3.2__tar.gz → 4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
quick_ini-4.0/PKG-INFO ADDED
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: quick_ini
3
+ Version: 4.0
4
+ Summary: A library for reading from and writing to .ini formatted files
5
+ Author-email: OllieZ-Mods <socksinthewash@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/olliez-mods/Quick-Ini
8
+ Project-URL: Bug Reports, https://github.com/olliez-mods/Quick-Ini/issues
9
+ Project-URL: Source, https://github.com/olliez-mods/Quick-Ini
10
+ Keywords: ini,config,configuration,parser,file
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Dynamic: license-file
25
+
26
+ # QuickINI
27
+
28
+ A simple and fast INI file parser for Python with support for loading from URLs and automatic type conversion.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install quick_ini
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ from quick_ini import QuickIni
40
+
41
+ # Load from file
42
+ QuickIni.load_file("config.ini")
43
+
44
+ # Load from URL
45
+ QuickIni.load_file("https://example.com/config.ini")
46
+
47
+ # Get values with automatic type conversion
48
+ debug = QuickIni.get_value("debug", False) # Returns boolean
49
+ port = QuickIni.get_value("port", 8080) # Returns integer
50
+
51
+ # Values inside a [section]
52
+ db_port = QuickIni.get_value("port", section="database") # or get_value("database.port")
53
+
54
+ # Get everything, or everything in one section
55
+ settings = QuickIni.get_all()
56
+ database = QuickIni.get_all("database")
57
+
58
+ # Write values back to file
59
+ QuickIni.write_value("new_setting", "value", add_if_not_found=True)
60
+ QuickIni.write_value("port", 5433, section="database")
61
+ ```
62
+
63
+ ## Keeping config.ini up to date with a template
64
+
65
+ Projects often ship a `config.ini.template` that you copy to `config.ini`. When the template gets new settings later, QuickINI can update `config.ini` for you:
66
+
67
+ ```python
68
+ QuickIni.load_file("config.ini", template=True) # uses config.ini.template
69
+ QuickIni.load_file("config.ini", template="defaults.ini") # uses defaults.ini
70
+ ```
71
+
72
+ - If `config.ini` doesn't exist, it is created from the template
73
+ - The template decides which settings exist, their order, sections and comments. Your values are kept exactly as you wrote them
74
+ - New settings from the template are added with their default values
75
+ - Settings that are no longer in the template are kept at the end of their section, under a comment
76
+ - The file is only rewritten when something changed, and the previous version is saved as `config.ini.bak`
77
+ - With `template=True` a missing template is skipped, so deployed copies without one still load. A template given by name must exist
78
+
79
+ ```python
80
+ report = QuickIni.get_sync_report()
81
+ if report and report["added"]:
82
+ print("New settings added to config.ini:", ", ".join(report["added"]))
83
+ ```
84
+
85
+ The report also has `created`, `changed`, `orphaned` (settings kept that aren't in the template) and `backup`. Use `QuickIni.sync_template("config.ini")` to sync without loading.
86
+
87
+ ## File Format
88
+
89
+ ```ini
90
+ # Comments start with #
91
+ debug = yes # comments can also go after a value
92
+ port = 8080
93
+ timeout = 2.5e1
94
+ color = \#fff # use \# to put a # in a value
95
+
96
+ # Lists
97
+ parts =
98
+ |one
99
+ |two
100
+
101
+ [database]
102
+ host = localhost
103
+ port = 5432
104
+ ```
105
+
106
+ ## Features
107
+
108
+ - Load INI files from local filesystem or URLs
109
+ - Automatic type conversion: int, float (including `-1.5` and `1e5`), bool (`true`/`false`, `yes`/`no`, `on`/`off`) and str
110
+ - Sections, plus `#` comments, including after a value (escape `#` as `\#` in values)
111
+ - Lists using `|` lines
112
+ - Keep `config.ini` up to date with a template file
113
+ - Write values back to files safely, the file is never left half written
114
+ - Error handling with detailed messages
115
+ - Static class design for easy use across modules
116
+
117
+ ## Examples
118
+
119
+ Runnable examples are in the [examples](examples) folder:
120
+
121
+ - [basic](examples/basic/basic.py): loading a file, defaults, types and lists
122
+ - [sections](examples/sections/sections.py): reading keys in `[sections]` and `get_all()`
123
+ - [writing](examples/writing/writing.py): changing and adding values
124
+ - [template_sync](examples/template_sync/template_sync.py): creating and updating `config.ini` from `config.ini.template`
125
+
126
+ Run one with `python examples/basic/basic.py` after installing QuickINI.
@@ -0,0 +1,101 @@
1
+ # QuickINI
2
+
3
+ A simple and fast INI file parser for Python with support for loading from URLs and automatic type conversion.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install quick_ini
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from quick_ini import QuickIni
15
+
16
+ # Load from file
17
+ QuickIni.load_file("config.ini")
18
+
19
+ # Load from URL
20
+ QuickIni.load_file("https://example.com/config.ini")
21
+
22
+ # Get values with automatic type conversion
23
+ debug = QuickIni.get_value("debug", False) # Returns boolean
24
+ port = QuickIni.get_value("port", 8080) # Returns integer
25
+
26
+ # Values inside a [section]
27
+ db_port = QuickIni.get_value("port", section="database") # or get_value("database.port")
28
+
29
+ # Get everything, or everything in one section
30
+ settings = QuickIni.get_all()
31
+ database = QuickIni.get_all("database")
32
+
33
+ # Write values back to file
34
+ QuickIni.write_value("new_setting", "value", add_if_not_found=True)
35
+ QuickIni.write_value("port", 5433, section="database")
36
+ ```
37
+
38
+ ## Keeping config.ini up to date with a template
39
+
40
+ Projects often ship a `config.ini.template` that you copy to `config.ini`. When the template gets new settings later, QuickINI can update `config.ini` for you:
41
+
42
+ ```python
43
+ QuickIni.load_file("config.ini", template=True) # uses config.ini.template
44
+ QuickIni.load_file("config.ini", template="defaults.ini") # uses defaults.ini
45
+ ```
46
+
47
+ - If `config.ini` doesn't exist, it is created from the template
48
+ - The template decides which settings exist, their order, sections and comments. Your values are kept exactly as you wrote them
49
+ - New settings from the template are added with their default values
50
+ - Settings that are no longer in the template are kept at the end of their section, under a comment
51
+ - The file is only rewritten when something changed, and the previous version is saved as `config.ini.bak`
52
+ - With `template=True` a missing template is skipped, so deployed copies without one still load. A template given by name must exist
53
+
54
+ ```python
55
+ report = QuickIni.get_sync_report()
56
+ if report and report["added"]:
57
+ print("New settings added to config.ini:", ", ".join(report["added"]))
58
+ ```
59
+
60
+ The report also has `created`, `changed`, `orphaned` (settings kept that aren't in the template) and `backup`. Use `QuickIni.sync_template("config.ini")` to sync without loading.
61
+
62
+ ## File Format
63
+
64
+ ```ini
65
+ # Comments start with #
66
+ debug = yes # comments can also go after a value
67
+ port = 8080
68
+ timeout = 2.5e1
69
+ color = \#fff # use \# to put a # in a value
70
+
71
+ # Lists
72
+ parts =
73
+ |one
74
+ |two
75
+
76
+ [database]
77
+ host = localhost
78
+ port = 5432
79
+ ```
80
+
81
+ ## Features
82
+
83
+ - Load INI files from local filesystem or URLs
84
+ - Automatic type conversion: int, float (including `-1.5` and `1e5`), bool (`true`/`false`, `yes`/`no`, `on`/`off`) and str
85
+ - Sections, plus `#` comments, including after a value (escape `#` as `\#` in values)
86
+ - Lists using `|` lines
87
+ - Keep `config.ini` up to date with a template file
88
+ - Write values back to files safely, the file is never left half written
89
+ - Error handling with detailed messages
90
+ - Static class design for easy use across modules
91
+
92
+ ## Examples
93
+
94
+ Runnable examples are in the [examples](examples) folder:
95
+
96
+ - [basic](examples/basic/basic.py): loading a file, defaults, types and lists
97
+ - [sections](examples/sections/sections.py): reading keys in `[sections]` and `get_all()`
98
+ - [writing](examples/writing/writing.py): changing and adding values
99
+ - [template_sync](examples/template_sync/template_sync.py): creating and updating `config.ini` from `config.ini.template`
100
+
101
+ Run one with `python examples/basic/basic.py` after installing QuickINI.
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "quick_ini"
7
+ version = "4.0"
8
+ description = "A library for reading from and writing to .ini formatted files"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "OllieZ-Mods", email = "socksinthewash@gmail.com" }]
13
+ requires-python = ">=3.10"
14
+ keywords = ["ini", "config", "configuration", "parser", "file"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Typing :: Typed",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/olliez-mods/Quick-Ini"
30
+ "Bug Reports" = "https://github.com/olliez-mods/Quick-Ini/issues"
31
+ Source = "https://github.com/olliez-mods/Quick-Ini"
32
+
33
+ [tool.setuptools]
34
+ packages = ["quick_ini"]
35
+
36
+ [tool.setuptools.package-data]
37
+ quick_ini = ["py.typed"]
File without changes