cli2 3.3.40__tar.gz → 3.3.42__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {cli2-3.3.40/cli2.egg-info → cli2-3.3.42}/PKG-INFO +1 -1
  2. {cli2-3.3.40 → cli2-3.3.42}/cli2/client.py +3 -6
  3. {cli2-3.3.40 → cli2-3.3.42}/cli2/group.py +23 -13
  4. {cli2-3.3.40 → cli2-3.3.42}/cli2/logging.py +4 -0
  5. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_client.py +1 -2
  6. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_group.py +8 -0
  7. {cli2-3.3.40 → cli2-3.3.42/cli2.egg-info}/PKG-INFO +1 -1
  8. {cli2-3.3.40 → cli2-3.3.42}/setup.py +1 -1
  9. {cli2-3.3.40 → cli2-3.3.42}/MANIFEST.in +0 -0
  10. {cli2-3.3.40 → cli2-3.3.42}/README.rst +0 -0
  11. {cli2-3.3.40 → cli2-3.3.42}/classifiers.txt +0 -0
  12. {cli2-3.3.40 → cli2-3.3.42}/cli2/__init__.py +0 -0
  13. {cli2-3.3.40 → cli2-3.3.42}/cli2/argument.py +0 -0
  14. {cli2-3.3.40 → cli2-3.3.42}/cli2/asyncio.py +0 -0
  15. {cli2-3.3.40 → cli2-3.3.42}/cli2/cli.py +0 -0
  16. {cli2-3.3.40 → cli2-3.3.42}/cli2/colors.py +0 -0
  17. {cli2-3.3.40 → cli2-3.3.42}/cli2/command.py +0 -0
  18. {cli2-3.3.40 → cli2-3.3.42}/cli2/configuration.py +0 -0
  19. {cli2-3.3.40 → cli2-3.3.42}/cli2/decorators.py +0 -0
  20. {cli2-3.3.40 → cli2-3.3.42}/cli2/display.py +0 -0
  21. {cli2-3.3.40 → cli2-3.3.42}/cli2/entry_point.py +0 -0
  22. {cli2-3.3.40 → cli2-3.3.42}/cli2/example_client.py +0 -0
  23. {cli2-3.3.40 → cli2-3.3.42}/cli2/example_client_complex.py +0 -0
  24. {cli2-3.3.40 → cli2-3.3.42}/cli2/example_nesting.py +0 -0
  25. {cli2-3.3.40 → cli2-3.3.42}/cli2/example_obj.py +0 -0
  26. {cli2-3.3.40 → cli2-3.3.42}/cli2/node.py +0 -0
  27. {cli2-3.3.40 → cli2-3.3.42}/cli2/overrides.py +0 -0
  28. {cli2-3.3.40 → cli2-3.3.42}/cli2/sphinx.py +0 -0
  29. {cli2-3.3.40 → cli2-3.3.42}/cli2/table.py +0 -0
  30. {cli2-3.3.40 → cli2-3.3.42}/cli2/test.py +0 -0
  31. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_cli.py +0 -0
  32. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_command.py +0 -0
  33. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_configuration.py +0 -0
  34. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_decorators.py +0 -0
  35. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_display.py +0 -0
  36. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_entry_point.py +0 -0
  37. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_inject.py +0 -0
  38. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_node.py +0 -0
  39. {cli2-3.3.40 → cli2-3.3.42}/cli2/test_table.py +0 -0
  40. {cli2-3.3.40 → cli2-3.3.42}/cli2.egg-info/SOURCES.txt +0 -0
  41. {cli2-3.3.40 → cli2-3.3.42}/cli2.egg-info/dependency_links.txt +0 -0
  42. {cli2-3.3.40 → cli2-3.3.42}/cli2.egg-info/entry_points.txt +0 -0
  43. {cli2-3.3.40 → cli2-3.3.42}/cli2.egg-info/requires.txt +0 -0
  44. {cli2-3.3.40 → cli2-3.3.42}/cli2.egg-info/top_level.txt +0 -0
  45. {cli2-3.3.40 → cli2-3.3.42}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cli2
3
- Version: 3.3.40
3
+ Version: 3.3.42
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -70,9 +70,7 @@ class Paginator:
70
70
 
71
71
  .. py:attribute:: callback
72
72
 
73
- Callback called for every item before filtering by expressions.
74
- This must return True or the item will be filtered *out* of yielded
75
- results.
73
+ Async callback called for every item before filtering by expressions.
76
74
  """
77
75
 
78
76
  def __init__(self, client, url, params=None, model=None, expressions=None,
@@ -274,10 +272,9 @@ class Paginator:
274
272
  python_filter = self.python_filter()
275
273
 
276
274
  async def yielder(items):
275
+ if callback:
276
+ await asyncio.gather(*[callback(item) for item in items])
277
277
  for item in items:
278
- if callback:
279
- if not await async_resolve(callback(item)):
280
- continue
281
278
  if not python_filter or python_filter.matches(item):
282
279
  yield item
283
280
 
@@ -195,19 +195,29 @@ class Group(EntryPoint, dict):
195
195
  for name, method in cls.__dict__.items():
196
196
  if leaf and getattr(final, name, '_') is None:
197
197
  continue
198
- wrapped_method = getattr(method, '__func__', None)
199
- cfg = getattr(
200
- wrapped_method,
201
- 'cli2',
202
- getattr(method, 'cli2', None),
203
- )
204
- if cfg is None:
205
- continue
206
- condition = cfg.get('condition', None)
207
- if condition:
208
- if not condition(final):
209
- continue
210
- self.cmd(method)
198
+ self.load_method(final, method)
199
+
200
+ def load_obj(self, obj):
201
+ """
202
+ Load all methods which have been decorated with @cmd
203
+ """
204
+ for name in dir(obj):
205
+ self.load_method(obj, getattr(obj, name))
206
+
207
+ def load_method(self, obj, method):
208
+ wrapped_method = getattr(method, '__func__', None)
209
+ cfg = getattr(
210
+ wrapped_method,
211
+ 'cli2',
212
+ getattr(method, 'cli2', None),
213
+ )
214
+ if cfg is None:
215
+ return
216
+ condition = cfg.get('condition', None)
217
+ if condition:
218
+ if not condition(obj):
219
+ return
220
+ self.cmd(method)
211
221
 
212
222
  def __call__(self, *argv):
213
223
  self.exit_code = 0
@@ -22,6 +22,10 @@ class YAMLFormatter:
22
22
 
23
23
  def configure():
24
24
  LOG_LEVEL = os.getenv('LOG_LEVEL', 'WARNING').upper()
25
+
26
+ if os.getenv('DEBUG'):
27
+ LOG_LEVEL = 'DEBUG'
28
+
25
29
  timestamper = structlog.processors.TimeStamper(fmt='%Y-%m-%d %H:%M:%S')
26
30
  pre_chain = [
27
31
  # add log level and timestamp to event_dict
@@ -376,9 +376,8 @@ async def test_pagination(httpx_mock):
376
376
  httpx_mock.add_response(url='http://lol/?page=3', json=[])
377
377
  client = Client(base_url='http://lol')
378
378
 
379
- def callback(item):
379
+ async def callback(item):
380
380
  item['b'] = item['a']
381
- return True
382
381
 
383
382
  paginator = client.paginate(
384
383
  '/',
@@ -232,9 +232,17 @@ def test_load_cls():
232
232
  group.load_cls(Foo)
233
233
  assert list(group.keys()) == ['help', 'test', 'test2']
234
234
 
235
+ group = Group()
236
+ group.load_obj(Foo())
237
+ assert list(group.keys()) == ['help', 'test', 'test2']
238
+
235
239
  class Child(Foo):
236
240
  test2 = None
237
241
 
238
242
  group = Group()
239
243
  group.load_cls(Child)
240
244
  assert list(group.keys()) == ['help', 'test']
245
+
246
+ group = Group()
247
+ group.load_obj(Child())
248
+ assert list(group.keys()) == ['help', 'test']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cli2
3
- Version: 3.3.40
3
+ Version: 3.3.42
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name='cli2',
6
- version='3.3.40',
6
+ version='3.3.42',
7
7
  setup_requires='setupmeta',
8
8
  install_requires=[
9
9
  'docstring_parser',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes