Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/ini.py @ 56:1f11672c4615
Optimize the documentation: make references working with Sphinx using :role:`target`
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 28 Feb 2018 00:36:11 +0100 |
| parents | aa8345dae995 |
| children | a43749f751e0 |
comparison
equal
deleted
inserted
replaced
| 55:51a8fa011659 | 56:1f11672c4615 |
|---|---|
| 61 def get_path_list(self, section, option): | 61 def get_path_list(self, section, option): |
| 62 v = self.get(section, option) | 62 v = self.get(section, option) |
| 63 return v.split(os.pathsep) | 63 return v.split(os.pathsep) |
| 64 | 64 |
| 65 def read(self, filenames): | 65 def read(self, filenames): |
| 66 """Not implemented. Use :meth:`readfp` instead""" | |
| 66 raise NotImplementedError("use `readfp()' instead") | 67 raise NotImplementedError("use `readfp()' instead") |
| 67 | 68 |
| 68 def readfp(self, fp, filename): | 69 def readfp(self, fp, filename): |
| 70 """Read from a file-like object `fp`. | |
| 71 | |
| 72 The `fp` argument must have a `readline()` method. | |
| 73 | |
| 74 """ | |
| 69 if hasattr(self, "filename"): | 75 if hasattr(self, "filename"): |
| 70 raise RuntimeError("already initialized") | 76 raise RuntimeError("already initialized") |
| 71 filename = os.path.normpath(os.path.abspath(filename)) | 77 filename = os.path.normpath(os.path.abspath(filename)) |
| 72 if PY2: | 78 if PY2: |
| 73 if isinstance(filename, str): | 79 if isinstance(filename, str): |
| 78 SafeConfigParser.readfp(self, fp, filename=filename) | 84 SafeConfigParser.readfp(self, fp, filename=filename) |
| 79 self.filename = filename | 85 self.filename = filename |
| 80 self.root = os.path.dirname(self.executable) | 86 self.root = os.path.dirname(self.executable) |
| 81 | 87 |
| 82 def getx(self, section, option): | 88 def getx(self, section, option): |
| 83 """Extended get() with some automatic type conversion support. | 89 """Extended `get()` with some automatic type conversion support. |
| 84 | 90 |
| 85 Default: Fetch as string (like `get()`). | 91 Default: Fetch as string (like :meth:`get`). |
| 86 | 92 |
| 87 If annotated with ``:bool:`` fetch as bool, if annotated with | 93 If annotated with ``:bool:`` fetch as bool, if annotated with |
| 88 ``:int:`` fetch as int, if annotated with ``:float:`` fetch as | 94 ``:int:`` fetch as int, if annotated with ``:float:`` fetch as |
| 89 float. | 95 float. |
| 90 | 96 |
| 111 u('false'): False, | 117 u('false'): False, |
| 112 u('off'): False} | 118 u('off'): False} |
| 113 | 119 |
| 114 def itemsx(self, section, options): | 120 def itemsx(self, section, options): |
| 115 """Get all the options given in `options` of section `section`. | 121 """Get all the options given in `options` of section `section`. |
| 116 Fetch them with `self.getx()` in the order given. | 122 Fetch them with :meth:`getx` in the order given. |
| 117 | 123 |
| 118 Return a list of ``(name, value)`` pairs for each option in | 124 Return a list of ``(name, value)`` pairs for each option in |
| 119 `options` in the given `section`. | 125 `options` in the given `section`. |
| 120 | 126 |
| 121 """ | 127 """ |
| 128 else: | 134 else: |
| 129 d.append((option, val, )) | 135 d.append((option, val, )) |
| 130 return d | 136 return d |
| 131 | 137 |
| 132 def items_as_dictx(self, section, options): | 138 def items_as_dictx(self, section, options): |
| 133 """Similar to `self.itemsx()` but return a (possibly ordered) | 139 """Similar to :meth:`itemsx` but return a (possibly ordered) |
| 134 dict instead of a list of key-value pairs. | 140 dict instead of a list of key-value pairs. |
| 135 | 141 |
| 136 """ | 142 """ |
| 137 return DictImpl(self.itemsx(section, options)) | 143 return DictImpl(self.itemsx(section, options)) |
| 138 | 144 |
