aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/fs.py
AgeCommit message (Collapse)AuthorFilesLines
2021-05-08modules/fs: support FileOrString argumentsFlorian Fischer1-26/+46
With this change File objects created with the builtin files() function can be used with the fs submodule like normal strings. All methods that seem reasonable support FileOrSting arguments. For example fs.exists() still only takes str arguments because meson already ensures that File objects do exist when creating them with files(). Each user facing function of the fs module has an additional FeatureNew check when used with File objects. The test cases for fs are extended appropriately with tests for File objects.
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-2/+2
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04various python neatness cleanupsEli Schwartz1-1/+1
All changes were created by running "pyupgrade --py3-only --keep-percent-format" and committing the results. I have not touched string formatting for now. - use set literals - simplify .format() parameter naming - remove __future__ - remove default "r" mode for open() - use OSError rather than compatibility aliases - remove stray parentheses in function(generator) scopes
2021-03-04Simplify module APIXavier Claessens1-1/+2
- ModuleState is now a real class that will have methods in the future for actions modules needs, instead of using interpreter internal API. - New ModuleObject base class, similar to InterpreterObject, that should be used by all objects returned by modules. Its methods gets the ModuleState passed as first argument. It has a `methods` dictionary to define what is public API that can be called from build definition. - Method return value is not required to be a ModuleReturnValue any more, it can be any type that interpreter can holderify, including ModuleObject. - Legacy module API is maintained until we port all modules. In the future modules should be updated: - Use methods dict. - Remove snippets. - Custom objects returned by modules should all be subclass of ModuleObject to get the state iface in their methods. - Modules should never call into interpreter directly and instead state object should have wrapper API. - Stop using ModuleReturnValue in methods that just return simple objects like strings. Possibly remove ModuleReturnValue completely since all objects that needs to be processed by interpreter (e.g. CustomTarget) should be created through ModuleState API.
2021-02-26modules/fs: Use typed_pos_argsDylan Baker1-75/+40
2021-02-04Introduce `fs.read` to read a file as a stringLuke Drummond1-1/+64
Following #7890, this patch introduces the ability to read the contents of a file to the fs module. This patch introduces the ability to read files at configure time, but has some restrictions: - binary files are not supported (I don't think this will prove a problem, and if people are wanting to do something with binary files, they should probably be shelling out to their own script). - Only files outside the build directory allowed. This limitation should prevent build loops. Given that reading an arbitrary file at configure time can affect the configuration in almost arbitrary ways, meson should force a reconfigure when the given file changes. This is non-configurable, but this can easily be changed with a future keyword argument.
2021-01-13Fix misspellsAntonin Décimo1-1/+1
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2020-11-20use real pathlib moduleDylan Baker1-1/+1
We added the _pathlib module to work around defeciencies in python 3.5's implementation, since we now rely on 3.6 lets drop this
2020-10-04pathlib: Fix resolve() by overriding it in Python 3.5Daniel Mensinger1-1/+1
2020-09-08typing: fully annotate fs moduleDaniel Mensinger1-4/+4
2020-02-06add FeatureNewMichael Hirsch, Ph.D1-0/+5
2020-02-06add fs.stem()Michael Hirsch, Ph.D1-2/+11
2020-02-06fs: add expanduser methodMichael Hirsch, Ph.D1-1/+8
this should help users specify leading `~` in various Meson options and variables without refactoring lots of places inside Meson itself.
2020-02-06fs: add methods as_posix, is_absoluteMichael Hirsch, Ph.D1-7/+43
fs: make exception specify method name fs: actually raise exceptions fs: resolve path e.g. /opt/foo/.. => /opt/foo fs: correct behavior of is_symlink
2020-01-08types: import typing as T (fixes #6333)Daniel Mensinger1-13/+13
2019-12-19fs: rename samefile => is_samepathMichael Hirsch, Ph.D1-5/+5
is_samepath better reflects the nature of this function--that files and directories can be compared. Also, instead of raising exceptions, simply return False when one or both .is_samepath(path1, path1) don't exist. This is more intuitive behavior and avoids having an extra if fs.exist() to go with every fs.is_samepath()
2019-12-04Add raise at the start of MesonExceptionMichael Brockus1-7/+7
2019-11-25fs: Add parent() and name() methodsXavier Claessens1-0/+17
2019-11-17fs: make replace_suffix not expand file to absolute path, just manipulate ↵Michael Hirsch, Ph.D1-1/+1
the string
2019-11-17fs: replace_suffixMichael Hirsch, Ph.D1-1/+1
2019-11-17fs: get file sizeMichael Hirsch, Ph.D1-2/+38
fs: add samefile
2019-11-17fs: add hash compute methodMichael Hirsch, Ph.D1-0/+18
2019-11-17add fs.with_suffixMichael Hirsch, Ph.D1-1/+11
2019-11-17fs: improve exception feedbackMichael Hirsch, Ph.D1-1/+1
2019-11-17fs: use expanduserMichael Hirsch, Ph.D1-1/+1
2019-11-17fs: deduplicate functionsMichael Hirsch, Ph.D1-8/+5
2019-11-17fs: use pathlib.Path, add type hint checkMichael Hirsch, Ph.D1-14/+17
2019-11-08Created the filesystem module.Jussi Pakkanen1-0/+59