Open michaelmhoffman opened 3 years ago
@jcrowgey Could you let me know what you think of this design?
Overall this looks good to me. Your recent work on this project has been very helpful and appreciated. I'm sorry for the long delays. In general, I'm not going to be able to work on gcalcli much for the foreseeable future.
On Mon, Jul 27, 2020 at 03:15:57PM -0700, Michael Hoffman wrote:
@jcrowgey Could you let me know what you think of this design?
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/insanum/gcalcli/issues/550#issuecomment-664665671
To get the TSV output of gcalcli agenda
to work automatically in Microsoft Excel with non-ASCII characters, it is necessary to set PYTHONIOENCODING=utf_16
. Things that don't work utf_16_le
(no BOM) or utf_8_sig
(BOM but for whatever reason Excel ignores the tabs by default). This does not seem like a sensible default but if you intend to use these files with Excel you should know about it.
The easiest way to use a UTF-16 file.tsv
is to use input redirection with the PYTHONIOENCODING
environment variable set. There's no user-accessible way to change the encoding of what's read with a file argument.
PYTHONIOENCODING=utf_16 gcalcli agendaupdate < file.tsv
The output of PYTHONIOENCODING=utf_16 gcalcli agenda
isn't easy to use some other Unix tools like grep with. Instead you can use iconv --to-code=utf-16
as part of a pipeline. For example:
gcalcli agenda | grep Title | iconv --to-code=utf-16 > file.csv
I often need to do bulk editing of my calendar which is not super convenient with the Google Calendar web interface. A spreadsheet interface would be much better.
What would you think about a way to do roundtrip updates through
gcalcli agenda --tsv
and a paired commandagendaupdate
for writing any changes back? We would need:gcalcli.gcal.GoogleCalendarInterface._tsv()
. I would like to replace the current long list of if statements with a modular design based around new classgcalcli.details.Handler
. EachHandler
represents the set of event properties that are captured by each item ofgcalcli.argparsers.DETAILS
. These objects would haveget()
handlers for TSV. They would be stored in acollections.OrderedDict
calledgcalcli.details.HANDLERS
.gcalcli.argparsers.DETAILS
to a superset ofgcalcli.details.HANDLERS.keys()
to avoid duplication.--header
.Handler
forid
to make it trivial to find the right Event later for the round trip.Handler.patch()
for a limited set of details. Throw error if there is a column not in the implemented set.Handler.patch()
for the rest of the details.Future extensions or subsequent refactoring could include:
details.Handler
subclassesDetail.format()
handlers that could be used forgcalcli.gcal.GoogleCalendarInterface._PrintEvent()
.