Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Encapsulate configuration file parser #44

Merged
merged 1 commit into from
Sep 4, 2015
Merged

Encapsulate configuration file parser #44

merged 1 commit into from
Sep 4, 2015

Conversation

AvdN
Copy link

@AvdN AvdN commented Sep 2, 2015

Changes to make it more easy to make changes to the configuration file
format:

  • both generation and parsing are in one module
  • name of config no longer hardcoded in several places
  • abstraction from direct access to ConfigObject class

There is an explicit jsonpath entry in the config file that can be set to have the JSON files
not reside under the directory with the configuration file.

It is now possible to start steve-cmd from a subdir of the project directory
(e.g. the json sub dir)

Changes to make it more easy to make changes to the configuration file
format:

- both generation and parsing are in one module
- name of config no longer hardcoded in several places
- abstraction from direct access to ConfigObject class

It is now possible to start steve-cmd from a subdir of the
project directory (e.g. the json dir)
@AvdN
Copy link
Author

AvdN commented Sep 2, 2015

PR 44 puts all the internals of accessing the config file in one place. The routine to access the config file is still there, but it returns a SteveConfig object that has a .get() method (exactly like ConfigObj but no longer directly). The name and creation are done via two new routines in util.py.

The above allows for implementation of an alternative configuration file format. I intend to provide a YAML based format (mapping within mapping), so that I can also save the config file easiliy without losing information (ConfigObj, drops the comments on a roundtrip).
What I want to save right now is a datetimestamp that indicates when the last sync between YAML and JSON files was made. Based on that timestamp I can sync in both directions, and detect if a single file was changed on both sides (which has to be resolved by hand). Based on that editing the YAML or JSON is possible and when further interaction with tools that require JSON is necessary, then the files are synchronised and the JSON made up to date with any changes in the YAML files. (This could of course be further automated to invoke a sync before doing a push e.g.)

@willkg
Copy link
Member

willkg commented Sep 4, 2015

I'm not excited about storing state in the config file. Issue #18 covers storing state. There are probably other things we want to store, like an item-by-item last_updated kind of thing. I'd rather not keep that in the config file. Better to have it elsewhere.

@@ -73,62 +200,31 @@ def _with_config(*args, **kw):

def get_project_config():
"""Finds and opens the config file in the current directory
or parent directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This should be dedented two spaces or alternatively reduce the length of the sentence and have it all on one line.

@willkg
Copy link
Member

willkg commented Sep 4, 2015

Other than that nit, this looks good. I'm going to land it now and fix the nit in another commit.

Thank you!

@willkg
Copy link
Member

willkg commented Sep 4, 2015

The "let's steve-cmd run in sub directories" thing is particularly awesome.

willkg added a commit that referenced this pull request Sep 4, 2015
Encapsulate configuration file parser
@willkg willkg merged commit 04bce6b into pyvideo:master Sep 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants