Generated using development version of Ansible on 15 Sep 2024. Details may differ from released versions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Copyright (c) 2001 - 2023 Python Software Foundation | |
# Copyright (c) 2024 Alex Willmer <[email protected]> | |
# License: Python Software Foundation License Version 2 | |
# Derived from https://github.com/python/cpython/blob/v3.12.6/Lib/posixpath.py#L423-L492 | |
""" | |
Show the route taken through symlinks to a resolved file path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1/usr/bin/env python2 | |
import StringIO | |
f1 = StringIO.StringIO() | |
f1.write(u'unicode string') | |
f1.write(b'byte string') | |
f1.close() | |
import io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[issue905] | |
ssh-args ansible_ssh_args="-o PermitLocalCommand=yes -o LocalCommand='touch {{ ssh_args_canary_file }}'" | |
ssh-common-args ansible_ssh_common_args="-o PermitLocalCommand=yes -o LocalCommand='touch {{ ssh_args_canary_file }}'" | |
ssh-extra-args ansible_ssh_extra_args="-o PermitLocalCommand=yes -o LocalCommand='touch {{ ssh_args_canary_file }}'" | |
[issue905:vars] | |
ansible_host=u2204.mynet | |
ssh_args_canary_file=/tmp/ssh_args_{{ inventory_hostname }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import sys | |
import warnings | |
# By default ResourceWarning output (and other) is hidden. | |
# Setting environment variable PYTHONWARNINGS=default will | |
# show them, similar to the below. | |
if not sys.warnoptions: | |
warnings.simplefilter('default') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def tree_layers_count(leaf_nodes_count: int, degree: int) -> int: | |
r""" | |
Return the number of layers required for a given number of leaf nodes, | |
if each node can have degree children & nodes are filled depth first. | |
E.g. to have 5 leaf nodes, a degree 4 tree requires 3 layers | |
* | |
_______________ _|_ _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: targets | |
gather_facts: false | |
vars: | |
ansible_python_interpreter: python3 | |
tasks: | |
- command: echo hello | |
delegate_to: localhost | |
- command: echo hello | |
connection: local |
In Python 3.11+ datetime.datetime.fromisoformat()
accepts any number of decimal places
for the seconds component. If there are more than 6 then the resulting datetime object
is truncated (not rounded) to microsecond precision.
Python 3.11.8 (main, Feb 6 2024, 21:21:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
>>> import datetime
>>> datetime.datetime.fromisoformat('2011-11-04T00:05:23.12345Z')
datetime.datetime(2011, 11, 4, 0, 5, 23, 123450, tzinfo=datetime.timezone.utc)
>>> datetime.datetime.fromisoformat('2011-11-04T00:05:23.1234567Z')
datetime.datetime(2011, 11, 4, 0, 5, 23, 123456, tzinfo=datetime.timezone.utc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To apply changes run | |
# nix-env --install --remove-all --file ~/macos.nix | |
# nix-env -irf ~/macos.nix | |
# | |
# Notes | |
# - Binaries are made available in ~/.nix-profile/bin/ | |
# | |
# TODO | |
# - Install ~/.nix-profile/bin/{python,python-config}{3.8,3.9,3.10,3.11,3.12}, | |
# but *not* .../{python{,3} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkeypatch that replaces the importlib PathFinder in sys.meta_path | |
# with one that handles EACCES returned by libc getcwd() on macOS. | |
# Workaround for https://github.com/python/cpython/issues/115911 | |
import errno | |
import sys | |
try: | |
import _frozen_importlib_external | |
except ImportError: | |
pass |
NewerOlder