def main(belversion, species, pathways): """Process Reactome into BEL Example: ./processReactome.py -b 1 -s "H**o sapiens" -s "Mus musculus" -p Metabolism Example: ./processReactome.py -b 2 -s "H**o sapiens" -p Metabolism -p "Transmembrane transport of small molecules" Result: reactome.bels """ setBelVersion(belversion) # quit and show help if no arguments are set if not species: click.help_option() print('Here') if 'all' in species: species = speciesList # Collect reactions reactionList = [] for specie in species: reactionList.extend(getReactions(specie, pathways=pathways)) # import json # with open('reactionlist.json', 'w') as f: # json.dump(reactionList, f, indent=4) # quit() # human, mouse and rat share rxnIds reactionList = set(reactionList) buildBelEvidences(reactionList, belversion, pathways=pathways)
def get_command(self, ctx, name): ns = {} fn = os.path.join(command_folder, name + '.py') try: with open(fn) as f: code = compile(f.read(), fn, 'exec') eval(code, ns, ns) return ns[name] except IOError: click.help_option()
def common_options(f): f = click.option("-i", "--input-dir", required=False, default='.', show_default=True, type=click.Path(exists=True, dir_okay=True, file_okay=False), help="base directory of the dataset")(f) f = click.option("-o", "--output-dir", required=False, default='.', show_default=True, type=click.Path(exists=True, dir_okay=True, file_okay=False), help="output directory for the created bag file")(f) f = click.option("--compression", required=False, type=click.Choice(compression_choices), default=rosbag.Compression.NONE, show_default=True, help="which compression to use for the created bag")(f) f = click.help_option('-h', '--help')(f) return f
def define_command(descriptor, wizard): callback = descriptor['callback'] command = click.command(name=descriptor['name'], short_help=descriptor['help'], cls=DeprecatedOptionsCommand)(click.pass_context(callback)) if 'arguments' in descriptor: for key, value in descriptor['arguments'].items(): command = click.argument(key, **value)(command) if 'options' in descriptor: for key, value in descriptor['options'].items(): if not wizard: value.pop('prompt', None) callbacks = [check_empty_values] if 'validators' in value: callbacks = callbacks + value.pop('validators') value['callback'] = partial(multiple_option_callback, callbacks) if type(key) == tuple: click_option = click.option(*key, **value) else: click_option = click.option(key, **value) command = click_option(command) command = click.help_option(hidden=True)(command) verbose_option = click.option('--verbose', is_flag=True, expose_value=False, callback=set_verbose_mode, help=help_msg.VERBOSE_OPTION) command = verbose_option(command) for group in descriptor['groups']: command_copy = copy.deepcopy(command) if '%s' in descriptor['help']: command_copy.help = descriptor['help'] % group.name else: command_copy.help = descriptor['help'] group.add_command(command_copy)
def define_command(descriptor): callback = descriptor['callback'] command = click.command(name=descriptor['name'], help=descriptor['help'], cls=DeprecatedOptionsCommand)( click.pass_context(callback)) if 'arguments' in descriptor: for key, value in descriptor['arguments'].items(): command = click.argument(key, **value)(command) if 'options' in descriptor: for key, value in descriptor['options'].items(): if type(key) == tuple: click_option = click.option(*key, **value) else: click_option = click.option(key, **value) command = click_option(command) command = click.help_option(hidden=True)(command) verbose_option = click.option('--verbose', is_flag=True, expose_value=False, callback=set_verbose_mode, help='Debug mode') command = verbose_option(command) for group in descriptor['groups']: command_copy = copy.deepcopy(command) if '%s' in descriptor['help']: command_copy.help = descriptor['help'] % group.name group.add_command(command_copy)
def common_options(f): """ Global/shared options decorator. """ f = click.help_option("-h", "--help")(f) f = click.version_option(__version__, "-v", "--version")(f) f = debug_option(f) return f
def common_options(f): """ Global/shared options decorator. :param f: :return: """ f = click.help_option('-h', '--help')(f) f = click.version_option(__version__, '-v', '--version')(f) f = debug_option(f) return f
def common_options(command): """ Mark ``cli`` commands with common flags. Used to mark ``cli`` commands with the flags that add the option flags that we want to include in all of them. """ options = [ click.version_option( changelog_gen.VERSION, "-v", "--version", prog_name="changelog-gen", ), click.help_option("--help", help="Show this message and exit."), ] for option in options: command = option(command) return command
def decorate(f, **kwargs): """ Work of actually decorating a function -- wrapped in here because we want to dispatch depending on how `common_options` is invoked """ f = version_option(f) f = debug_option(f) f = verbose_option(f) f = click.help_option("-h", "--help")(f) # if the format option is being allowed, it needs to be applied to `f` if not kwargs.get("no_format_option"): f = format_option(f) # if the --map-http-status option is being allowed, ... if not kwargs.get("no_map_http_status_option"): f = map_http_status_option(f) return f
def decorate(f, **kwargs): """ Work of actually decorating a function -- wrapped in here because we want to dispatch depending on how `common_options` is invoked """ f = version_option(f) f = debug_option(f) f = verbose_option(f) f = click.help_option('-h', '--help')(f) # if the format option is being allowed, it needs to be applied to `f` if not kwargs.get('no_format_option'): f = format_option(f) # if the --map-http-status option is being allowed, ... if not kwargs.get('no_map_http_status_option'): f = map_http_status_option(f) return f
def help_options(f): f = click.help_option( help='Show help message for this command and exit.')(f) f = all_help_option(f) return f
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Click options used for multiple scommands. """ from __future__ import absolute_import, print_function import click help_option = [ # pylint: disable=invalid-name click.help_option('-h', '--help', help=u'Show this help message.')] quiet_option = [ # pylint: disable=invalid-name click.option('-q', '--quiet', is_flag=True, default=False, help=u'Print no messages.')] def add_options(options): """ Decorator that adds multiple Click options. The list is reversed because of the way Click processes options Parameters: options: list of click.option definitions
self.fail( '%s "%s" is a file.' % (self.path_type, filename_to_ui(value)), param, ctx) if not self.dir_okay and stat.S_ISDIR(st.st_mode): self.fail( '%s "%s" is a directory.' % (self.path_type, filename_to_ui(value)), param, ctx) if self.writable and not os.access(value, os.W_OK): self.fail( '%s "%s" is not writable.' % (self.path_type, filename_to_ui(value)), param, ctx) if self.readable and not os.access(value, os.R_OK): self.fail( '%s "%s" is not readable.' % (self.path_type, filename_to_ui(value)), param, ctx) return self.coerce_path_result(rv) def noncontext_callback(f): @wraps(f) def fake_callback(ctx, param, value): return f(value) return fake_callback option_of_common_help = click.help_option(help="show usages details") option_of_not_implement_help = click.help_option( help="Sorry, this command is not implemented now!")
def add_help_option(self): """Add a help option to the command.""" click.help_option(*('--help', '-h'))(self)
def common_options(f): # any shared/common options for all commands return click.help_option("-h", "--help")(f)
""" Grab value of --monokrom option and set global state of _show_colors """ global _show_colors _show_colors = not value _default_options = [ click.option( "-m", "--monokrom", is_flag=True, callback=_set_monochrome, help="Vis ikke farver i terminalen", ), click.help_option(help="Vis denne hjælp tekst"), ] def default_options(): def _add_options(func): for option in reversed(_default_options): func = option(func) return func return _add_options def print(*args, **kwargs): """ Custom print function based on click.secho.
def add_help_option(self): """Add a help option to the command.""" click.help_option(*("--help", "-h"))(self)