lexor.command package
Submodules
lexor.command.config module
Config
This module is in charge of providing all the necessary settings to
the rest of the modules in lexor.
-
class lexor.command.config.ConfigDispAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]
Bases: argparse.Action
Derived argparse Action class to use when displaying the
configuration file and location.
-
lexor.command.config.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.config.get_cfg(names, defaults=None)[source]
Obtain settings from the configuration file.
-
lexor.command.config.read_config()[source]
Read a configuration file.
-
lexor.command.config.run()[source]
Run command.
-
lexor.command.config.set_style_cfg(obj, name, defaults)[source]
Given an obj, this can be a Parser, Converter or Writer. It
sets the attribute defaults to the specified defaults in the
configuration file or by the user by overwriting values in the
parameter defaults.
-
lexor.command.config.update_single(cfg, name, defaults=None)[source]
Helper function for get_cfg.
-
lexor.command.config.value_completer(**_)[source]
value completer.
-
lexor.command.config.var_completer(**_)[source]
var completer.
-
lexor.command.config.write_config(cfg_file)[source]
Write the configuration file.
lexor.command.defaults module
Defaults
Print the default values for each command.
-
lexor.command.defaults.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.defaults.name_completer(**_)[source]
var completer.
-
lexor.command.defaults.run()[source]
Run command.
lexor.command.develop module
Develop
Routine to append a path to the develop section in the configuration
file.
-
lexor.command.develop.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.develop.run()[source]
Append the path to the develop section in the configuration
file.
lexor.command.dist module
Distribute
Package a style along with auxiliary and test files.
-
lexor.command.dist.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.dist.run()[source]
Run the command.
-
lexor.command.dist.style_completer(parsed_args, **_)[source]
Return a list of valid files to edit.
lexor.command.document module
Document
Routine to create an xml file with the documentation of a lexor
style.
-
lexor.command.document.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.document.append_main(doc, mod)[source]
Append the main module. Return a dictionary containing all the
modules used in the style.
-
lexor.command.document.check_filename(arg)[source]
Check if the inputfile exists.
-
lexor.command.document.full_class_name(cls)[source]
Obtain the full class name.
-
lexor.command.document.get_class_node(cls)[source]
Return a class node. Assumes that cls is a valid class.
-
lexor.command.document.get_defaults_node(obj)[source]
Obtain defaults node.
-
lexor.command.document.get_function_node(func)[source]
Return a function node.
-
lexor.command.document.get_info_node(info)[source]
Generate the info node.
-
lexor.command.document.get_mapping_node(mapping)[source]
Generate the mapping node.
-
lexor.command.document.get_member_node(member)[source]
Return a property node.
-
lexor.command.document.get_property_node(prop)[source]
Return a property node.
-
lexor.command.document.make_module_node(mod, name=None)[source]
Create a module node documenation.
-
lexor.command.document.run()[source]
Run the command.
-
lexor.command.document.separate_objects(mod, remove=None)[source]
Given a module, it separates the objects into a dictionary.
-
lexor.command.document.xml_style(lang_str)[source]
Parses a style string.
lexor.command.edit module
Edit
Module to open files with an editor.
-
lexor.command.edit.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.edit.run()[source]
Run the edit command.
-
lexor.command.edit.valid_files(parsed_args, **_)[source]
Return a list of valid files to edit.
lexor.command.install module
Install
Routine to install a parser/writer/converter style.
-
lexor.command.install.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.install.download_file(url, base='.')[source]
Download a file.
-
lexor.command.install.install_style(style, install_dir)[source]
Install a given style to the install_dir path.
-
lexor.command.install.run()[source]
Run the command.
-
lexor.command.install.unzip_file(local_name)[source]
Extract the contents of a zip file.
lexor.command.lang module
Language
This module provides functions to load the different languages
parsers, writers and converters.
## Constants
LEXOR_PATH: The paths where lexor looks for the parsing, writing
and converting styles.
-
lexor.command.lang.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.lang.get_style_module(type_, lang, style, to_lang=None)[source]
Return a parsing/writing/converting module.
-
lexor.command.lang.load_aux(info)[source]
Wrapper around load_mod for easy use when developing styles.
The only parameter is the dictionary INFO that needs to exist
with every style. INFO is returned by the init function in
the lexor module.
-
lexor.command.lang.load_mod(modbase, dirpath)[source]
Return a dictionary containing the modules located in
dirpath. The name modbase must be provided so that each
module may have a unique identifying name. The result will be a
dictionary of modules. Each of the modules will have the name
“modbase_modname” where modname is a module in the directory.
-
lexor.command.lang.load_rel(path, module)[source]
Load relative to a path. If path is the name of a file the
filename will be dropped.
-
lexor.command.lang.map_explanations(mod, exp)[source]
Helper function to create a map of msg codes to explanations
in the lexor language modules.
-
lexor.command.lang.run()[source]
Run the command.
lexor.command.paste module
Paste
Routine to append paste templates.
-
lexor.command.paste.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.paste.lang_completer(**_)[source]
Return the meta var.
-
lexor.command.paste.make_auxilary(base, type_, fmt, aux_type='')[source]
Creates a new node parser module.
-
lexor.command.paste.make_style(base, type_, fmt)[source]
Creates a new style file.
-
lexor.command.paste.run()[source]
Run the command.
-
lexor.command.paste.style_completer(**_)[source]
Return the meta var.
lexor.command.test module
Lexor Test
This module contains various test for lexor.
-
lexor.command.test.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.test.compare_with(str_obj, expected)[source]
Calls nose.eq_ to compare the strings and prints a custom
message.
-
lexor.command.test.find_failed(tests, lang, style)[source]
Run the tests and return a list of the tests that fail.
-
lexor.command.test.nose_msg_explanations(lang, type_, style, name)[source]
Gather the MSG_EXPLANATION list and run the tests it
contains.
-
lexor.command.test.parse_convert_write(callerfile, in_, out_, style, tolang)[source]
Provide the filename as the input and the style you wish
to compare it against.
-
lexor.command.test.parse_msg(msg)[source]
Obtain the tests embedded inside the messages declared in a
style. The format of the messages is as follows:
<tab>[A-Z][0-9]*: <msg>
or
<tab>([A-Z][0-9]*|Okay):
<tab><tab>msg ...
<tab><tab>msg continues
<tab>([A-Z][0-9]*|Okay): msg
Where <tab> consists of 4 whitespaces. This function returns the
message without the tests and a list of tuples of the form
(code, msg) along with the message
-
lexor.command.test.parse_write(callerfile, in_, out_, style, lang)[source]
Provide the filename as the input and the style you wish
to compare it against.
-
lexor.command.test.print_log(node)[source]
Display the error obtained from parsing.
-
lexor.command.test.run()[source]
Run command.
-
lexor.command.test.run_develop(param, cfg, verbose)[source]
Run develop tests.
-
lexor.command.test.run_installed(param, cfg, verbose)[source]
Run installed tests.
lexor.command.to module
to
Execute lexor by transforming a file “to” another language.
-
lexor.command.to.add_parser(subp, fclass)[source]
Add a parser to the main subparser.
-
lexor.command.to.convert_and_write(f_name, parser, in_lang, log, arg)[source]
Auxiliary function to reduce the number of branches in run.
-
lexor.command.to.get_input(input_file, cfg, default='_')[source]
Returns the text to be parsed along with the name assigned to
that text. The last output is the extension of the file.
-
lexor.command.to.input_language(tolang)[source]
Parses the tolang argument.
-
lexor.command.to.language_style(lang_str)[source]
Parses a language string. In particular, the options –from
and –log.
-
lexor.command.to.parse_styles(lang_str)[source]
Parses a language string. In particular, the options –from
and –log.
-
lexor.command.to.run()[source]
Run the command.
-
lexor.command.to.run_converter(param)[source]
Auxiliary function for convert and write.
-
lexor.command.to.run_writer(param)[source]
Auxiliary function for convert and write.
-
lexor.command.to.split_at(delimiter, text, opens='[<(', closes=']>)', quotes='"\'')[source]
Custom function to split at commas. Taken from stackoverflow
http://stackoverflow.com/a/20599372/788553
-
lexor.command.to.style_parameters(style)[source]
Parsers a style name along with its parameters.
-
lexor.command.to.write_document(writer, doc, fname, arg)[source]
Auxiliary function for convert_and_write.
-
lexor.command.to.write_log(writer, log, quiet)[source]
Write the log file to stderr.
Module contents
Command
Collection of functions to create lexor’s command line utility.
-
lexor.command.date(short=False)[source]
Return the current date as a string.
-
lexor.command.error(msg)[source]
Print a message to the standard error stream and exit.
-
lexor.command.exec_cmd(cmd, verbose=False)[source]
Run a subprocess and return its output and errors.
-
lexor.command.import_mod(name)[source]
Return a module by string.
-
lexor.command.warn(msg)[source]
Print a message to the standard error