Commit graph

15 commits

Author SHA1 Message Date
Pedro Algarvio
f2a783643d Update to latest `pyupgrade` hook. Stop skipping it on CI.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-01-26 15:18:32 -08:00
Daniel A. Wozniak
d9b50659b2 Pyupgrade and drop six 2021-07-06 09:04:28 -04:00
Blacken Salt
0b2a5613b3
Blacken salt 2020-04-03 13:05:41 -05:00
Gareth J. Greenaway
e14b655c01
More unicode changes. Adding print_function to all files. Updating various reads & writes to files. 2018-01-17 09:02:17 -08:00
Gareth J. Greenaway
db41d9b303
Updating various utils and related tests for unicode goodness. 2018-01-17 09:02:17 -08:00
Erik Johnson
473fbb18e9
Add top-level docstrings to a bunch of salt.utils modules which are missing them 2017-10-16 13:38:41 -05:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
Bo Maryniuk
b70731156f Lintfix 2015-07-17 12:01:06 +02:00
Bo Maryniuk
625476e300 Implement blkid getter, compatible with different systems and providing different result. 2015-07-16 22:26:09 +02:00
Bo Maryniuk
5d77dcefe6 Report all FS types, if filter was not specified. 2015-04-14 14:37:36 +02:00
Bo Maryniuk
0beaf12cbc Preserve type if not specified 2015-04-13 15:33:01 +02:00
Bo Maryniuk
0341f4e5ba Dead code removal 2015-04-13 15:32:50 +02:00
Pedro Algarvio
b076e27ce4 Py3 compatibility fixes. 2015-01-30 22:25:23 +00:00
Pedro Algarvio
b36d48b84f Move salt.modules.fsutils to salt.utils.fsutils. It's not a salt module. 2015-01-30 22:25:23 +00:00
Renamed from salt/modules/fsutils.py (Browse further)