Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] [BREAKING] Change configuration layout #80

Merged
merged 3 commits into from
Oct 7, 2020

Conversation

ingrinder
Copy link
Collaborator

@ingrinder ingrinder commented Jun 26, 2020

Description

This PR is is to enable configuration rearrangement, as in #57.

Apologies that this is in the form of a single squashed commit... however I rebased this branch quite a lot of times and the history was a mess, so it got squashed into one.

While I've provided an implementation here, if you don't think it's suitable we can also use this PR to discuss an alternative.

Reason and / or context

See #57.

Changes

  • Configuration completely rearranged.
    • Entries are now specified as dicts containing their type and options keys respective options.
    • All entry-specific options are in the entry's definition thing.
    • Entries can be specified multiple times with different options as a side-effect of this. I may or may not have a plan to try out custom-defined entries with this... 😆
  • All Entry subclasses now have entry_options options as an attribute, which contains the entry-specific options.
  • The main global configuration now contains configuration only globally applicable.

These changes are all breaking to anybody with a configuration file (as it will now be unusable and crash Archey 😦). This could be very similarly implemented using entries' options as dict values on the keys already present, however this won't allow for the multiple-entry specifying I mentioned earlier.

Alternatively, we could add code to handle old configuration files... With a warning to update it, or automatically convert it to this format? This is still pretty awkard though.

How has this been tested ?

  • Still runs on all of my systems fine as far as I can tell.
  • All unit tests are passing (after some modification, but nothing breaking).

Types of changes :

  • Bug fix (non-breaking change which fixes an issue)
  • Typo / style fix (non-breaking change which improves readability)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist :

  • [IF NEEDED] I have updated the README.md file accordingly ;
  • [IF NEEDED] I have updated the test cases (which pass) accordingly ;
  • My changes looks good ;
  • I agree that my code may be modified in the future ;
  • My code follows the code style of this project (PEP8).

@ingrinder ingrinder added backward compatibility ⬇️ This is about a feature not working as expected on old systems enhancement ⬆️ Implements a new feature, fixes or improves existing ones labels Jun 26, 2020
@ingrinder ingrinder linked an issue Jun 26, 2020 that may be closed by this pull request
@ingrinder ingrinder added this to the v4.8.0 milestone Jun 26, 2020
@ingrinder ingrinder changed the title Add configuration rearrangement [FEATURE] [BREAKING] Add configuration rearrangement Jun 27, 2020
@HorlogeSkynet
Copy link
Owner

HorlogeSkynet commented Jun 27, 2020

The patch everyone was waiting for !! 😱 Thanks for this, 🙂

As it's a "proposal", what do you think about something like this :

{
	"allow_overriding": true,
	"parallel_loading": true,
	"suppress_warnings": false,
	"entries": [
		{ "User" : true },  // Enabled
		{ "Hostname" : {} },  // Disabled(?)
		{ "Model" : null },  // Disabled
		{ "Distro" : false },  // Disabled
		{ "Kernel" : true },
		{ "Uptime" : true },
		{ "WindowManager" : true },
		{ "DesktopEnvironment" : true },
		{ "Shell" : true },
		{ "Terminal" : true },
		{ "Packages" : true },
		{ "Temperature" : {
				"char_before_unit": " ",  // Options are simple entry's keys
				"sensors_chipsets": [],
				"use_fahrenheit": false
			}
		},
		{ "CPU" : {
				"name" : "Processor"  // Entry name overriding
			}
		},
		{ "GPU" : {
				"one_line": true,
				"max_count": 2,
				"disabled": true  // Disabled(!!) [handy when we temporary wanna hide an entry without losing its config]
			}
		},
		/* ... */

It would remove type & options required explicit definitions, as long as providing "temporary" entry disabling and entry renaming capabilities.


OUTDATED : Check below commits description for a simpler proposal.

👋

@HorlogeSkynet
Copy link
Owner

Hey Michael ! I've postponed the milestone to the end of August, tell me whether you thing it is do-able or not when you can, bye 👋

@HorlogeSkynet
Copy link
Owner

@ingrinder hey again Michael, do you think you will be able to spare some time in the near future to officially finish ongoing work ? Just tell me whether I should keep up alone or not.
Thanks !! Bye 👋

@HorlogeSkynet HorlogeSkynet modified the milestones: v4.8.0, v4.9.0 Sep 26, 2020
@HorlogeSkynet HorlogeSkynet changed the title [FEATURE] [BREAKING] Add configuration rearrangement [WIP] [FEATURE] [BREAKING] Change configuration layout Sep 26, 2020
@HorlogeSkynet HorlogeSkynet marked this pull request as draft September 27, 2020 09:02
@HorlogeSkynet HorlogeSkynet changed the base branch from master to develop October 3, 2020 11:49
ingrinder and others added 2 commits October 3, 2020 13:55
This commit closes #57.

`config.json` has been reshuffled so that entries are now each a dict,
with `type` and `options` keys.

Entries now have an extra `entry_options` attribute, which has options
for that specific entry instance. Additionally, entries' default
behaviour is now primarily defined inside each entry.

  + Entries have new `entry_options` attribute.
  + Entries can be rearranged in the configuration.
  + Entries can be specified multiple times in the configuration,
    with each one having independent options from the others.

  * Various miscellaneous changes to support the new `entry_options` attribute.
  * `LanIp` and `WanIp` renamed to `LanIP` and `WanIP` respectively.
  * Corrects `Raspberry` spelling :)
- Simplifies entries options implementation by avoiding nested dictionaries
- Stops providing a global `Configuration` reference to entries (only one to `default_strings` for i18n)
- Sets `use_unicode` option as `Terminal`-specific
- Sets `honor_ansi_color` option as project-global
- Renames `RAM` `warning` & `danger` options to `{warning,danger}_use_percent` (as `Disk` ones)

* Keeps previous `WAN_IP` & `LAN_IP` spellings for BC purposes
* Adds omitting new `Processes` entry to default configuration template
* Sets `Disk.get_df_output_dict` as private method

+ Implements temporary entry hiding (`disabled` option field)
+ Defaults entry `name` attribute to instantiated class name
+ Allows entry renaming (`name` option field)
+ Fixes `Disk` behavior when no configuration options are passed
+ Extends documentation of new configuration layout in README
@HorlogeSkynet HorlogeSkynet marked this pull request as ready for review October 4, 2020 09:29
@HorlogeSkynet HorlogeSkynet changed the title [WIP] [FEATURE] [BREAKING] Change configuration layout [FEATURE] [BREAKING] Change configuration layout Oct 4, 2020
@HorlogeSkynet HorlogeSkynet added the typo ✏️ This is about a typo omitted within the project environment label Oct 4, 2020
archey/__main__.py Show resolved Hide resolved
archey/__main__.py Show resolved Hide resolved
archey/config.json Show resolved Hide resolved
archey/config.json Show resolved Hide resolved
archey/config.json Show resolved Hide resolved
archey/entries/ram.py Show resolved Hide resolved
archey/entries/terminal.py Show resolved Hide resolved
archey/entry.py Show resolved Hide resolved
archey/entry.py Show resolved Hide resolved
archey/__main__.py Show resolved Hide resolved
@HorlogeSkynet HorlogeSkynet added this to IN PROGRESS in Core via automation Oct 4, 2020
@HorlogeSkynet HorlogeSkynet merged commit 8938de2 into develop Oct 7, 2020
Core automation moved this from IN PROGRESS to DONE Oct 7, 2020
@HorlogeSkynet HorlogeSkynet deleted the feature/config_rearrange branch October 7, 2020 16:38
HorlogeSkynet pushed a commit that referenced this pull request Nov 22, 2020
`config.json` has been reshuffled so that entries are now represented as a dict with `type` as long as their respective options as keys.

+ Entries order can be rearranged from configuration (closes #57)
+ Entries now have an extra `options` attribute, which contains their own settings
+ Entries can be specified multiple times in the configuration with each one having independent options from the others
+ Implements temporary entry hiding (`disabled` option field)
+ Defaults entry `name` attribute to instantiated class name
+ Allows entry renaming (`name` option field)
+ Adapts documentation of new configuration layout in README

* Various miscellaneous changes to support the new `entry_options` attribute.
* `LanIp` and `WanIp` internally renamed to `LanIP` and `WanIP` respectively
* Sets `Disk.get_df_output_dict` as private method
* Fixes `Raspberry` spelling :)

- Stops providing a global `Configuration` reference to entries (only one to `default_strings` for i18n)
- Sets `use_unicode` option as `Terminal`-specific
- Sets `honor_ansi_color` option as project-global

Co-authored-by: Samuel FORESTIER <dev@samuel.domains>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backward compatibility ⬇️ This is about a feature not working as expected on old systems enhancement ⬆️ Implements a new feature, fixes or improves existing ones typo ✏️ This is about a typo omitted within the project environment
Projects
Core
  
DONE
Development

Successfully merging this pull request may close these issues.

[FEATURE] Configuration option to rearrange modules.
2 participants