Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
d976e758
Commit
d976e758
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
2.6.2: add satella.files.split
parent
6018483b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
CHANGELOG.md
+1
-1
1 addition, 1 deletion
CHANGELOG.md
docs/files.rst
+6
-1
6 additions, 1 deletion
docs/files.rst
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/files.py
+22
-1
22 additions, 1 deletion
satella/files.py
tests/test_files.py
+7
-1
7 additions, 1 deletion
tests/test_files.py
with
37 additions
and
5 deletions
CHANGELOG.md
+
1
−
1
View file @
d976e758
# v2.6.2
*
_TBA_
*
added
`satella.files.split`
# v2.6.1
...
...
This diff is collapsed.
Click to expand it.
docs/files.rst
+
6
−
1
View file @
d976e758
...
...
@@ -9,4 +9,9 @@ read_re_sub_and_write
find_files
----------
.. autofunction:: satella.files.find_files
\ No newline at end of file
.. autofunction:: satella.files.find_files
split
-----
.. autofuction:: satella.files.split
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
d976e758
__version__
=
'
2.6.2
_a1
'
__version__
=
'
2.6.2
'
This diff is collapsed.
Click to expand it.
satella/files.py
+
22
−
1
View file @
d976e758
...
...
@@ -2,7 +2,28 @@ import typing as tp
import
re
import
os
__all__
=
[
'
read_re_sub_and_write
'
,
'
find_files
'
]
__all__
=
[
'
read_re_sub_and_write
'
,
'
find_files
'
,
'
split
'
]
SEPARATORS
=
{
'
\\
'
,
'
/
'
}
SEPARATORS
.
add
(
os
.
path
.
sep
)
def
_has_separator
(
path
:
str
)
->
bool
:
return
any
(
map
(
lambda
x
:
x
in
path
,
SEPARATORS
))
def
split
(
path
:
str
)
->
tp
.
List
[
str
]:
"""
An exact reverse of os.path.join
Is is true that
>>>
os
.
path
.
join
(
split
(
a
))
==
a
"""
data
=
list
(
os
.
path
.
split
(
path
))
while
_has_separator
(
data
[
0
]):
data
=
list
(
os
.
path
.
split
(
data
[
0
]))
+
data
[
1
:]
return
data
def
read_re_sub_and_write
(
path
:
str
,
pattern
:
tp
.
Union
[
re
.
compile
,
str
],
...
...
This diff is collapsed.
Click to expand it.
tests/test_files.py
+
7
−
1
View file @
d976e758
...
...
@@ -2,10 +2,16 @@ import os
import
tempfile
import
unittest
import
shutil
from
satella.files
import
read_re_sub_and_write
,
find_files
from
satella.files
import
read_re_sub_and_write
,
find_files
,
split
class
TestFiles
(
unittest
.
TestCase
):
def
test_split
(
self
):
self
.
assertEqual
(
split
(
'
c:/windows/system32/system.exe
'
),
[
'
c:/
'
,
'
windows
'
,
'
system32
'
,
'
system32.exe
'
])
self
.
assertEqual
(
split
(
'
~/user/something/./else
'
),
[
'
~
'
,
'
user
'
,
'
something
'
,
'
.
'
,
'
else
'
])
def
setUp
(
self
)
->
None
:
self
.
filename
=
tempfile
.
mktemp
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment