Commit graph libervia-backend/sat/tools/common
Author SHA1 Message Date
Goffi
9b5d3ea17d tools (common): new async_utils module with an async version of lru_cache 2022-01-25 17:25:10 +01:00
Goffi
7b05d97229 merge bookmark 0.9 2021-12-01 16:13:31 +01:00
Goffi
9eecdc184c tools (common/async_process): use parent environment by default 2021-11-30 17:28:42 +01:00
Goffi
50d7cb2a51 merge bookmark @ 2021-09-08 11:20:37 +02:00
Goffi
adad4494c3 tools (common/uri): fix uri parsing for Python 3.9+ 2021-09-08 11:14:47 +02:00
Goffi
436696f28c merge branche "@" 2021-08-27 14:51:40 +02:00
Goffi
506368275a tools (common/date_utils): parse now alone (when used without relative delta) 2021-08-27 14:48:38 +02:00
Goffi
cb62511fa7 tools (common/async_process): remove useless encoding + use full path for command:
- arguments don't need to be encoded anymore, `spawnProcess` handles str directly now
- use full path even for first argument: even if first argument should be only executable
  name, it appears that using full path only in `command` is not enough (seen with Python
  where system installation is used instead of the VirtualEnv one when full path is not
  used as first argument).
(grafted from 25cbaf04772855cd8aead18771465a4f00f5fa03)
2021-07-29 22:51:01 +02:00
Goffi
60fe49f883 tools (common/async_process): remove useless encoding + use full path for command:
- arguments don't need to be encoded anymore, `spawnProcess` handles str directly now
- use full path even for first argument: even if first argument should be only executable
  name, it appears that using full path only in `command` is not enough (seen with Python
  where system installation is used instead of the VirtualEnv one when full path is not
  used as first argument).
2021-07-29 22:51:01 +02:00
Goffi
aab8a38836 tools (common/date_utils): accept more units (shortcuts) + fix timezone when date with relative delta is used 2021-07-29 22:51:01 +02:00
Goffi
7adbf3ead8 core, frontends: fix invalid translatable strings.
Some f-strings where used in translatable text, this has been fixed by using explicit
`format()` call (using a script based on `tokenize`).

As tokenize messes with spaces, a reformating tool (`black`) has been applied to some
files afterwards.
2021-06-14 18:35:12 +02:00
Goffi
80ee158daa tools (common/template_xmlui: add multi and value propertied to OptionsWidget 2021-06-04 14:44:33 +02:00
Goffi
4e36667134 tools (common/utils): new methods to parse and generate file size with symbols:
- `parseSize` lets parse a size which can be either a int, or a string with a symbol like
  `Mio`
- `getSizeMultiplier` returns a tuple of size with it's multiplier symbol
- `getHumanSize` returns a string with size and adapted multiplier.
2021-05-05 15:37:33 +02:00
Goffi
af053c5f34 tools (common/date_utils): fix date_only for short, long and full format 2021-05-01 18:36:13 +02:00
Goffi
2596f7ae77 tools (common/regex): move code to make user friendly URLs from web frontend 2021-04-16 18:32:44 +02:00
Goffi
018d09caaa Renamed the project from "Salut à Toi" to "Libervia":
This renaming follows the decision taken at the General Assemblee of January 27th 2021 (cf.
https://repos.goffi.org/sat_docs/raw-file/tip/association/2021-01-27%20-%20compte%20rendu%20de%20l%27AG%20extraordinaire.pdf)
2021-03-20 20:42:04 +01:00
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
591b9fe8bc tools (common/template): new fallback settings:
`fallback` can be used to change fallback behaviour. By default, fallback is done on
`default` theme, this can be set to an other theme with a string, or to a list of
fallback. The list can also be empty is no fallback is desired (notably usefull for "main"
themes, on which other themes may fallback).

This setting replaces `css_default_fallback`.
2021-03-19 14:01:52 +01:00
Goffi
32899b71e2 tools (common/email): try to guess sender domain when necessary:
when `DNSNAME` is `localhost.localdomain` and is `mail_sender_domain` is not set, a guess
is done to find a proper domain, using `email_from`.
2021-02-19 15:53:24 +01:00
Goffi
a692ba8e2e tools (common/tls): removed unused import 2020-10-19 09:28:26 +02:00
Goffi
03cffe789c core: minor typos, docstring/comments update 2020-09-20 14:05:40 +02:00
Goffi
820fa05d49 tools (common/template): use to_json instead of json + added missing args to date_fmt 2020-07-16 09:07:26 +02:00
Goffi
9aa7b1b7f2 tools (common/data_objects): removed deprecated code:
`BlogItem`, `BlogItems` and `parsePubSubMetadata` are not needed anymore with the new blog
data serialisation.
2020-07-16 09:07:26 +02:00
Goffi
282d2a93d9 tools (common/data_objects): implemented json dumping for BlogItems/BlogItem 2020-06-19 15:47:16 +02:00
Goffi
4b0d91cb2e common (template): better json dumping:
default method is set for json dumping (the `tojson` filter), if the object has a `json`
attribute, it will be called, otherwise it is replaced by None, this avoids crash when
rendering the template.
2020-06-19 15:45:57 +02:00
Goffi
9ba6df5503 tools (common/utils): new OrderedSet class 2020-06-08 08:54:53 +02:00
Goffi
7000fcda34 tools (common/dynamic_import): log a warning if bridge can't be imported 2020-06-01 11:14:20 +02:00
Goffi
d09be4ba42 tools/common (tls): moved re-usable Twisted TLS code from Libervia to tools/common 2020-05-29 21:07:10 +02:00
Goffi
205bd5cdb4 tools (common/template): new icon_from_client method:
this method is available from template, and returns the name of the icon to use according
to disco client data.
2020-05-18 23:41:36 +02:00
Goffi
9780bd3480 plugin pubsub schema, tools (common/template xmlui): use a JID for publisher:
- a JidWidget is used instead of text for publisher, nothing is set if publisher attribute
  doesn't exist
- added missing JidWidget implementation in tools.common.template_xmlui
2020-05-18 23:37:04 +02:00
Goffi
19a9e38983 tools (common/template): theme settings with possibility to disable default fallback for CSS:
- themes can now have a `settings.json` file at their root to modify the renderer
  behaviour
- the `css_default_fallback` boolean (true by default) can be used to disable the fallback
  mechanism when CSS files are checked. Useful when a theme doesn't follow the CSS naming of
  default theme.
- introduced some type hints
2020-05-03 17:01:39 +02:00
Goffi
2908be8898 tools (common/template): typos 2020-05-03 13:40:04 +02:00
Goffi
3f735d406e tools (common/template): list themes and parse their browser data, available through new getThemesData method 2020-05-01 16:26:39 +02:00
Goffi
794b5be810 tools (common/utils): new recursive_update method for dicts 2020-04-29 13:53:00 +02:00
Goffi
a5aac84c6a tools (common/data_objects): added __iter__ to Identities 2020-04-25 15:54:26 +02:00
Goffi
5b217e1b40 tools (common/data_objects): new avatar_basename property 2020-04-19 22:52:15 +02:00
Goffi
ef90f2d3f7 tools (common/files_utils): put extra suffix before file extension 2020-04-01 22:29:43 +02:00
Goffi
6a7d247754 core: use serialised dict for extra in messageNew and historyGet 2020-02-18 18:13:17 +01:00
Goffi
bc3abd6920 tools (common/async_process): fixed stderr handling + added global "run" 2020-02-09 23:56:40 +01:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
5ffa208962 tools (common/files_utils): fixed get_unique_name when path is a str and not a Path 2020-01-27 19:53:31 +01:00
Goffi
174f7bec4c tools (common/files_utils): get_unique_name now uses and returns Path instances. 2019-12-20 12:28:04 +01:00
Goffi
ed73fd8bf8 tools (common/template): removed warning catches, jinja2>=2.10.3 now handles them correctly 2019-10-18 17:51:44 +02:00
Goffi
d4bf063788 tools (common): helping method to calculate luminance:
- a new `utils` module has been added for backend and frontends generic utilities
- per_luminance method calculate the perceived luminance of a colour (is it dark or
  light?). This is useful to automatically select the suitable colour in a theme.
2019-10-01 22:49:10 +02:00
Goffi
76aadbb3fb jp: jp asyncio port:
/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\

This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).

During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
2019-09-25 08:56:41 +02:00
Goffi
e87c07b200 common (template): suppress jinja2 depreaction warning (to be removed once 2.10.1 is released) 2019-09-25 08:41:36 +02:00
Goffi
a2ce271498 tools (common/email): fixed email sending after python 3 port 2019-08-16 17:06:52 +02:00
Goffi
4b2d53b797 tools (async_process): log command as str 2019-08-16 17:06:51 +02:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00