Commit graph

53 commits

Author SHA1 Message Date
e737e60862
Revert files/directories argument to glob, use separate functions.
I thought it was clever at first, but now I'm feeling that having
mutually exclusive arguments to a single function in this case is
better served by just having two functions. Which also saves us
from ever having to deal with the exception case.
2021-11-07 18:58:35 -08:00
125681da18
Let pathclass.join take spawn_kwargs. 2021-11-07 18:55:28 -08:00
154f02f5bb
Use r-string for re.match windows drive letter. 2021-11-07 18:54:17 -08:00
281e95f184
Make force_sep a kw-only argument. 2021-11-07 18:53:57 -08:00
b68ac864fa
Return a pathclass object from @property drive. 2021-10-24 00:16:33 -07:00
a4196f2b13
Add aliases assert_is_dir, assert_not_dir. 2021-10-10 00:31:43 -07:00
05586e7e79
Let is_directory be canonical function, but keep the aliases. 2021-10-10 00:31:25 -07:00
0a1ab15637
Add convenient pathclass.read, write. 2021-10-04 17:19:20 -07:00
bebcd6c7f3
Fix docstring column wrapping. 2021-09-23 22:36:39 -07:00
cd1fce3211
Add aliases is_directory, is_folder -> is_dir. 2021-09-23 22:36:14 -07:00
446626f1ce
Add pathclass.glob, glob_many. 2021-09-23 22:36:01 -07:00
e0f37b986c
Use double backslash even in docstring. 2021-09-13 18:00:56 -07:00
0416f0babf
Discourage writes to pathclass._absolute_path. 2021-09-09 17:30:46 -07:00
63251b979b
Describe Path parameters in docstring. 2021-08-09 16:27:33 -07:00
81782383a9
Use regular path.join when constructing glob patterns.
I don't like the idea of having an intermediate Path object that isn't
a real path.
2021-08-09 08:36:20 -07:00
13bf8e2e47
Improve Windows reserved name check by adding to pathclass. 2021-07-24 12:24:24 -07:00
244691713d Add constant WINDOWS_BADCHARS for use in other programs. 2020-12-05 15:06:27 -08:00
ebe009f2a2 Add assert_not_file, assert_not_directory to round it out. 2020-12-05 14:55:02 -08:00
44d9bd9913 Add assert_is_link, assert_not_link. 2020-12-05 14:51:51 -08:00
Ethan Dalool
d29501bae7 Having removed self.spawn(other), add back Path(other). 2020-11-02 23:18:19 -08:00
Ethan Dalool
426da9b52b Let listdir spawn children with _correct_case already set. 2020-10-28 14:56:52 -07:00
Ethan Dalool
adf7353ae6 Cache _case_correct property to cut down on fs calls. 2020-10-28 14:55:49 -07:00
Ethan Dalool
a05d34ea9e Add Path.makedirs. 2020-09-24 14:16:51 -07:00
Ethan Dalool
ba88731ae2 Fix cwd. 2020-09-22 01:55:30 -07:00
Ethan Dalool
c6d7450028 Add Path.open. 2020-09-20 17:31:28 -07:00
Ethan Dalool
a2337346fb Add helpful pathclass.cwd function. 2020-09-12 10:15:14 -07:00
Ethan Dalool
9874f12a2a Return self from correct_case instead of self.absolute_path. 2020-09-02 09:11:49 -07:00
Ethan Dalool
27291df9ad Sort Pathclass by normcase instead of absolute path. 2020-09-02 08:52:13 -07:00
Ethan Dalool
53528741b2 Assert exists before trying to calculate size; explicit elif.
If you have a path that you expect to expect to be a file, it is
confusing to see the traceback where it attempts to listdir because
self.is_file failed and the else was to treat it as a dir.
I prefer this explicit exists check, and explicit dir check.
Yeah, potential for race conditions exists.
2020-08-28 17:31:31 -07:00
Ethan Dalool
3a5e160504 Add Path.__lt__ so they are sortable. 2020-07-20 18:03:48 -07:00
Ethan Dalool
453b2d2fb1 Fix pathclass.glob actually only looking at cwd.
In other news, don't ever trust anything I do.
2020-07-16 21:28:40 -07:00
Ethan Dalool
ff9895a390 Add method glob to get child items with a glob pattern. 2020-07-07 22:25:44 -07:00
Ethan Dalool
417c14a023 Let directories @size property work also.
I was hesitant at first because of course it can be slow to run,
but previously you'd have to have an if so that you know whether you've
got int or none corresponding to files and folders anyway, so I don't
think the caller-side complexity is increased at all, and saves me from
having to write this as a helper function outside the class.
Only for special cases like preparing to handle permissionerror
would you need to use your own function.
2020-03-12 18:18:59 -07:00
Ethan Dalool
081313d7ef Add pathclass.drive for convenient splitdrive. 2020-03-12 17:45:42 -07:00
Ethan Dalool
13f19719b2 Add Pathclass.touch. 2020-03-02 17:46:19 -08:00
Ethan Dalool
c22bcd290f Add pathclass.assert_exists and assert_not_exists. 2020-02-19 16:22:22 -08:00
Ethan Dalool
f7e314f392 Replace some % formatters with fstrings. 2020-02-18 00:42:33 -08:00
Ethan Dalool
8238481262 Fix == between two Extensions. 2020-02-06 11:52:18 -08:00
Ethan Dalool
0cb646fda0 Appease some flake8 linting. 2020-01-31 20:53:29 -08:00
Ethan Dalool
b88450b567 Add pathclass.Extension class to enrich extension operations.
I often found myself writing code like if a.extension == 'png' and
trying to remember if I'm supposed to compare against 'png' or '.png',
and then it would trip up on files like A.PNG because I forgot to
lower() it.

So this class handles all that for you. You can == against it and it
will use os.path.normcase to give you OS-appropriate case sens,
and == works whether you include the dot or not. Then you can use
ext.with_dot or ext.no_dot to get reliably dotted strings.
2020-01-27 21:33:09 -08:00
Ethan Dalool
751ab5eaac Add method spawn that inherits force_sep.
I am considering some other instance attributes similar to force_sep.
And since these need to be carried over into newly spawned Paths,
I want to consolidate that into a single method so I don't have
to risk forgetting it on a new object.
2020-01-20 21:52:40 -08:00
Ethan Dalool
5e397b1928 Simplify normalize_sep. 2020-01-20 21:49:14 -08:00
Ethan Dalool
af1538a139 Tighten the regex for bare drives. 2020-01-20 21:29:33 -08:00
Ethan Dalool
b0ed32a1d5 Add Path.dot_extension property. 2019-08-05 17:34:17 -07:00
Ethan Dalool
452ad7f937 Add force_sep attribute. 2019-08-03 01:01:00 -07:00
Ethan Dalool
85572ba406 Add parameter simple to remove .\ from relative path. 2019-08-01 08:58:13 -07:00
Ethan Dalool
d9d10a843e Fix relative backsteps. 2019-08-01 08:57:18 -07:00
Ethan Dalool
6a34c8eae9 Add method Path.add_extension. 2019-08-01 08:47:27 -07:00
Ethan Dalool
b8aaecd15f Move case correction to after self==other check. 2019-08-01 08:47:04 -07:00
Ethan Dalool
e478aca497 Improve Path.__contains__ check. 2019-08-01 08:46:37 -07:00