September 25, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 24 September 2015 at 13:22:32 UTC, Suliman wrote:
> What this string in config.d do?
> auto r = regex("(?:^\\s*)(\\w+)(?:\\s*=\\s*\")(.*)(?:\"\\s*$)");
It matches this pattern:
key = "value"
skipping any blank characters.
|
September 25, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 24-Sep-2015 16:22, Suliman wrote: > On Tuesday, 22 September 2015 at 20:43:32 UTC, skilion wrote: >> I've been waiting for a good sync client for OneDrive (15 GB for >> free!) on Linux, but Microsoft seems to have other plans... >> So I've decided to write my own, using D. Take a look: >> >> http://skilion.github.io/onedrive/ > > > What this string in config.d do? > auto r = regex("(?:^\\s*)(\\w+)(?:\\s*=\\s*\")(.*)(?:\"\\s*$)"); > > Removing anonymous groups and using raw-literal: regex(`^\s*(\w+)\s*=\s*"(.*)"\s*$`) Looks simpler I guess. Though if key="value" is expected I'd suggest to use lazy .* - `"(.*?)"` to stop on first " if any. -- Dmitry Olshansky |
September 25, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On Friday, 25 September 2015 at 07:40:18 UTC, Dmitry Olshansky wrote: > Removing anonymous groups and using raw-literal: > > regex(`^\s*(\w+)\s*=\s*"(.*)"\s*$`) > > Looks simpler I guess. Good advice, thanks. > Though if key="value" is expected I'd suggest to use lazy .* - `"(.*?)"` to stop on first " if any. After playing a bit with it, I realized that it doesn't work in this case (a="a"a" still match). The right solution would be "(.[^"])" |
September 26, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to skilion | On 25-Sep-2015 22:37, skilion wrote: > On Friday, 25 September 2015 at 07:40:18 UTC, Dmitry Olshansky wrote: >> Removing anonymous groups and using raw-literal: >> >> regex(`^\s*(\w+)\s*=\s*"(.*)"\s*$`) >> >> Looks simpler I guess. > > Good advice, thanks. > >> Though if key="value" is expected I'd suggest to use lazy .* - >> `"(.*?)"` to stop on first " if any. > > After playing a bit with it, I realized that it doesn't work in this > case (a="a"a" still match). The right solution would be "(.[^"])" I hope that was ([^"]*) Yeah, .*? won't work because of '$' at the end of the pattern. Anyway to allow classical escapes in string literal I'd go for: `"(?:[^"]+|\")*"` -- Dmitry Olshansky |
September 26, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On 26-Sep-2015 11:31, Dmitry Olshansky wrote: > On 25-Sep-2015 22:37, skilion wrote: >> On Friday, 25 September 2015 at 07:40:18 UTC, Dmitry Olshansky wrote: >>> Removing anonymous groups and using raw-literal: >>> >>> regex(`^\s*(\w+)\s*=\s*"(.*)"\s*$`) >>> >>> Looks simpler I guess. >> >> Good advice, thanks. >> >>> Though if key="value" is expected I'd suggest to use lazy .* - >>> `"(.*?)"` to stop on first " if any. >> >> After playing a bit with it, I realized that it doesn't work in this >> case (a="a"a" still match). The right solution would be "(.[^"])" > > I hope that was ([^"]*) > > Yeah, .*? won't work because of '$' at the end of the pattern. > Anyway to allow classical escapes in string literal I'd go for: > > `"(?:[^"]+|\")*"` > i.e. `"(?:[^"]+|\\")*"` to defeat regex escaping. -- Dmitry Olshansky |
September 26, 2015 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On Saturday, 26 September 2015 at 08:31:02 UTC, Dmitry Olshansky wrote:
>
> I hope that was ([^"]*)
Right. I should not post anything without testing it first.
|
May 21, 2016 Re: OneDrive Client written in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole | On Wednesday, 23 September 2015 at 04:30:23 UTC, Rikki Cattermole wrote:
> On 23/09/15 8:43 AM, skilion wrote:
>> I've been waiting for a good sync client for OneDrive (15 GB for free!)
>> on Linux, but Microsoft seems to have other plans...
>> So I've decided to write my own, using D. Take a look:
>>
>> http://skilion.github.io/onedrive/
>
> You probably should not be exposing developer information for authentication.
> You need to get the authentication fixed. Users should login via user/pass.
>
> Once that is done, get that on Reddit! It is awesome!
... good work. I appreciate it very much.
Just one note systemd:
systemctl --user enable onedrive
systemctl --user start one drive
requires libpam-systemd
This is not in all Debian Jessie distributions! Otherwise you will get a "Failed to get D-Bus connection - Connection refused"
Regards Frieder
|
Copyright © 1999-2021 by the D Language Foundation