airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] mik-laj commented on issue #6881: [AIRFLOW-6326] Sort cli commands and arg
Date Sat, 04 Jan 2020 20:18:27 GMT
mik-laj commented on issue #6881: [AIRFLOW-6326] Sort cli commands and arg
URL: https://github.com/apache/airflow/pull/6881#issuecomment-570816359
 
 
   I think, we can sort using followng function:
   ```python
       @classmethod
       def sort_args(cls, args):
           def partition(pred, iterable):
               """
               Use a predicate to partition entries into false entries and true entries
               """
               t1, t2 = tee(iterable)
               return filterfalse(pred, t1), filter(pred, t2)
           positional, optional = partition(lambda x: cls.args[x].flags[0].startswith("-"),
args)
           yield from positional
           yield from sorted(optional, key=lambda x: cls.args[x].flags[0])
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message