You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,32 @@
1
1
# Change log for CommonPy
2
2
3
+
## Version 1.12.0
4
+
5
+
Additions in this release:
6
+
* New function `network` in the `network_utils` module. It is a companion to `net` and takes the same arguments, but returns only one value (the response). If an error occurs, it raises the error as an exception. This makes it possible for callers to use `network(...)` in somewhat more Pythonic style than `net(...)`, by wrapping the call to `network(...)` in `try`-`except`.
7
+
8
+
Changes in this release:
9
+
* Removed `slice` from `data_utils` module because it shadows a Python built-in.
10
+
* Fixed `hostname` in `network_utils` to be more general and not hardwire a test for `http`.
11
+
* Fixed a bunch of `flake8` warnings.
12
+
13
+
14
+
## Version 1.11.0
15
+
16
+
Additions in this release:
17
+
* New class `CaseFoldSet`, similar to `CaseFoldDict` but … a set.
18
+
19
+
Changes in this release:
20
+
* Fixed a bug in the class documentation in the `README.md` file.
21
+
* Added missing dependency for [twine]() in requirements-dev
22
+
* Now using lazy `import`s in more places, for faster load times.
23
+
24
+
3
25
## Version 1.10.0
4
26
5
27
Changes in this release:
6
28
7
-
*`data_utils.flattened` now would outputs `[]` as the value of dict or mapping keys whose original values are an empty sequence (e.g., when the value of a dict key is `[]`). Previously, it would output `None` as the value, which was an unexpected transformation of the input.
29
+
*`data_utils.flattened` now outputs `[]` as the value of dict or mapping keys whose original values are an empty sequence (e.g., when the value of a dict key is `[]`). Previously, it would output `None` as the value, which was an unexpected transformation of the input.
Copy file name to clipboardExpand all lines: README.md
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,9 +62,10 @@ The following subsections describe the different modules available.
62
62
63
63
The `data_structures` module provides miscellaneous data classes.
64
64
65
-
| Function | Purpose |
66
-
|-----------------------|---------|
67
-
|`CaseInsensitiveDict`| A version of `dict` that compares keys in a case-insensitive manner |
65
+
| Class | Purpose |
66
+
|----------------|---------|
67
+
|`CaseFoldDict`| A version of `dict` that compares keys in a case-insensitive manner |
68
+
|`CaseFoldSet`| A version of `set` that compares keys in a case-insensitive manner |
68
69
69
70
70
71
### Data utilities
@@ -73,14 +74,14 @@ The `data_utils` module provides a number of miscellaneous simple functions for
73
74
74
75
| Function | Purpose |
75
76
|--------------------|---------|
77
+
|`expanded_range(string)`| Given a string of the form "X-Y", returns the list of integers it represents |
76
78
|`flattened(thing)`| Takes a list or dictionary and returns a recursively flattened version |
77
-
|`unique(list)`| Takes a list and return a version without duplicates |
78
79
|`ordinal(integer)`| Returns a string with the number followed by "st", "nd, "rd", or "th" |
79
-
|`slice(list, n)`| Yields `n` number of slices from the `list`|
80
-
|`timestamp()`| Returns a string for an easily-readable form of the current time and date |
81
80
|`parsed_datetime(string)`| Returns a date object representing the given date string |
82
81
|`pluralized(word, n, include_num)`| Returns a plural version of `word` if `n > 1`|
83
-
|`expanded_range(string)`| Given a string of the form "X-Y", returns the list of integers it represents |
82
+
|`sliced(list, n)`| Yields `n` number of slices from the `list`|
83
+
|`timestamp()`| Returns a string for an easily-readable form of the current time and date |
84
+
|`unique(list)`| Takes a list and return a version without duplicates |
84
85
85
86
86
87
### File utilities
@@ -89,20 +90,20 @@ The `file_utils` module provides a number of miscellaneous simple functions for
89
90
90
91
| Function | Purpose |
91
92
|--------------------|---------|
92
-
|`readable(dest)`| Returns `True` if file or directory `dest` is accessible and readable |
93
-
|`writable(dest)`| Returns `True` if file or directory `dest` can be written |
94
-
|`nonempty(file)`| Returns `True` if file `file` is not empty |
95
-
|`relative(file)`| Returns a path string for `file` relative to the current directory |
96
-
|`filename_basename(file)`| Returns `file` without any extensions |
97
-
|`filename_extension(file)`| Returns the extension of filename `file`|
98
93
|`alt_extension(file, ext)`| Returns `file` with the extension replaced by `ext`|
99
-
|`rename_existing(file)`| Renames `file` to `file.bak`|
100
-
|`delete_existing(file)`| Deletes the given `file`|
101
94
|`copy_file(src, dst)`| Copies file from `src` to `dst`|
95
+
|`delete_existing(file)`| Deletes the given `file`|
96
+
|`filename_basename(file)`| Returns `file` without any extensions |
97
+
|`filename_extension(file)`| Returns the extension of filename `file`|
98
+
|`files_in_directory(dir, ext, recursive)`||
99
+
|`filtered_by_extensions(list, endings)`||
100
+
|`nonempty(file)`| Returns `True` if file `file` is not empty |
102
101
|`open_file(file)`| Opens the `file` by calling the equivalent of "open" on this system |
103
102
|`open_url(url)`| Opens the `url` in the user's default web browser |
104
-
|`filtered_by_extensions(list, endings)`||
105
-
|`files_in_directory(dir, ext, recursive)`||
103
+
|`readable(dest)`| Returns `True` if file or directory `dest` is accessible and readable |
104
+
|`relative(file)`| Returns a path string for `file` relative to the current directory |
105
+
|`rename_existing(file)`| Renames `file` to `file.bak`|
106
+
|`writable(dest)`| Returns `True` if file or directory `dest` can be written |
106
107
107
108
108
109
### Interruptible wait and interruption handling utilities
@@ -112,11 +113,11 @@ The `interrupt` module includes `wait(...)`, a replacement for `sleep(...)` that
112
113
| Function | Purpose |
113
114
|--------------------------|---------|
114
115
|`config_interrupt(callback, raise_ex, signal)`| Sets up a callback function |
115
-
|`wait(duration)`| Waits for `duration` in an interruptible fashion |
116
116
|`interrupt()`| Interrupts any `wait` in progress |
117
117
|`interrupted() `| Returns `True` if an interruption has been called |
118
118
|`raise_for_interrupts()`| Raises an exception if `interrupt()` has been invoked |
119
119
|`reset_interrupts()`| Resets the interruption flag |
120
+
|`wait(duration)`| Waits for `duration` in an interruptible fashion |
120
121
121
122
122
123
### Module utilities
@@ -125,11 +126,11 @@ The `module_utils` collection of functions is useful for working with paths rela
125
126
126
127
| Function | Purpose |
127
128
|--------------------|---------|
129
+
|`config_path(module_name)`| Returns the path to local config data directory for the module |
130
+
|`datadir_path(module_name)`| Returns the path to the `/data` subdirectory of the module |
128
131
|`desktop_path()`| Returns the path to the user's Desktop directory on this system |
129
-
|`module_path(module_name)`| Returns the path to the installed module |
130
132
|`installation_path(module_name)`| Returns the path to module's installation directory |
131
-
|`datadir_path(module_name)`| Returns the path to the `/data` subdirectory of the module |
132
-
|`config_path(module_name)`| Returns the path to local config data directory for the module |
133
+
|`module_path(module_name)`| Returns the path to the installed module |
133
134
134
135
Function `config_path(...)` is useful to use in conjunction with Python's [`configparser`](https://docs.python.org/3/library/configparser.html) module. It returns `~/.config/modulename/` on Unix-like systems.
135
136
@@ -146,8 +147,8 @@ The `network_utils` module provides several functions that are useful when perfo
146
147
|`net(...)`| See below |
147
148
|`netlock(url)`| Returns the hostname, port number (if any), and login info (if any) |
148
149
|`network_available()`| Returns `True` if external hosts are reacheable over the network |
149
-
|`scheme(url)`| Returns the protocol portion of the url; e.g., "https" |
150
150
|`on_localhost(url)`| Returns `True` if the address of `url` points to the local host |
151
+
|`scheme(url)`| Returns the protocol portion of the url; e.g., "https" |
151
152
152
153
153
154
#### _`net`_
@@ -259,6 +260,7 @@ CommonPy makes use of numerous open-source packages, without which it would have
259
260
*[pywin32](https://github.com/mhammond/pywin32)– Windows APIs for Python
0 commit comments