-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
(Preliminary) pull req - settings instead virtual_midnight and data_file #17
base: master
Are you sure you want to change the base?
Conversation
…ly provided. Adding data_file to settings instead using get_timelog_file(). Removing filename as parameter from TimeLog and TimeWindow. Using settings.data_dir instead. Also using directly settings.virtual_midnight instead local variable
@@ -17,7 +17,6 @@ | |||
settings_file = settings.get_config_file() | |||
if os.path.exists(settings_file): | |||
settings.load(settings_file) | |||
timelog = gtimelog.TimeLog(settings.get_timelog_file(), | |||
settings.virtual_midnight) | |||
timelog = gtimelog.TimeLog(settings, settings.get_timelog_file()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the filename is more important and should be the 1st argument.
I intend to change the parser at some point to look for blank lines as an indication that the next day started, instead of doing complicated comparisons with virtual_midnight. This would perhaps even mean that you can use a TimeLog() without passing in settings, eventually, maybe.
I don't like this, but I find it difficult to articulate why. For one, this is a huge diff that mixes several changes in a single commit. Another thing, I want to reduce coupling, and by having TimeLog/TimeWindow use the Settings object that is full of GUI bits makes me sad. At one point I was thinking of splitting the Settings into non-GUI bits (virtual-midnight) and GUI bits (everything else), but the more I think of it, the more I become convincing that parsing a timelog.txt shouldn't need any configuration settings. I was always careful about writing blank lines to separate days, and if I changed the parser to take that into effect, it would no longer require virtual-midnight. |
Hi Marius. What I would like to have is some kind of global application object, that is available in application parts. Object that holds the state of the application and is passed to constructors of application parts. I think, the object Settings is good for it. So if there is a need to have some parameter available, some application state, it will be added into Settings and immediately available wherever needed. What case do I have to have data_file as parameter? Why to store it in a configuration file? I think data_file is just plain value, it should not be created dynamically. And I would like it to be in (my) configuration file. But I can imagine that you wont, and there may be more parameters that should be available during app runtime but not written into configuration file. I propose to have some "write filter". Sequence of parameter names, that should be written into file. If parameter is not on the list, it just won't be written. Days splitting by blank line - I think it can work for reading/parsing data file and can be convenient to even have different "virtual midnight" for different days. I like the idea. But how gtimelog will know, when it should put/write blank line into data file? IMO this is the place where "virtual midnight" has to be available to application. What if "virtual midnight" will be used as default day separator for writing, but for reading parser will depends on blank line? |
Sorry for responding late. I'm on vacation trying to deal with burnout, and am not feeling up to reading walls of text right now. I'll come back later. |
Thanks for info. I consider gtimelog as free time project so when you find time to respond, respond. |
Meanwhile I want a strict separation between the GTK+ GUI bits and the non-GUI bits that deal with data parsing/updating/analysis. I also want the data parsing/updating to be config-independent.
Agreed: users who aren't interested shouldn't be forced to care.
Why? Parsing code shouldn't care. Updating code shouldn't care. Analysis might care (but I have a hunch multiple methods are better than a single method with options). Reporting will care. It may make sense to extract a ReportSettings interface that contains all the options for reports, and then have the main Settings object extend it with all the other options. (Since Python doesn't have interfaces, I'm thinking of a ReportSettings class that has a bunch of attributes with comments but no .ini parsing/updating code, since it's not meant to be used separately.)
That's in fact precisely my inspiration for this: I had a couple of long nights and had to change my virtual_midnight setting once ;-)
That's precisely my plan. I'm also thinking about adding a |
Hallo Marius.
I'm sending 2 preliminary pull requests. So you can see what I'm working on.
In this pull request I'm using settings instead virtual_midnight and data_file. Settings are availeble in TimeLog and TimeWindow classes. Inside the classes values are retrieved directly from settings.
Data_file is alse added as settings parameter. Resolved in constructor of settings or when settings are loaded from file.
What do you think about it. If there are many errors like PEP8/formatting, ignore them for now. Is this idea better than in later pull request?