ActivityWatch / aw-core

Core library for ActivityWatch
Mozilla Public License 2.0
48 stars 47 forks source link

query2: Add support for escaped strings #76

Closed johan-bjareholt closed 5 years ago

johan-bjareholt commented 5 years ago

This + web-ui escaping should fix https://github.com/ActivityWatch/aw-webui/issues/133

codecov[bot] commented 5 years ago

Codecov Report

Merging #76 into master will increase coverage by 0.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage      95%   95.01%   +0.01%     
==========================================
  Files          33       33              
  Lines        1540     1546       +6     
  Branches      233      233              
==========================================
+ Hits         1463     1469       +6     
  Misses         46       46              
  Partials       31       31
Impacted Files Coverage Δ
aw_analysis/query2.py 99.02% <100%> (+0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3f6b4fe...df80655. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #76 into master will increase coverage by 0.03%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage      95%   95.03%   +0.03%     
==========================================
  Files          33       33              
  Lines        1540     1551      +11     
  Branches      233      233              
==========================================
+ Hits         1463     1474      +11     
  Misses         46       46              
  Partials       31       31
Impacted Files Coverage Δ
aw_analysis/query2.py 99.04% <100%> (+0.03%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3f6b4fe...6ea0923. Read the comment docs.

ErikBjare commented 5 years ago

I'm not comfortable with the parser internals, but have you considered options like these?: https://stackoverflow.com/questions/1885181/how-do-i-un-escape-a-backslash-escaped-string-in-python

johan-bjareholt commented 5 years ago

@ErikBjare That's the opposite of what this PR achieves? This code doesn't un-escape, it makes it possible to escape. Doing \n on a string and get a newline is still the case even with this code.

ErikBjare commented 5 years ago

Ah, fair enough. I don't see any tests for strings like "Hello \\"world\\"!" though. Shouldn't there be?

johan-bjareholt commented 5 years ago

We should add that just to be sure of future changes not breaking it, but that's safe currently as it only matches the first quote type with another one of the same type.

ErikBjare commented 5 years ago

@johan-bjareholt Sorry, the first example I made wasn't what I really meant. Edited the comment.

johan-bjareholt commented 5 years ago

I realized that there was multiple faults with the previous code after writing some more tests, should be better now.

johan-bjareholt commented 5 years ago

Fixed yet another bug, I have now tested with creating buckets containing a ' with aw-fakedata and it works. Will also have to test with buckets containing a "