Show More
@@ -49,18 +49,16 def process_handler(cmd, callback, stderr=subprocess.PIPE): | |||
|
49 | 49 | Parameters |
|
50 | 50 | ---------- |
|
51 | 51 | cmd : str or list |
|
52 | A command to be executed by the system, using :class:`subprocess.Popen`. | |
|
53 | If a string is passed, it will be run in the system shell. If a list is | |
|
54 | passed, it will be used directly as arguments. | |
|
55 | ||
|
52 | A command to be executed by the system, using :class:`subprocess.Popen`. | |
|
53 | If a string is passed, it will be run in the system shell. If a list is | |
|
54 | passed, it will be used directly as arguments. | |
|
56 | 55 | callback : callable |
|
57 | A one-argument function that will be called with the Popen object. | |
|
58 | ||
|
56 | A one-argument function that will be called with the Popen object. | |
|
59 | 57 | stderr : file descriptor number, optional |
|
60 | By default this is set to ``subprocess.PIPE``, but you can also pass the | |
|
61 | value ``subprocess.STDOUT`` to force the subprocess' stderr to go into | |
|
62 | the same file descriptor as its stdout. This is useful to read stdout | |
|
63 | and stderr combined in the order they are generated. | |
|
58 | By default this is set to ``subprocess.PIPE``, but you can also pass the | |
|
59 | value ``subprocess.STDOUT`` to force the subprocess' stderr to go into | |
|
60 | the same file descriptor as its stdout. This is useful to read stdout | |
|
61 | and stderr combined in the order they are generated. | |
|
64 | 62 | |
|
65 | 63 | Returns |
|
66 | 64 | ------- |
@@ -117,12 +115,12 def getoutput(cmd): | |||
|
117 | 115 | Parameters |
|
118 | 116 | ---------- |
|
119 | 117 | cmd : str or list |
|
120 | A command to be executed in the system shell. | |
|
118 | A command to be executed in the system shell. | |
|
121 | 119 | |
|
122 | 120 | Returns |
|
123 | 121 | ------- |
|
124 | 122 | output : str |
|
125 | A string containing the combination of stdout and stderr from the | |
|
123 | A string containing the combination of stdout and stderr from the | |
|
126 | 124 | subprocess, in whatever order the subprocess originally wrote to its |
|
127 | 125 | file descriptors (so the order of the information in this string is the |
|
128 | 126 | correct order as would be seen if running the command in a terminal). |
@@ -141,7 +139,7 def getoutputerror(cmd): | |||
|
141 | 139 | Parameters |
|
142 | 140 | ---------- |
|
143 | 141 | cmd : str or list |
|
144 | A command to be executed in the system shell. | |
|
142 | A command to be executed in the system shell. | |
|
145 | 143 | |
|
146 | 144 | Returns |
|
147 | 145 | ------- |
@@ -159,7 +157,7 def get_output_error_code(cmd): | |||
|
159 | 157 | Parameters |
|
160 | 158 | ---------- |
|
161 | 159 | cmd : str or list |
|
162 | A command to be executed in the system shell. | |
|
160 | A command to be executed in the system shell. | |
|
163 | 161 | |
|
164 | 162 | Returns |
|
165 | 163 | ------- |
@@ -82,12 +82,12 class ProcessHandler(object): | |||
|
82 | 82 | Parameters |
|
83 | 83 | ---------- |
|
84 | 84 | cmd : str |
|
85 | A command to be executed in the system shell. | |
|
85 | A command to be executed in the system shell. | |
|
86 | 86 | |
|
87 | 87 | Returns |
|
88 | 88 | ------- |
|
89 | 89 | output : str |
|
90 | A string containing the combination of stdout and stderr from the | |
|
90 | A string containing the combination of stdout and stderr from the | |
|
91 | 91 | subprocess, in whatever order the subprocess originally wrote to its |
|
92 | 92 | file descriptors (so the order of the information in this string is the |
|
93 | 93 | correct order as would be seen if running the command in a terminal). |
@@ -103,12 +103,12 class ProcessHandler(object): | |||
|
103 | 103 | Parameters |
|
104 | 104 | ---------- |
|
105 | 105 | cmd : str |
|
106 | A command to be executed in the system shell. | |
|
106 | A command to be executed in the system shell. | |
|
107 | 107 | |
|
108 | 108 | Returns |
|
109 | 109 | ------- |
|
110 | 110 | output : str |
|
111 | A string containing the combination of stdout and stderr from the | |
|
111 | A string containing the combination of stdout and stderr from the | |
|
112 | 112 | subprocess, in whatever order the subprocess originally wrote to its |
|
113 | 113 | file descriptors (so the order of the information in this string is the |
|
114 | 114 | correct order as would be seen if running the command in a terminal). |
@@ -124,7 +124,7 class ProcessHandler(object): | |||
|
124 | 124 | Parameters |
|
125 | 125 | ---------- |
|
126 | 126 | cmd : str |
|
127 | A command to be executed in the system shell. | |
|
127 | A command to be executed in the system shell. | |
|
128 | 128 | |
|
129 | 129 | Returns |
|
130 | 130 | ------- |
@@ -128,7 +128,7 def system(cmd): | |||
|
128 | 128 | Parameters |
|
129 | 129 | ---------- |
|
130 | 130 | cmd : str or list |
|
131 | A command to be executed in the system shell. | |
|
131 | A command to be executed in the system shell. | |
|
132 | 132 | |
|
133 | 133 | Returns |
|
134 | 134 | ------- |
@@ -152,7 +152,7 def getoutput(cmd): | |||
|
152 | 152 | Parameters |
|
153 | 153 | ---------- |
|
154 | 154 | cmd : str or list |
|
155 | A command to be executed in the system shell. | |
|
155 | A command to be executed in the system shell. | |
|
156 | 156 | |
|
157 | 157 | Returns |
|
158 | 158 | ------- |
@@ -181,7 +181,7 try: | |||
|
181 | 181 | |
|
182 | 182 | This is a special version for windows that use a ctypes call to CommandLineToArgvW |
|
183 | 183 | to do the argv splitting. The posix parameter is ignored. |
|
184 | ||
|
184 | ||
|
185 | 185 | If strict=False, process_common.arg_split(...strict=False) is used instead. |
|
186 | 186 | """ |
|
187 | 187 | #CommandLineToArgvW returns path to executable if called with empty string. |
@@ -551,13 +551,13 def system(cmd): | |||
|
551 | 551 | Parameters |
|
552 | 552 | ---------- |
|
553 | 553 | cmd : str |
|
554 | A command to be executed in the system shell. | |
|
554 | A command to be executed in the system shell. | |
|
555 | 555 | |
|
556 | 556 | Returns |
|
557 | 557 | ------- |
|
558 | 558 | None : we explicitly do NOT return the subprocess status code, as this |
|
559 | 559 | utility is meant to be used extensively in IPython, where any return value |
|
560 | would trigger :func:`sys.displayhook` calls. | |
|
560 | would trigger : func:`sys.displayhook` calls. | |
|
561 | 561 | """ |
|
562 | 562 | with AvoidUNCPath() as path: |
|
563 | 563 | if path is not None: |
@@ -50,7 +50,7 def flag_calls(func): | |||
|
50 | 50 | |
|
51 | 51 | def undoc(func): |
|
52 | 52 | """Mark a function or class as undocumented. |
|
53 | ||
|
53 | ||
|
54 | 54 | This is found by inspecting the AST, so for now it must be used directly |
|
55 | 55 | as @undoc, not as e.g. @decorators.undoc |
|
56 | 56 | """ |
@@ -37,10 +37,10 def get_stream_enc(stream, default=None): | |||
|
37 | 37 | # won't need to make changes all over IPython. |
|
38 | 38 | def getdefaultencoding(prefer_stream=True): |
|
39 | 39 | """Return IPython's guess for the default encoding for bytes as text. |
|
40 | ||
|
40 | ||
|
41 | 41 | If prefer_stream is True (default), asks for stdin.encoding first, |
|
42 | 42 | to match the calling Terminal, but that is often None for subprocesses. |
|
43 | ||
|
43 | ||
|
44 | 44 | Then fall back on locale.getpreferredencoding(), |
|
45 | 45 | which should be a sensible platform default (that respects LANG environment), |
|
46 | 46 | and finally to sys.getdefaultencoding() which is the most conservative option, |
@@ -28,12 +28,10 def extract_vars(*names,**kw): | |||
|
28 | 28 | *names : str |
|
29 | 29 | One or more variable names which will be extracted from the caller's |
|
30 | 30 | frame. |
|
31 | ||
|
32 | depth : integer, optional | |
|
31 | **kw : integer, optional | |
|
33 | 32 | How many frames in the stack to walk when looking for your variables. |
|
34 | 33 | The default is 0, which will use the frame where the call was made. |
|
35 | 34 | |
|
36 | ||
|
37 | 35 | Examples |
|
38 | 36 | -------- |
|
39 | 37 | :: |
@@ -22,7 +22,6 def complete_object(obj, prev_completions): | |||
|
22 | 22 | The object to complete. |
|
23 | 23 | prev_completions : list |
|
24 | 24 | List of attributes discovered so far. |
|
25 | ||
|
26 | 25 | This should return the list of attributes in obj. If you only wish to |
|
27 | 26 | add to the attributes already discovered normally, return |
|
28 | 27 | own_attrs + prev_completions. |
@@ -16,12 +16,12 def import_item(name): | |||
|
16 | 16 | Parameters |
|
17 | 17 | ---------- |
|
18 | 18 | name : string |
|
19 | The fully qualified name of the module/package being imported. | |
|
19 | The fully qualified name of the module/package being imported. | |
|
20 | 20 | |
|
21 | 21 | Returns |
|
22 | 22 | ------- |
|
23 | 23 | mod : module object |
|
24 | The module that was imported. | |
|
24 | The module that was imported. | |
|
25 | 25 | """ |
|
26 | 26 | |
|
27 | 27 | parts = name.rsplit('.', 1) |
@@ -113,11 +113,9 class Tee(object): | |||
|
113 | 113 | Parameters |
|
114 | 114 | ---------- |
|
115 | 115 | file_or_name : filename or open filehandle (writable) |
|
116 | File that will be duplicated | |
|
117 | ||
|
116 | File that will be duplicated | |
|
118 | 117 | mode : optional, valid mode for open(). |
|
119 | If a filename was give, open with this mode. | |
|
120 | ||
|
118 | If a filename was give, open with this mode. | |
|
121 | 119 | channel : str, one of ['stdout', 'stderr'] |
|
122 | 120 | """ |
|
123 | 121 | if channel not in ['stdout', 'stderr']: |
@@ -195,15 +193,14 def temp_pyfile(src, ext='.py'): | |||
|
195 | 193 | Parameters |
|
196 | 194 | ---------- |
|
197 | 195 | src : string or list of strings (no need for ending newlines if list) |
|
198 | Source code to be written to the file. | |
|
199 | ||
|
196 | Source code to be written to the file. | |
|
200 | 197 | ext : optional, string |
|
201 | Extension for the generated file. | |
|
198 | Extension for the generated file. | |
|
202 | 199 | |
|
203 | 200 | Returns |
|
204 | 201 | ------- |
|
205 | 202 | (filename, open filehandle) |
|
206 | It is the caller's responsibility to close the open file and unlink it. | |
|
203 | It is the caller's responsibility to close the open file and unlink it. | |
|
207 | 204 | """ |
|
208 | 205 | fname = tempfile.mkstemp(ext)[1] |
|
209 | 206 | with open(Path(fname), "w") as f: |
@@ -43,14 +43,13 class Struct(dict): | |||
|
43 | 43 | |
|
44 | 44 | Parameters |
|
45 | 45 | ---------- |
|
46 | args : dict, Struct | |
|
46 | *args : dict, Struct | |
|
47 | 47 | Initialize with one dict or Struct |
|
48 | kw : dict | |
|
48 | **kw : dict | |
|
49 | 49 | Initialize with key, value pairs. |
|
50 | 50 | |
|
51 | 51 | Examples |
|
52 | 52 | -------- |
|
53 | ||
|
54 | 53 | >>> s = Struct(a=10,b=30) |
|
55 | 54 | >>> s.a |
|
56 | 55 | 10 |
@@ -68,7 +67,6 class Struct(dict): | |||
|
68 | 67 | |
|
69 | 68 | Examples |
|
70 | 69 | -------- |
|
71 | ||
|
72 | 70 | >>> s = Struct() |
|
73 | 71 | >>> s['a'] = 10 |
|
74 | 72 | >>> s.allow_new_attr(False) |
@@ -95,7 +93,6 class Struct(dict): | |||
|
95 | 93 | |
|
96 | 94 | Examples |
|
97 | 95 | -------- |
|
98 | ||
|
99 | 96 | >>> s = Struct() |
|
100 | 97 | >>> s.a = 10 |
|
101 | 98 | >>> s.a |
@@ -130,7 +127,6 class Struct(dict): | |||
|
130 | 127 | |
|
131 | 128 | Examples |
|
132 | 129 | -------- |
|
133 | ||
|
134 | 130 | >>> s = Struct(a=10) |
|
135 | 131 | >>> s.a |
|
136 | 132 | 10 |
@@ -155,7 +151,6 class Struct(dict): | |||
|
155 | 151 | |
|
156 | 152 | Examples |
|
157 | 153 | -------- |
|
158 | ||
|
159 | 154 | >>> s = Struct(a=10,b=30) |
|
160 | 155 | >>> s2 = Struct(a=20,c=40) |
|
161 | 156 | >>> s += s2 |
@@ -170,7 +165,6 class Struct(dict): | |||
|
170 | 165 | |
|
171 | 166 | Examples |
|
172 | 167 | -------- |
|
173 | ||
|
174 | 168 | >>> s1 = Struct(a=10,b=30) |
|
175 | 169 | >>> s2 = Struct(a=20,c=40) |
|
176 | 170 | >>> s = s1 + s2 |
@@ -186,7 +180,6 class Struct(dict): | |||
|
186 | 180 | |
|
187 | 181 | Examples |
|
188 | 182 | -------- |
|
189 | ||
|
190 | 183 | >>> s1 = Struct(a=10,b=30) |
|
191 | 184 | >>> s2 = Struct(a=40) |
|
192 | 185 | >>> s = s1 - s2 |
@@ -202,7 +195,6 class Struct(dict): | |||
|
202 | 195 | |
|
203 | 196 | Examples |
|
204 | 197 | -------- |
|
205 | ||
|
206 | 198 | >>> s1 = Struct(a=10,b=30) |
|
207 | 199 | >>> s2 = Struct(a=40) |
|
208 | 200 | >>> s1 -= s2 |
@@ -236,7 +228,6 class Struct(dict): | |||
|
236 | 228 | |
|
237 | 229 | Examples |
|
238 | 230 | -------- |
|
239 | ||
|
240 | 231 | >>> s = Struct(a=10,b=30) |
|
241 | 232 | >>> s2 = s.copy() |
|
242 | 233 | >>> type(s2) is Struct |
@@ -251,7 +242,6 class Struct(dict): | |||
|
251 | 242 | |
|
252 | 243 | Examples |
|
253 | 244 | -------- |
|
254 | ||
|
255 | 245 | >>> s = Struct(a=10) |
|
256 | 246 | >>> s.hasattr('a') |
|
257 | 247 | True |
@@ -284,7 +274,7 class Struct(dict): | |||
|
284 | 274 | |
|
285 | 275 | Parameters |
|
286 | 276 | ---------- |
|
287 | __loc_data : dict, Struct | |
|
277 | __loc_data__ : dict, Struct | |
|
288 | 278 | The data to merge into self |
|
289 | 279 | __conflict_solve : dict |
|
290 | 280 | The conflict policy dict. The keys are binary functions used to |
@@ -292,12 +282,11 class Struct(dict): | |||
|
292 | 282 | the keys the conflict resolution function applies to. Instead of |
|
293 | 283 | a list of strings a space separated string can be used, like |
|
294 | 284 | 'a b c'. |
|
295 | kw : dict | |
|
285 | **kw : dict | |
|
296 | 286 | Additional key, value pairs to merge in |
|
297 | 287 | |
|
298 | 288 | Notes |
|
299 | 289 | ----- |
|
300 | ||
|
301 | 290 | The `__conflict_solve` dict is a dictionary of binary functions which will be used to |
|
302 | 291 | solve key conflicts. Here is an example:: |
|
303 | 292 | |
@@ -338,7 +327,6 class Struct(dict): | |||
|
338 | 327 | |
|
339 | 328 | Examples |
|
340 | 329 | -------- |
|
341 | ||
|
342 | 330 | This show the default policy: |
|
343 | 331 | |
|
344 | 332 | >>> s = Struct(a=10,b=30) |
@@ -43,7 +43,7 def find_mod(module_name): | |||
|
43 | 43 | """ |
|
44 | 44 | Find module `module_name` on sys.path, and return the path to module `module_name`. |
|
45 | 45 | |
|
46 |
- If `module_name` refers to a module directory, then return path to __init__ file. |
|
|
46 | - If `module_name` refers to a module directory, then return path to __init__ file. | |
|
47 | 47 | - If `module_name` is a directory without an __init__file, return None. |
|
48 | 48 | - If module is missing or does not have a `.py` or `.pyw` extension, return None. |
|
49 | 49 | - Note that we are not interested in running bytecode. |
@@ -52,7 +52,7 def find_mod(module_name): | |||
|
52 | 52 | Parameters |
|
53 | 53 | ---------- |
|
54 | 54 | module_name : str |
|
55 | ||
|
55 | ||
|
56 | 56 | Returns |
|
57 | 57 | ------- |
|
58 | 58 | module_path : str |
@@ -60,15 +60,15 def strip_encoding_cookie(filelike): | |||
|
60 | 60 | |
|
61 | 61 | def read_py_file(filename, skip_encoding_cookie=True): |
|
62 | 62 | """Read a Python file, using the encoding declared inside the file. |
|
63 | ||
|
63 | ||
|
64 | 64 | Parameters |
|
65 | 65 | ---------- |
|
66 | 66 | filename : str |
|
67 | The path to the file to read. | |
|
67 | The path to the file to read. | |
|
68 | 68 | skip_encoding_cookie : bool |
|
69 | If True (the default), and the encoding declaration is found in the first | |
|
70 | two lines, that line will be excluded from the output. | |
|
71 | ||
|
69 | If True (the default), and the encoding declaration is found in the first | |
|
70 | two lines, that line will be excluded from the output. | |
|
71 | ||
|
72 | 72 | Returns |
|
73 | 73 | ------- |
|
74 | 74 | A unicode string containing the contents of the file. |
@@ -82,18 +82,18 def read_py_file(filename, skip_encoding_cookie=True): | |||
|
82 | 82 | |
|
83 | 83 | def read_py_url(url, errors='replace', skip_encoding_cookie=True): |
|
84 | 84 | """Read a Python file from a URL, using the encoding declared inside the file. |
|
85 | ||
|
85 | ||
|
86 | 86 | Parameters |
|
87 | 87 | ---------- |
|
88 | 88 | url : str |
|
89 | The URL from which to fetch the file. | |
|
89 | The URL from which to fetch the file. | |
|
90 | 90 | errors : str |
|
91 | How to handle decoding errors in the file. Options are the same as for | |
|
92 | bytes.decode(), but here 'replace' is the default. | |
|
91 | How to handle decoding errors in the file. Options are the same as for | |
|
92 | bytes.decode(), but here 'replace' is the default. | |
|
93 | 93 | skip_encoding_cookie : bool |
|
94 | If True (the default), and the encoding declaration is found in the first | |
|
95 | two lines, that line will be excluded from the output. | |
|
96 | ||
|
94 | If True (the default), and the encoding declaration is found in the first | |
|
95 | two lines, that line will be excluded from the output. | |
|
96 | ||
|
97 | 97 | Returns |
|
98 | 98 | ------- |
|
99 | 99 | A unicode string containing the contents of the file. |
@@ -109,7 +109,7 def get_py_filename(name, force_win32=None): | |||
|
109 | 109 | raise IOError('File `%r` not found.' % name) |
|
110 | 110 | |
|
111 | 111 | |
|
112 | def filefind(filename, path_dirs=None): | |
|
112 | def filefind(filename: str, path_dirs=None) -> str: | |
|
113 | 113 | """Find a file by looking through a sequence of paths. |
|
114 | 114 | |
|
115 | 115 | This iterates through a sequence of paths looking for a file and returns |
@@ -139,7 +139,12 def filefind(filename, path_dirs=None): | |||
|
139 | 139 | |
|
140 | 140 | Returns |
|
141 | 141 | ------- |
|
142 | Raises :exc:`IOError` or returns absolute path to file. | |
|
142 | path : str | |
|
143 | returns absolute path to file. | |
|
144 | ||
|
145 | Raises | |
|
146 | ------ | |
|
147 | IOError | |
|
143 | 148 | """ |
|
144 | 149 | |
|
145 | 150 | # If paths are quoted, abspath gets confused, strip them... |
@@ -178,7 +183,6 def get_home_dir(require_writable=False) -> str: | |||
|
178 | 183 | |
|
179 | 184 | Parameters |
|
180 | 185 | ---------- |
|
181 | ||
|
182 | 186 | require_writable : bool [default: False] |
|
183 | 187 | if True: |
|
184 | 188 | guarantees the return value is a writable directory, otherwise |
@@ -40,15 +40,15 def pkg_commit_hash(pkg_path): | |||
|
40 | 40 | Parameters |
|
41 | 41 | ---------- |
|
42 | 42 | pkg_path : str |
|
43 | directory containing package | |
|
44 | only used for getting commit from active repo | |
|
43 | directory containing package | |
|
44 | only used for getting commit from active repo | |
|
45 | 45 | |
|
46 | 46 | Returns |
|
47 | 47 | ------- |
|
48 | 48 | hash_from : str |
|
49 | Where we got the hash from - description | |
|
49 | Where we got the hash from - description | |
|
50 | 50 | hash_str : str |
|
51 | short form of hash | |
|
51 | short form of hash | |
|
52 | 52 | """ |
|
53 | 53 | # Try and get commit from written commit text file |
|
54 | 54 | if _sysinfo.commit: |
@@ -71,12 +71,12 def pkg_info(pkg_path): | |||
|
71 | 71 | Parameters |
|
72 | 72 | ---------- |
|
73 | 73 | pkg_path : str |
|
74 | path containing __init__.py for package | |
|
74 | path containing __init__.py for package | |
|
75 | 75 | |
|
76 | 76 | Returns |
|
77 | 77 | ------- |
|
78 | 78 | context : dict |
|
79 | with named parameters of interest | |
|
79 | with named parameters of interest | |
|
80 | 80 | """ |
|
81 | 81 | src, hsh = pkg_commit_hash(pkg_path) |
|
82 | 82 | return dict( |
@@ -45,7 +45,7 def toggle_set_term_title(val): | |||
|
45 | 45 | |
|
46 | 46 | Parameters |
|
47 | 47 | ---------- |
|
48 |
|
|
|
48 | val : bool | |
|
49 | 49 | If True, set_term_title() actually writes to the terminal (using the |
|
50 | 50 | appropriate platform-specific module). If False, it is a no-op. |
|
51 | 51 | """ |
@@ -111,7 +111,7 def test_rich_output_metadata(method_mime): | |||
|
111 | 111 | |
|
112 | 112 | def test_rich_output_display(): |
|
113 | 113 | """test RichOutput.display |
|
114 | ||
|
114 | ||
|
115 | 115 | This is a bit circular, because we are actually using the capture code we are testing |
|
116 | 116 | to test itself. |
|
117 | 117 | """ |
@@ -54,8 +54,8 def setup_module(): | |||
|
54 | 54 | def teardown_module(): |
|
55 | 55 | """Teardown testenvironment for the module: |
|
56 | 56 | |
|
57 |
|
|
|
58 |
|
|
|
57 | - Remove tempdir | |
|
58 | - restore sys.path | |
|
59 | 59 | """ |
|
60 | 60 | # Note: we remove the parent test dir, which is the root of all test |
|
61 | 61 | # subdirs we may have created. Use shutil instead of os.removedirs, so |
@@ -56,7 +56,7 HOME_TEST_DIR = join(TMP_TEST_DIR, "home_test_dir") | |||
|
56 | 56 | def setup_module(): |
|
57 | 57 | """Setup testenvironment for the module: |
|
58 | 58 | |
|
59 |
|
|
|
59 | - Adds dummy home dir tree | |
|
60 | 60 | """ |
|
61 | 61 | # Do not mask exceptions here. In particular, catching WindowsError is a |
|
62 | 62 | # problem because that exception is only defined on Windows... |
@@ -66,7 +66,7 def setup_module(): | |||
|
66 | 66 | def teardown_module(): |
|
67 | 67 | """Teardown testenvironment for the module: |
|
68 | 68 | |
|
69 |
|
|
|
69 | - Remove dummy home dir tree | |
|
70 | 70 | """ |
|
71 | 71 | # Note: we remove the parent test dir, which is the root of all test |
|
72 | 72 | # subdirs we may have created. Use shutil instead of os.removedirs, so |
@@ -12,6 +12,6 from IPython.utils import sysinfo | |||
|
12 | 12 | |
|
13 | 13 | def test_json_getsysinfo(): |
|
14 | 14 | """ |
|
15 |
test that it is easily jsonable and don't return bytes somewhere. |
|
|
15 | test that it is easily jsonable and don't return bytes somewhere. | |
|
16 | 16 | """ |
|
17 | 17 | json.dumps(sysinfo.get_sys_info()) |
@@ -252,7 +252,6 def indent(instr,nspaces=4, ntabs=0, flatten=False): | |||
|
252 | 252 | |
|
253 | 253 | Parameters |
|
254 | 254 | ---------- |
|
255 | ||
|
256 | 255 | instr : basestring |
|
257 | 256 | The string to be indented. |
|
258 | 257 | nspaces : int (default: 4) |
@@ -266,7 +265,6 def indent(instr,nspaces=4, ntabs=0, flatten=False): | |||
|
266 | 265 | |
|
267 | 266 | Returns |
|
268 | 267 | ------- |
|
269 | ||
|
270 | 268 | str|unicode : string indented by ntabs and nspaces. |
|
271 | 269 | |
|
272 | 270 | """ |
@@ -390,7 +388,6 def wrap_paragraphs(text, ncols=80): | |||
|
390 | 388 | |
|
391 | 389 | Returns |
|
392 | 390 | ------- |
|
393 | ||
|
394 | 391 | list of complete paragraphs, wrapped to fill `ncols` columns. |
|
395 | 392 | """ |
|
396 | 393 | paragraph_re = re.compile(r'\n(\s*\n)+', re.MULTILINE) |
@@ -410,7 +407,7 def wrap_paragraphs(text, ncols=80): | |||
|
410 | 407 | |
|
411 | 408 | def long_substr(data): |
|
412 | 409 | """Return the longest common substring in a list of strings. |
|
413 | ||
|
410 | ||
|
414 | 411 | Credit: http://stackoverflow.com/questions/2892931/longest-common-substring-from-more-than-two-strings-python |
|
415 | 412 | """ |
|
416 | 413 | substr = '' |
@@ -474,7 +471,7 def strip_email_quotes(text): | |||
|
474 | 471 | def strip_ansi(source): |
|
475 | 472 | """ |
|
476 | 473 | Remove ansi escape codes from text. |
|
477 | ||
|
474 | ||
|
478 | 475 | Parameters |
|
479 | 476 | ---------- |
|
480 | 477 | source : str |
@@ -651,7 +648,6 def compute_item_matrix(items, row_first=False, empty=None, *args, **kwargs) : | |||
|
651 | 648 | |
|
652 | 649 | Parameters |
|
653 | 650 | ---------- |
|
654 | ||
|
655 | 651 | items |
|
656 | 652 | list of strings to columize |
|
657 | 653 | row_first : (default False) |
@@ -666,14 +662,11 def compute_item_matrix(items, row_first=False, empty=None, *args, **kwargs) : | |||
|
666 | 662 | |
|
667 | 663 | Returns |
|
668 | 664 | ------- |
|
669 | ||
|
670 | 665 | strings_matrix |
|
671 | ||
|
672 | 666 | nested list of string, the outer most list contains as many list as |
|
673 | 667 | rows, the innermost lists have each as many element as columns. If the |
|
674 | 668 | total number of elements in `items` does not equal the product of |
|
675 | 669 | rows*columns, the last element of some lists are filled with `None`. |
|
676 | ||
|
677 | 670 | dict_info |
|
678 | 671 | some info to make columnize easier: |
|
679 | 672 | |
@@ -713,14 +706,11 def columnize(items, row_first=False, separator=' ', displaywidth=80, spread=Fa | |||
|
713 | 706 | ---------- |
|
714 | 707 | items : sequence of strings |
|
715 | 708 | The strings to process. |
|
716 | ||
|
717 | 709 | row_first : (default False) |
|
718 | 710 | Whether to compute columns for a row-first matrix instead of |
|
719 | 711 | column-first (default). |
|
720 | ||
|
721 | 712 | separator : str, optional [default is two spaces] |
|
722 | 713 | The string that separates columns. |
|
723 | ||
|
724 | 714 | displaywidth : int, optional [default is 80] |
|
725 | 715 | Width of the display in number of characters. |
|
726 | 716 |
@@ -23,20 +23,18 def generate_tokens(readline): | |||
|
23 | 23 | |
|
24 | 24 | def line_at_cursor(cell, cursor_pos=0): |
|
25 | 25 | """Return the line in a cell at a given cursor position |
|
26 | ||
|
26 | ||
|
27 | 27 | Used for calling line-based APIs that don't support multi-line input, yet. |
|
28 | ||
|
28 | ||
|
29 | 29 | Parameters |
|
30 | 30 | ---------- |
|
31 | ||
|
32 | cell: str | |
|
31 | cell : str | |
|
33 | 32 | multiline block of text |
|
34 | cursor_pos: integer | |
|
33 | cursor_pos : integer | |
|
35 | 34 | the cursor position |
|
36 | ||
|
35 | ||
|
37 | 36 | Returns |
|
38 | 37 | ------- |
|
39 | ||
|
40 | 38 | (line, offset): (string, integer) |
|
41 | 39 | The line with the current cursor, and the character offset of the start of the line. |
|
42 | 40 | """ |
@@ -58,15 +56,14 def line_at_cursor(cell, cursor_pos=0): | |||
|
58 | 56 | |
|
59 | 57 | def token_at_cursor(cell, cursor_pos=0): |
|
60 | 58 | """Get the token at a given cursor |
|
61 | ||
|
59 | ||
|
62 | 60 | Used for introspection. |
|
63 | ||
|
61 | ||
|
64 | 62 | Function calls are prioritized, so the token for the callable will be returned |
|
65 | 63 | if the cursor is anywhere inside the call. |
|
66 | ||
|
64 | ||
|
67 | 65 | Parameters |
|
68 | 66 | ---------- |
|
69 | ||
|
70 | 67 | cell : unicode |
|
71 | 68 | A block of Python code |
|
72 | 69 | cursor_pos : int |
General Comments 0
You need to be logged in to leave comments.
Login now