MCPcopy Index your code
hub / github.com/httpie/cli / build

Method build

tests/utils/plugins_cli.py:44–85  ·  view source on GitHub ↗

Create an installable dummy plugin at the given path. It will create a setup.py with the specified entry points, as well as dummy classes in a python module to imitate real plugins.

(self)

Source from the content-addressed store, hash-verified

42 entry_points: List[EntryPoint] = field(default_factory=list)
43
44 def build(self) -> None:
45 '''
46 Create an installable dummy plugin at the given path.
47
48 It will create a setup.py with the specified entry points,
49 as well as dummy classes in a python module to imitate
50 real plugins.
51 '''
52
53 groups = defaultdict(list)
54 for entry_point in self.entry_points:
55 groups[entry_point.group].append(entry_point.name)
56
57 setup_eps = {
58 group: [
59 f'{name} = {self.import_name}:{name.title()}'
60 for name in names
61 ]
62 for group, names in groups.items()
63 }
64
65 self.path.mkdir(parents=True, exist_ok=True)
66 with open(self.path / 'setup.py', 'w') as stream:
67 stream.write(textwrap.dedent(f'''
68 from setuptools import setup
69
70 setup(
71 name='{self.name}',
72 version='{self.version}',
73 py_modules=['{self.import_name}'],
74 entry_points={setup_eps!r},
75 install_requires=['httpie']
76 )
77 '''))
78
79 with open(self.path / (self.import_name + '.py'), 'w') as stream:
80 stream.write('from httpie.plugins import *\n')
81 stream.writelines(
82 f'class {name.title()}({CLASSES[group].__name__}): ...\n'
83 for group, names in groups.items()
84 for name in names
85 )
86
87 def dump(self) -> Dict[str, Any]:
88 return {

Callers 2

make_dummy_pluginMethod · 0.95
test_plugins_upgradeFunction · 0.45

Calls 2

itemsMethod · 0.45
writeMethod · 0.45

Tested by 1

test_plugins_upgradeFunction · 0.36