Commit Graph

344 Commits (10b8e93b7419126864d9bab2effbe813962865ee)

Author SHA1 Message Date
Åke Forslund 1258480f30 Improve audio utils log 2020-04-27 08:38:44 +02:00
Åke Forslund 707be52f21 Update time util docstrings 2020-04-17 23:42:04 +02:00
Åke Forslund 313aaa660d Improve documentation of download util 2020-04-17 23:42:04 +02:00
Åke Forslund c5dccc16e2 Improve getting tmp download path 2020-04-17 23:42:04 +02:00
Åke Forslund 3a908a1e35 Minor cleanup of download docstrings and imports 2020-04-17 23:42:04 +02:00
Åke Forslund 06157e3331 Reuse ensure_directory_exists() in create_file()
ensure_directory_exists() now takes the directory permissions as an
optional argument.
2020-04-17 23:42:04 +02:00
Åke Forslund 26ef052891 Minor cleanups
- Remove superfluous parentheses
- Remove unneccessary pass
2020-04-17 23:42:04 +02:00
Åke Forslund aa42552d97 Refactor test change loglevel and add tests for process_utils 2020-04-17 23:42:04 +02:00
Åke Forslund b0be6a7ff9 Correct some docstrings 2020-04-17 23:42:04 +02:00
Åke Forslund 82e350064c Simplify and clean up curate_cache
- create helper functions for getting file stats and removing files in
order of age
- create wrapper function for turning MB into bytes
2020-04-17 23:42:04 +02:00
Åke Forslund e3f4d22b7e Simplify record function 2020-04-17 23:42:04 +02:00
Åke Forslund cf40c2e36c Refactor play_* functions to use a common base
Adds comments for PULSE ENVIRONMENT
2020-04-17 23:42:11 +02:00
Åke Forslund 60c0af69d6 Replace read_stripped_lines with generator 2020-04-17 23:42:04 +02:00
Åke Forslund a0709c885c Mark redunant string_utils as to be removed 2020-04-17 23:42:04 +02:00
Åke Forslund 71683d18d4 Refactor util library.
Move utils away from the __init__.py file
2020-04-17 23:42:04 +02:00
Åke Forslund 7e88ae7e88 Correct the datdir/res path
Comment says the folder to be checked should be datadir/res, this makes
the code mean the same thing.
2020-04-17 23:42:04 +02:00
Åke Forslund b991453bcf Update docstrings of mycroft/util/__init__.py 2020-04-17 23:42:04 +02:00
Åke Forslund c8be703e49 Additional zero was prepended.
The formatting of small numbers was fixed in lingua franca
2020-03-26 18:43:19 +01:00
Åke Forslund 968370cbf1 Remove exec permission from format files
mycroft/util/format.py and test/unittests/util/test_format.py
2020-02-13 07:59:16 +01:00
Åke Forslund 9245f551f4 Remove backwards compat. imports from lang tools
This removes the whole mycroft.util.lang submodule replacing it with a
minimum needed set of functions

extract_datetime: when a date was missing en-us would return the current date
to not mess up existing skills. This is no longer the case, if an
utterance doesn't contain a date the function will return None as
indicated by the docstring
2020-02-12 09:27:50 +01:00
Åke Forslund 9c8c8e0144 Send time reference for "now" to Lingua-franca
This will provide timezone info as well as now reference to the
extracted sentences.
2020-01-29 15:33:28 +01:00
Åke Forslund 37caf7837d Remove logic from format.py and parse.py
The functions are still there providing the docstrings but calling the
lingua_franca functions.

Note, there is a INTENTIONAL addition of an inconsistence. Making the
extract_datetime return todays date instead of None as is documented.
This needs to be removed as soon as the mycroft default skills have been
added.
2020-01-18 08:58:23 +01:00
Åke Forslund 1b5b4f3d84 Add wrapper for extract_datetime 2020-01-18 08:58:23 +01:00
Åke Forslund 2cc90f3f9f Remove functions from format.py and parse.py 2020-01-18 08:58:23 +01:00
Åke Forslund 32666e9d68 Remove content from lang specific files
The files are kept for backwards compatibility but these just contains imports
of lingua-franca versions of variables
2020-01-18 08:58:23 +01:00
Åke Forslund 1b88db4fa1 Replace format and parse calls with lingua-franca 2020-01-18 08:58:23 +01:00
ChanceNCounter 4e8db9c860 clean up nice_duration handler
* Replace integer values with enum values for clarity
* Simplify exception thrown on incompatible input
* Pythonify (and de-Chanceify) zero-output logic
2019-12-17 05:10:34 -08:00
ChanceNCounter 5eb6b51eb2 Fix extractnumber_en failure on "%" (#2110)
Closes MycroftAI/mycroft-core#2110
2019-12-05 14:19:37 -08:00
Åke e7d9e8be1b
Merge pull request #2402 from maxbachmann/cleanup
Improve speed of pronounce_number_en
2019-11-29 17:07:59 +01:00
maxbachmann 4174689906 improve runtime 2019-11-29 16:56:36 +01:00
Åke e6385720b3
Merge pull request #2396 from maxbachmann/python2cleanup
cleanup python2 unicode
2019-11-27 08:46:20 +01:00
Åke e78a9730e1
Merge pull request #2386 from maxbachmann/dev
Add more time idioms (half past, etc.)
2019-11-27 08:41:02 +01:00
maxbachmann 87220ee85c add some more time idioms 2019-11-27 01:53:23 +01:00
maxbachmann 7a48297132 cleanup python2 unicode 2019-11-26 23:09:32 +01:00
Christian Clauss a1ff3fb355 Upgrade from pycodestyle to flake8 2019-11-19 23:07:52 +01:00
Mike Woudenberg cc5631c45f Adds rudimentary Dutch parsing support 2019-11-14 08:47:36 +01:00
Steve Penrod 0b8f7f54a4 Remove unnecessary code
The check for "this" performed in the case of "this quarter of an hour"
was copy/pasted in a large checkin.  The change it made to
daySpecified made no difference since the or in the later code
looked for an unspecified absolute hour.  I can come up with no
senseable phrase that matches the conditions and couldn't even
create a nonsensical phrase that made a difference.

Since all of the existing unit tests pass without this code,
I'm going to just remove it.
2019-11-04 09:39:09 +01:00
Åke 324fe988aa
Merge pull request #2356 from ChanceNCounter/spanish-language-parsers
fix bug in isFractional_es and improve coverage
2019-10-14 16:04:57 +02:00
Åke 8126bcafce
Merge pull request #2346 from ChanceNCounter/tests/util-parse-en
fix bug, redundancy in parse_en; improve coverage
2019-10-07 13:22:23 +02:00
ChanceNCounter 1c41e523ce fix bug in isFractional_es and improve coverage
- Fix: isFractional_es() parsed fractions incorrectly
- Update: earlier commit msg suggested another fix:
  - Month parsing not fixed
  - Several failing tests (skipped) document problem
  - TODO and an issue also created
- Substantially improve parse_es.py test coverage
- TODO or comment several found bugs
  - Many lines remain uncovered, incl possible bugs
2019-10-05 14:46:09 -07:00
Åke 8ffad68251
Merge pull request #2347 from ChanceNCounter/extractnumber-es-fix-and-add-extractnumbers
Fix extractnumber_es, add extract_numbers_es
2019-10-04 08:46:03 +02:00
Åke 90ceaa3c88
Merge pull request #2342 from ChanceNCounter/fix/convert-mixed-fraction-param-default
add default value to nice_number param
2019-10-04 08:43:15 +02:00
ChanceNCounter 1107f5d6cc Fix extractnumber_es, add extract_numbers_es
- Fix bug causing extractnumber_es to return a sum instead of a list
- Add Spanish parser to extract_numbers and extract_number

==== Fixed Issues ====
Closes #2310

====  Tech Notes ====
Further obscures #2056: short_scale and ordinals parameters added to the
Spanish parsers, but they don't do anything. Present for compat only.
There is a TODO for this.

==== Localization Notes ====
It's all Spanish stuff!

This will require a native Spanish speaker to analyze the relationship
between extractnumber and isFractional, and determine why certain
fractions do not parse correctly. There is a TODO for this.
2019-10-03 17:11:39 -07:00
ChanceNCounter 16d6bf4b22 fix bug, redundancy in parse_en; improve coverage
- Remove unreachable conditions from parse_en:1122-1133
  - input string passed through clean_string() on line 763
  - articles stripped from input before line 1122
  - removed conditions relied on presence of "the" in input
- Improved test coverage on parse_en.py by approx 65 statements
  - Directly test certain helper functions which are difficult to
invoke indirectly
  - Add tests for certain missed conditions
  - Approx. 20 uncovered statements remain
2019-10-03 14:41:21 -07:00
ChanceNCounter 8c50fe9700 add optional 'clock' param for displayed output
Add one more optional parameter: bool clock, always produces
digital clock-like output. "0h 3m" becomes "0:03:00".

Has no effect on resolutions YEARS or DAYS, and MINUTES won't print hrs.
2019-10-02 07:55:22 +02:00
ChanceNCounter 4253929d2c - make nice_duration handle years, datetimes, and ms
- Companion enum:
mycroft.util.format.TimeResolution
offers YEARS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS

- Will only return ms if MILLISECONDS is chosen. Default: SECONDS

- Update tests
2019-10-02 07:55:22 +02:00
ChanceNCounter 388d9afaa7 add default value to nice_number param
Add default value to nice_number & convert_mixed_fraction `denominator`

Add tests for convert_mixed_fraction
2019-10-01 06:55:44 -07:00
ChanceNCounter a44167a3a4 Fixes index error in parse_en.extract_datetime()
==== Fixed Issues ====
#2333

====  Tech Notes ====
extract_datetime("day after tomorrow") attempted to check the previous
word. This resulted in an index error. Fixed by introducing a nested
condition. Seems to have solved it.

A similar bug is present in other parts of this file, such as line 843.

I have also discovered a number of other oddities, but they may be
outside the scope of this issue. At least Mycroft can now extract from
"day after tomorrow."

==== Localization Notes ====
I haven't checked parsers for any other languages.
2019-09-28 14:31:59 -07:00
Åke Forslund 39d0053493 Catch inspect error in logger
Inspect would in certain cases fail to find the line number. This
catches the exception and provides a basic name for the logger.
2019-09-24 20:58:34 +02:00
Åke Forslund 29dbbe1bee Update to use the old dns connection test aswell
This handles capture portals as well.

The standard connection logic is now

Check outside ip is reachable and after that check that www.google.com
is resolvable and connectable.

TODO: create endpoint on backend with known response to perform check
upon.
2019-09-17 09:27:43 +02:00