From aa44fe7a60a4f3326cc47877b3e246b56d46d6ac Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 13:41:35 -0500 Subject: Add python 3.5 support, ConfigFileError, and more type hints Also, get_all, set_all, and delete_all in JsonParser have been renamed to just all. --- CHANGELOG.md | 195 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 105 insertions(+), 90 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a3ce8..e6ac91f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,167 +5,182 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +Added + +- Support for Python 3.5 by removing use of f-strings from codebase. +- A generic `ConfigFileError`. +- More type hints from `typings` have been added to `ConfigFile` for better type information. + +Changed + +- `ParsingError` now inherits from `ConfigFileError` rather than `Exception`. +- Errors have been moved to `exceptions.py`. +- The `get_all`, `set_all`, and `delete_all` optional parameter options in `JsonParser` have + been renamed to just `all`. This shouldn't have any effect since `JsonParser` is not intended + to be used directly, and that option is not in `ConfigFile`. + ## 0.10.0 - 2020-05-10 Changed - - `toml` and `pyyaml` are now optional extra dependencies. This allows you to - not have to install them if you aren't using them. - - - `retrieve_all` in `JsonParser`'s `get` method is now called `get_all` for - consistency. It isn't publicly available yet. The thought is to write a custom - ini parser first that supports multiple of the same keys and subsections. - This way you can have the `get_all`, `set_all`, `delete_all`, etc. methods - for all file type parsers. I would have to weight if that added complexity - of not using the built-in configparser and roll our own for some added - features is worth it or see if there are ways to work around it with - configparser that are ideal. +- `toml` and `pyyaml` are now optional extra dependencies. This allows you to + not have to install them if you aren't using them. -Fixed +- `retrieve_all` in `JsonParser`'s `get` method is now called `get_all` for + consistency. It isn't publicly available yet. The thought is to write a custom + ini parser first that supports multiple of the same keys and subsections. + This way you can have the `get_all`, `set_all`, `delete_all`, etc. methods + for all file type parsers. I would have to weight if that added complexity + of not using the built-in configparser and roll our own for some added + features is worth it or see if there are ways to work around it with + configparser that are ideal. - - You can now specify a default and still coerce your return type. Previously, - if you specified a default, there was no logic in that branch to coerce your - return type as well. +Fixed +- You can now specify a default and still coerce your return type. Previously, + if you specified a default, there was no logic in that branch to coerce your + return type as well. ## 0.9.0 - 2020-02-09 Added - - `default` optional parameter to the `get()` method of `ConfigFile`. - The allows a default value to be fallen back to if the given key is missing. - - - `return_type` optional parameter to `get()` method of `ConfigFile`. This - allows you to coerce the return type to one of your choosing by feeding it - the return value. +- `default` optional parameter to the `get()` method of `ConfigFile`. + The allows a default value to be fallen back to if the given key is missing. + +- `return_type` optional parameter to `get()` method of `ConfigFile`. This + allows you to coerce the return type to one of your choosing by feeding it + the return value. Changed - - Automatic type parsing is now off by default. This is because of the addition of - the `return_type` optional parameter. After using the package more, I think - the explicitness of specifying the type you're after or that you'd like to - automatically parse the type to one of the basic types is more maintainable. - However, I think the option to automatically parse or parse a whole section of - values is still a useful one. - - - The `parse_type` parameter to `ConfigFile`'s `get()` method is now called - `parse_types`. +- Automatic type parsing is now off by default. This is because of the addition of + the `return_type` optional parameter. After using the package more, I think + the explicitness of specifying the type you're after or that you'd like to + automatically parse the type to one of the basic types is more maintainable. + However, I think the option to automatically parse or parse a whole section of + values is still a useful one. + +- The `parse_type` parameter to `ConfigFile`'s `get()` method is now called + `parse_types`. ## 0.8.0 - 2020-02-02 Added - - More type hints to `ConfigFile` and `IniParser`. - - `nested_lookup` dependency to help with modifying deeply nested structures - (JSON + YAML) - - `JsonParser` so you can now specify `.json` files to be parsed. - +- More type hints to `ConfigFile` and `IniParser`. +- `nested_lookup` dependency to help with modifying deeply nested structures + (JSON + YAML) +- `JsonParser` so you can now specify `.json` files to be parsed. + Changed - - The original content of the passed in file is now called `content` - instead of `contents`. This is for consistency since the parsed version is - called `parsed_content`. +- The original content of the passed in file is now called `content` + instead of `contents`. This is for consistency since the parsed version is + called `parsed_content`. ## 0.7.0 - 2020-01-27 Fixed - - Support for using custom parsers with `ConfigFile` with the `parser` optional - argument. This was technically supported before, but it was not tested and found - to not actually use the passed in parser once tested. +- Support for using custom parsers with `ConfigFile` with the `parser` optional + argument. This was technically supported before, but it was not tested and found + to not actually use the passed in parser once tested. Changed - - The `reset()` method on `ConfigFile` is now called `restore_original()`. - The behavior is the same. This was done to better describe what exactly that method - is doing. Since the file is not written back out with every `set()` or `delete()` - and calling `save()` explicitly is required, `reset()` may have been confused with - resetting the changes you've made rather than deleting and restoring the original - configuration file. +- The `reset()` method on `ConfigFile` is now called `restore_original()`. + The behavior is the same. This was done to better describe what exactly that method + is doing. Since the file is not written back out with every `set()` or `delete()` + and calling `save()` explicitly is required, `reset()` may have been confused with + resetting the changes you've made rather than deleting and restoring the original + configuration file. ## 0.6.0 - 2020-01-24 Changed - - Bumped down python version requirement to 3.6 and now test 3.6, 3.7, and 3.8 on CI. +- Bumped down python version requirement to 3.6 and now test 3.6, 3.7, and 3.8 on CI. ## 0.5.0 - 2020-01-19 Added - - Support for retrieving entire sections as a `dict` with `get()`. +- Support for retrieving entire sections as a `dict` with `get()`. ## 0.4.0 - 2020-01-19 Added - - `reset()` and `save()` methods to `ConfigFile`. This allows you to reset your - configuration file to an "original state," given the original config file path. - However, say you have a `config/config.json` file. Then it will automatically try - to look for `config/config.original.json` if no file path is specified. The `save()` - method should be called after your changes to the config file. It will write them - back out. - - - Raise test coverage to 93%. +- `reset()` and `save()` methods to `ConfigFile`. This allows you to reset your + configuration file to an "original state," given the original config file path. + However, say you have a `config/config.json` file. Then it will automatically try + to look for `config/config.original.json` if no file path is specified. The `save()` + method should be called after your changes to the config file. It will write them + back out. + +- Raise test coverage to 93%. ## 0.3.3 - 2020-01-18 Changed - - `_split_on_dot` is no longer in base parser (now in a utils file). Also, the default +- `_split_on_dot` is no longer in base parser (now in a utils file). Also, the default behavior is now to split on every dot and split on only the last dot if specified - + Fixed - - `ConfigFile` was trying to use `_split_on_dot`, but it no longer inherited from base parser. - - - `TypeError` when setting the key/value pairs since configparser requires the option - to be a string. The parser now just converts the value to a string if it is not one - and then adds the key/value pair. It would still be parsed correctly when retrieving - it. +- `ConfigFile` was trying to use `_split_on_dot`, but it no longer inherited from base parser. + +- `TypeError` when setting the key/value pairs since configparser requires the option + to be a string. The parser now just converts the value to a string if it is not one + and then adds the key/value pair. It would still be parsed correctly when retrieving + it. ## 0.3.1 - 2020-01-17 Fixed - - `isinstance` call for `BaseParser` to be correctly used. +- `isinstance` call for `BaseParser` to be correctly used. ## 0.3.0 - 2020-01-17 Added - - Abstract base parser as a contract for concrete file format parser implementations. - - - Exposed `ConfigFile`, `BaseParser`, and `ParsingError` to the Public API. The base - parser is exposed to allow future custom extensions of the config file and what it +- Abstract base parser as a contract for concrete file format parser implementations. + +- Exposed `ConfigFile`, `BaseParser`, and `ParsingError` to the Public API. The base + parser is exposed to allow future custom extensions of the config file and what it can parse by its users. - - - `has_section` and `has_key` is now changed to a single `has` method which determines - whether you're checking a section or key by the presence of a dot. - - - `IniParser` to support the ini format. It uses configparser internally, but it is - only exposed through the `ConfigFile` object. + +- `has_section` and `has_key` is now changed to a single `has` method which determines + whether you're checking a section or key by the presence of a dot. + +- `IniParser` to support the ini format. It uses configparser internally, but it is + only exposed through the `ConfigFile` object. ## 0.2.0 - 2020-01-04 Added - - Parsing of strings to their native values +- Parsing of strings to their native values ## 0.1.0 - 2020-01-04 Added - - Created the config_file package with only the version inside it - - - toml and pyyaml to dependencies - - - Pre-commit pipeline with autoflake, isort, black, and flake8 - - - MIT license - - - Contributing guidelines - - - bump2version for easily upgrading versions of config file - - - pytest to dev dependencies for testing later on +- Created the config_file package with only the version inside it + +- toml and pyyaml to dependencies + +- Pre-commit pipeline with autoflake, isort, black, and flake8 + +- MIT license + +- Contributing guidelines + +- bump2version for easily upgrading versions of config file + +- pytest to dev dependencies for testing later on -- cgit v1.2.3 From 95c47a183409fabed81f078a70967f053679737e Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 15:13:53 -0500 Subject: Change path, parser, and contents to be properties Also, restore_original now raises a FileNotFoundError. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index e6ac91f..2c9e591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ Changed - The `get_all`, `set_all`, and `delete_all` optional parameter options in `JsonParser` have been renamed to just `all`. This shouldn't have any effect since `JsonParser` is not intended to be used directly, and that option is not in `ConfigFile`. +- `path`, `parser`, and `contents` on the `ConfigFile` are now all properties and can only be retrieved. +- `restore_original` in `ConfigFile` now raises a `FileNotFoundError` instead of an `OSError` if the original + file path does not exist. ## 0.10.0 - 2020-05-10 -- cgit v1.2.3 From 58808235ea6880c3a0ecfa976a700c81431dc902 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 15:30:11 -0500 Subject: Revert Python 3.5 support --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c9e591..3f89271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Added -- Support for Python 3.5 by removing use of f-strings from codebase. - A generic `ConfigFileError`. - More type hints from `typings` have been added to `ConfigFile` for better type information. -- cgit v1.2.3 From ee78049f1e33bcb9894f43d51e44b079edfab91f Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 20 Jun 2020 16:32:23 -0500 Subject: Add types to base parser and update build badge --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f89271..1e52d9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Changed - Errors have been moved to `exceptions.py`. - The `get_all`, `set_all`, and `delete_all` optional parameter options in `JsonParser` have been renamed to just `all`. This shouldn't have any effect since `JsonParser` is not intended - to be used directly, and that option is not in `ConfigFile`. + to be used directly, and that option was not in `ConfigFile`. - `path`, `parser`, and `contents` on the `ConfigFile` are now all properties and can only be retrieved. - `restore_original` in `ConfigFile` now raises a `FileNotFoundError` instead of an `OSError` if the original file path does not exist. -- cgit v1.2.3 From 2c293cc0ac6678253c6af8101ba93866785f64c0 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 21 Jun 2020 11:12:26 -0500 Subject: WIP for refactoring tests --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e52d9b..29e4663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ Changed - The `get_all`, `set_all`, and `delete_all` optional parameter options in `JsonParser` have been renamed to just `all`. This shouldn't have any effect since `JsonParser` is not intended to be used directly, and that option was not in `ConfigFile`. -- `path`, `parser`, and `contents` on the `ConfigFile` are now all properties and can only be retrieved. +- `path` on the `ConfigFile` is now a property that can only be retrieved. `contents` is now private + but you can use `.stringify()` instead to get the contents. `parser` is now also private. - `restore_original` in `ConfigFile` now raises a `FileNotFoundError` instead of an `OSError` if the original file path does not exist. -- cgit v1.2.3 From fbf798d86b1c2a5d70f39f084ee4e2a376fe6914 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 11 Jul 2020 14:57:24 -0500 Subject: Add dummy toml and yaml parsers --- CHANGELOG.md | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e4663..037dcc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -Added +### Added - A generic `ConfigFileError`. - More type hints from `typings` have been added to `ConfigFile` for better type information. +- `YamlParser` and `TomlParser`. This means `ConfigFile` can now accept yaml and toml files, + as long as `PyYaml` is also installed if you're trying to use a yaml file and `toml` is + installed if you're trying to use a toml file. -Changed +### Changed - `ParsingError` now inherits from `ConfigFileError` rather than `Exception`. - Errors have been moved to `exceptions.py`. @@ -26,7 +29,7 @@ Changed ## 0.10.0 - 2020-05-10 -Changed +### Changed - `toml` and `pyyaml` are now optional extra dependencies. This allows you to not have to install them if you aren't using them. @@ -40,7 +43,7 @@ Changed features is worth it or see if there are ways to work around it with configparser that are ideal. -Fixed +### Fixed - You can now specify a default and still coerce your return type. Previously, if you specified a default, there was no logic in that branch to coerce your @@ -48,7 +51,7 @@ Fixed ## 0.9.0 - 2020-02-09 -Added +### Added - `default` optional parameter to the `get()` method of `ConfigFile`. The allows a default value to be fallen back to if the given key is missing. @@ -57,7 +60,7 @@ Added allows you to coerce the return type to one of your choosing by feeding it the return value. -Changed +### Changed - Automatic type parsing is now off by default. This is because of the addition of the `return_type` optional parameter. After using the package more, I think @@ -71,14 +74,14 @@ Changed ## 0.8.0 - 2020-02-02 -Added +### Added - More type hints to `ConfigFile` and `IniParser`. - `nested_lookup` dependency to help with modifying deeply nested structures (JSON + YAML) - `JsonParser` so you can now specify `.json` files to be parsed. -Changed +### Changed - The original content of the passed in file is now called `content` instead of `contents`. This is for consistency since the parsed version is @@ -86,13 +89,13 @@ Changed ## 0.7.0 - 2020-01-27 -Fixed +### Fixed - Support for using custom parsers with `ConfigFile` with the `parser` optional argument. This was technically supported before, but it was not tested and found to not actually use the passed in parser once tested. -Changed +### Changed - The `reset()` method on `ConfigFile` is now called `restore_original()`. The behavior is the same. This was done to better describe what exactly that method @@ -103,19 +106,19 @@ Changed ## 0.6.0 - 2020-01-24 -Changed +### Changed - Bumped down python version requirement to 3.6 and now test 3.6, 3.7, and 3.8 on CI. ## 0.5.0 - 2020-01-19 -Added +### Added - Support for retrieving entire sections as a `dict` with `get()`. ## 0.4.0 - 2020-01-19 -Added +### Added - `reset()` and `save()` methods to `ConfigFile`. This allows you to reset your configuration file to an "original state," given the original config file path. @@ -128,12 +131,12 @@ Added ## 0.3.3 - 2020-01-18 -Changed +### Changed - `_split_on_dot` is no longer in base parser (now in a utils file). Also, the default behavior is now to split on every dot and split on only the last dot if specified -Fixed +### Fixed - `ConfigFile` was trying to use `_split_on_dot`, but it no longer inherited from base parser. @@ -144,13 +147,13 @@ Fixed ## 0.3.1 - 2020-01-17 -Fixed +### Fixed - `isinstance` call for `BaseParser` to be correctly used. ## 0.3.0 - 2020-01-17 -Added +### Added - Abstract base parser as a contract for concrete file format parser implementations. @@ -166,24 +169,10 @@ Added ## 0.2.0 - 2020-01-04 -Added +### Added - Parsing of strings to their native values ## 0.1.0 - 2020-01-04 -Added - -- Created the config_file package with only the version inside it - -- toml and pyyaml to dependencies - -- Pre-commit pipeline with autoflake, isort, black, and flake8 - -- MIT license - -- Contributing guidelines - -- bump2version for easily upgrading versions of config file - -- pytest to dev dependencies for testing later on + - Initial Release \ No newline at end of file -- cgit v1.2.3 From 040359d1bba7de17033d932024c36e1f5437f516 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Wed, 5 Aug 2020 20:45:14 -0500 Subject: Update changelog to remove old info --- CHANGELOG.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 037dcc8..0b288a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,24 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- A generic `ConfigFileError`. -- More type hints from `typings` have been added to `ConfigFile` for better type information. -- `YamlParser` and `TomlParser`. This means `ConfigFile` can now accept yaml and toml files, - as long as `PyYaml` is also installed if you're trying to use a yaml file and `toml` is - installed if you're trying to use a toml file. +- `ConfigFile` can now accept yaml and toml files as optional extra file types. + As long as the extras (`yaml` and `toml`) are installed, those file types can also + be used. ### Changed -- `ParsingError` now inherits from `ConfigFileError` rather than `Exception`. -- Errors have been moved to `exceptions.py`. -- The `get_all`, `set_all`, and `delete_all` optional parameter options in `JsonParser` have - been renamed to just `all`. This shouldn't have any effect since `JsonParser` is not intended - to be used directly, and that option was not in `ConfigFile`. - `path` on the `ConfigFile` is now a property that can only be retrieved. `contents` is now private but you can use `.stringify()` instead to get the contents. `parser` is now also private. + - `restore_original` in `ConfigFile` now raises a `FileNotFoundError` instead of an `OSError` if the original file path does not exist. +### Fixed + +- `default` in `ConfigFile`'s `get` method can now be `None`. Previously, it was defaulted to the + value `None` so there was no way of distinguishing between the default value and a user inputted + value of `None`. + ## 0.10.0 - 2020-05-10 ### Changed -- cgit v1.2.3