(value)
| 1282 | |
| 1283 | |
| 1284 | def parse_entry_point(value): |
| 1285 | # type: (str) -> Union[ModuleEntryPoint, CallableEntryPoint] |
| 1286 | |
| 1287 | # The format of the value of an entry point (minus the name part), is specified here: |
| 1288 | # https://packaging.python.org/en/latest/specifications/entry-points/#file-format |
| 1289 | |
| 1290 | # The spec allows for extras via a trailing: [extra1,extra2,...] |
| 1291 | entry_point, _, _ = value.strip().partition("[") |
| 1292 | |
| 1293 | module, sep, object_reference = entry_point.strip().partition(":") |
| 1294 | module = module.strip() |
| 1295 | object_reference = object_reference.strip() |
| 1296 | if not module or (sep and not object_reference): |
| 1297 | raise ValueError("Invalid entry point specification: {value!r}.".format(value=value)) |
| 1298 | |
| 1299 | if object_reference: |
| 1300 | return CallableEntryPoint(module=module, attrs=tuple(object_reference.split("."))) |
| 1301 | return ModuleEntryPoint(module=module) |
| 1302 | |
| 1303 | |
| 1304 | @attr.s(frozen=True) |
no test coverage detected