Commit graph

28 commits

Author SHA1 Message Date
Erik Johnson
002aa88a97
Replace yaml usage with a helper to ensure unicode is handled properly
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.

To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.

Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
2018-01-03 14:14:21 -06: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
a69cd74f75 Merge branch '2016.11' into 'nitrogen'
Conflicts:
  - salt/cloud/clouds/nova.py
  - salt/spm/__init__.py
2017-04-28 09:23:42 -06:00
rallytime
62c4d37c2f Use salt.utils.yamlloader with SaltYamlSafeLoader as the Loader with yaml.load 2017-04-18 13:41:07 -06:00
Eric Radman
3f2e13d1fc Remove repeated words in docs (#37871)
Found using

find . -name '*.rst' | xargs igor -R -r
2016-11-23 14:53:17 -07:00
rallytime
d684d49490 Merge branch '2016.3' into 'develop'
Conflicts:
  - doc/topics/releases/2015.5.10.rst
  - doc/topics/releases/2015.8.8.rst
2016-03-28 11:16:22 -06:00
Erik Johnson
1b97e4a3df Improve state module docs, replace references to state.highstate/state.sls with state.apply
Resolves #32037.
2016-03-21 22:56:17 -05:00
Justin Findlay
4953f7b0df doc/ref/renderers/index.rst: remove env support 2016-02-16 19:26:57 -07:00
Thomas Jackson
85864eca4a Comma cleanup 2014-12-12 11:37:59 -08:00
Thomas Jackson
3859204103 Fix typo in renderers doc, the directory name was wrong 2014-12-10 18:42:16 -08:00
Thomas Güttler
7d25e086d3 "Full List of Renderes" was a sub section of "Examples" before. 2014-04-07 09:27:21 +02:00
Seth House
12481b9e38 Added ref anchor for renderer docs 2014-02-27 19:38:57 -07:00
Mike Place
826bad4cfb Merge conflict and rebase.
Conflicts:
	doc/ref/renderers/index.rst
2014-02-26 13:32:08 -07:00
Henrik Holmboe
de1548aeb0 Missing comma 2014-02-24 14:21:57 +01:00
Mike Place
6186eeab68 Renderer index re-write for clarity. 2014-02-19 13:55:34 -07:00
Erik Johnson
1b876fc53a Clarify docs on custom types 2013-07-08 21:36:34 -05:00
Gary Wilson Jr
bd499e5640 Fixed several minor misspellings and acronym capitalizations. 2013-03-18 16:42:57 -05:00
Erik Johnson
7415755653 More docs updates
Added the same links to returner and renderer docs as I did for grains,
states, and modules last night.
2012-12-19 14:35:43 -06:00
Jack Kuan
bf0eff9785 Move stateconf module doc to its own rst file.
Also added an example of using render pipes(#!jinja|mako|yaml) as
per @UtahDave's request.
2012-11-28 23:08:56 -05:00
Jack Kuan
0b9e5e1f9e Fix doc to align with last change. 2012-11-15 11:20:44 -05:00
Jack Kuan
bc1183924f Doc updates, typo fixes. Add -s option for template renderers. 2012-11-15 01:20:10 -05:00
Jack Kuan
7f3ac3fe89 Add some docs on render pipe.
Also, added a stateconf state so that its stateconf.set function
can be used by the stateconf renderer.
2012-11-13 02:01:34 -05:00
G. Clifford Williams
d399da4259 Merge branch 'master' of https://github.com/saltstack/salt into develop
Conflicts:
	doc/ref/renderers/all/index.rst
2012-10-20 11:54:50 -05:00
G. Clifford Williams
1c5042c2ec added wempy to list in ./doc/ref/renderers/index.rst 2012-10-16 11:21:00 -05:00
Alec Koumjian
eb907cb084 Update doc/ref/renderers/index.rst
Telling users where they can put their custom renderers.
2012-09-23 16:21:05 -07:00
L.C. Rees
3315dad9e7 documentation updates 2012-05-22 22:43:12 -06:00
Thomas S Hatch
fa03eebf15 Add some docs on the sls shebang line 2012-02-09 11:13:55 -07:00
Seth House
a912520cf8 Reorganized and reworded the contents page for better focus
Also moved the TOC to its own doc to provide a complete and
comprehensive overview. Removed some extra and unecessary toctree calls.
2011-10-30 12:41:14 -06:00
Renamed from doc/ref/renderers.rst (Browse further)