omlish 0.0.0.dev166__py3-none-any.whl → 0.0.0.dev167__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev166'
2
- __revision__ = 'e832ee32347c3f4c51e8ead2186def228e3aac1c'
1
+ __version__ = '0.0.0.dev167'
2
+ __revision__ = '4dc487c3620d4629b8a2895a84511a4be478a801'
3
3
 
4
4
 
5
5
  #
omlish/lite/strings.py CHANGED
@@ -21,6 +21,15 @@ def snake_case(name: str) -> str:
21
21
  ##
22
22
 
23
23
 
24
+ def strip_with_newline(s: str) -> str:
25
+ if not s:
26
+ return ''
27
+ return s.strip() + '\n'
28
+
29
+
30
+ ##
31
+
32
+
24
33
  def is_dunder(name: str) -> bool:
25
34
  return (
26
35
  name[:2] == name[-2:] == '__' and
omlish/os/atomics.py CHANGED
@@ -122,7 +122,7 @@ class AtomicPathSwapping(abc.ABC):
122
122
  ##
123
123
 
124
124
 
125
- class OsRenameAtomicPathSwap(AtomicPathSwap):
125
+ class OsReplaceAtomicPathSwap(AtomicPathSwap):
126
126
  def __init__(
127
127
  self,
128
128
  kind: AtomicPathSwapKind,
@@ -150,7 +150,7 @@ class OsRenameAtomicPathSwap(AtomicPathSwap):
150
150
  return self._tmp_path
151
151
 
152
152
  def _commit(self) -> None:
153
- os.rename(self._tmp_path, self._dst_path)
153
+ os.replace(self._tmp_path, self._dst_path)
154
154
 
155
155
  def _abort(self) -> None:
156
156
  shutil.rmtree(self._tmp_path, ignore_errors=True)
@@ -197,7 +197,7 @@ class TempDirAtomicPathSwapping(AtomicPathSwapping):
197
197
  else:
198
198
  raise TypeError(kind)
199
199
 
200
- return OsRenameAtomicPathSwap(
200
+ return OsReplaceAtomicPathSwap(
201
201
  kind,
202
202
  dst_path,
203
203
  tmp_path,
omlish/os/paths.py ADDED
@@ -0,0 +1,32 @@
1
+ # ruff: noqa: UP006 UP007
2
+ # @omlish-lite
3
+ import os.path
4
+ import typing as ta
5
+
6
+
7
+ def abs_real_path(p: str) -> str:
8
+ return os.path.abspath(os.path.realpath(p))
9
+
10
+
11
+ def is_path_in_dir(base_dir: str, target_path: str) -> bool:
12
+ base_dir = abs_real_path(base_dir)
13
+ target_path = abs_real_path(target_path)
14
+
15
+ return target_path.startswith(base_dir + os.path.sep)
16
+
17
+
18
+ def relative_symlink(
19
+ src: str,
20
+ dst: str,
21
+ *,
22
+ target_is_directory: bool = False,
23
+ dir_fd: ta.Optional[int] = None,
24
+ **kwargs: ta.Any,
25
+ ) -> None:
26
+ os.symlink(
27
+ os.path.relpath(src, os.path.dirname(dst)),
28
+ dst,
29
+ target_is_directory=target_is_directory,
30
+ dir_fd=dir_fd,
31
+ **kwargs,
32
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omlish
3
- Version: 0.0.0.dev166
3
+ Version: 0.0.0.dev167
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=0BnQGD2dcXEma0Jop2ZesvDNzSj3CAJBNq8aTGuBz9A,7276
2
- omlish/__about__.py,sha256=fXaHA2dVpft8O6khsmrd4euInIFrrMexrl8b4pMj_ME,3409
2
+ omlish/__about__.py,sha256=6MZuOZq8DwHRIcwPmVPdl5xZJjs_D7eV9-nFWn00wgI,3409
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=ubu7lHwss5V4UznbejAI0qXhXahrU01MysuHOZI9C4U,8116
5
5
  omlish/cached.py,sha256=UI-XTFBwA6YXWJJJeBn-WkwBkfzDjLBBaZf4nIJA9y0,510
@@ -381,7 +381,7 @@ omlish/lite/runtime.py,sha256=XQo408zxTdJdppUZqOWHyeUR50VlCpNIExNGHz4U6O4,459
381
381
  omlish/lite/secrets.py,sha256=3Mz3V2jf__XU9qNHcH56sBSw95L3U2UPL24bjvobG0c,816
382
382
  omlish/lite/socket.py,sha256=7OYgkXTcQv0wq7TQuLnl9y6dJA1ZT6Vbc1JH59QlxgY,1792
383
383
  omlish/lite/socketserver.py,sha256=doTXIctu_6c8XneFtzPFVG_Wq6xVmA3p9ymut8IvBoU,1586
384
- omlish/lite/strings.py,sha256=QURcE4-1pKVW8eT_5VCJpXaHDWR2dW2pYOChTJnZDiQ,1504
384
+ omlish/lite/strings.py,sha256=SkCQPtw1grKGr1KFgJr3CL3ocvCEcPwH7XIzb-JxFAY,1610
385
385
  omlish/lite/typing.py,sha256=U3-JaEnkDSYxK4tsu_MzUn3RP6qALBe5FXQXpD-licE,1090
386
386
  omlish/logs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
387
387
  omlish/logs/abc.py,sha256=ho4ABKYMKX-V7g4sp1BByuOLzslYzLlQ0MESmjEpT-o,8005
@@ -433,11 +433,12 @@ omlish/math/bits.py,sha256=yip1l8agOYzT7bFyMGc0RR3XlnGCfHMpjw_SECLLh1I,3477
433
433
  omlish/math/floats.py,sha256=UimhOT7KRl8LXTzOI5cQWoX_9h6WNWe_3vcOuO7-h_8,327
434
434
  omlish/math/stats.py,sha256=MegzKVsmv2kra4jDWLOUgV0X7Ee2Tbl5u6ql1v4-dEY,10053
435
435
  omlish/os/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
436
- omlish/os/atomics.py,sha256=gArGtyH5l3UjLKwKIqFJ5XkRnNouXntPEtkRbI0ch_0,5071
436
+ omlish/os/atomics.py,sha256=NQfwifLu48ZniOvaqAuDy8dBTB3tKZntL22T0-8NYwM,5074
437
437
  omlish/os/deathsig.py,sha256=hk9Yq2kyDdI-cI7OQH7mOfpRbOKzY_TfPKEqgrjVYbA,641
438
438
  omlish/os/files.py,sha256=1tNy1z5I_CgYKA5c6lOfsXc-hknP4tQDbSShdz8HArw,1308
439
439
  omlish/os/journald.py,sha256=2nI8Res1poXkbLc31--MPUlzYMESnCcPUkIxDOCjZW0,3903
440
440
  omlish/os/linux.py,sha256=whJ6scwMKSFBdXiVhJW0BCpJV4jOGMr-a_a3Bhwz6Ls,18938
441
+ omlish/os/paths.py,sha256=o1vTpQgbOQR0X6Wtb_7oqajxykMy58yJ0WCQIaY9gAA,735
441
442
  omlish/os/pidfile.py,sha256=S4Nbe00oSxckY0qCC9AeTEZe7NSw4eJudnQX7wCXzks,1738
442
443
  omlish/os/sizes.py,sha256=ohkALLvqSqBX4iR-7DMKJ4pfOCRdZXV8htH4QywUNM0,152
443
444
  omlish/reflect/__init__.py,sha256=4-EuCSX1qpEWfScCFzAJv_XghHFu4cXxpxKeBKrosQ4,720
@@ -556,9 +557,9 @@ omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,329
556
557
  omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
557
558
  omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
558
559
  omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
559
- omlish-0.0.0.dev166.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
560
- omlish-0.0.0.dev166.dist-info/METADATA,sha256=k2XolFifVQc4PpG7_98r62S2OP6NpxBerLqcXtxl-tg,4264
561
- omlish-0.0.0.dev166.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
562
- omlish-0.0.0.dev166.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
563
- omlish-0.0.0.dev166.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
564
- omlish-0.0.0.dev166.dist-info/RECORD,,
560
+ omlish-0.0.0.dev167.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
561
+ omlish-0.0.0.dev167.dist-info/METADATA,sha256=XQoZ5IEtdiX_6-I2wMBv-GB3-Nz6-WbQLpzCKbEjxkI,4264
562
+ omlish-0.0.0.dev167.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
563
+ omlish-0.0.0.dev167.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
564
+ omlish-0.0.0.dev167.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
565
+ omlish-0.0.0.dev167.dist-info/RECORD,,