An entry point as defined by Python packaging conventions. See `the packaging docs on entry points `_ for more information. >>> ep = EntryPoint( ... name=None, group=None, value='package.module:attr [extra1, extra2]
| 144 | |
| 145 | |
| 146 | class EntryPoint: |
| 147 | """An entry point as defined by Python packaging conventions. |
| 148 | |
| 149 | See `the packaging docs on entry points |
| 150 | <https://packaging.python.org/specifications/entry-points/>`_ |
| 151 | for more information. |
| 152 | |
| 153 | >>> ep = EntryPoint( |
| 154 | ... name=None, group=None, value='package.module:attr [extra1, extra2]') |
| 155 | >>> ep.module |
| 156 | 'package.module' |
| 157 | >>> ep.attr |
| 158 | 'attr' |
| 159 | >>> ep.extras |
| 160 | ['extra1', 'extra2'] |
| 161 | |
| 162 | If the value package or module are not valid identifiers, a |
| 163 | ValueError is raised on access. |
| 164 | |
| 165 | >>> EntryPoint(name=None, group=None, value='invalid-name').module |
| 166 | Traceback (most recent call last): |
| 167 | ... |
| 168 | ValueError: ('Invalid object reference...invalid-name... |
| 169 | >>> EntryPoint(name=None, group=None, value='invalid-name').attr |
| 170 | Traceback (most recent call last): |
| 171 | ... |
| 172 | ValueError: ('Invalid object reference...invalid-name... |
| 173 | >>> EntryPoint(name=None, group=None, value='invalid-name').extras |
| 174 | Traceback (most recent call last): |
| 175 | ... |
| 176 | ValueError: ('Invalid object reference...invalid-name... |
| 177 | |
| 178 | The same thing happens on construction. |
| 179 | |
| 180 | >>> EntryPoint(name=None, group=None, value='invalid-name') |
| 181 | Traceback (most recent call last): |
| 182 | ... |
| 183 | ValueError: ('Invalid object reference...invalid-name... |
| 184 | |
| 185 | """ |
| 186 | |
| 187 | pattern = re.compile( |
| 188 | r'(?P<module>[\w.]+)\s*' |
| 189 | r'(:\s*(?P<attr>[\w.]+)\s*)?' |
| 190 | r'((?P<extras>\[.*\])\s*)?$' |
| 191 | ) |
| 192 | """ |
| 193 | A regular expression describing the syntax for an entry point, |
| 194 | which might look like: |
| 195 | |
| 196 | - module |
| 197 | - package.module |
| 198 | - package.module:attribute |
| 199 | - package.module:object.attribute |
| 200 | - package.module:attr [extra1, extra2] |
| 201 | |
| 202 | Other combinations are possible as well. |
| 203 |
searching dependent graphs…